diff --git a/files/classes/comment.py b/files/classes/comment.py index 38ed5b802..f3388ba5d 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -307,6 +307,34 @@ class Comment(Base): return body + def plainbody(self, v): + if self.post and self.post.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" + + body = self.body + + if not body: return "" + + if not v or v.slurreplacer: + for s, r in SLURS.items(): body = body.replace(s, r) + + 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") + + if v and v.controversial: + for i in re.finditer('(/comments/.*?)"', body): + url = i.group(1) + p = urlparse(url).query + p = parse_qs(p) + + if 'sort' not in p: + p['sort'] = ['controversial'] + + url_noquery = url.split('?')[0] + body = body.replace(url, f"{url_noquery}?{urlencode(p, True)}") + + return body + @lazy def collapse_for_user(self, v): diff --git a/files/classes/submission.py b/files/classes/submission.py index 83909cc24..f41e3a496 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -348,6 +348,18 @@ class Submission(Base): if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net") return body + def plainbody(self, v): + if self.club and not (v and v.paid_dues): return "COUNTRY CLUB ONLY" + body = self.body + + if not v or v.slurreplacer: + for s,r in SLURS.items(): + body = body.replace(s, r) + + 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") + return body + @lazy def realtitle(self, v): if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY' @@ -359,6 +371,16 @@ class Submission(Base): return title + @lazy + def plaintitle(self, v): + if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY' + else: title = self.title + + if not v or v.slurreplacer: + for s,r in SLURS.items(): title = title.replace(s, r) + + return title + @property @lazy def is_image(self): diff --git a/files/templates/submission.html b/files/templates/submission.html index 40ceec2e5..f48a1b3cc 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -83,15 +83,15 @@ {% if comment_info and not comment_info.is_banned and not linked_comment.deleted_utc > 0 %} -{{'@'+comment_info.author.username}} comments on "{{p.title}} - {{'SITE_NAME' | app_config}}" +{{'@'+comment_info.author.username}} comments on "{{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}}" {% if comment_info.edited_utc %}{% endif %} - + - + {% if p.url and p.url.lower().endswith('.mp4') %} @@ -101,9 +101,9 @@ - + - + @@ -112,15 +112,15 @@ {% endif %} {% else %} -{{p.title}} - {{'SITE_NAME' | app_config}} +{{p.plaintitle(v)}} - {{'SITE_NAME' | app_config}} {% if p.edited_utc %}{% endif %} - + - + {% if p.url and p.url.lower().endswith('.mp4') %} @@ -130,9 +130,9 @@ - + - + diff --git a/files/templates/submission_banned.html b/files/templates/submission_banned.html index f36412b20..70cce4e7c 100644 --- a/files/templates/submission_banned.html +++ b/files/templates/submission_banned.html @@ -10,7 +10,7 @@ {% endif %} {% block title %} -{{p.title}} +{{p.plaintitle(v)}} {% if p.is_banned %} {% else %} @@ -55,7 +55,7 @@
-
{{p.title}}
+
{{p.plaintitle(v)}}