From 382df30e1fa4121716bb65c69494607ba6183166 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 9 Jul 2022 10:35:47 +0200 Subject: [PATCH] show ALL timestamps in user's timezone + move scripts to the bottom of HTML templates to mimic rocketloader's behavior on localhost (for testing) --- files/classes/badges.py | 35 +++-- files/helpers/jinja2.py | 3 +- files/routes/front.py | 2 +- files/templates/admins.html | 5 +- files/templates/badges.html | 4 +- files/templates/ban_modal.html | 6 +- files/templates/chat.html | 3 +- files/templates/default.html | 3 +- files/templates/delete_post_modal.html | 4 +- files/templates/followers.html | 3 +- files/templates/following.html | 3 +- files/templates/home.html | 58 ++++---- files/templates/login.html | 4 +- files/templates/poll_votes.html | 4 +- files/templates/settings.html | 4 +- files/templates/settings2.html | 4 +- files/templates/settings_blocks.html | 4 +- files/templates/settings_profile.html | 21 +-- files/templates/settings_security.html | 4 +- files/templates/sign_up.html | 4 +- files/templates/sign_up_failed_ref.html | 4 +- files/templates/sub/subs.html | 5 +- files/templates/submission.html | 172 ++++++++++++------------ files/templates/submit.html | 3 +- files/templates/userpage.html | 14 +- files/templates/userpage_comments.html | 2 +- files/templates/userpage_private.html | 10 +- files/templates/util/assetcache.html | 4 +- files/templates/votes.html | 5 +- 29 files changed, 207 insertions(+), 190 deletions(-) diff --git a/files/classes/badges.py b/files/classes/badges.py index e298869f3..832f1a6bd 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -39,24 +39,33 @@ class Badge(Base): def __repr__(self): return f"" + @property + @lazy + def until(self): + if self.badge_id == 28: return self.user.agendaposter + if self.badge_id == 94: return self.user.progressivestack + if self.badge_id == 95: return self.user.bird + if self.badge_id == 96: return self.user.flairchanged + if self.badge_id == 97: return self.user.longpost + if self.badge_id == 98: return self.user.marseyawarded + if self.badge_id == 109: return self.user.rehab + return None + @property @lazy def text(self): - if self.name == "Chud": - ti = self.user.agendaposter - if ti: text = self.badge.description + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') + if self.badge_id == 28: + if ti: text = self.badge.description + " until" else: text = self.badge.description + " permanently" elif self.badge_id in {94,95,96,97,98,109}: - if self.badge_id == 94: ti = self.user.progressivestack - elif self.badge_id == 95: ti = self.user.bird - elif self.badge_id == 96: ti = self.user.flairchanged - elif self.badge_id == 97: ti = self.user.longpost - elif self.badge_id == 98: ti = self.user.marseyawarded - elif self.badge_id == 109: ti = self.user.rehab - text = self.badge.description + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') - elif self.description: text = self.description - elif self.badge.description: text = self.badge.description - else: return self.name + text = self.badge.description + " until" + elif self.description: + text = self.description + elif self.badge.description: + text = self.badge.description + else: + return self.name + return f'{self.name} - {text}' @property diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index aefa4417e..40e0ca164 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -3,7 +3,6 @@ from .get import * from os import listdir, environ from .const import * import time -from datetime import datetime @app.template_filter("post_embed") def post_embed(id, v): @@ -54,7 +53,7 @@ def inject_constants(): "AUTOJANNY_ID":AUTOJANNY_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR, - "COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "datetime":datetime, "time":time, + "COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "time":time, "HOLE_NAME": HOLE_NAME, "HOLE_STYLE_FLAIR": HOLE_STYLE_FLAIR, "HOLE_REQUIRED": HOLE_REQUIRED, "LOTTERY_ENABLED": LOTTERY_ENABLED, "GUMROAD_LINK": GUMROAD_LINK, "DEFAULT_THEME": DEFAULT_THEME, "DESCRIPTION": DESCRIPTION, "PERMS": PERMS, diff --git a/files/routes/front.py b/files/routes/front.py index 192cfd304..614775422 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -246,7 +246,7 @@ def random_user(v): u = g.db.query(User.username).filter(User.song != None).order_by(func.random()).first() if u: u = u[0] - else: abort(404) + else: return "No users have set a profile anthem so far!" return redirect(f"/@{u}") diff --git a/files/templates/admins.html b/files/templates/admins.html index 895b216e2..985875e53 100644 --- a/files/templates/admins.html +++ b/files/templates/admins.html @@ -4,8 +4,6 @@ {% block content %} - -

 
Admins

