diff --git a/docker-compose.yml b/docker-compose.yml index 009424fa2..12416fbff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - DATABASE_URL=postgresql://postgres@postgres:5432 - MASTER_KEY=XuxGqp5NyygJrM24b5gt3YgyvFVGdQnwVDwLzLwpu3eQwY - REDIS_URL=redis://redis - - DOMAIN=0.0.0.0 + - DOMAIN=localhost - SITE_NAME=Drama - GIPHY_KEY=3435tdfsdudebussylmaoxxt43 - FORCE_HTTPS=0 diff --git a/env b/env index f897886da..7054dabfd 100644 --- a/env +++ b/env @@ -1,6 +1,6 @@ -export DATABASE_URL="postgresql://postgres@0.0.0.0:5432" +export DATABASE_URL="postgresql://postgres@localhost:5432" export MASTER_KEY="XuxGqp5NyygJrM24b5gt3YgyvFVGdQnwVDwLzLwpu3eQwY" -export DOMAIN="0.0.0.0" +export DOMAIN="localhost" export SITE_NAME="Drama" export GIPHY_KEY="3435tdfsdudebussylmaoxxt43" export FORCE_HTTPS="0" diff --git a/files/__main__.py b/files/__main__.py index 1e6134282..956d3c282 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -43,7 +43,7 @@ app.config["SESSION_REFRESH_EACH_REQUEST"] = True app.config["SLOGAN"] = environ.get("SLOGAN", "").strip() app.config["DEFAULT_COLOR"] = environ.get("DEFAULT_COLOR", "ff0000").strip() app.config["DEFAULT_THEME"] = environ.get("DEFAULT_THEME", "midnight").strip() -app.config["FORCE_HTTPS"] = int(environ.get("FORCE_HTTPS", 1)) if ("0.0.0.0" not in app.config["SERVER_NAME"] and "0.0.0.0" not in app.config["SERVER_NAME"]) else 0 +app.config["FORCE_HTTPS"] = int(environ.get("FORCE_HTTPS", 1)) if ("localhost" not in app.config["SERVER_NAME"] and "localhost" not in app.config["SERVER_NAME"]) else 0 app.config["UserAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" app.config["HCAPTCHA_SITEKEY"] = environ.get("HCAPTCHA_SITEKEY","").strip() app.config["HCAPTCHA_SECRET"] = environ.get("HCAPTCHA_SECRET","").strip() @@ -62,14 +62,14 @@ app.config["RATELIMIT_DEFAULTS_EXEMPT_WHEN"]=lambda:False app.config["RATELIMIT_HEADERS_ENABLED"]=True app.config["CACHE_TYPE"] = "filesystem" app.config["CACHE_DIR"] = "cache" -app.config["RATELIMIT_STORAGE_URL"] = environ.get("REDIS_URL", "redis://0.0.0.0") +app.config["RATELIMIT_STORAGE_URL"] = environ.get("REDIS_URL", "redis://localhost") app.config['MAIL_SERVER'] = 'smtp.gmail.com' app.config['MAIL_PORT'] = 587 app.config['MAIL_USE_TLS'] = True app.config['MAIL_USERNAME'] = environ.get("MAIL_USERNAME", "").strip() app.config['MAIL_PASSWORD'] = environ.get("MAIL_PASSWORD", "").strip() -r=redis.Redis(host=environ.get("REDIS_URL", "redis://0.0.0.0"), decode_responses=True, ssl_cert_reqs=None) +r=redis.Redis(host=environ.get("REDIS_URL", "redis://localhost"), decode_responses=True, ssl_cert_reqs=None) limiter = Limiter( app, @@ -111,7 +111,7 @@ def before_request(): session.permanent = True if not session.get("session_id"): session["session_id"] = secrets.token_hex(16) - if app.config["FORCE_HTTPS"] and request.url.startswith("http://") and "0.0.0.0" not in app.config["SERVER_NAME"]: + if app.config["FORCE_HTTPS"] and request.url.startswith("http://") and "localhost" not in app.config["SERVER_NAME"]: url = request.url.replace("http://", "https://", 1) return redirect(url, code=301) diff --git a/files/assets/css/midnight.css b/files/assets/css/midnight.css index 4b3000b6e..0f65cdbab 100644 --- a/files/assets/css/midnight.css +++ b/files/assets/css/midnight.css @@ -1,16 +1,16 @@ @charset "UTF-8"; :root { - --dark: #8b949e; - --secondary: #8b949e; + --dark: #505961; + --secondary: #505961; --white: #c9d1d9; --black: #c9d1d9; --light: #b1bac4; --muted: #c9d1d9; - --gray: #8b949e; + --gray: #505961; --gray-100: #c9d1d9; --gray-200: #b1bac4; - --gray-300: #8b949e; + --gray-300: #505961; --gray-400: #6e7681; --gray-500: #484f58; --gray-600: #21262d; diff --git a/files/assets/images/Drama/banner.webp b/files/assets/images/Drama/banner.webp index 16938a116..6420d4655 100644 Binary files a/files/assets/images/Drama/banner.webp and b/files/assets/images/Drama/banner.webp differ diff --git a/files/assets/images/Drama/cached.webp b/files/assets/images/Drama/cached.webp index 16938a116..0b76fd59f 100644 Binary files a/files/assets/images/Drama/cached.webp and b/files/assets/images/Drama/cached.webp differ diff --git a/files/assets/images/Drama/headericon.webp b/files/assets/images/Drama/headericon.webp index bcb42bded..c52f150b3 100644 Binary files a/files/assets/images/Drama/headericon.webp and b/files/assets/images/Drama/headericon.webp differ diff --git a/files/assets/images/Drama/icon.webp b/files/assets/images/Drama/icon.webp index bcb42bded..0b0615849 100644 Binary files a/files/assets/images/Drama/icon.webp and b/files/assets/images/Drama/icon.webp differ diff --git a/files/assets/images/badges/Agendaposter.webp b/files/assets/images/badges/Agendaposter.webp index 1d375db12..a0ced368e 100644 Binary files a/files/assets/images/badges/Agendaposter.webp and b/files/assets/images/badges/Agendaposter.webp differ diff --git a/files/assets/images/badges/Artisan.webp b/files/assets/images/badges/Artisan.webp index 221b0e8e6..c525fb81a 100644 Binary files a/files/assets/images/badges/Artisan.webp and b/files/assets/images/badges/Artisan.webp differ diff --git a/files/assets/images/badges/Balls.webp b/files/assets/images/badges/Balls.webp index 18e9dceb2..b25491c70 100644 Binary files a/files/assets/images/badges/Balls.webp and b/files/assets/images/badges/Balls.webp differ diff --git a/files/assets/images/badges/Dinner.webp b/files/assets/images/badges/Dinner.webp new file mode 100644 index 000000000..62fd3516f Binary files /dev/null and b/files/assets/images/badges/Dinner.webp differ diff --git a/files/assets/images/badges/Landchad.webp b/files/assets/images/badges/Landchad.webp index 270d1c3b6..6b07327b5 100644 Binary files a/files/assets/images/badges/Landchad.webp and b/files/assets/images/badges/Landchad.webp differ diff --git a/files/assets/images/badges/Lolcow.webp b/files/assets/images/badges/Lolcow.webp index fb3ce5985..d8b41c3ea 100644 Binary files a/files/assets/images/badges/Lolcow.webp and b/files/assets/images/badges/Lolcow.webp differ diff --git a/files/assets/images/badges/Paypig.webp b/files/assets/images/badges/Paypig.webp index 7e0164ca5..7705b5945 100644 Binary files a/files/assets/images/badges/Paypig.webp and b/files/assets/images/badges/Paypig.webp differ diff --git a/files/assets/images/badges/Provider.webp b/files/assets/images/badges/Provider.webp new file mode 100644 index 000000000..a553bd7f5 Binary files /dev/null and b/files/assets/images/badges/Provider.webp differ diff --git a/files/assets/images/badges/Renthog.webp b/files/assets/images/badges/Renthog.webp index 03eb2d591..80f499dd0 100644 Binary files a/files/assets/images/badges/Renthog.webp and b/files/assets/images/badges/Renthog.webp differ diff --git a/files/assets/images/badges/Unpausable.webp b/files/assets/images/badges/Unpausable.webp index 183fac025..58853d9f9 100644 Binary files a/files/assets/images/badges/Unpausable.webp and b/files/assets/images/badges/Unpausable.webp differ diff --git a/files/assets/images/badges/agendaposter.webp b/files/assets/images/badges/agendaposter.webp index 1d375db12..a0ced368e 100644 Binary files a/files/assets/images/badges/agendaposter.webp and b/files/assets/images/badges/agendaposter.webp differ diff --git a/files/assets/images/badges/lolcow.webp b/files/assets/images/badges/lolcow.webp index fb3ce5985..d8b41c3ea 100644 Binary files a/files/assets/images/badges/lolcow.webp and b/files/assets/images/badges/lolcow.webp differ diff --git a/files/assets/images/badges/patron-1.webp b/files/assets/images/badges/patron-1.webp index 7e0164ca5..7705b5945 100644 Binary files a/files/assets/images/badges/patron-1.webp and b/files/assets/images/badges/patron-1.webp differ diff --git a/files/assets/images/badges/patron-2.webp b/files/assets/images/badges/patron-2.webp index 03eb2d591..80f499dd0 100644 Binary files a/files/assets/images/badges/patron-2.webp and b/files/assets/images/badges/patron-2.webp differ diff --git a/files/assets/images/badges/patron-3.webp b/files/assets/images/badges/patron-3.webp index 270d1c3b6..6b07327b5 100644 Binary files a/files/assets/images/badges/patron-3.webp and b/files/assets/images/badges/patron-3.webp differ diff --git a/files/assets/images/badges/patron-4.webp b/files/assets/images/badges/patron-4.webp index c42018597..75bea7f0b 100644 Binary files a/files/assets/images/badges/patron-4.webp and b/files/assets/images/badges/patron-4.webp differ diff --git a/files/assets/images/badges/patron-5.webp b/files/assets/images/badges/patron-5.webp index cfec38cfd..a9aeeec9a 100644 Binary files a/files/assets/images/badges/patron-5.webp and b/files/assets/images/badges/patron-5.webp differ diff --git a/files/assets/images/badges/provider.webp b/files/assets/images/badges/provider.webp new file mode 100644 index 000000000..a553bd7f5 Binary files /dev/null and b/files/assets/images/badges/provider.webp differ diff --git a/files/assets/images/badges/unpausable.webp b/files/assets/images/badges/unpausable.webp index 183fac025..58853d9f9 100644 Binary files a/files/assets/images/badges/unpausable.webp and b/files/assets/images/badges/unpausable.webp differ diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 79164016e..64ed7ceb2 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -268,4 +268,28 @@ function markdown(first, second) { } document.getElementById(second).innerHTML = marked(input) +} + +function charLimit(form, text) { + + var input = document.getElementById(form); + + var text = document.getElementById(text); + + var length = input.value.length; + + var maxLength = input.getAttribute("maxlength"); + + if (length >= maxLength) { + text.style.color = "#E53E3E"; + } + else if (length >= maxLength * .72){ + text.style.color = "#FFC107"; + } + else { + text.style.color = "#A0AEC0"; + } + + text.innerText = length + ' / ' + maxLength; + } \ No newline at end of file diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index a409b8863..0c7b0a60e 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -74,7 +74,7 @@ function charLimit(form, text) { text.style.color = "#A0AEC0"; } - text.innerText = maxLength - length; + text.innerText = length + ' / ' + maxLength; } diff --git a/files/classes/flags.py b/files/classes/flags.py index 476ea9760..e719c403c 100644 --- a/files/classes/flags.py +++ b/files/classes/flags.py @@ -2,6 +2,7 @@ from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base from files.helpers.lazy import lazy +from files.helpers.const import censor_slurs import time class Flag(Base): @@ -29,6 +30,10 @@ class Flag(Base): def created_datetime(self): return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc))) + @lazy + def realreason(self, v): + return censor_slurs(self.reason, v) + class CommentFlag(Base): @@ -53,4 +58,8 @@ class CommentFlag(Base): @property @lazy def created_datetime(self): - return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc))) \ No newline at end of file + return str(time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(self.created_utc))) + + @lazy + def realreason(self, v): + return censor_slurs(self.reason, v) \ No newline at end of file diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index 9bb308732..8e4cf6af6 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -163,16 +163,6 @@ ACTIONTYPES={ "icon": "fa-user-slash", "color": "bg-muted", }, - "club_allow":{ - "str":'allowed user {self.target_link} into the {cc}', - "icon":"fa-user-slash", - "color": "bg-danger", - }, - "club_ban":{ - "str":'disallowed user {self.target_link} from the {cc}', - "icon": "fa-user-slash", - "color": "bg-muted", - }, "nuke_user":{ "str":'removed all content of {self.target_link}', "icon":"fa-user-slash", @@ -253,16 +243,6 @@ ACTIONTYPES={ "icon":"fa-feather-alt", "color": "bg-muted", }, - "club":{ - "str": 'marked post {self.target_link} as club-only', - "icon":"fa-eye-slash", - "color": "bg-danger", - }, - "unclub":{ - "str": 'unmarked post {self.target_link} as club-only', - "icon":"fa-eye", - "color": "bg-muted", - }, "ban_comment":{ "str": 'removed {self.target_link}', "icon":"fa-comment", diff --git a/files/helpers/const.py b/files/helpers/const.py index 41afaa0f6..14e413d03 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -143,6 +143,8 @@ if SITE == 'rdrama.net': LLM_ID = 253 DAD_ID = 2513 MOM_ID = 4588 + BUG_THREAD = 18459 + EMOJI_THREAD = 22479 elif SITE == "pcmemes.net": BASEDBOT_ID = 800 NOTIFICATIONS_ID = 1046 @@ -159,6 +161,8 @@ elif SITE == "pcmemes.net": LLM_ID = 0 DAD_ID = 0 MOM_ID = 0 + BUG_THREAD = 4103 + EMOJI_THREAD = 0 else: BASEDBOT_ID = 0 NOTIFICATIONS_ID = 1 @@ -175,12 +179,14 @@ else: LLM_ID = 0 DAD_ID = 0 MOM_ID = 0 + BUG_THREAD = 0 + EMOJI_THREAD = 0 PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6' PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() single_words = "|".join([slur.lower() for slur in SLURS.keys()]) -SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)(nigger)((?=[\s<,.]|s[\s<,.])|$)") +SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)") def sub_matcher(match: re.Match) -> str: return SLURS[match.group(0).lower()] @@ -389,6 +395,14 @@ BADGES = { 'name': 'Unblockable', 'description': 'This user is unblockable' }, + 88: { + 'name': 'Provider', + 'description': 'This user provided a bountiful feast for Thanksgiving' + }, + 89: { + 'name': 'Dinner', + 'description': 'Yes, it is edible' + }, } AWARDS = { @@ -748,7 +762,4 @@ TROLLTITLES = [ "[META] Getting really sick of @{username}โ€™s shit", "Pretty sure this is @{username}'s Reddit account", "Hey jannies can you please ban @{username}", -] - -BUG_THREAD = 18459 -EMOJI_THREAD = 22479 \ No newline at end of file +] \ No newline at end of file diff --git a/files/routes/admin.py b/files/routes/admin.py index 5d87bb2e5..eebe599a9 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -97,14 +97,6 @@ def club_allow(v, username): x.club_banned = False g.db.add(x) - - ma=ModAction( - kind="club_allow", - user_id=v.id, - target_user_id=u.id, - ) - g.db.add(ma) - g.db.commit() return {"message": f"@{username} has been allowed into the {cc}!"} @@ -127,13 +119,6 @@ def club_ban(v, username): u.club_allowed = False g.db.add(x) - ma=ModAction( - kind="club_ban", - user_id=v.id, - target_user_id=u.id, - ) - g.db.add(ma) - g.db.commit() return {"message": f"@{username} has been kicked from the {cc}. Deserved."} @@ -164,30 +149,30 @@ def remove_admin(v, username): return {"message": "Admin removed!"} -@app.post("/@/make_fake_admin") +@app.post("/@/make_meme_admin") @limiter.limit("1/second") @admin_level_required(2) -def make_fake_admin(v, username): +def make_meme_admin(v, username): if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) user.admin_level = 1 g.db.add(user) g.db.commit() - return {"message": "User has been made fake admin!"} + return {"message": "User has been made meme admin!"} -@app.post("/@/remove_fake_admin") +@app.post("/@/remove_meme_admin") @limiter.limit("1/second") @admin_level_required(2) -def remove_fake_admin(v, username): +def remove_meme_admin(v, username): if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) user.admin_level = 0 g.db.add(user) g.db.commit() - return {"message": "Fake admin removed!"} + return {"message": "Meme admin removed!"} @app.post("/admin/monthly") diff --git a/files/routes/posts.py b/files/routes/posts.py index acce38216..104986ec6 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -20,6 +20,7 @@ from urllib.parse import ParseResult, urlunparse, urlparse, quote site = environ.get("DOMAIN").strip() CATBOX_KEY = environ.get("CATBOX_KEY").strip() +titleheaders = {"User-Agent": f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"} with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}") @@ -34,14 +35,6 @@ def toggle_club(pid, v): post.club = not post.club g.db.add(post) - if post.author_id!=v.id: - ma=ModAction( - kind="club" if post.club else "unclub", - user_id=v.id, - target_submission_id=post.id, - ) - g.db.add(ma) - g.db.commit() if post.club: return {"message": "Post has been marked as club-only!"} @@ -397,19 +390,18 @@ def edit_post(pid, v): def get_post_title(v): url = request.values.get("url", None) - if not url: return abort(400) + if not url: abort(400) - headers = {"User-Agent": f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"} - try: x = requests.get(url, headers=headers, timeout=5) - except BaseException: return {"error": "Could not reach page"}, 400 + try: x = requests.get(url, headers=titleheaders, timeout=5) + except: abort(400) - if not x.status_code == 200: return {"error": f"Page returned {x.status_code}"}, x.status_code + soup = BeautifulSoup(x.content, 'html.parser') + + title = soup.find('title') + if not title: abort(400) + + return {"url": url, "title": title.string} - try: - soup = BeautifulSoup(x.content, 'html.parser') - return {"url": url, "title": soup.find('title').string} - except BaseException: - return {"error": f"Could not find a title"}, 400 def archiveorg(url): try: requests.get(f'https://web.archive.org/save/{url}', headers={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}, timeout=100) @@ -766,6 +758,8 @@ def submit_post(v): if v.paid_dues: club = bool(request.values.get("club","")) else: club = False + if embed and len(embed) > 1500: embed = None + new_post = Submission( private=bool(request.values.get("private","")), club=club, diff --git a/files/routes/settings.py b/files/routes/settings.py index e67fa212b..51b6cd209 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -825,11 +825,10 @@ def settings_block_user(v): user = get_user(request.values.get("username"), graceful=True) + if not user: return {"error": "That user doesn't exist."}, 404 + if user.unblockable: return {"error": "This user is unblockable."}, 403 - if not user: - return {"error": "That user doesn't exist."}, 404 - if user.id == v.id: return {"error": "You can't block yourself."}, 409 @@ -853,8 +852,7 @@ def settings_block_user(v): g.db.commit() - if v.admin_level == 1: return {"message": f"@{user.username} banned!"} - else: return {"message": f"@{user.username} blocked."} + return {"message": f"@{user.username} blocked."} @app.post("/settings/unblock") @@ -878,8 +876,6 @@ def settings_unblock_user(v): g.db.commit() - if v.admin_level == 1: return {"message": f"@{user.username} unbanned!"} - return {"message": f"@{user.username} unblocked."} diff --git a/files/routes/static.py b/files/routes/static.py index 924104ac7..3d9b2b566 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -173,7 +173,7 @@ def log(v): actions = g.db.query(ModAction) if not (v and v.admin_level > 1): - actions = actions.filter(ModAction.kind.notin_(["shadowban","unshadowban","club","unclub","club_allow","club_ban","check"])) + actions = actions.filter(ModAction.kind.notin_(["shadowban","unshadowban","check"])) if admin_id: actions = actions.filter_by(user_id=admin_id) if kind: actions = actions.filter_by(kind=kind) diff --git a/files/routes/users.py b/files/routes/users.py index 284240d50..aeef7b113 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -17,14 +17,15 @@ site = environ.get("DOMAIN").strip() beams_client = PushNotifications(instance_id=PUSHER_INSTANCE_ID, secret_key=PUSHER_KEY) + @app.get("/@/upvoters") @auth_desired def upvoters(v, username): id = get_user(username).id - votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).limit(25).all() + votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all() - votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all() + votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) @@ -41,9 +42,9 @@ def upvoters(v, username): def downvoters(v, username): id = get_user(username).id - votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).limit(25).all() + votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all() - votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all() + votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) @@ -60,9 +61,9 @@ def downvoters(v, username): def upvoting(v, username): id = get_user(username).id - votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).limit(25).all() + votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).limit(25).all() + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) @@ -79,9 +80,9 @@ def upvoting(v, username): def downvoting(v, username): id = get_user(username).id - votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).limit(25).all() + votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() - votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).limit(25).all() + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() votes = Counter(dict(votes)) + Counter(dict(votes2)) @@ -247,10 +248,32 @@ def leaderboard(v): users4 = users.order_by(User.comment_count.desc()).limit(10).all() users5 = users.order_by(User.received_award_count.desc()).limit(10).all() users7 = users.order_by(User.coins_spent.desc()).limit(20).all() + + + + + votes1 = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Vote.vote_type==-1).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all() + + votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==-1).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all() + + votes3 = Counter(dict(votes1)) + Counter(dict(votes2)) + + users8 = g.db.query(User).filter(User.id.in_(votes3.keys())).all() + users9 = [] + for user in users8: users9.append((user, votes3[user.id])) + + users9 = sorted(users9, key=lambda x: x[1], reverse=True)[:25] + + + + + + + if 'pcmemes.net' in request.host: users6 = users.order_by(User.basedcount.desc()).limit(10).all() - return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7) - return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users7=users7) + return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7, users9=users9) + return render_template("leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users7=users7, users9=users9) @app.get("/@/css") @@ -308,8 +331,7 @@ def unsubscribe(v, post_id): @app.get("/report_bugs") @auth_required def reportbugs(v): - if request.host == 'rdrama.net': return redirect('https://rdrama.net/post/18459') - return render_template("reportbugs.html", v=v) + return redirect(f'/post/{BUG_THREAD}') @app.post("/@/message") @limiter.limit("1/second") diff --git a/files/templates/agendaposters.html b/files/templates/agendaposters.html index df0ecf0f4..5a2168b70 100644 --- a/files/templates/agendaposters.html +++ b/files/templates/agendaposters.html @@ -10,7 +10,7 @@ {% for user in users %} - {{users.index(user)+1}} + {{loop.index}} {{user.username}} {% endfor %} diff --git a/files/templates/api.html b/files/templates/api.html index 82b209790..97ba4c444 100644 --- a/files/templates/api.html +++ b/files/templates/api.html @@ -17,7 +17,7 @@

