From 88e4d114fa961e0b4ac5e4c20305ca9fac9c099c Mon Sep 17 00:00:00 2001 From: justcool393 Date: Mon, 24 Jul 2023 05:17:22 -0500 Subject: [PATCH] Base userpage template so we're not copying the same code all the time --- files/routes/users.py | 4 +- files/templates/userpage.html | 600 +++++++++++++++++++-- files/templates/userpage_comments.html | 31 ++ files/templates/userpage_private.html | 2 +- files/templates/userpage_submissions.html | 624 +--------------------- 5 files changed, 597 insertions(+), 664 deletions(-) create mode 100644 files/templates/userpage_comments.html diff --git a/files/routes/users.py b/files/routes/users.py index 76fafd41e..25809fb07 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -776,7 +776,7 @@ def u_username_comments(username, v=None): is_following = (v and user.has_follower(v)) if request.headers.get("Authorization"): return {"data": [c.json for c in listing]} - return render_template("userpage.html", u=user, v=v, listing=listing, page=page, sort=sort, t=t,next_exists=next_exists, is_following=is_following, standalone=True) + return render_template("userpage_comments.html", u=user, v=v, listing=listing, page=page, sort=sort, t=t,next_exists=next_exists, is_following=is_following, standalone=True) @app.get("/@/info") @@ -961,7 +961,7 @@ def saved_comments(v, username): if request.headers.get("Authorization"): return {"data": [x.json for x in listing]} return render_template( - "userpage.html", + "userpage_comments.html", u=v, v=v, listing=listing, diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 1d7969fb8..ab230c8a4 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -1,24 +1,542 @@ -{% extends "userpage_submissions.html" %} +{% extends "default.html" %} {%- import 'component/sorting_time.html' as sorting_time -%} -{% block content %} +{% block pagetype %}userpage{% endblock %} -
+{% block title %} + +{% if u and u.profilecss and not request.values.get('nocss') %} + +{% endif %} + +{{u.username}}'s profile - {{SITE_TITLE}} + + + + + + + + + + + + + + + + + +{% endblock %} + +{% block desktopUserBanner %} + +
+
+
+
+
+
+
+
+ +
+
+ {% if u.is_suspended %} +
BANNED USER{% if u.ban_reason %}: + {% if u.ban_reason_link %}{% endif %} + {{u.ban_reason | safe}} + {% if u.ban_reason_link %}{% endif %} + {% endif %}
+ {% if u.unban_utc %}
>{{u.unban_string}}
{% endif %} + {% endif %} +
+

{{u.username}}

+ + {% if u.username != u.original_username %} + + + + {% endif %} + + {% if u.verified %} + + {% endif %} + + {% if u.admin_level > 1 or (u.admin_level == 1 and not(v and v.admin_level >= 2)) %} + + + + {% endif %} + {% if v and v.has_follower(u) %} + Follows you + {% endif %} +
+ {% if v and v.id != u.id %} + + {% endif %} + {% if v and v.id == u.id %} + + {% endif %} +
+
+ + {% if u.customtitle %}

{{u.customtitle | safe}}

+ {% else %}

+				{% endif %}
+				
+				{% if v and v.admin_level >= 2 %}
+					
+				{% endif %}
+
+				
+
+				{% if u.bio_html %}
+					

+					
{{u.bio_html | safe}}
+ {% else %} +

+					

No bio...

+ {% endif %} + + {% if u.friends_html %} +

Friends:

+ {{u.friends_html | safe}} + {% endif %} + + {% if u.enemies_html %} +

Enemies:

+ {{u.enemies_html | safe}} + {% endif %} + + {% if FEATURES['AWARDS'] and u.received_awards %} +
+

Awards received

+ {% for a in u.received_awards %} + + + x{{a['count']}} + + {% endfor %} +
+ {% endif %} + +
+
+ {% if v and v.id != u.id %} + Unfollow + + Follow + Message + + {% if v and v.admin_level >= 3 %} + Make admin + Remove admin + {% if u.admin_level > 1 %} + Revert admin actions + {% endif %} + {% endif %} + +
+ {{forms.formkey(v)}} +

+							
+							

+							
+							 
+							
+							 
+							
+							 
+							
+						
+ +
+ + {% elif v and v.id == u.id %} + Edit profile + Profile views + {% endif %} + + {% if v and v.id != u.id and v.admin_level >= 2 %} +

+
+
+ +
+ {{forms.formkey(v)}} + +
+
+ + +
+     + +
+
+
+ +
+

+						{% if u.is_suspended %}
+							
+ {{forms.formkey(v)}} + + +
+ {% else %} +
+ {{forms.formkey(v)}} + + + +
+ + +
+ +
+ {% endif %} +

+						

+
+						Shadowban
+
+						Unshadowban
+
+
+						

+						
+						{% if v and v.admin_level >= 3 %}
+							Verify
+							Unverify
+						{% endif %}
+
+						

+						
+ + + +
+

+						
+ + + +
+

+						
+						
+						{% endif %}
+					

+					

User ID: {{u.id}}

+ + {% if u.is_private %} +

User has private mode enabled.

+ {% endif %} + {% if v and v.admin_level >= 2 %} + Alts: +
    + {% for account in u.alts_unique %} +
  • @{{account.username}}{% if account._is_manual %} [m]{% endif %}
  • + {% endfor %} +
+ {% endif %} + {% if u.is_suspended %} +

Banned by: @{{u.banned_by.username}}

+ {% endif %} +
+
+ +
+ {% for b in u.badges %} + {% if b.url %} + {{b.name}} + {% else %} + {{b.name}} + {% endif %} + {% endfor %} +
+ + +
+
+
+
+
+
+
+{% endblock %} + +{% block mobileUserBanner %} +
+
+
+ + @{{u.username}}'s banner + p +
+
+
+
+
+ +
+
+ {% if u.is_suspended %} +
BANNED USER{% if u.ban_reason %}: {{u.ban_reason | safe}}{% endif %}
+ {% if u.unban_utc %}
>{{u.unban_string}}
{% endif %} + {% endif %} + +

{{u.username}}

+ + {% if u.username != u.original_username %} + + + + {% endif %} + + {% if u.verified %} +   + {% endif %} + + {% if u.admin_level > 1 or (u.admin_level == 1 and not(v and v.admin_level >= 2)) %} + + + + {% endif %} + {% if v and v.has_follower(u) and not v.is_nofollow %} + Follows you + {% endif %} + {% if u.customtitle %}

{{u.customtitle | safe}}

+ {% else %} +

