forked from MarseyWorld/MarseyWorld
fds
parent
c73121cfa3
commit
9604d9e2fa
|
@ -35,7 +35,8 @@ def searchparse(text):
|
||||||
@app.get("/search/posts")
|
@app.get("/search/posts")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def searchposts(v):
|
def searchposts(v):
|
||||||
|
if not v or v.oldsite: template = ''
|
||||||
|
else: template = 'CHRISTMAS/'
|
||||||
|
|
||||||
query = request.values.get("q", '').strip()
|
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 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:
|
if 'q' in criteria:
|
||||||
words=criteria['q'].split()
|
words=criteria['q'].split()
|
||||||
words=[Submission.title.ilike('%'+x+'%') for x in words]
|
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 '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:
|
if 'domain' in criteria:
|
||||||
domain=criteria['domain']
|
domain=criteria['domain']
|
||||||
posts=posts.filter(
|
posts=posts.filter(
|
||||||
|
@ -161,8 +179,7 @@ def searchposts(v):
|
||||||
domain_obj=None
|
domain_obj=None
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return {"total":total, "data":[x.json for x in posts]}
|
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",
|
return render_template(f"{template}search.html",
|
||||||
v=v,
|
v=v,
|
||||||
query=query,
|
query=query,
|
||||||
|
@ -180,6 +197,8 @@ def searchposts(v):
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def searchcomments(v):
|
def searchcomments(v):
|
||||||
|
|
||||||
|
if not v or v.oldsite: template = ''
|
||||||
|
else: template = 'CHRISTMAS/'
|
||||||
|
|
||||||
query = request.values.get("q", '').strip()
|
query = request.values.get("q", '').strip()
|
||||||
|
|
||||||
|
@ -191,11 +210,18 @@ def searchcomments(v):
|
||||||
|
|
||||||
criteria=searchparse(query)
|
criteria=searchparse(query)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None)
|
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:
|
if 'q' in criteria:
|
||||||
words=criteria['q'].split()
|
words=criteria['q'].split()
|
||||||
words=[Comment.body_html.ilike('%'+x+'%') for x in words]
|
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 '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 not(v and v.admin_level > 1): comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False)
|
||||||
|
|
||||||
if t:
|
if t:
|
||||||
|
@ -253,8 +275,6 @@ def searchcomments(v):
|
||||||
comments = get_comments(ids, v=v)
|
comments = get_comments(ids, v=v)
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return {"total":total, "data":[x.json for x in comments]}
|
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)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<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 %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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 %}
|
{% endif %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<script src="/static/assets/js/bootstrap.js?a=3"></script>
|
<script src="/static/assets/js/bootstrap.js?a=3"></script>
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<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">
|
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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 %}
|
{% endif %}
|
||||||
|
|
||||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<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 %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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 %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="row justify-content-around">
|
<div class="row justify-content-around">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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 rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
|
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<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 %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<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 %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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 %}
|
{% endif %}
|
||||||
|
|
||||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||||
|
|
|
@ -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>
|
<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>
|
<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>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -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>
|
<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>
|
<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>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -589,7 +589,9 @@
|
||||||
<i class="fas fa-square text-gray-500 opacity-25 fa-stack-2x"></i>
|
<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>
|
<i class="fas text-gray-500 fa-ghost fa-stack-1x text-lg"></i>
|
||||||
</span>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<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 %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<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 rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue