From 8c04bfd319842def4cc0f0caf6fd333224e14149 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 28 Sep 2021 04:44:47 +0200 Subject: [PATCH] squashing --- files/classes/comment.py | 6 +- files/classes/submission.py | 6 +- files/classes/user.py | 2 +- files/helpers/const.py | 121 ++++++--------------- files/templates/admin/badge_grant.html | 2 +- files/templates/admin/removed_posts.html | 2 +- files/templates/award_modal.html | 2 +- files/templates/changelog.html | 2 +- files/templates/comments.html | 114 +++++++++---------- files/templates/gif_modal.html | 2 +- files/templates/header.html | 24 ++-- files/templates/home.html | 2 +- files/templates/mobile_navigation_bar.html | 14 +-- files/templates/settings2.html | 2 +- files/templates/submission.html | 78 ++++++------- files/templates/submission_banned.html | 2 +- files/templates/submission_listing.html | 69 ++++++------ files/templates/submit.html | 2 +- 18 files changed, 198 insertions(+), 254 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 4408410bc..9f9fe610b 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -4,7 +4,7 @@ from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship, deferred from files.helpers.lazy import lazy -from files.helpers.const import SLURS +from files.helpers.const import SLURS, replace_keep_case from files.__main__ import Base from .flags import CommentFlag from os import environ @@ -286,8 +286,8 @@ class Comment(Base): if not body: return "" - if not v or v.slurreplacer: - for s, r in SLURS.items(): body = body.replace(s, r) + if not v or v.slurreplacer: + for s, r in SLURS.items(): body = replace_keep_case(f"{s} ", f"{r} ", replace_keep_case(f" {s}", f" {r}", body)) if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com") diff --git a/files/classes/submission.py b/files/classes/submission.py index 99f128d30..4faefa3b8 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -4,7 +4,7 @@ from sqlalchemy.orm import relationship, deferred import re, random from urllib.parse import urlparse from files.helpers.lazy import lazy -from files.helpers.const import SLURS +from files.helpers.const import SLURS, replace_keep_case from files.__main__ import Base from .flags import * from os import environ @@ -344,7 +344,7 @@ class Submission(Base): if not v or v.slurreplacer: for s,r in SLURS.items(): - body = body.replace(s, r) + body = replace_keep_case(f"{s} ", f"{r} ", replace_keep_case(f" {s}", f" {r}", body)) if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com") if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net") @@ -357,7 +357,7 @@ class Submission(Base): else: title = self.title if not v or v.slurreplacer: - for s,r in SLURS.items(): title = title.replace(s, r) + for s,r in SLURS.items(): title = replace_keep_case(f"{s} ", f"{r} ", replace_keep_case(f" {s}", f" {r}", title)) return title diff --git a/files/classes/user.py b/files/classes/user.py index 7c865f0b6..98d1c3a79 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -120,7 +120,7 @@ class User(Base): flairchanged = Column(Boolean, default=False) newtab = Column(Boolean, default=False) newtabexternal = Column(Boolean, default=True) - oldreddit = Column(Boolean) + oldreddit = Column(Boolean, default=True) nitter = Column(Boolean) controversial = Column(Boolean, default=False) submissions = relationship("Submission", lazy="dynamic", primaryjoin="Submission.author_id==User.id", viewonly=True) diff --git a/files/helpers/const.py b/files/helpers/const.py index 2058e14da..01eb10ab6 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1,97 +1,31 @@ from os import environ +import re site = environ.get("DOMAIN").strip() SLURS = { - " faggot":" cute twink", - " Faggot":" Cute twink", - " FAGGOT":" CUTE TWINK", - " fag":" cute twink", - " Fag":" Cute twink", - " FAG":" CUTE TWINK", - " kill yourself":" keep yourself safe", - " KILL YOURSELF":" KEEP YOURSELF SAFE", - " nigger":" 🏀", - " Nigger":" 🏀", - " NIGGER":" 🏀", - " pedo":" libertarian", - " Pedo":" Libertarian ", - " PEDO":" LIBERTARIAN ", - " rapist":" male feminist", - " Rapist":" Male feminist", - " RAPIST":" MALE FEMINIST", - " steve akins":" penny verity oaken", - " Steve Akins":" Penny Verity Oaken", - " STEVE AKINS":" PENNY VERITY OAKEN", - " trannie":" 🚂🚃🚃", - " Trannie":" 🚂🚃🚃", - " TRANNIE":" 🚂🚃🚃", - " tranny":" 🚂🚃🚃", - " Tranny":" 🚂🚃🚃", - " TRANNY":" 🚂🚃🚃", - " troon":" 🚂🚃🚃", - " Troon":" 🚂🚃🚃", - " TROON":" 🚂🚃🚃", - " NoNewNormal": " HorseDewormerAddicts", - " nonewnormal": " horsedewormeraddicts", - " Kike": " https://sciencedirect.com/science/article/abs/pii/S016028960600033X", - " kike": " https://sciencedirect.com/science/article/abs/pii/S016028960600033X", - " retard":" r-slur", - " Retard":" R-slur", - " RETARD":" R-SLUR", - " janny":" j-slur", - " Janny":" J-slur", - " JANNY":" J-SLUR", - " jannie":" j-slur", - " Jannie":" J-slur", - " JANNIE":" J-SLUR", - - "faggot ":"cute twink ", - "Faggot ":"Cute twink ", - "FAGGOT ":"CUTE TWINK ", - "fag ":"cute twink ", - "Fag ":"Cute twink ", - "FAG ":"CUTE TWINK ", - "kill yourself ":"keep yourself safe ", - "KILL YOURSELF ":"KEEP YOURSELF SAFE ", - "nigger ":"🏀 ", - "Nigger ":"🏀 ", - "NIGGER ":"🏀 ", - "pedo ":"libertarian ", - "Pedo ":"Libertarian ", - "PEDO ":"LIBERTARIAN ", - "steve akins ":"penny verity oaken ", - "Steve Akins ":"Penny Verity Oaken ", - "STEVE AKINS ":"PENNY VERITY OAKEN ", - "trannie ":"🚂🚃🚃 ", - "Trannie ":"🚂🚃🚃 ", - "TRANNIE ":"🚂🚃🚃 ", - "tranny ":"🚂🚃🚃 ", - "Tranny ":"🚂🚃🚃 ", - "TRANNY ":"🚂🚃🚃 ", - "troon ":"🚂🚃🚃 ", - "Troon ":"🚂🚃🚃 ", - "TROON ":"🚂🚃🚃 ", - "NoNewNormal ": "HorseDewormerAddicts ", - "nonewnormal ": "horsedewormeraddicts ", - "Kike ": "https://sciencedirect.com/science/article/abs/pii/S016028960600033X ", - "kike ": "https://sciencedirect.com/science/article/abs/pii/S016028960600033X ", - "retard ":"r-slur ", - "Retard ":"R-slur ", - "RETARD ":"R-SLUR ", - "janny ":"j-slur ", - "Janny ":"J-slur ", - "JANNY ":"J-SLUR ", - "jannie ":"j-slur ", - "Jannie ":"J-slur ", - "JANNIE ":"J-SLUR ", - - " nig ":" 🏀 ", - " Nig ":" 🏀 ", - " NIG ":" 🏀 ", - " nigs ":" 🏀s ", - " Nigs ":" 🏀s ", - " NIGS ":" 🏀s ", + "faggot":"cute twink", + "fag":"cute twink", + "kill yourself":"keep yourself safe", + "nigger":"🏀", + "pedophile":"libertarian", + "pedo":"libertarian", + "rapist":"male feminist", + "steve akins":"penny verity oaken", + "trannie":"🚂🚃🚃", + "tranny":"🚂🚃🚃", + "troon":"🚂🚃🚃", + "kike": "https://sciencedirect.com/science/article/abs/pii/S016028960600033X", + "retard":"r-slur", + "janny":"j-slur", + "jannie":"j-slur", + "latinos":"latinx", + "latino":"latinx", + "latinas":"latinx", + "latina":"latinx", + "hispanics":"latinx", + "hispanic":"latinx", + "nig":"🏀", } LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him,", '![](https://i.kym-cdn.com/photos/images/newsfeed/001/038/094/0a1.jpg)', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!'] @@ -123,3 +57,12 @@ LONGPOSTBOT_ACCOUNT = 1832 PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6' PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() + +def replace_keep_case(word, replacement, text): + def func(match): + g = match.group() + if g.islower(): return replacement.lower() + if g.istitle(): return replacement.title() + if g.isupper(): return replacement.upper() + return replacement + return re.sub(word, func, text, flags=re.I) \ No newline at end of file diff --git a/files/templates/admin/badge_grant.html b/files/templates/admin/badge_grant.html index d8744d5de..8ff12eb5b 100644 --- a/files/templates/admin/badge_grant.html +++ b/files/templates/admin/badge_grant.html @@ -55,7 +55,7 @@ {% for badge in badge_types %} - + {{badge.name}} {{badge.description}} diff --git a/files/templates/admin/removed_posts.html b/files/templates/admin/removed_posts.html index fc82c3c51..30390ab26 100644 --- a/files/templates/admin/removed_posts.html +++ b/files/templates/admin/removed_posts.html @@ -9,7 +9,7 @@ {% block content %} -
+
diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index 47f44ae94..557bb5f5a 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -19,7 +19,7 @@ {% endif %}
- {{award.title}} + {{award.title}} {{award.owned}} owned
{% endfor %} diff --git a/files/templates/changelog.html b/files/templates/changelog.html index 37c3436cb..69d3f3663 100644 --- a/files/templates/changelog.html +++ b/files/templates/changelog.html @@ -5,7 +5,7 @@ {% block desktopBanner %} -
+
diff --git a/files/templates/comments.html b/files/templates/comments.html index 342ced978..298f03742 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -117,7 +117,7 @@ {{single_comment(reply, level=level+1)}} {% endfor %}
-
+ {% endif %} @@ -249,8 +249,8 @@ Cancel Reply
- Cancel - Reply + Cancel + Reply
@@ -276,8 +276,8 @@ Cancel Save Edit
- Cancel - Save Edit + Cancel + Save Edit
{% endif %} @@ -317,77 +317,77 @@
  • Votes
  • {% if v %} -
  • Unsave
  • + Unsave -
  • Save
  • + Save {% if v.id!=c.author_id %} -
  • Give Award
  • + Give Award {% endif %} -
  • Reply
  • + Reply {% endif %} -
  • Context
  • -
  • Copy link
  • + Context + Copy link {% if v %} -
  • Report
  • + Report {% endif %} {% if v and c.parent_submission and c.author_id==v.id %} -
  • Edit
  • + Edit {% if c.deleted_utc > 0 %} -
  • Undelete
  • + Undelete {% else %} -
  • Delete
  • + Delete {% endif %} {% endif %} {% if v and v.admin_level==6 and v.id==c.author_id %} -
  • Undistinguish
  • -
  • Distinguish
  • + Undistinguish + Distinguish {% endif %} {% if v and not v.id==c.author_id and v.admin_level == 0 %} -
  • Unblock user
  • -
  • Block user
  • + Unblock user + Block user {% endif %} {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %} -
  • Unpin
  • + Unpin -
  • Pin
  • + Pin {% endif %} {% if v and v.admin_level>=3 %} {% if "/reported/" in request.path %} -
  • Approve
  • -
  • Remove
  • + Approve + Remove {% else %} -
  • Approve
  • -
  • Remove
  • + Approve + Remove {% endif %} {% endif %} {% if v and c.parent_submission and (c.author_id==v.id or v.admin_level > 0) %} -
  • Unmark +18
  • -
  • Mark +18
  • + Unmark +18 + Mark +18 {% endif %} {% if v and v.admin_level==6 and v.id != c.author_id %} -
  • Unban user
  • -
  • Ban user
  • + Unban user + Ban user {% endif %} {% if v and v.admin_level >=4 and c.oauth_app %} -
  • API App
  • + API App {% endif %} -
  • + {% if v and request.path.startswith('/@') and v.admin_level == 0 %} {% if voted==1 %}
  • {% endif %} {% elif v %} @@ -433,8 +433,8 @@ Cancel Comment
    - Cancel - Comment + Cancel + Comment
    @@ -454,7 +454,7 @@ {{single_comment(reply, level=level+1)}} {% endfor %}
    -
    + {% endif %} @@ -478,65 +478,65 @@
  • Votes
  • {% if v %} -
  • Save
  • + Save -
  • Unsave
  • + Unsave {% endif %} - + Copy link -
  • Context
  • + Context -
  • Report
  • + Report {% if v and c.parent_submission and c.author_id==v.id %} -
  • Edit
  • + Edit {% if c.deleted_utc > 0 %} -
  • Undelete
  • + Undelete {% else %} -
  • Delete
  • + Delete {% endif %} {% endif %} {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %} -
  • Pin
  • -
  • Unpin
  • + Pin + Unpin {% endif %} {% if v %} {% if v.admin_level>=1 and v.id==c.author_id %} -
  • Distinguish
  • -
  • Undistinguish
  • + Distinguish + Undistinguish {% endif %} {% if v.admin_level>=3 %} {% if "/reported/" in request.path %} -
  • Remove
  • -
  • Approve
  • + Remove + Approve {% else %} -
  • Remove
  • -
  • Approve
  • + Remove + Approve {% endif %} {% endif %} {% if v.admin_level >=4 and c.oauth_app %} -
  • API App
  • + API App {% endif %} {% if not v.id==c.author_id and v.admin_level == 0 %} -
  • Block user
  • -
  • Unblock user
  • + Block user + Unblock user {% endif %} {% endif %} {% if v and c.parent_submission and (c.author_id==v.id or v.admin_level > 0) %} -
  • Mark +18
  • -
  • Unmark +18
  • + Mark +18 + Unmark +18 {% endif %} {% if v and (c.post and v.admin_level == 6) %} {% if c.author_id != v.id %} -
  • Ban user
  • -
  • Unban user
  • + Ban user + Unban user {% endif %} {% endif %} diff --git a/files/templates/gif_modal.html b/files/templates/gif_modal.html index e37121b42..ab6097770 100644 --- a/files/templates/gif_modal.html +++ b/files/templates/gif_modal.html @@ -4,7 +4,7 @@