diff --git a/files/classes/user.py b/files/classes/user.py index 607409242..ec4fb4ebe 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -100,6 +100,7 @@ class User(Base): fp = Column(String) sigs_disabled = Column(Boolean) fish = Column(Boolean) + progressivestack = Column(Integer) friends = deferred(Column(String)) friends_html = deferred(Column(String)) enemies = deferred(Column(String)) diff --git a/files/helpers/const.py b/files/helpers/const.py index 36cfb7b68..20e37e31d 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1,37 +1,26 @@ -from os import environ +from os import environ, listdir import re from copy import deepcopy SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() +marseys = [] +others = [] +for x in sorted(x.replace('.webp','') for x in listdir("files/assets/images/emojis")): + if x.startswith('mar') or x.endswith('sey'): marseys.append(x) + else: others.append(x) +allemojis = marseys + others + AJ_REPLACEMENTS = { - " you're ": ' $#3$2 ', ' your ': " you're ", - ' $#3$2 ': ' your ', - " too ": ' $#3$3 ', - ' to ': " too ", - ' $#3$3 ': ' to ', - ' my ': ' their ', - ' mine ': ' their ', + ' to ': " too ", - " You're ": ' $#3$2 ', ' Your ': " You're ", - ' $#3$2 ': ' Your ', - " Too ": ' $#3$3 ', ' To ': " Too ", - ' $#3$3 ': ' To ', - ' My ': ' Their ', - ' Mine ': ' Their ', - " YOU'RE ": ' $#3$2 ', ' YOUR ': " YOU'RE ", - ' $#3$2 ': ' YOUR ', - " TOO ": ' $#3$3 ', ' TO ': " TOO ", - ' $#3$3 ': ' TO ', - ' MY ': ' THEIR ', - ' MINE ': ' THEIR ', } SLURS = { @@ -549,7 +538,7 @@ AWARDS = { "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", - "price": 500 + "price": 300 }, "fireflies": { "kind": "fireflies", @@ -557,7 +546,7 @@ AWARDS = { "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", - "price": 500 + "price": 300 }, "train": { "kind": "train", @@ -565,8 +554,16 @@ AWARDS = { "description": "Summons a train on the post.", "icon": "fas fa-train", "color": "text-pink", - "price": 500 + "price": 300 }, + "wholesome": { + "kind": "wholesome", + "title": "Wholesome", + "description": "Summons a wholesome marsey on the post.", + "icon": "fas fa-smile-beam", + "color": "text-yellow", + "price": 300 + }, "pin": { "kind": "pin", "title": "1-Hour Pin", @@ -615,6 +612,14 @@ AWARDS = { "color": "text-purple", "price": 2500 }, + "progressivestack": { + "kind": "progressivestack", + "title": "Progressive Stack", + "description": "Makes votes on the recipient's posts and comments weigh double in the ranking algorithm for 6 hours.", + "icon": "fas fa-bullhorn", + "color": "text-red", + "price": 3000 + }, "marsey": { "kind": "marsey", "title": "Marsey", diff --git a/files/helpers/markdown.py b/files/helpers/markdown.py index 341ad8908..6e94f13a8 100644 --- a/files/helpers/markdown.py +++ b/files/helpers/markdown.py @@ -25,7 +25,7 @@ class RedditorMention(SpanToken): pattern = re.compile("(^|\s|\n)(u/|/u/)((\w|-){3,25})") parse_inner = False def __init__(self, match_obj): - self.target = (match_obj.group(2), match_obj.group(3)) + self.target = (match_obj.group(1), match_obj.group(3)) class CustomRenderer(HTMLRenderer): diff --git a/files/routes/admin.py b/files/routes/admin.py index 6e6f329d4..f86f22b87 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -219,7 +219,7 @@ def monthly(v): @app.get('/admin/sidebar') -@admin_level_required(2) +@admin_level_required(3) def get_sidebar(v): try: @@ -232,7 +232,7 @@ def get_sidebar(v): @app.post('/admin/sidebar') @limiter.limit("1/second") -@admin_level_required(2) +@admin_level_required(3) @validate_formkey def post_sidebar(v): @@ -786,7 +786,7 @@ def admin_title_change(user_id, v): user=g.db.query(User).with_for_update().filter_by(id=user.id).first() user.customtitle=new_name - if request.values.get("locked"): user.flairchanged = time.time() + 2629746 + if request.values.get("locked"): user.flairchanged = int(time.time()) + 2629746 g.db.add(user) if user.flairchanged: kind = "set_flair_locked" diff --git a/files/routes/awards.py b/files/routes/awards.py index f4b2fd60d..127f69cde 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -24,7 +24,7 @@ AWARDS3 = { "description": "Makes fireflies swarm the post.", "icon": "fas fa-sparkles", "color": "text-warning", - "price": 500 + "price": 300 }, "shit": { "kind": "shit", @@ -32,7 +32,7 @@ AWARDS3 = { "description": "Makes flies swarm the post.", "icon": "fas fa-poop", "color": "text-black-50", - "price": 500 + "price": 300 }, } @@ -261,7 +261,7 @@ def award_post(pid, v): elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter_expires_utc == 0): if author.username == "911roofer": abort(403) if author.agendaposter_expires_utc and time.time() < author.agendaposter_expires_utc: author.agendaposter_expires_utc += 86400 - else: author.agendaposter_expires_utc = time.time() + 86400 + else: author.agendaposter_expires_utc = int(time.time()) + 86400 author.agendaposter = True if not author.has_badge(26): @@ -273,7 +273,7 @@ def award_post(pid, v): author.customtitleplain = new_name author.customtitle = filter_emojis_only(new_name) if len(author.customtitle) > 1000: abort(403) - author.flairchanged = time.time() + 86400 + author.flairchanged = int(time.time()) + 86400 elif kind == "pause": author.mute = True send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award!") @@ -290,18 +290,18 @@ def award_post(pid, v): send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") elif kind == "marsey": if author.marseyawarded: author.marseyawarded += 86400 - else: author.marseyawarded = time.time() + 86400 + else: author.marseyawarded = int(time.time()) + 86400 elif kind == "pizzashill": if author.bird: return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404 if author.longpost: author.longpost += 86400 - else: author.longpost = time.time() + 86400 + else: author.longpost = int(time.time()) + 86400 send_repeatable_notification(IDIO_ID, f"@{v.username} used {kind} award on [{post.shortlink}]({post.shortlink})") elif kind == "bird": if author.longpost: return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404 if author.bird: author.bird += 86400 - else: author.bird = time.time() + 86400 + else: author.bird = int(time.time()) + 86400 elif kind == "eye": author.eye = True send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award!") @@ -331,6 +331,9 @@ def award_post(pid, v): new_badge = Badge(badge_id=90, user_id=author.id) g.db.add(new_badge) send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") + elif kind == "progressivestack": + if author.progressivestack: author.progressivestack += 21600 + else: author.progressivestack = int(time.time()) + 21600 if post.author.received_award_count: post.author.received_award_count += 1 else: post.author.received_award_count = 1 @@ -438,7 +441,7 @@ def award_comment(cid, v): elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter_expires_utc == 0): if author.username == "911roofer": abort(403) if author.agendaposter_expires_utc and time.time() < author.agendaposter_expires_utc: author.agendaposter_expires_utc += 86400 - else: author.agendaposter_expires_utc = time.time() + 86400 + else: author.agendaposter_expires_utc = int(time.time()) + 86400 author.agendaposter = True if not author.has_badge(26): @@ -450,7 +453,7 @@ def award_comment(cid, v): author.customtitleplain = new_name author.customtitle = filter_emojis_only(new_name) if len(author.customtitle) > 1000: abort(403) - author.flairchanged = time.time() + 86400 + author.flairchanged = int(time.time()) + 86400 elif kind == "pause": author.mute = True send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award!") @@ -467,18 +470,18 @@ def award_comment(cid, v): send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") elif kind == "marsey": if author.marseyawarded: author.marseyawarded += 86400 - else: author.marseyawarded = time.time() + 86400 + else: author.marseyawarded = int(time.time()) + 86400 elif kind == "pizzashill": if author.bird: return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404 if author.longpost: author.longpost += 86400 - else: author.longpost = time.time() + 86400 + else: author.longpost = int(time.time()) + 86400 send_repeatable_notification(IDIO_ID, f"@{v.username} used {kind} award on [{c.shortlink}]({c.shortlink})") elif kind == "bird": if author.longpost: return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404 if author.bird: author.bird += 86400 - else: author.bird = time.time() + 86400 + else: author.bird = int(time.time()) + 86400 elif kind == "eye": author.eye = True send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award!") @@ -508,6 +511,9 @@ def award_comment(cid, v): new_badge = Badge(badge_id=90, user_id=author.id) g.db.add(new_badge) send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") + elif kind == "progressivestack": + if author.progressivestack: author.progressivestack += 21600 + else: author.progressivestack = int(time.time()) + 21600 if c.author.received_award_count: c.author.received_award_count += 1 else: c.author.received_award_count = 1 diff --git a/files/routes/posts.py b/files/routes/posts.py index ce96480f3..32eb627c4 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -27,8 +27,7 @@ titleheaders = {"User-Agent": f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleW if path.exists(f'snappy_{site_name}.txt'): with open(f'snappy_{site_name}.txt', "r") as f: - snappyquotes = f.read().split("{[para]}") - + snappyquotes = f.read().split("{[para]}") + [f':#{x}:' for x in marseys] @app.post("/toggle_club/") @auth_required def toggle_club(pid, v): diff --git a/files/routes/static.py b/files/routes/static.py index 3b79654be..e7229e04a 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -12,7 +12,6 @@ from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2 site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() - @app.get("/privacy") @auth_desired def privacy(v): @@ -21,10 +20,9 @@ def privacy(v): @app.get("/emojis") @auth_desired def emojis(v): - emojis = (x.replace('.webp','') for x in os.listdir("files/assets/images/emojis")) if not v or v.oldsite: template = '' else: template = 'CHRISTMAS/' - return render_template(f"{template}emojis.html", v=v, emojis=emojis) + return render_template(f"{template}emojis.html", v=v, emojis=allemojis) @app.get('/sidebar') @auth_desired diff --git a/files/routes/votes.py b/files/routes/votes.py index e18ff923f..aba69dd77 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -118,6 +118,7 @@ def api_vote_post(post_id, new, v): post.upvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1).count() post.downvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=-1).count() post.realupvotes = g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1, real=True).count() - g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=1, real=False).count() + g.db.query(Vote.id).filter_by(submission_id=post.id, vote_type=-1).count() + if post.author.progressivestack: post.realupvotes *= 2 g.db.add(post) g.db.commit() except: g.db.rollback() @@ -184,6 +185,7 @@ def api_vote_comment(comment_id, new, v): comment.upvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=1).count() comment.downvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=-1).count() comment.realupvotes = g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=1, real=True).count() - g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=1, real=False).count() + g.db.query(CommentVote.id).filter_by(comment_id=comment.id, vote_type=-1).count() + if comment.author.progressivestack: comment.realupvotes *= 2 g.db.add(comment) g.db.commit() except: g.db.rollback() diff --git a/files/templates/CHRISTMAS/default.html b/files/templates/CHRISTMAS/default.html index 10fea4bc1..de30fbb04 100644 --- a/files/templates/CHRISTMAS/default.html +++ b/files/templates/CHRISTMAS/default.html @@ -336,7 +336,7 @@ - + diff --git a/files/templates/CHRISTMAS/settings_profile.html b/files/templates/CHRISTMAS/settings_profile.html index 8cf41f57d..d3b024348 100644 --- a/files/templates/CHRISTMAS/settings_profile.html +++ b/files/templates/CHRISTMAS/settings_profile.html @@ -416,7 +416,7 @@ - + {% if v %} - + {% if v.agendaposter %} - + {% endif %} diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index ab403230c..0c3826651 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -81,7 +81,7 @@ - + - + {% if v.agendaposter %} - + {% endif %}
diff --git a/files/templates/login.html b/files/templates/login.html index 794920193..dac7afa7a 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -18,7 +18,7 @@ {% endblock %} - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 1df51ebd4..83f385a38 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -14,7 +14,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index eff79a718..fed1c8424 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -34,7 +34,7 @@ - + {% if v.agendaposter %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index e56e2412b..7948c5ae6 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -31,7 +31,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 6c55b27c3..f2b9e9eb1 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -32,7 +32,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/submission.html b/files/templates/submission.html index 6540425d1..b2ee00d03 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -13,6 +13,45 @@ {% block title %} +{% if p.award_count("wholesome") %} + + + + + + +{% endif %} + +{% if p.award_count("wholesome") > 1 %} + + + + + +{% endif %} + +{% if p.award_count("wholesome") > 2 %} + + + + + +{% endif %} + +{% if p.award_count("wholesome") > 3 %} + + + + + +{% endif %} + {% if p.award_count("train") %} - + {% if v.agendaposter %} - + {% endif %} {% endblock %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 302570beb..6816c659e 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -167,7 +167,7 @@

-							
+							
 							

 							
 							 
@@ -180,6 +180,8 @@
 							
 						
+
+
{{u.username}} will receive 0 {{'COINS_NAME' | app_config}}
@@ -446,7 +448,7 @@

 						 
-						
+						
 						

 						
 						 
@@ -459,6 +461,8 @@
 						
 					
+
+
{{u.username}} will receive 0 {{'COINS_NAME' | app_config}}
@@ -702,6 +706,8 @@ {% endif %} + +