remove duplicated code in userpage

pull/52/head
justcool393 2022-12-06 19:34:48 -06:00
parent 6514751daf
commit 79f7befd42
6 changed files with 41 additions and 95 deletions

View File

@ -877,7 +877,7 @@ def u_username(username, v=None):
if (v and v.client) or request.path.endswith(".json"):
return {"data": [x.json(g.db) for x in listing]}
return render_template("userpage/userpage.html",
return render_template("userpage/submissions.html",
unban=u.unban_string,
u=u,
v=v,
@ -891,7 +891,7 @@ def u_username(username, v=None):
if (v and v.client) or request.path.endswith(".json"):
return {"data": [x.json(g.db) for x in listing]}
return render_template("userpage/userpage.html",
return render_template("userpage/submissions.html",
u=u,
v=v,
listing=listing,
@ -1125,7 +1125,7 @@ def saved_posts(v:User, username):
try: page = max(1, int(request.values.get("page", 1)))
except: abort(400, "Invalid page input!")
return get_saves_and_subscribes(v, "userpage/userpage.html", SaveRelationship, page, False)
return get_saves_and_subscribes(v, "userpage/submissions.html", SaveRelationship, page, False)
@app.get("/@<username>/saved/comments")
@auth_required
@ -1141,7 +1141,7 @@ def subscribed_posts(v:User, username):
try: page = max(1, int(request.values.get("page", 1)))
except: abort(400, "Invalid page input!")
return get_saves_and_subscribes(v, "userpage/userpage.html", Subscription, page, False)
return get_saves_and_subscribes(v, "userpage/submissions.html", Subscription, page, False)
@app.post("/fp/<fp>")
@auth_required

View File

@ -1,7 +1,6 @@
{% extends "userpage/userpage.html" %}
{% block content %}
{%- include "userpage/header.html" -%}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %}" style="margin-top: 10px;">
{% block userpage_content %}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %} userpage-comments" style="margin-top: 10px;">
<div class="col">
{% if listing %}
<div class="posts p-3 p-md-0">
@ -29,20 +28,4 @@
{% endif %}
</div>
</div>
{% if u.song %}
{% if v and v.id == u.id %}
<div id="v_username" class="d-none">{{v.username}}</div>
{% else %}
<div id="u_username" class="d-none">{{u.username}}</div>
{% endif %}
{% endif %}
{% if v %}
<div id='tax' class="d-none">{% if v.patron or u.patron %}0{% else %}0.03{% endif %}</div>
<div id="username" class="d-none">{{u.username}}</div>
<script defer src="{{'js/userpage_v.js' | asset}}"></script>
{% endif %}
<script defer src="{{'js/userpage.js' | asset}}"></script>
{% endblock %}

View File

@ -1,6 +1,6 @@
{% extends "userpage/userpage.html" %}
{% block content %}
<div class="row justify-content-center">
{% block userpage_content %}
<div class="row justify-content-center userpage-private">
<div class="col-10 col-md-5">
<div class="text-center px-3 my-3">
<span class="fa-stack fa-2x text-muted mb-4">
@ -12,29 +12,4 @@
</div>
</div>
</div>
{% if u.song %}
{% if v and v.id == u.id %}
<div id="v_username" class="d-none">{{v.username}}</div>
{% else %}
<div id="u_username" class="d-none">{{u.username}}</div>
{% endif %}
{% endif %}
{% endblock %}
{% block pagenav %}
{% if u.song %}
<div id="uid" class="d-none">{{u.id}}</div>
{% endif %}
{% if v %}
<div id='tax' class="d-none">{% if v.patron or u.patron %}0{% else %}0.03{% endif %}</div>
<div id="username" class="d-none">{{u.username}}</div>
{%- include "modals/emoji.html" -%}
<script defer src="{{'js/userpage_v.js' | asset}}"></script>
{% endif %}
<script defer src="{{'js/userpage.js' | asset}}"></script>
{% endblock %}

View File

@ -0,0 +1,10 @@
{%- extends 'userpage/userpage.html' -%}
{% block userpage_content %}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %} userpage-submissions" style="margin-top: 10px;">
<div class="col">
<div class="posts">
{% include "submission_listing.html" %}
</div>
</div>
</div>
{% endblock %}

View File

@ -13,17 +13,10 @@
<link rel="stylesheet" href="/{{u.id}}/profilecss">
{% endif %}
{% endblock %}
{%- include 'userpage/banner.html' -%}
{% block content %}
{%- include 'userpage/banner.html' -%}
{%- include 'userpage/header.html' -%}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %}" style="margin-top: 10px;">
<div class="col">
<div class="posts">
{% include "submission_listing.html" %}
</div>
</div>
</div>
{% block userpage_content required %}{% endblock %}
{% if FEATURES['USERS_PROFILE_SONG'] and u.song %}
{% if v and v.id == u.id %}
<div id="v_username" class="d-none">{{v.username}}</div>
@ -39,6 +32,7 @@
{% endif %}
<script defer src="{{'js/userpage.js' | asset}}"></script>
{% endblock %}
{% endblock %}
{% block pagenav %}
{% if listing %}