+				{% endif %}
+
+				{% if v and v.admin_level >= 2 %}
+					
+				{% endif %}
+
+				
+ {{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   + + follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}   + + {% if u.basedcount %} +
Based count: {{u.basedcount}} + {% endif %} + +
joined {{u.created_date}} +
+ {% if u.bio_html %} +

{{u.bio_html | safe}}

+ {% endif %} + + {% if u.friends_html %} +

Friends:

+ {{u.friends_html | safe}} + {% endif %} + + {% if u.enemies_html %} +

Enemies:

+ {{u.enemies_html | safe}} + {% endif %} + + {% if FEATURES['AWARDS'] and u.received_awards %} +
+

Awards received

+ {% for a in u.received_awards %} + + + x{{a['count']}} + + {% endfor %} +
+ {% endif %} + +
+ {% for b in u.badges %} + {% if b.url %} + {{b.name}} + {% else %} + {{b.name}} + {% endif %} + {% endfor %} +
+ {% if v and v.id == u.id %} + Edit profile + Profile views + {% endif %} + + {% if v and v.id != u.id %} + Unfollow + + Follow + Message + + {% if v and v.admin_level >= 3 %} + Make admin + Remove admin + {% if u.admin_level > 1 %} + Revert admin actions + {% endif %} + {% endif %} + +
+

+						{{forms.formkey(v)}} 
+						
+						

+						
+						 
+						
+						 
+						
+						 
+						
+					
+ +
+ + {% if v and v.admin_level >= 2 %} + + + + +

+
+ +
+ +
+ {{forms.formkey(v)}} + +
+
+ + +
+     + +
+
+
+ +
+

+						{% if u.is_suspended %}
+							
+ + + +
+ {% else %} +
+ {{forms.formkey(v)}} + + + +
+
+ + +
+
+ +
+ {% endif %} +

+						

+
+						Shadowban
+
+						Unshadowban
+
+
+						

+
+						{% if v and v.admin_level >= 3 %}
+							Verify
+							Unverify
+						{% endif %}
+
+						

+						
+ + + +
+

+						
+ + + +
+ {% endif %} + {% endif %} +

+				

User ID: {{u.id}}

+ + {% if u.is_private %} +

User has private mode enabled.

+ {% endif %} + {% if v and v.admin_level >= 2 %} + Alts: +
    + {% for account in u.alts_unique %} +
  • @{{account.username}}{% if account._is_manual %} [m]{% endif %}
  • + {% endfor %} +
+ {% endif %} + {% if u.is_suspended %} +

Banned by: @{{u.banned_by.username}}

+ {% endif %} +
+
+
+
+{% endblock %} + +{% block content %} +{% block userpage_nav %} +
- {{sorting_time.sort_dropdown(sort, t, SORTS_COMMENTS)}} + {{sorting_time.sort_dropdown(sort, t, SORTS_POSTS)}}
{% endif %} - -
- -
- - {% if listing %} -
- {% with comments=listing %} - {% include "comments.html" %} - {% endwith %} -
- {% else %} -
- - - - - {% if '/saved/' in request.path %} -

You haven't saved any comments yet

- {% elif v and v.id == u.id %} -

You haven't made any comments yet

-

Your commenting history will show here.

- {% else %} -

@{{u.username}} hasn't made any comments yet

-

Their commenting history will show here.

- {% endif %} -
- - {% endif %} -
-
+{% endblock %} +{% block userpage_content required %}{% endblock %} {% if v %} -
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
+
{% if v.patron or u.patron or v.alts_patron or u.alts_patron %}0{% else %}0.03{% endif %}
{{u.username}}
{% endif %} {% endblock %} + +{% block pagenav %} +{% if listing %} + +{% endif %} + + + + + +{% endblock %} + +{% block GIFpicker %} +{% endblock %} diff --git a/files/templates/userpage_comments.html b/files/templates/userpage_comments.html new file mode 100644 index 000000000..789145c5d --- /dev/null +++ b/files/templates/userpage_comments.html @@ -0,0 +1,31 @@ +{% extends "userpage/userpage.html" %} +{% block userpage_content %} +
+
+ {% if listing %} +
+ {% with comments=listing %} + {% include "comments.html" %} + {% endwith %} +
+ {% else %} +
+ + + + + {% if '/saved/' in request.path %} +

You haven't saved any comments yet

+ {% elif v and v.id == u.id %} +

You haven't made any comments yet

+

Your commenting history will show here.

+ {% else %} +

@{{u.username}} hasn't made any comments yet

+

Their commenting history will show here.

+ {% endif %} +
+ + {% endif %} +
+
+{% endblock %} diff --git a/files/templates/userpage_private.html b/files/templates/userpage_private.html index 415a5d4ca..abe474468 100644 --- a/files/templates/userpage_private.html +++ b/files/templates/userpage_private.html @@ -1,4 +1,4 @@ -{% extends "userpage.html" %} +{% extends "userpage/userpage.html" %} {% block content %} diff --git a/files/templates/userpage_submissions.html b/files/templates/userpage_submissions.html index 1158b08af..54a23b760 100644 --- a/files/templates/userpage_submissions.html +++ b/files/templates/userpage_submissions.html @@ -1,628 +1,10 @@ -{% extends "default.html" %} -{%- import 'component/sorting_time.html' as sorting_time -%} - -{% block pagetype %}userpage{% endblock %} - -{% block title %} - -{% if u and u.profilecss and not request.values.get('nocss') %} - -{% endif %} - -{{u.username}}'s profile - {{SITE_TITLE}} - - - - - - - - - - - - - - - - - -{% endblock %} - -{% block desktopUserBanner %} - -
-
-
-
-
-
-
-
- -
-
- {% if u.is_suspended %} -
BANNED USER{% if u.ban_reason %}: - {% if u.ban_reason_link %}{% endif %} - {{u.ban_reason | safe}} - {% if u.ban_reason_link %}{% endif %} - {% endif %}
- {% if u.unban_utc %}
>{{u.unban_string}}
{% endif %} - {% endif %} -
-

{{u.username}}

- - {% if u.username != u.original_username %} - - - - {% endif %} - - {% if u.verified %} - - {% endif %} - - {% if u.admin_level > 1 or (u.admin_level == 1 and not(v and v.admin_level >= 2)) %} - - - - {% endif %} - {% if v and v.has_follower(u) %} - Follows you - {% endif %} -
- {% if v and v.id != u.id %} - - {% endif %} - {% if v and v.id == u.id %} - - {% endif %} -
-
- - {% if u.customtitle %}

{{u.customtitle | safe}}

- {% else %}

-				{% endif %}
-				
-				{% if v and v.admin_level >= 2 %}
-					
-				{% endif %}
-
-				
-
-				{% if u.bio_html %}
-					

-					
{{u.bio_html | safe}}
- {% else %} -

-					

No bio...

- {% endif %} - - {% if u.friends_html %} -

Friends:

- {{u.friends_html | safe}} - {% endif %} - - {% if u.enemies_html %} -

Enemies:

- {{u.enemies_html | safe}} - {% endif %} - - {% if FEATURES['AWARDS'] and u.received_awards %} -
-

Awards received

- {% for a in u.received_awards %} - - - x{{a['count']}} - - {% endfor %} -
- {% endif %} - -
-
- {% if v and v.id != u.id %} - Unfollow - - Follow - Message - - {% if v and v.admin_level >= 3 %} - Make admin - Remove admin - {% if u.admin_level > 1 %} - Revert admin actions - {% endif %} - {% endif %} - -
- {{forms.formkey(v)}} -

-							
-							

-							
-							 
-							
-							 
-							
-							 
-							
-						
- -
- - {% elif v and v.id == u.id %} - Edit profile - Profile views - {% endif %} - - {% if v and v.id != u.id and v.admin_level >= 2 %} -

-
-
- -
- {{forms.formkey(v)}} - -
-
- - -
-     - -
-
-
- -
-

-						{% if u.is_suspended %}
-							
- {{forms.formkey(v)}} - - -
- {% else %} -
- {{forms.formkey(v)}} - - - -
- - -
- -
- {% endif %} -

-						

-
-						Shadowban
-
-						Unshadowban
-
-
-						

-						
-						{% if v and v.admin_level >= 3 %}
-							Verify
-							Unverify
-						{% endif %}
-
-						

-						
- - - -
-

-						
- - - -
-

-						
-						
-						{% endif %}
-					

-					

User ID: {{u.id}}

- - {% if u.is_private %} -

User has private mode enabled.

- {% endif %} - {% if v and v.admin_level >= 2 %} - Alts: -
    - {% for account in u.alts_unique %} -
  • @{{account.username}}{% if account._is_manual %} [m]{% endif %}
  • - {% endfor %} -
- {% endif %} - {% if u.is_suspended %} -

Banned by: @{{u.banned_by.username}}

- {% endif %} -
-
- -
- {% for b in u.badges %} - {% if b.url %} - {{b.name}} - {% else %} - {{b.name}} - {% endif %} - {% endfor %} -
- - -
-
-
-
-
-
-
-{% endblock %} - -{% block mobileUserBanner %} -
-
-
- - @{{u.username}}'s banner - p -
-
-
-
-
- -
-
- {% if u.is_suspended %} -
BANNED USER{% if u.ban_reason %}: {{u.ban_reason | safe}}{% endif %}
- {% if u.unban_utc %}
>{{u.unban_string}}
{% endif %} - {% endif %} - -

{{u.username}}

- - {% if u.username != u.original_username %} - - - - {% endif %} - - {% if u.verified %} -   - {% endif %} - - {% if u.admin_level > 1 or (u.admin_level == 1 and not(v and v.admin_level >= 2)) %} - - - - {% endif %} - {% if v and v.has_follower(u) and not v.is_nofollow %} - Follows you - {% endif %} - {% if u.customtitle %}

{{u.customtitle | safe}}

- {% else %} -

-				{% endif %}
-
-				{% if v and v.admin_level >= 2 %}
-					
-				{% endif %}
-
-				
- {{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   - - follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}   - - {% if u.basedcount %} -
Based count: {{u.basedcount}} - {% endif %} - -
joined {{u.created_date}} -
- {% if u.bio_html %} -

{{u.bio_html | safe}}

- {% endif %} - - {% if u.friends_html %} -

Friends:

- {{u.friends_html | safe}} - {% endif %} - - {% if u.enemies_html %} -

Enemies:

- {{u.enemies_html | safe}} - {% endif %} - - {% if FEATURES['AWARDS'] and u.received_awards %} -
-

Awards received

- {% for a in u.received_awards %} - - - x{{a['count']}} - - {% endfor %} -
- {% endif %} - -
- {% for b in u.badges %} - {% if b.url %} - {{b.name}} - {% else %} - {{b.name}} - {% endif %} - {% endfor %} -
- {% if v and v.id == u.id %} - Edit profile - Profile views - {% endif %} - - {% if v and v.id != u.id %} - Unfollow - - Follow - Message - - {% if v and v.admin_level >= 3 %} - Make admin - Remove admin - {% if u.admin_level > 1 %} - Revert admin actions - {% endif %} - {% endif %} - -
-

-						{{forms.formkey(v)}} 
-						
-						

-						
-						 
-						
-						 
-						
-						 
-						
-					
- -
- - {% if v and v.admin_level >= 2 %} - - - - -

-
- -
- -
- {{forms.formkey(v)}} - -
-
- - -
-     - -
-
-
- -
-

-						{% if u.is_suspended %}
-							
- - - -
- {% else %} -
- {{forms.formkey(v)}} - - - -
-
- - -
-
- -
- {% endif %} -

-						

-
-						Shadowban
-
-						Unshadowban
-
-
-						

-
-						{% if v and v.admin_level >= 3 %}
-							Verify
-							Unverify
-						{% endif %}
-
-						

-						
- - - -
-

-						
- - - -
- {% endif %} - {% endif %} -

-				

User ID: {{u.id}}

- - {% if u.is_private %} -

User has private mode enabled.

- {% endif %} - {% if v and v.admin_level >= 2 %} - Alts: -
    - {% for account in u.alts_unique %} -
  • @{{account.username}}{% if account._is_manual %} [m]{% endif %}
  • - {% endfor %} -
- {% endif %} - {% if u.is_suspended %} -

Banned by: @{{u.banned_by.username}}

- {% endif %} -
-
-
-
-{% endblock %} - -{% block content %} - -
+{% extends "userpage/userpage.html" %} +{% block userpage_content %} + - -{% if not "saved" in request.full_path %} -
- -
-
- - -
- {{sorting_time.sort_dropdown(sort, t, SORTS_POSTS)}} -
-
-{% endif %} - -
- -
-
{% include "submission_listing.html" %}
-
-
- -{% if v %} -
{% if v.patron or u.patron or v.alts_patron or u.alts_patron %}0{% else %}0.03{% endif %}
- -
{{u.username}}
-{% endif %} - -{% endblock %} - -{% block pagenav %} -{% if listing %} - -{% endif %} - - - - - -{% endblock %} - -{% block GIFpicker %} {% endblock %}