From 0b8abce4091a9e8956315419a958ad9e5951c058 Mon Sep 17 00:00:00 2001 From: beese_buck <16601315+cant-be-blenk@users.noreply.github.com> Date: Tue, 18 Jan 2022 21:27:32 -0800 Subject: [PATCH 1/8] make seals gooder I think --- files/templates/submission.html | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/files/templates/submission.html b/files/templates/submission.html index f607afe24d..a8228c8b2e 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -34,12 +34,16 @@ } } - @keyframes wholesome1 { - 0% {top:0%; left: 50%;} - 25% {top:50%; left:98%;} - 50% {top:98%; left: 50%} - 75% {top:50%; left:0%;} - 100% {top:0%; left: 50%;} + @keyframes moveX { + from { left: 0; } to { left: 98%; } + } + + @keyframes moveY { + from { top: 0; } to { top: 98%; } + } + + .seal { + animation: moveX 4s linear 0s infinite alternate, moveY 6.8s linear 0s infinite alternate !important; } .seal { @@ -48,13 +52,6 @@ pointer-events: none; width: 100% !important; height: 100% !important; - animation-duration: 10s !important; - animation-iteration-count: infinite !important; - animation-fill-mode: forwards !important; - animation-timing-function: linear !important; - } - .seal1 { - animation-name: wholesome1 !important; }
{cc} ONLY
" + if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id])): return f"{CC} ONLY
" body = self.body_html @@ -364,7 +360,7 @@ class Comment(Base): return body def plainbody(self, v): - if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id])): return f"{cc} ONLY
" + if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id])): return f"{CC} ONLY
" body = self.body diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index 62d6d1e5af..59db52b3e0 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -5,10 +5,7 @@ import time from files.helpers.lazy import lazy from os import environ from copy import deepcopy - -site = environ.get("DOMAIN").strip() -if site == 'pcmemes.net': cc = "SPLASH MOUNTAIN" -else: cc = "COUNTRY CLUB" +from files.helpers.const import * class ModAction(Base): __tablename__ = "modactions" @@ -94,7 +91,7 @@ class ModAction(Base): def target_link(self): if self.target_user: return f'{self.target_user.username}' elif self.target_post: - if self.target_post.club: return f'{cc} ONLY' + if self.target_post.club: return f'{CC} ONLY' return f'{self.target_post.title.replace("<","").replace(">","")}' elif self.target_comment_id: return f'comment' diff --git a/files/classes/submission.py b/files/classes/submission.py index 69194a7309..e3311e400d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -7,17 +7,12 @@ from flask import render_template from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base -from files.helpers.const import AUTOPOLLER_ID, AUTOBETTER_ID, censor_slurs, TROLLTITLES +from files.helpers.const import * from files.helpers.lazy import lazy from .flags import Flag from .comment import Comment from flask import g -site = environ.get("DOMAIN").strip() -site_name = environ.get("SITE_NAME").strip() -if site == 'pcmemes.net': cc = "SPLASH MOUNTAIN" -else: cc = "COUNTRY CLUB" - class Submission(Base): __tablename__ = "submissions" @@ -232,22 +227,22 @@ class Submission(Base): @property @lazy def thumb_url(self): - if self.over_18: return f"https://{site}/static/assets/images/nsfw.webp" - elif not self.url: return f"https://{site}/static/assets/images/{site_name}/default_text.webp" + if self.over_18: return f"{SITE_FULL}/static/assets/images/nsfw.webp" + elif not self.url: return f"{SITE_FULL}/static/assets/images/{SITE_NAME}/default_text.webp" elif self.thumburl: return self.thumburl - elif self.is_youtube or self.is_video: return f"https://{site}/static/assets/images/default_thumb_yt.webp" - else: return f"https://{site}/static/assets/images/default_thumb_link.webp" + elif self.is_youtube or self.is_video: return f"{SITE_FULL}/static/assets/images/default_thumb_yt.webp" + else: return f"{SITE_FULL}/static/assets/images/default_thumb_link.webp" @property @lazy def full_thumb(self): - if self.thumb_url.startswith('/'): return f'https://{site}' + self.thumb_url + if self.thumb_url.startswith('/'): return SITE_FULL + self.thumb_url return self.thumb_url @property @lazy def full_url(self): - if self.url and self.url.startswith('/'): return f'https://{site}' + self.url + if self.url and self.url.startswith('/'): return SITE_FULL + self.url return self.url @property @@ -352,7 +347,7 @@ class Submission(Base): else: return "" def realbody(self, v): - if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"{cc} ONLY
" + if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"{CC} ONLY
" body = self.body_html @@ -382,7 +377,7 @@ class Submission(Base): return body def plainbody(self, v): - if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"{cc} ONLY
" + if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"{CC} ONLY
" body = self.body @@ -402,7 +397,7 @@ class Submission(Base): def realtitle(self, v): if self.club and not (v and (v.paid_dues or v.id == self.author_id)): if v: return random.choice(TROLLTITLES).format(username=v.username) - else: return f'{cc} MEMBERS ONLY' + else: return f'{CC} MEMBERS ONLY' elif self.title_html: title = self.title_html else: title = self.title @@ -414,7 +409,7 @@ class Submission(Base): def plaintitle(self, v): if self.club and not (v and (v.paid_dues or v.id == self.author_id)): if v: return random.choice(TROLLTITLES).format(username=v.username) - else: return f'{cc} MEMBERS ONLY' + else: return f'{CC} MEMBERS ONLY' else: title = self.title title = censor_slurs(title, v) diff --git a/files/classes/user.py b/files/classes/user.py index 5aec1a24b7..d220ca2173 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -18,8 +18,6 @@ from files.helpers.security import * import random from os import environ, remove, path -site = environ.get("DOMAIN").strip() -site_name = environ.get("SITE_NAME").strip() defaulttheme = environ.get("DEFAULT_THEME", "midnight").strip() defaultcolor = environ.get("DEFAULT_COLOR", "fff").strip() defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip() @@ -28,7 +26,7 @@ cardview = bool(int(environ.get("CARD_VIEW", 1))) class User(Base): __tablename__ = "users" - if site == "pcmemes.net": + if SITE == "pcmemes.net": quadrant = Column(String) basedcount = Column(Integer, default=0) pills = deferred(Column(String, default="")) @@ -428,15 +426,15 @@ class User(Base): @lazy def banner_url(self): if self.bannerurl: return self.bannerurl - else: return f"https://{site}/static/assets/images/{site_name}/site_preview.webp?a=1" + else: return f"{SITE_FULL}/static/assets/images/{SITE_NAME}/site_preview.webp?a=1" @property @lazy def profile_url(self): - if self.agendaposter: return f"https://{site}/static/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?a=204" + if self.agendaposter: return f"{SITE_FULL}/static/assets/images/defaultpictures/agendaposter/{random.randint(1, 50)}.webp?a=204" if self.profileurl: return self.profileurl - if "rama" in site: return f"https://{site}/static/assets/images/defaultpictures/{random.randint(1, 150)}.webp?a=202" - return f"https://{site}/static/assets/images/default-profile-pic.webp?a=204" + if SITE_NAME == 'Drama': return f"{SITE_FULL}/static/assets/images/defaultpictures/{random.randint(1, 150)}.webp?a=202" + return f"{SITE_FULL}/static/assets/images/default-profile-pic.webp?a=204" @lazy def json_popover(self, v): @@ -457,7 +455,7 @@ class User(Base): @property @lazy def full_profileurl(self): - if self.profile_url.startswith('/'): return f'https://{site}' + self.profile_url + if self.profile_url.startswith('/'): return SITE_FULL + self.profile_url return self.profile_url @property diff --git a/files/helpers/const.py b/files/helpers/const.py index 5dc9db6e9e..b7be3ab134 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -2,9 +2,15 @@ from os import environ, listdir import re from copy import deepcopy from json import loads +from files.__main__ import app SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() +if SITE == "localhost": SITE_FULL = 'http://' + SITE +else: SITE_FULL = 'https://' + SITE +if SITE == 'pcmemes.net': CC = "SPLASH MOUNTAIN" +else: CC = "COUNTRY CLUB" +CC_TITLE = CC.title() with open("files/assets/js/emoji_modal.js", 'r') as file: marseytext = file.read().split('emojis: ')[1].split('cops police"},')[0] + '"}}' @@ -787,4 +793,27 @@ NOTIFIED_USERS = { } num_banners = len(listdir('files/assets/images/Drama/banners')) + 1 -num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1 \ No newline at end of file +num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1 + +@app.template_filter("full_link") +def full_link(url): + + return f"{SITE_FULL}{url}" + +@app.template_filter("app_config") +def app_config(x): + return app.config.get(x) + +@app.template_filter("post_embed") +def post_embed(id, v): + + try: id = int(id) + except: return None + + p = get_post(id, v, graceful=True) + + return render_template("submission_listing.html", listing=[p], v=v) + +@app.context_processor +def inject_constants(): + return {"num_banners":num_banners, "num_sidebar":num_sidebar, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE} \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py deleted file mode 100644 index be6a359496..0000000000 --- a/files/helpers/jinja2.py +++ /dev/null @@ -1,27 +0,0 @@ -from files.__main__ import app -from .get import * -from os import listdir, environ -from .const import * - -@app.template_filter("full_link") -def full_link(url): - - return f"https://{app.config['SERVER_NAME']}{url}" - -@app.template_filter("app_config") -def app_config(x): - return app.config.get(x) - -@app.template_filter("post_embed") -def post_embed(id, v): - - try: id = int(id) - except: return None - - p = get_post(id, v, graceful=True) - - return render_template("submission_listing.html", listing=[p], v=v) - -@app.context_processor -def inject_constants(): - return {"num_banners":num_banners, "num_sidebar":num_sidebar, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID": AUTOJANNY_ID, "NOTIFICATIONS_ID": NOTIFICATIONS_ID, "PUSHER_ID": PUSHER_ID} \ No newline at end of file diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 993b23fcf7..d205648f46 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -9,8 +9,6 @@ from mistletoe import markdown from json import loads, dump from random import random -site = environ.get("DOMAIN").strip() - allowed_tags = tags = ['b', 'blockquote', 'br', @@ -166,7 +164,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): for tag in soup.find_all("a"): if tag.get("href"): - if site not in tag["href"] and not tag["href"].startswith('/'): + if not tag["href"].startswith(SITE_FULL) and not tag["href"].startswith('/'): tag["target"] = "_blank" tag["rel"] = "nofollow noopener noreferrer" diff --git a/files/mail/__init__.py b/files/mail/__init__.py index 868febe2fe..469cd098d4 100644 --- a/files/mail/__init__.py +++ b/files/mail/__init__.py @@ -5,17 +5,16 @@ from urllib.parse import quote from files.helpers.security import * from files.helpers.wrappers import * +from files.helpers.const import * from files.classes import * from files.__main__ import app, mail, limiter from flask_mail import Message -site = environ.get("DOMAIN").strip() name = environ.get("SITE_NAME").strip() - def send_mail(to_address, subject, html): - msg = Message(html=html, subject=subject, sender=f"{name}@{site}", recipients=[to_address]) + msg = Message(html=html, subject=subject, sender=f"{name}@{SITE}", recipients=[to_address]) mail.send(msg) diff --git a/files/routes/admin.py b/files/routes/admin.py index bfad24748e..f83209d96d 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -17,7 +17,6 @@ from files.helpers.discord import add_role from datetime import datetime import requests -SITE_NAME = environ.get("SITE_NAME", "").strip() GUMROAD_ID = environ.get("GUMROAD_ID", "tfcvri").strip() GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip() @@ -25,11 +24,8 @@ CF_KEY = environ.get("CF_KEY", "").strip() CF_ZONE = environ.get("CF_ZONE", "").strip() CF_HEADERS = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/json"} -if SITE_NAME == 'PCM': cc = "splash mountain" -else: cc = "country club" month = datetime.now().strftime('%B') - @app.get("/refund") @admin_level_required(3) def refund(v): @@ -166,7 +162,7 @@ def club_allow(v, username): g.db.add(x) g.db.commit() - return {"message": f"@{username} has been allowed into the {cc}!"} + return {"message": f"@{username} has been allowed into the {CC_TITLE}!"} @app.post("/@Please remove the following link(s) from your comment, and then you will be able to post it:
From 0536b03a4615624aa1447d613d23b6dcd2c0aa62 Mon Sep 17 00:00:00 2001 From: Aevann1Date: Wed, 19 Jan 2022 11:19:38 +0200 Subject: [PATCH 8/8] fds --- files/routes/posts.py | 16 ++++++++-------- files/templates/submission.html | 2 +- files/templates/submit.html | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index f6ba288ca9..5cb5f05968 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -398,7 +398,7 @@ def edit_post(pid, v): body = request.values.get("body", "").strip().replace('','') - if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403 + if len(body) > 20000: return {"error":"Character limit is 20000!"}, 403 if v.marseyawarded: marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", title)) @@ -470,7 +470,7 @@ def edit_post(pid, v): elif v.bird: if len(body) > 140 : return {"error":"You have to type less than 140 characters!"}, 403 - if len(body_html) > 20000: return {"error":"Submission body too long!"}, 400 + if len(body_html) > 40000: return {"error":"Submission body too long!"}, 400 p.body_html = body_html @@ -850,10 +850,10 @@ def submit_post(v): g.db.add(ma) return redirect("/notifications") - if len(str(body)) > 10000: + if len(str(body)) > 20000: - if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"10000 character limit for text body."}, 400 - return render_template("submit.html", v=v, error="10000 character limit for text body.", title=title, url=url, body=request.values.get("body", "")), 400 + if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"There's a 20000 character limit for text body."}, 400 + return render_template("submit.html", v=v, error="There's a 20000 character limit for text body.", title=title, url=url, body=request.values.get("body", "")), 400 if len(url) > 2048: @@ -902,7 +902,7 @@ def submit_post(v): elif v.bird: if len(body) > 140 : return {"error":"You have to type less than 140 characters!"}, 403 - if len(body_html) > 20000: return {"error":"Submission body too long!"}, 400 + if len(body_html) > 40000: return {"error":"Submission body too long!"}, 400 bans = filter_comment_html(body_html) if bans: @@ -925,7 +925,7 @@ def submit_post(v): app_id=v.client.application.id if v.client else None, is_bot = request.headers.get("Authorization"), url=url, - body=body[:10000], + body=body[:20000], body_html=body_html, embed_url=embed, title=title[:500], @@ -1073,7 +1073,7 @@ def submit_post(v): body_html = sanitize(body) - if len(body_html) < 20000: + if len(body_html) < 40000: c = Comment(author_id=SNAPPY_ID, distinguish_level=6, parent_submission=new_post.id, diff --git a/files/templates/submission.html b/files/templates/submission.html index a40d5a0ca5..17230e3561 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -479,7 +479,7 @@ - + diff --git a/files/templates/submit.html b/files/templates/submit.html index bd48af0c40..f7982aeb10 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -106,10 +106,10 @@