allow ppl to avoid effortposts and nsfw

pull/222/head
Aevann 2024-02-07 03:20:52 +02:00
parent 76587eeb33
commit cf2f91df64
2 changed files with 9 additions and 4 deletions

View File

@ -111,8 +111,13 @@ def searchposts(v):
) for x in criteria['q']]
posts = posts.filter(*words)
if 'nsfw' in criteria: posts = posts.filter(Post.nsfw==True)
if 'effortpost' in criteria: posts = posts.filter(Post.effortpost==True)
if 'nsfw' in criteria:
nsfw = criteria['nsfw'].lower().strip() == 'true'
posts = posts.filter_by(nsfw=nsfw)
if 'effortpost' in criteria:
effortpost = criteria['effortpost'].lower().strip() == 'true'
posts = posts.filter_by(effortpost=effortpost)
if 'domain' in criteria:
domain = criteria['domain']

View File

@ -86,13 +86,13 @@
{% endif %}
{% if FEATURES['NSFW_MARKING'] %}
<div>
<div style="display: inline-block; width: 150px; text-align: center">NSFW Only:</div>
<div style="display: inline-block; width: 150px; text-align: center">NSFW:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this, 'bool')" class="searchparam mb-1">nsfw:true</button>
</div>
{% endif %}
{% if request.path.startswith('/search/posts') %}
<div>
<div style="display: inline-block; width: 150px; text-align: center">Effortposts Only:</div>
<div style="display: inline-block; width: 150px; text-align: center">Effortpost:</div>
<button type="button" data-nonce="{{g.nonce}}" data-onclick="addParam(this, 'bool')" class="searchparam mb-1">effortpost:true</button>
</div>
{% endif %}