@@ -30,4 +28,7 @@
 		{% endfor %}
 	
 
+
+
+
 {% endblock %}
diff --git a/files/templates/badges.html b/files/templates/badges.html
index d61f65b66..37852ce2d 100644
--- a/files/templates/badges.html
+++ b/files/templates/badges.html
@@ -1,6 +1,5 @@
 {% extends "default.html" %}
 {% block content %}
-
 
 
 
@@ -37,4 +36,7 @@
 		{% endfor %}
 	
 
+
+
+
 {% endblock %}
\ No newline at end of file
diff --git a/files/templates/ban_modal.html b/files/templates/ban_modal.html
index c619fecfa..a5a9860cb 100644
--- a/files/templates/ban_modal.html
+++ b/files/templates/ban_modal.html
@@ -1,6 +1,4 @@
 
-
-
 
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/files/templates/chat.html b/files/templates/chat.html
index 915e94fcb..459efa804 100644
--- a/files/templates/chat.html
+++ b/files/templates/chat.html
@@ -109,8 +109,6 @@
 
 
 
-	
-
 	{% include "header.html" %}
 	
 	
@@ -196,6 +194,7 @@ + {% include "emoji_modal.html" %} diff --git a/files/templates/default.html b/files/templates/default.html index 94ff38d8e..553ba4616 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -11,7 +11,6 @@ {% endif %} - {% if v %} @@ -377,6 +376,8 @@
+ + {% if v %} diff --git a/files/templates/delete_post_modal.html b/files/templates/delete_post_modal.html index 05381601c..8eac25a0c 100644 --- a/files/templates/delete_post_modal.html +++ b/files/templates/delete_post_modal.html @@ -1,5 +1,3 @@ - - + + \ No newline at end of file diff --git a/files/templates/followers.html b/files/templates/followers.html index b167c0b33..9dbff40fc 100644 --- a/files/templates/followers.html +++ b/files/templates/followers.html @@ -1,6 +1,5 @@ {% extends "default.html" %} {% block content %} -
 
 	
@@ -30,4 +29,6 @@
 
 
 
+
+
 {% endblock %}
\ No newline at end of file
diff --git a/files/templates/following.html b/files/templates/following.html
index 55630df99..94316e19e 100644
--- a/files/templates/following.html
+++ b/files/templates/following.html
@@ -1,6 +1,5 @@
 {% extends "default.html" %}
 {% block content %}
-
 
 
 	
@@ -30,4 +29,6 @@
 
 
 
+
+
 {% endblock %}
\ No newline at end of file
diff --git a/files/templates/home.html b/files/templates/home.html
index 6b1e98ff5..1b3521301 100644
--- a/files/templates/home.html
+++ b/files/templates/home.html
@@ -9,35 +9,6 @@
 		}
 	
 {% endif %}