View File

@ -1,40 +1,24 @@
{% extends "userpage/userpage.html" %}
{% block content %}
{%- include "userpage/header.html" -%}
{{macros.comment_reply_box(u.fullname, 'replying-to-' + u.fullname, '', 'mb-3', true, '/comments/')}}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %} px-3 p-md-0" style="margin-top: 10px;">
<div class="col">
<div class="comment-section" id="replies-of-{{u.fullname}}">
{% with comments=listing %}
{% include "comments.html" %}
{% endwith %}
</div>
{% if not listing %}
<div class="text-center px-3 my-3">
<span class="fa-stack fa-2x text-muted mb-4">
<i class="fas fa-square text-gray-500 opacity-25 fa-stack-2x"></i>
<i class="fas text-gray-500 fa-scroll-old fa-stack-1x text-lg"></i>
</span>
<h5>There's no comments on {% if u.id == v.id %}your{% else %}@{{u.username}}'s{% endif %} wall yet!</h5>
{% block userpage_content %}
<div class="userpage-wall">
{{macros.comment_reply_box(u.fullname, 'replying-to-' + u.fullname, '', 'mb-3', true, '/comments/')}}
<div class="row no-gutters {% if listing %}mt-md-3{% elif not listing %}my-md-3{% endif %} px-3 p-md-0 userpage-wall" style="margin-top: 10px;">
<div class="col">
<div class="comment-section" id="replies-of-{{u.fullname}}">
{% with comments=listing %}
{% include "comments.html" %}
{% endwith %}
</div>
{% endif %}
{% if not listing %}
<div class="text-center px-3 my-3">
<span class="fa-stack fa-2x text-muted mb-4">
<i class="fas fa-square text-gray-500 opacity-25 fa-stack-2x"></i>
<i class="fas text-gray-500 fa-scroll-old fa-stack-1x text-lg"></i>
</span>
<h5>There's no comments on {% if u.id == v.id %}your{% else %}@{{u.username}}'s{% endif %} wall yet!</h5>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% if u.song %}
{% if v and v.id == u.id %}
<div id="v_username" class="d-none">{{v.username}}</div>
{% else %}
<div id="u_username" class="d-none">{{u.username}}</div>
{% endif %}
{% endif %}
{% if v %}
<div id='tax' class="d-none">{% if v.patron or u.patron %}0{% else %}0.03{% endif %}</div>
<div id="username" class="d-none">{{u.username}}</div>
<script defer src="{{'js/userpage_v.js' | asset}}"></script>
{% endif %}
<script defer src="{{'js/userpage.js' | asset}}"></script>
{% endblock %}