remotes/1693045480750635534/spooky-22
Aevann1 2021-12-29 09:08:10 +02:00
parent c73121cfa3
commit 9604d9e2fa
12 changed files with 54 additions and 32 deletions

View File

@ -35,7 +35,8 @@ def searchparse(text):
@app.get("/search/posts")
@auth_desired
def searchposts(v):
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
query = request.values.get("q", '').strip()
@ -63,6 +64,27 @@ def searchposts(v):
if not (v and v.admin_level > 1): posts = posts.filter(Submission.private == False)
if 'author' in criteria:
author = get_user(criteria['author'])
if author.is_private:
if request.headers.get("Authorization"):
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
return render_template(f"{template}search.html",
v=v,
query=query,
total=0,
page=page,
listing=[],
sort=sort,
t=t,
next_exists=False,
domain=None,
domain_obj=None,
error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them."
)
else: posts = posts.filter(Submission.author_id == author.id)
if 'q' in criteria:
words=criteria['q'].split()
words=[Submission.title.ilike('%'+x+'%') for x in words]
@ -71,10 +93,6 @@ def searchposts(v):
if 'over18' in criteria: posts = posts.filter(Submission.over_18==True)
if 'author' in criteria:
author = get_user(criteria['author'])
if not author.is_private: posts = posts.filter(Submission.author_id == author.id)
if 'domain' in criteria:
domain=criteria['domain']
posts=posts.filter(
@ -161,8 +179,7 @@ def searchposts(v):
domain_obj=None
if request.headers.get("Authorization"): return {"total":total, "data":[x.json for x in posts]}
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
return render_template(f"{template}search.html",
v=v,
query=query,
@ -180,6 +197,8 @@ def searchposts(v):
@auth_desired
def searchcomments(v):
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
query = request.values.get("q", '').strip()
@ -191,11 +210,18 @@ def searchcomments(v):
criteria=searchparse(query)
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None)
if 'author' in criteria:
author = get_user(criteria['author'])
if author.is_private:
if request.headers.get("Authorization"):
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
return render_template(f"{template}search_comments.html", v=v, query=query, total=0, page=page, comments=[], sort=sort, t=t, next_exists=False, error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them.")
else: comments = comments.filter(Comment.author_id == author.id)
if 'q' in criteria:
words=criteria['q'].split()
words=[Comment.body_html.ilike('%'+x+'%') for x in words]
@ -204,10 +230,6 @@ def searchcomments(v):
if 'over18' in criteria: comments = comments.filter(Comment.over_18==True)
if 'author' in criteria:
author = get_user(criteria['author'])
if not author.is_private: comments = comments.filter(Comment.author_id == author.id)
if not(v and v.admin_level > 1): comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False)
if t:
@ -253,8 +275,6 @@ def searchcomments(v):
comments = get_comments(ids, v=v)
if request.headers.get("Authorization"): return {"total":total, "data":[x.json for x in comments]}
if not v or v.oldsite: template = ''
else: template = 'CHRISTMAS/'
return render_template(f"{template}search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists)

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
{% if v.agendaposter %}
<style>
html {
@ -39,7 +39,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
{% endif %}
</head>

View File

@ -7,7 +7,7 @@
<script src="/static/assets/js/bootstrap.js?a=3"></script>
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
{% if v.agendaposter %}
<style>
@ -32,7 +32,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
{% endif %}
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
{% endif %}
<div class="row justify-content-around">

View File

@ -18,7 +18,7 @@
{% endblock %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7">
<link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">

View File

@ -14,7 +14,7 @@
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
</head>

View File

@ -34,7 +34,7 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
{% if v.agendaposter %}
<style>
html {

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
{% endif %}
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">

View File

@ -31,7 +31,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %}</title>
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
</head>

View File

@ -32,7 +32,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %}</title>
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
</head>

View File

@ -589,7 +589,9 @@
<i class="fas fa-square text-gray-500 opacity-25 fa-stack-2x"></i>
<i class="fas text-gray-500 fa-ghost fa-stack-1x text-lg"></i>
</span>
<h2 class="h5">There are no posts here.</h2>
{% if request.path.startswith('/search') and error %}
<h2 class="h5">{{error}}</h2>
{% endif %}
</div>
</div>
</div>

View File

@ -26,7 +26,7 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
{% if v.agendaposter %}
<style>
html {
@ -50,7 +50,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=6">
<link rel="stylesheet" href="/static/assets/css/main.css?a=7">
<link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
{% endif %}
{% endblock %}