-
-{% if v and FP %}
-	{% if not v.fp %}
-		
-	{% endif %}
-{% endif %}
   
 
@@ -243,4 +214,33 @@ {% endif %} +{% if v and FP %} + {% if not v.fp %} + + {% endif %} +{% endif %} + {% endblock %} diff --git a/files/templates/login.html b/files/templates/login.html index 68487ab70..662c50145 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -9,8 +9,6 @@ - - @@ -120,6 +118,8 @@
+ + diff --git a/files/templates/poll_votes.html b/files/templates/poll_votes.html index 2da9149eb..1a40dc55f 100644 --- a/files/templates/poll_votes.html +++ b/files/templates/poll_votes.html @@ -9,8 +9,6 @@ {% if thing %} - -
 	
 
@@ -43,6 +41,8 @@ + + {% endif %} diff --git a/files/templates/settings.html b/files/templates/settings.html index 9599fb1be..2487a8f66 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -6,8 +6,6 @@ - - @@ -262,6 +260,8 @@ {% block onload %}{% endblock %} + + diff --git a/files/templates/settings2.html b/files/templates/settings2.html index ca9cad2c5..845db65d4 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -7,8 +7,6 @@ - - @@ -172,6 +170,8 @@ {% block scripts %} {% endblock %} + + \ No newline at end of file diff --git a/files/templates/settings_blocks.html b/files/templates/settings_blocks.html index 2b74e48f3..366493a9f 100644 --- a/files/templates/settings_blocks.html +++ b/files/templates/settings_blocks.html @@ -4,8 +4,6 @@ {% block content %} - -
@@ -118,4 +116,6 @@
+ + {% endblock %} \ No newline at end of file diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index ba4f92e0c..273eb4183 100644 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -463,14 +463,9 @@
- - {% if v.flairchanged %} - {% set ti = datetime.utcfromtimestamp(v.flairchanged).strftime('%Y-%m-%d %H:%M:%S') %} - {% endif %} -
- +
    @@ -738,9 +733,17 @@
- - {% include "emoji_modal.html" %} {% include "gif_modal.html" %} -{% endblock %} +{% if v.flairchanged %} + +{% endif %} + + + +{% endblock %} \ No newline at end of file diff --git a/files/templates/settings_security.html b/files/templates/settings_security.html index 73eaf727d..d761b8482 100644 --- a/files/templates/settings_security.html +++ b/files/templates/settings_security.html @@ -4,8 +4,6 @@ {% block content %} - -
@@ -265,4 +263,6 @@
+ + {% endblock %} \ No newline at end of file diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 025882988..0758adeb7 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -8,8 +8,6 @@ - - @@ -151,6 +149,8 @@
+ + {% if hcaptcha %} diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 8f29e2026..7a4f41a40 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -9,8 +9,6 @@ - - @@ -102,6 +100,8 @@ + + diff --git a/files/templates/sub/subs.html b/files/templates/sub/subs.html index ae08eeb2a..2f3d634dd 100644 --- a/files/templates/sub/subs.html +++ b/files/templates/sub/subs.html @@ -1,7 +1,5 @@ {% extends "default.html" %} {% block content %} - -
 
 	
@@ -31,4 +29,7 @@
 		{% endfor %}
 	
 
+
+
+
 {% endblock %}
\ No newline at end of file
diff --git a/files/templates/submission.html b/files/templates/submission.html
index 5df09550a..11bc853a9 100644
--- a/files/templates/submission.html
+++ b/files/templates/submission.html
@@ -22,97 +22,12 @@
 	}
 
 
-{% if success %}
-	
-{% endif %}
-
-
-{% if p.award_count("crab", v) %}
-	
-{% endif %}
-
-{% if fart and not (v and v.has_badge(128)) %}
-	
-{% endif %}
-
 {% if SITE_NAME == 'PCM' %}
 	{% set wholesome = '/i/wholesome.webp' %}
 {% else %}
 	{% set wholesome = '/e/marseywholesome.webp' %}
 {% endif %}
 
-{% if p.award_count("confetti", v) %}
-	
-{% endif %} - -{% if p.award_count("firework", v) %} - -
- -
- - {% if p.award_count("firework", v) > 1 %} -
- -
- {% endif %} - - {% if p.award_count("firework", v) > 2 %} -
- -
- {% endif %} - - {% if p.award_count("firework", v) > 3 %} -
- -
- {% endif %} -{% endif %} - -{% if p.award_count("ricardo", v) %} - -
- -
- - {% if p.award_count("ricardo", v) > 1 %} -
- -
- {% endif %} - - {% if p.award_count("ricardo", v) > 2 %} -
- -
- {% endif %} -{% endif %} - {% if g.inferior_browser %} {% if p.award_count("wholesome", v) %}