In the apps tab of Drama settings, fill in and submit the form to request an access token. You will need:

  • an application name
  • -
  • a Redirect URI. May not use HTTP unless using 0.0.0.0 (use HTTPS instead).
  • +
  • a Redirect URI. May not use HTTP unless using localhost (use HTTPS instead).
  • a brief description of what your bot is intended to do

Don't worry too much about accuracy; you will be able to change all of these later.

@@ -54,7 +54,7 @@

In the apps tab of Drama settings, fill in and submit the form to request new API keys. You will need:

  • an application name
  • -
  • a Redirect URI. May not use HTTP unless using 0.0.0.0 (use HTTPS instead).
  • +
  • a Redirect URI. May not use HTTP unless using localhost (use HTTPS instead).
  • a brief description of what your application is intended to do

Don't worry too much about accuracy; you will be able to change all of these later.

diff --git a/files/templates/authforms.html b/files/templates/authforms.html index af7ac35ec..f8d84d86b 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,11 +15,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/banned.html b/files/templates/banned.html index 5fb884ca7..68369b2f9 100644 --- a/files/templates/banned.html +++ b/files/templates/banned.html @@ -12,7 +12,7 @@ {% for user in users %} - {{users.index(user)+1}} + {{loop.index}} {{user.username}} {% if user.ban_reason %}{{user.ban_reason}}{% endif %} {{user.banned_by.username}} diff --git a/files/templates/comment_failed.html b/files/templates/comment_failed.html index 7305fca1a..aca4ece1e 100644 --- a/files/templates/comment_failed.html +++ b/files/templates/comment_failed.html @@ -26,15 +26,16 @@ {% if parent_fullname %}{% endif %} {% if parent_submission %}{% endif %} - + +