diff --git a/.gitignore b/.gitignore index 82c550881..50afe338a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ +image.png image.gif -dramacache/ +cache/ __pycache__/ *.py[cod] *$py.class diff --git a/appspec.yml b/appspec.yml index 0ab4dac11..5a7cff88d 100644 --- a/appspec.yml +++ b/appspec.yml @@ -2,12 +2,12 @@ version: 0.0 os: linux files: - source: / - destination: drama + destination: files permissions: - - object: drama/* + - object: files/* mode: 4755 hooks: AfterInstall: - location: scripts/install_pip ApplicationStart: - - location: scripts/start_drama \ No newline at end of file + - location: scripts/start_files \ No newline at end of file diff --git a/compilecss.py b/compilecss.py index b8d4de186..50e0d0ef4 100644 --- a/compilecss.py +++ b/compilecss.py @@ -1,7 +1,7 @@ for theme in ['midnight', 'dark', 'light', 'coffee', 'tron', '4chan']: - with open(f"./drama/assets/style/{theme}_ff66ac.css", encoding='utf-8') as t: + with open(f"./files/assets/style/{theme}_ff66ac.css", encoding='utf-8') as t: text = t.read() for color in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','62ca56','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']: newtext = text.replace("ff66ac", color).replace("ff4097", color).replace("ff1a83", color).replace("ff3390", color).replace("rgba(255, 102, 172, 0.25)", color) - with open(f"./drama/assets/style/{theme}_{color}.css", encoding='utf-8', mode='w') as nt: + with open(f"./files/assets/style/{theme}_{color}.css", encoding='utf-8', mode='w') as nt: nt.write(newtext) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index dc261b01c..ae466bd6b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,36 +1,43 @@ version: '2.3' services: - drama: + files: build: context: . volumes: - - "./:/drama/service" + - "./:/service" environment: - - PYTHONPATH="drama/service" + - PYTHONPATH="/service" - REDIS_URL=redis://redis - DATABASE_URL=postgresql://postgres@postgres:5432/postgres - DATABASE_CONNECTION_POOL_URL=postgresql://postgres@postgres:5432/postgres - MASTER_KEY=${MASTER_KEY:-KTVciAUQFpFh2WdJ/oiHJlxl6FvzRZp8kYzAAv3l2OA=} - - domain=localhost + - DOMAIN=localhost - SITE_NAME=Drama - CLOUDFLARE_ZONE=vcxvdfgfc6r554etrgd - CLOUDFLARE_KEY=vcxvdfgfc6r554etrgd - TENOR_KEY=vcxvdfgfc6r554etrgd - MAILGUN_KEY=vcxvdfgfc6r554etrgd - MAILGUN_DOMAIN=rdrama.net - - admin_email=drama@rdrama.net - FORCE_HTTPS=0 - DISCORD_SERVER_ID=vcxvdfgfc6r554etrgd - DISCORD_CLIENT_ID=vcxvdfgfc6r554etrgd - DISCORD_CLIENT_SECRET=vcxvdfgfc6r554etrgd - DISCORD_BOT_TOKEN=vcxvdfgfc6r554etrgd - - imgurkey=vcxvdfgfc6r554etrgd + - IMGUR_KEY=vcxvdfgfc6r554etrgd - FACEBOOK_TOKEN=vcxvdfgfc6r554etrgd - #- HCAPTCHA_SITEKEY=vcxvdfgfc6r554etrgd + #- HCAPTCHA_SITEKEY=vcxvdfgfc6r554etrgd - HCAPTCHA_SECRET=vcxvdfgfc6r554etrgd - - youtubekey=vcxvdfgfc6r554etrgd + - YOUTUBE_KEY=vcxvdfgfc6r554etrgd - PUSHER_KEY=vcxvdfgfc6r554etrgd + - SPAM_SIMILARITY_THRESHOLD=0.5 + - SPAM_SIMILAR_COUNT_THRESHOLD=5 + - SPAM_URL_SIMILARITY_THRESHOLD=0.1 + - COMMENT_SPAM_SIMILAR_THRESHOLD=0.5 + - COMMENT_SPAM_COUNT_THRESHOLD=5 + - READ_ONLY=0 + - BOT_DISABLE=0 + - COINS_NAME=Dramacoins links: - "redis" - "postgres" diff --git a/drama/classes/lolwtf.py b/drama/classes/lolwtf.py deleted file mode 100644 index 5e4a7a5ee..000000000 --- a/drama/classes/lolwtf.py +++ /dev/null @@ -1,2 +0,0 @@ - -from drama.__main__ import Base, app \ No newline at end of file diff --git a/drama/__main__.py b/files/__main__.py similarity index 72% rename from drama/__main__.py rename to files/__main__.py index 63a2d19b2..e66533913 100644 --- a/drama/__main__.py +++ b/files/__main__.py @@ -30,28 +30,15 @@ app = Flask(__name__, app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3) app.url_map.strict_slashes = False -app.config["SITE_NAME"]=environ.get("SITE_NAME", "Drama").strip() - -app.config["SITE_COLOR"]=environ.get("SITE_COLOR", "805ad5").strip() - -app.config["DRAMAPATH"]=environ.get("DRAMAPATH", path.dirname(path.realpath(__file__))) - +app.config["SITE_NAME"]=environ.get("SITE_NAME").strip() +app.config["COINS_NAME"]=environ.get("COINS_NAME").strip() app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -app.config['DATABASE_URL'] = environ.get( - "DATABASE_CONNECTION_POOL_URL", - environ.get("DATABASE_URL")) - -app.config['SQLALCHEMY_READ_URIS'] = [ - environ.get("DATABASE_CONNECTION_READ_01_URL"), - environ.get("DATABASE_CONNECTION_READ_02_URL"), - environ.get("DATABASE_CONNECTION_READ_03_URL") -] +app.config['DATABASE_URL'] = environ.get("DATABASE_CONNECTION_POOL_URL",environ.get("DATABASE_URL")) app.config['SECRET_KEY'] = environ.get('MASTER_KEY') -app.config["SERVER_NAME"] = environ.get("domain").strip() +app.config["SERVER_NAME"] = environ.get("DOMAIN").strip() -app.config["SHORT_DOMAIN"]=environ.get("SHORT_DOMAIN","").strip() -app.config["SESSION_COOKIE_NAME"] = "session_drama" +app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower() app.config["VERSION"] = "1.0.0" app.config['MAX_CONTENT_LENGTH'] = 64 * 1024 * 1024 app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1))) @@ -61,7 +48,6 @@ app.config["PERMANENT_SESSION_LIFETIME"] = 60 * 60 * 24 * 365 app.config["SESSION_REFRESH_EACH_REQUEST"] = True app.config["FORCE_HTTPS"] = int(environ.get("FORCE_HTTPS", 1)) if ("localhost" not in app.config["SERVER_NAME"] and "127.0.0.1" not in app.config["SERVER_NAME"]) else 0 -app.config["DISABLE_SIGNUPS"]=int(environ.get("DISABLE_SIGNUPS",0)) app.jinja_env.cache = {} @@ -70,34 +56,26 @@ app.config["UserAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit if "localhost" in app.config["SERVER_NAME"]: app.config["CACHE_TYPE"] = "null" else: - app.config["CACHE_TYPE"] = environ.get("CACHE_TYPE", 'filesystem').strip() + app.config["CACHE_TYPE"] = "filesystem" -app.config["CACHE_DIR"] = environ.get("CACHE_DIR", "dramacache") +app.config["CACHE_DIR"] = environ.get("CACHE_DIR", "cache") # captcha configs app.config["HCAPTCHA_SITEKEY"] = environ.get("HCAPTCHA_SITEKEY","").strip() -app.config["HCAPTCHA_SECRET"] = environ.get( - "HCAPTCHA_SECRET","").strip() -app.config["SIGNUP_HOURLY_LIMIT"]=int(environ.get("SIGNUP_HOURLY_LIMIT",0)) +app.config["HCAPTCHA_SECRET"] = environ.get("HCAPTCHA_SECRET","").strip() # antispam configs -app.config["SPAM_SIMILARITY_THRESHOLD"] = float( - environ.get("SPAM_SIMILARITY_THRESHOLD", 0.5)) -app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int( - environ.get("SPAM_SIMILAR_COUNT_THRESHOLD", 5)) -app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float( - environ.get("SPAM_URL_SIMILARITY_THRESHOLD", 0.1)) -app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"] = float( - environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5)) -app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int( - environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 5)) +app.config["SPAM_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_SIMILARITY_THRESHOLD")) +app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int(environ.get("SPAM_SIMILAR_COUNT_THRESHOLD")) +app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_URL_SIMILARITY_THRESHOLD")) +app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"] = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD")) +app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD")) -app.config["CACHE_REDIS_URL"] = environ.get( - "REDIS_URL").strip().lstrip() if environ.get("REDIS_URL") else None +app.config["CACHE_REDIS_URL"] = environ.get("REDIS_URL").strip() app.config["CACHE_DEFAULT_TIMEOUT"] = 60 app.config["CACHE_KEY_PREFIX"] = "flask_caching_" -app.config["REDIS_POOL_SIZE"]=int(environ.get("REDIS_POOL_SIZE", 10)) +app.config["REDIS_POOL_SIZE"] = 10 redispool=ConnectionPool( max_connections=app.config["REDIS_POOL_SIZE"], @@ -105,7 +83,7 @@ redispool=ConnectionPool( ) if app.config["CACHE_TYPE"]=="redis" else None app.config["CACHE_OPTIONS"]={'connection_pool':redispool} if app.config["CACHE_TYPE"]=="redis" else {} -app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", False))) +app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY"))) app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False))) app.config["TENOR_KEY"]=environ.get("TENOR_KEY",'').strip() @@ -115,18 +93,15 @@ Markdown(app) cache = Cache(app) Compress(app) -app.config["RATELIMIT_STORAGE_URL"] = environ.get("REDIS_URL").strip() if environ.get("REDIS_URL") else 'memory://' +app.config["RATELIMIT_STORAGE_URL"] = environ.get("REDIS_URL").strip() app.config["RATELIMIT_KEY_PREFIX"] = "flask_limiting_" app.config["RATELIMIT_ENABLED"] = True app.config["RATELIMIT_DEFAULTS_DEDUCT_WHEN"]=lambda:True app.config["RATELIMIT_DEFAULTS_EXEMPT_WHEN"]=lambda:False app.config["RATELIMIT_HEADERS_ENABLED"]=True -#app.config["DISABLESIGNUPS"] = bool(int(environ.get("DISABLESIGNUPS", "0"))) - -def limiter_key_func(): - return request.remote_addr +def limiter_key_func(): return request.remote_addr limiter = Limiter( @@ -196,9 +171,9 @@ UA_BAN_CACHE_TTL = int(environ.get("UA_BAN_CACHE_TTL", 3600)) # import and bind all routing functions -import drama.classes -from drama.routes import * -import drama.helpers.jinja2 +import files.classes +from files.routes import * +import files.helpers.jinja2 @cache.memoize(UA_BAN_CACHE_TTL) def get_useragent_ban_response(user_agent_str): @@ -210,8 +185,8 @@ def get_useragent_ban_response(user_agent_str): # return False, (None, None) result = g.db.query( - drama.classes.Agent).filter( - drama.classes.Agent.kwd.in_( + files.classes.Agent).filter( + files.classes.Agent.kwd.in_( user_agent_str.split())).first() if result: return True, (result.mock or "Follow the robots.txt, dumbass", @@ -267,26 +242,6 @@ def before_request(): else: g.system="other/other" - -def log_event(name, link): - - x = requests.get(link) - - if x.status_code != 200: - return - - text = f'> **{name}**\r> {link}' - - url = environ.get("DISCORD_WEBHOOK") - headers = {"Content-Type": "application/json"} - data = {"username": "drama", - "content": text - } - - x = requests.post(url, headers=headers, json=data) - print(x.status_code) - - @app.after_request def after_request(response): diff --git a/drama/classes/__init__.py b/files/classes/__init__.py similarity index 100% rename from drama/classes/__init__.py rename to files/classes/__init__.py diff --git a/drama/classes/agents.py b/files/classes/agents.py similarity index 91% rename from drama/classes/agents.py rename to files/classes/agents.py index fb0d0ad2e..dfce0c62d 100644 --- a/drama/classes/agents.py +++ b/files/classes/agents.py @@ -1,5 +1,5 @@ from sqlalchemy import * -from drama.__main__ import Base +from files.__main__ import Base class Agent(Base): diff --git a/drama/classes/alts.py b/files/classes/alts.py similarity index 90% rename from drama/classes/alts.py rename to files/classes/alts.py index 5bc5c16d8..04a6f00ef 100644 --- a/drama/classes/alts.py +++ b/files/classes/alts.py @@ -1,5 +1,5 @@ from sqlalchemy import * -from drama.__main__ import Base +from files.__main__ import Base class Alt(Base): diff --git a/drama/classes/award.py b/files/classes/award.py similarity index 97% rename from drama/classes/award.py rename to files/classes/award.py index 9eb2e7c1a..cc1f1ea0d 100644 --- a/drama/classes/award.py +++ b/files/classes/award.py @@ -1,6 +1,6 @@ from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.__main__ import Base +from files.__main__ import Base AWARDS = { "ban": { diff --git a/drama/classes/badges.py b/files/classes/badges.py similarity index 97% rename from drama/classes/badges.py rename to files/classes/badges.py index 2af5edc35..bd5787dfc 100644 --- a/drama/classes/badges.py +++ b/files/classes/badges.py @@ -1,7 +1,7 @@ from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.__main__ import Base, app +from files.__main__ import Base, app class BadgeDef(Base): diff --git a/drama/classes/clients.py b/files/classes/clients.py similarity index 94% rename from drama/classes/clients.py rename to files/classes/clients.py index 588db1f47..b1449e11b 100644 --- a/drama/classes/clients.py +++ b/files/classes/clients.py @@ -5,7 +5,7 @@ from sqlalchemy.orm import relationship, lazyload from .mix_ins import Stndrd from .submission import Submission from .comment import Comment -from drama.__main__ import Base +from files.__main__ import Base class OauthApp(Base, Stndrd): diff --git a/drama/classes/comment.py b/files/classes/comment.py similarity index 99% rename from drama/classes/comment.py rename to files/classes/comment.py index 38e0db165..da0528dec 100644 --- a/drama/classes/comment.py +++ b/files/classes/comment.py @@ -1,8 +1,8 @@ from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship, deferred -from drama.helpers.lazy import lazy -from drama.__main__ import Base +from files.helpers.lazy import lazy +from files.__main__ import Base from .mix_ins import * from .flags import CommentFlag diff --git a/drama/classes/domains.py b/files/classes/domains.py similarity index 81% rename from drama/classes/domains.py rename to files/classes/domains.py index 17e620f6a..5fbb26b9e 100644 --- a/drama/classes/domains.py +++ b/files/classes/domains.py @@ -1,5 +1,5 @@ from sqlalchemy import * -from drama.__main__ import Base +from files.__main__ import Base class BannedDomain(Base): diff --git a/drama/classes/flags.py b/files/classes/flags.py similarity index 96% rename from drama/classes/flags.py rename to files/classes/flags.py index 3d8f3519a..7d36ba7f0 100644 --- a/drama/classes/flags.py +++ b/files/classes/flags.py @@ -1,6 +1,6 @@ from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.__main__ import Base +from files.__main__ import Base from .mix_ins import * class Flag(Base, Stndrd): diff --git a/drama/classes/images.py b/files/classes/images.py similarity index 95% rename from drama/classes/images.py rename to files/classes/images.py index 701dd8dcd..5840c350a 100644 --- a/drama/classes/images.py +++ b/files/classes/images.py @@ -1,6 +1,6 @@ from sqlalchemy import * from flask import g -from drama.__main__ import Base +from files.__main__ import Base class Image(Base): diff --git a/files/classes/lolwtf.py b/files/classes/lolwtf.py new file mode 100644 index 000000000..5d26c7cf8 --- /dev/null +++ b/files/classes/lolwtf.py @@ -0,0 +1,2 @@ + +from files.__main__ import Base, app \ No newline at end of file diff --git a/drama/classes/mix_ins.py b/files/classes/mix_ins.py similarity index 98% rename from drama/classes/mix_ins.py rename to files/classes/mix_ins.py index 9f5728008..731d36ab4 100644 --- a/drama/classes/mix_ins.py +++ b/files/classes/mix_ins.py @@ -1,4 +1,4 @@ -from drama.helpers.lazy import lazy +from files.helpers.lazy import lazy import math import random import time diff --git a/drama/classes/mod_logs.py b/files/classes/mod_logs.py similarity index 99% rename from drama/classes/mod_logs.py rename to files/classes/mod_logs.py index b18fc4d81..941e08d3c 100644 --- a/drama/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -1,6 +1,6 @@ from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.__main__ import Base +from files.__main__ import Base from .mix_ins import * import time diff --git a/drama/classes/submission.py b/files/classes/submission.py similarity index 99% rename from drama/classes/submission.py rename to files/classes/submission.py index 7bab4d740..511214c8c 100644 --- a/drama/classes/submission.py +++ b/files/classes/submission.py @@ -3,13 +3,13 @@ from sqlalchemy import * from sqlalchemy.orm import relationship, deferred import re, random from urllib.parse import urlparse -from drama.helpers.lazy import lazy -from drama.__main__ import Base +from files.helpers.lazy import lazy +from files.__main__ import Base from .mix_ins import * from .flags import * from os import environ -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() class SubmissionAux(Base): diff --git a/drama/classes/subscriptions.py b/files/classes/subscriptions.py similarity index 93% rename from drama/classes/subscriptions.py rename to files/classes/subscriptions.py index 9cd327e39..8c41470fa 100644 --- a/drama/classes/subscriptions.py +++ b/files/classes/subscriptions.py @@ -1,6 +1,6 @@ from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.__main__ import Base +from files.__main__ import Base import time diff --git a/drama/classes/user.py b/files/classes/user.py similarity index 98% rename from drama/classes/user.py rename to files/classes/user.py index 33d102c55..7f0516b70 100644 --- a/drama/classes/user.py +++ b/files/classes/user.py @@ -2,8 +2,8 @@ from sqlalchemy.orm import deferred, contains_eager, aliased from secrets import token_hex import pyotp -from drama.helpers.discord import delete_role -from drama.helpers.images import * +from files.helpers.discord import delete_role +from files.helpers.images import * from .alts import Alt from .submission import SaveRelationship from .comment import Notification @@ -11,10 +11,10 @@ from .subscriptions import * from .userblock import * from .badges import * from .clients import * -from drama.__main__ import Base, cache -from drama.helpers.security import * +from files.__main__ import Base, cache +from files.helpers.security import * -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() class User(Base, Stndrd, Age_times): __tablename__ = "users" @@ -79,7 +79,7 @@ class User(Base, Stndrd, Age_times): ban_reason = Column(String, default="") login_nonce = Column(Integer, default=0) reserved = Column(String(256)) - dramacoins = Column(Integer, default=0) + coins = Column(Integer, default=0) mfa_secret = deferred(Column(String(16))) is_private = Column(Boolean, default=False) stored_subscriber_count = Column(Integer, default=0) @@ -491,7 +491,7 @@ class User(Base, Stndrd, Age_times): data = self.json_core data["badges"] = [x.json_core for x in self.badges] - data['dramacoins'] = int(self.dramacoins) + data['coins'] = int(self.coins) data['post_count'] = self.post_count data['comment_count'] = self.comment_count diff --git a/drama/classes/userblock.py b/files/classes/userblock.py similarity index 94% rename from drama/classes/userblock.py rename to files/classes/userblock.py index 547fab79b..ee491901a 100644 --- a/drama/classes/userblock.py +++ b/files/classes/userblock.py @@ -1,7 +1,7 @@ from sqlalchemy import * from sqlalchemy.orm import relationship from .mix_ins import * -from drama.__main__ import Base +from files.__main__ import Base class UserBlock(Base, Stndrd, Age_times): diff --git a/drama/classes/votes.py b/files/classes/votes.py similarity index 97% rename from drama/classes/votes.py rename to files/classes/votes.py index 4873d50bb..8b19f2685 100644 --- a/drama/classes/votes.py +++ b/files/classes/votes.py @@ -1,7 +1,7 @@ from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship -from drama.__main__ import Base +from files.__main__ import Base class Vote(Base): diff --git a/drama/helpers/alerts.py b/files/helpers/alerts.py similarity index 99% rename from drama/helpers/alerts.py rename to files/helpers/alerts.py index ec0d44296..44eb22d9f 100644 --- a/drama/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -1,6 +1,6 @@ import mistletoe -from drama.classes import * +from files.classes import * from flask import g from .markdown import * from .sanitize import * diff --git a/drama/helpers/base36.py b/files/helpers/base36.py similarity index 100% rename from drama/helpers/base36.py rename to files/helpers/base36.py diff --git a/drama/helpers/discord.py b/files/helpers/discord.py similarity index 100% rename from drama/helpers/discord.py rename to files/helpers/discord.py diff --git a/drama/helpers/filters.py b/files/helpers/filters.py similarity index 95% rename from drama/helpers/filters.py rename to files/helpers/filters.py index e6bc67d47..c4c33cebe 100644 --- a/drama/helpers/filters.py +++ b/files/helpers/filters.py @@ -1,7 +1,7 @@ from bs4 import BeautifulSoup from flask import * from urllib.parse import urlparse -from drama.classes import BannedDomain +from files.classes import BannedDomain def filter_comment_html(html_text): diff --git a/drama/helpers/get.py b/files/helpers/get.py similarity index 99% rename from drama/helpers/get.py rename to files/helpers/get.py index 43110e8ee..efa3b333b 100644 --- a/drama/helpers/get.py +++ b/files/helpers/get.py @@ -1,4 +1,4 @@ -from drama.classes import * +from files.classes import * from flask import g from sqlalchemy.orm import joinedload, aliased diff --git a/drama/helpers/images.py b/files/helpers/images.py similarity index 85% rename from drama/helpers/images.py rename to files/helpers/images.py index d16158b6e..759947636 100644 --- a/drama/helpers/images.py +++ b/files/helpers/images.py @@ -2,11 +2,11 @@ import requests from os import environ from PIL import Image as IImage, ImageSequence import base64 -from drama.classes.images import * +from files.classes.images import * CF_KEY = environ.get("CLOUDFLARE_KEY").strip() CF_ZONE = environ.get("CLOUDFLARE_ZONE").strip() -imgurkey = environ.get("imgurkey").strip() +IMGUR_KEY = environ.get("IMGUR_KEY").strip() def upload_file(file=None, resize=False, png=False): @@ -35,12 +35,10 @@ def upload_file(file=None, resize=False, png=False): try: with open(filedir, 'rb') as f: data={'image': base64.b64encode(f.read())} - req = requests.post('https://api.imgur.com/3/upload.json', headers = {"Authorization": f"Client-ID {imgurkey}"}, data=data) + req = requests.post('https://api.imgur.com/3/upload.json', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}, data=data) resp = req.json()['data'] url = resp['link'].replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg") + "?maxwidth=9999" - except: - print(req.text) - return + except: return new_image = Image(text=url, deletehash=resp["deletehash"]) g.db.add(new_image) diff --git a/drama/helpers/jinja2.py b/files/helpers/jinja2.py similarity index 87% rename from drama/helpers/jinja2.py rename to files/helpers/jinja2.py index d19bdbdfc..20897b42b 100644 --- a/drama/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -1,6 +1,6 @@ from os import environ, path from .get import * -from drama.__main__ import app, cache +from files.__main__ import app, cache @app.template_filter("total_users") @@ -14,7 +14,7 @@ def total_users(x): @cache.memoize(timeout=60 * 60 * 24) def source_code(file_name): - return open(path.expanduser('~') + '/drama/' + + return open(path.expanduser('~') + '/files/' + file_name, mode="r+").read() diff --git a/drama/helpers/lazy.py b/files/helpers/lazy.py similarity index 100% rename from drama/helpers/lazy.py rename to files/helpers/lazy.py diff --git a/drama/helpers/markdown.py b/files/helpers/markdown.py similarity index 100% rename from drama/helpers/markdown.py rename to files/helpers/markdown.py diff --git a/drama/helpers/redis.py b/files/helpers/redis.py similarity index 100% rename from drama/helpers/redis.py rename to files/helpers/redis.py diff --git a/drama/helpers/sanitize.py b/files/helpers/sanitize.py similarity index 95% rename from drama/helpers/sanitize.py rename to files/helpers/sanitize.py index 70e5ce973..eb53d4b37 100644 --- a/drama/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -6,7 +6,7 @@ from functools import partial from .get import * from os import path -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() _allowed_tags = tags = ['b', 'blockquote', @@ -72,7 +72,7 @@ def a_modify(attrs, new=False): attrs[(None, "rel")] = "nofollow noopener" # Force https for all external links in comments - # (Drama already forces its own https) + # (Website already forces its own https) new_url = ParseResult(scheme="https", netloc=parsed_url.netloc, path=parsed_url.path, @@ -178,12 +178,12 @@ def sanitize(text, linkgen=False, flair=False): start = '<s>' end = '</s>' - if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '').replace(end, '') + if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '').replace(end, '') if flair: emojisize = 20 else: emojisize = 30 for i in re.finditer(':(.{1,30}?):', sanitized): - if path.isfile(f'./drama/assets/images/emojis/{i.group(1)}.gif'): + if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f':{i.group(1)}:', f'') sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/embed/").replace("https://music.youtube.com/watch?v=", "https://youtube.com/embed/").replace("/watch?v=", "/embed/").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/embed/") diff --git a/drama/helpers/security.py b/files/helpers/security.py similarity index 100% rename from drama/helpers/security.py rename to files/helpers/security.py diff --git a/drama/helpers/session.py b/files/helpers/session.py similarity index 100% rename from drama/helpers/session.py rename to files/helpers/session.py diff --git a/drama/helpers/sqla_values.py b/files/helpers/sqla_values.py similarity index 100% rename from drama/helpers/sqla_values.py rename to files/helpers/sqla_values.py diff --git a/drama/helpers/thumbs.py b/files/helpers/thumbs.py similarity index 100% rename from drama/helpers/thumbs.py rename to files/helpers/thumbs.py diff --git a/drama/helpers/wrappers.py b/files/helpers/wrappers.py similarity index 96% rename from drama/helpers/wrappers.py rename to files/helpers/wrappers.py index 4ba2bd33b..0fb05f179 100644 --- a/drama/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -3,7 +3,7 @@ from sqlalchemy.sql import visitors from werkzeug.wrappers.response import Response as RespObj from .get import * from .alerts import send_notification -from drama.__main__ import app +from files.__main__ import app def get_logged_in_user(): @@ -48,7 +48,7 @@ def check_ban_evade(v): if random.randint(0,30) < v.ban_evade: v.ban(reason="ban evasion") - send_notification(1046, v, "Your Drama account has been permanently suspended for the following reason:\n\n> ban evasion") + send_notification(1046, v, "Your account has been permanently suspended for the following reason:\n\n> ban evasion") for post in g.db.query(Submission).filter_by(author_id=v.id).all(): if post.is_banned: diff --git a/drama/mail/__init__.py b/files/mail/__init__.py similarity index 100% rename from drama/mail/__init__.py rename to files/mail/__init__.py diff --git a/drama/mail/mail.py b/files/mail/mail.py similarity index 87% rename from drama/mail/mail.py rename to files/mail/mail.py index 5738978e2..34953ae76 100644 --- a/drama/mail/mail.py +++ b/files/mail/mail.py @@ -4,16 +4,17 @@ import time from flask import * from urllib.parse import quote -from drama.helpers.security import * -from drama.helpers.wrappers import * -from drama.classes import * -from drama.__main__ import app +from files.helpers.security import * +from files.helpers.wrappers import * +from files.classes import * +from files.__main__ import app -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() +name = environ.get("SITE_NAME").strip() mailgun_domain = environ.get("MAILGUN_DOMAIN").strip() def send_mail(to_address, subject, html, plaintext=None, files={}, - from_address=f"Drama "): + from_address=f"{name} "): url = f"https://api.mailgun.net/v3/{mailgun_domain}/messages" @@ -49,7 +50,7 @@ def send_verification_email(user, email=None): html=render_template("email/email_verify.html", action_url=link, v=user), - subject="Validate your Drama account email." + subject=f"Validate your {name} account email." ) diff --git a/drama/routes/__init__.py b/files/routes/__init__.py similarity index 100% rename from drama/routes/__init__.py rename to files/routes/__init__.py diff --git a/drama/routes/admin.py b/files/routes/admin.py similarity index 96% rename from drama/routes/admin.py rename to files/routes/admin.py index cf616d986..21e6cdd22 100644 --- a/drama/routes/admin.py +++ b/files/routes/admin.py @@ -5,17 +5,17 @@ import imagehash from os import remove from PIL import Image as IMAGE -from drama.helpers.wrappers import * -from drama.helpers.alerts import * -from drama.helpers.sanitize import * -from drama.helpers.markdown import * -from drama.helpers.security import * -from drama.helpers.get import * -from drama.helpers.images import * -from drama.classes import * +from files.helpers.wrappers import * +from files.helpers.alerts import * +from files.helpers.sanitize import * +from files.helpers.markdown import * +from files.helpers.security import * +from files.helpers.get import * +from files.helpers.images import * +from files.classes import * from flask import * import matplotlib.pyplot as plt -from drama.__main__ import app, cache +from files.__main__ import app, cache from .front import frontlist @app.get("/admin/shadowbanned") @@ -443,7 +443,7 @@ def admin_image_purge(v): name = request.form.get("url") image = g.db.query(Image).filter(Image.text == name).first() if image: - requests.delete(f'https://api.imgur.com/3/image/{image.deletehash}', headers = {"Authorization": f"Client-ID {imgurkey}"}) + requests.delete(f'https://api.imgur.com/3/image/{image.deletehash}', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}) headers = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/json"} data = {'files': [name]} url = f"https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache" @@ -646,16 +646,16 @@ def ban_user(user_id, v): if days > 0: if message: - text = f"Your Drama account has been suspended for {days} days for the following reason:\n\n> {message}" + text = f"Your account has been suspended for {days} days for the following reason:\n\n> {message}" else: - text = f"Your Drama account has been suspended for {days} days." + text = f"Your account has been suspended for {days} days." user.ban(admin=v, reason=reason, days=days) else: if message: - text = f"Your Drama account has been permanently suspended for the following reason:\n\n> {message}" + text = f"Your account has been permanently suspended for the following reason:\n\n> {message}" else: - text = "Your Drama account has been permanently suspended." + text = "Your account has been permanently suspended." user.ban(admin=v, reason=reason) @@ -701,7 +701,7 @@ def unban_user(user_id, v): x.unban() send_notification(1046, user, - "Your Drama account has been reinstated. Please carefully review and abide by the [rules](/post/2510) to ensure that you don't get suspended again.") + "Your account has been reinstated. Please carefully review and abide by the [rules](/post/2510) to ensure that you don't get suspended again.") ma=ModAction( kind="unexile_user", @@ -907,7 +907,7 @@ def refund(v): if u.id == 253: continue posts=sum([x[0]+x[1]-1 for x in g.db.query(Submission.upvotes, Submission.downvotes).options(lazyload('*')).filter_by(author_id = u.id, is_banned = False, deleted_utc = 0).all()]) comments=sum([x[0]+x[1]-1 for x in g.db.query(Comment.upvotes, Comment.downvotes).options(lazyload('*')).filter_by(author_id = u.id, is_banned = False, deleted_utc = 0).all()]) - u.dramacoins = int(posts+comments) + u.coins = int(posts+comments) g.db.add(u) return "sex" @@ -931,7 +931,7 @@ def admin_banned_domains(v): @validate_formkey def admin_toggle_ban_domain(v): - domain=request.form.get("domain").strip() + domain=request.form.get("DOMAIN").strip() if not domain: abort(400) reason=request.form.get("reason", "").strip() diff --git a/drama/routes/awards.py b/files/routes/awards.py similarity index 92% rename from drama/routes/awards.py rename to files/routes/awards.py index 12b500018..7fafd9a14 100644 --- a/drama/routes/awards.py +++ b/files/routes/awards.py @@ -1,8 +1,8 @@ -from drama.__main__ import app -from drama.helpers.wrappers import * -from drama.helpers.alerts import * -from drama.helpers.get import * -from drama.classes.award import * +from files.__main__ import app +from files.helpers.wrappers import * +from files.helpers.alerts import * +from files.helpers.get import * +from files.classes.award import * from flask import g, request @@ -15,13 +15,12 @@ def banaward_trigger(post=None, comment=None): if not author.is_suspended: author.ban(reason="1-day ban award used", days=1) - send_notification(1046, author, f"Your Drama account has been suspended for a day for {link}. It sucked and you should feel bad.") + send_notification(1046, author, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.") elif author.unban_utc > 0: author.unban_utc += 24*60*60 g.db.add(author) - send_notification(1046, author, - f"Your Drama account has been suspended for yet another day for {link}. Seriously man?") + send_notification(1046, author, f"Your account has been suspended for yet another day for {link}. Seriously man?") ACTIONS = { diff --git a/drama/routes/comments.py b/files/routes/comments.py similarity index 97% rename from drama/routes/comments.py rename to files/routes/comments.py index e6135546f..ce9822339 100644 --- a/drama/routes/comments.py +++ b/files/routes/comments.py @@ -1,19 +1,19 @@ import traceback import sys -from drama.helpers.wrappers import * -from drama.helpers.filters import * -from drama.helpers.alerts import * -from drama.helpers.images import * -from drama.helpers.session import * -from drama.classes import * -from drama.routes.front import comment_idlist +from files.helpers.wrappers import * +from files.helpers.filters import * +from files.helpers.alerts import * +from files.helpers.images import * +from files.helpers.session import * +from files.classes import * +from files.routes.front import comment_idlist from pusher_push_notifications import PushNotifications, PusherAuthError from flask import * -from drama.__main__ import app, limiter +from files.__main__ import app, limiter -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() choices = ['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 reddit was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures."] @@ -259,7 +259,7 @@ def api_comment(v): threshold *= 2 if len(similar_comments) > threshold: - text = "Your Drama account has been suspended for 1 day for the following reason:\n\n> Too much spam!" + text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" send_notification(1046, v, text) v.ban(reason="Spamming.", @@ -539,7 +539,7 @@ def api_comment(v): }, ) except PusherAuthError as e: - traceback.print_tb(e.__traceback__) + sys.stderr.write(traceback.format_exc()) sys.stderr.flush() @@ -656,7 +656,7 @@ def edit_comment(cid, v): threshold *= 2 if len(similar_comments) > threshold: - text = "Your Drama account has been suspended for 1 day for the following reason:\n\n> Too much spam!" + text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" send_notification(1046, v, text) v.ban(reason="Spamming.", diff --git a/drama/routes/discord.py b/files/routes/discord.py similarity index 87% rename from drama/routes/discord.py rename to files/routes/discord.py index 72f7a6d95..6e29b5fc7 100644 --- a/drama/routes/discord.py +++ b/files/routes/discord.py @@ -1,15 +1,14 @@ -from drama.helpers.wrappers import * -from drama.helpers.security import * -from drama.helpers.discord import add_role -from drama.__main__ import app +from files.helpers.wrappers import * +from files.helpers.security import * +from files.helpers.discord import add_role +from files.__main__ import app SERVER_ID = environ.get("DISCORD_SERVER_ID",'').strip() CLIENT_ID = environ.get("DISCORD_CLIENT_ID",'').strip() CLIENT_SECRET = environ.get("DISCORD_CLIENT_SECRET",'').strip() BOT_TOKEN = environ.get("DISCORD_BOT_TOKEN").strip() +COINS_NAME = environ.get("COINS_NAME").strip() DISCORD_ENDPOINT = "https://discordapp.com/api/v6" - - WELCOME_CHANNEL="846509313941700618" @app.get("/discord") @@ -17,7 +16,7 @@ WELCOME_CHANNEL="846509313941700618" def join_discord(v): if v.is_banned != 0: return "You're banned" - if v.admin_level == 0 and v.dramacoins < 150: return "You must earn 150 dramacoins before entering the Discord server. You earn dramacoins by making posts/comments and getting upvoted." + if v.admin_level == 0 and v.coins < 150: return f"You must earn 150 {COINS_NAME} before entering the Discord server. You earn {COINS_NAME} by making posts/comments and getting upvoted." now=int(time.time()) @@ -126,7 +125,7 @@ def discord_redirect(v): time.sleep(0.1) - if v.dramacoins > 100: add_role(v, "linked") + if v.coins > 100: add_role(v, "linked") else: add_role(v, "norep") else: diff --git a/drama/routes/errors.py b/files/routes/errors.py similarity index 97% rename from drama/routes/errors.py rename to files/routes/errors.py index 4b43a2380..01281af43 100644 --- a/drama/routes/errors.py +++ b/files/routes/errors.py @@ -1,11 +1,11 @@ import jinja2.exceptions -from drama.helpers.wrappers import * -from drama.helpers.session import * +from files.helpers.wrappers import * +from files.helpers.session import * from flask import * from urllib.parse import quote, urlencode import time -from drama.__main__ import app +from files.__main__ import app # Errors diff --git a/drama/routes/feeds.py b/files/routes/feeds.py similarity index 91% rename from drama/routes/feeds.py rename to files/routes/feeds.py index 91582b42b..bcee4c7bf 100644 --- a/drama/routes/feeds.py +++ b/files/routes/feeds.py @@ -1,11 +1,11 @@ import html from .front import frontlist from datetime import datetime -from drama.helpers.jinja2 import full_link -from drama.helpers.get import * +from files.helpers.jinja2 import full_link +from files.helpers.get import * from yattag import Doc -from drama.__main__ import app +from files.__main__ import app @app.get('/rss//') def feeds_user(sort='hot', t='all'): diff --git a/drama/routes/flagging.py b/files/routes/flagging.py similarity index 70% rename from drama/routes/flagging.py rename to files/routes/flagging.py index ce62d97ac..3c613427d 100644 --- a/drama/routes/flagging.py +++ b/files/routes/flagging.py @@ -1,8 +1,8 @@ -from drama.helpers.wrappers import * -from drama.helpers.get import * +from files.helpers.wrappers import * +from files.helpers.get import * from flask import g -from drama.__main__ import app -from drama.helpers.sanitize import sanitize +from files.__main__ import app +from files.helpers.sanitize import sanitize @app.post("/flag/post/") @auth_desired @@ -11,11 +11,10 @@ def api_flag_post(pid, v): post = get_post(pid) if v: - existing = g.db.query(Flag).filter_by( - user_id=v.id, post_id=post.id).first() + existing = g.db.query(Flag).filter_by(user_id=v.id, post_id=post.id).first() if existing: return "", 409 - reason = sanitize(request.form.get("reason", "")[:100].strip(), flair=True) + reason = sanitize(request.form.get("reason", "").strip()[:100], flair=True) flag = Flag(post_id=post.id, user_id=v.id, diff --git a/drama/routes/front.py b/files/routes/front.py similarity index 98% rename from drama/routes/front.py rename to files/routes/front.py index dff0e095e..272af70d1 100644 --- a/drama/routes/front.py +++ b/files/routes/front.py @@ -1,8 +1,8 @@ -from drama.helpers.wrappers import * -from drama.helpers.get import * +from files.helpers.wrappers import * +from files.helpers.get import * -from drama.__main__ import app, cache -from drama.classes.submission import Submission +from files.__main__ import app, cache +from files.classes.submission import Submission @app.get("/post/") def slash_post(): diff --git a/drama/routes/login.py b/files/routes/login.py similarity index 98% rename from drama/routes/login.py rename to files/routes/login.py index 875c2f008..c13acb9a5 100644 --- a/drama/routes/login.py +++ b/files/routes/login.py @@ -1,6 +1,6 @@ from urllib.parse import urlencode -from drama.mail import * -from drama.__main__ import app, limiter +from files.mail import * +from files.__main__ import app, limiter valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") valid_password_regex = re.compile("^.{8,100}$") @@ -135,8 +135,8 @@ def login_post(): @app.get("/@me") @auth_required def me(v): - if request.headers.get("Authorization"): v.json - else: redirect(v.url) + if request.headers.get("Authorization"): return v.json + else: return redirect(v.url) @app.post("/logout") @@ -404,7 +404,7 @@ def post_forgot(): url = f"https://{app.config['SERVER_NAME']}/reset?id={user.id}&time={now}&token={token}" send_mail(to_address=user.email, - subject="Drama - Password Reset Request", + subject="Password Reset Request", html=render_template("email/password_reset.html", action_url=url, v=user) @@ -537,7 +537,7 @@ def request_2fa_disable(): action_url=f"https://{app.config['SERVER_NAME']}/reset_2fa?id={user.id}&t={valid}&token={token}" send_mail(to_address=user.email, - subject="Drama - 2FA Removal Request", + subject="2FA Removal Request", html=render_template("email/2fa_remove.html", action_url=action_url, v=user) diff --git a/drama/routes/oauth.py b/files/routes/oauth.py similarity index 95% rename from drama/routes/oauth.py rename to files/routes/oauth.py index 16283b14c..802ccd8b7 100644 --- a/drama/routes/oauth.py +++ b/files/routes/oauth.py @@ -1,9 +1,9 @@ -from drama.helpers.wrappers import * -from drama.helpers.alerts import * -from drama.helpers.get import * -from drama.classes import * +from files.helpers.wrappers import * +from files.helpers.alerts import * +from files.helpers.get import * +from files.classes import * from flask import * -from drama.__main__ import app +from files.__main__ import app @app.get("/authorize") @auth_required diff --git a/drama/routes/posts.py b/files/routes/posts.py similarity index 95% rename from drama/routes/posts.py rename to files/routes/posts.py index 1a574b59c..bce0f5bb5 100644 --- a/drama/routes/posts.py +++ b/files/routes/posts.py @@ -3,22 +3,22 @@ import mistletoe import urllib.parse import gevent -from drama.helpers.wrappers import * -from drama.helpers.sanitize import * -from drama.helpers.filters import * -from drama.helpers.markdown import * -from drama.helpers.session import * -from drama.helpers.thumbs import * -from drama.helpers.alerts import send_notification -from drama.helpers.discord import send_message -from drama.classes import * +from files.helpers.wrappers import * +from files.helpers.sanitize import * +from files.helpers.filters import * +from files.helpers.markdown import * +from files.helpers.session import * +from files.helpers.thumbs import * +from files.helpers.alerts import send_notification +from files.helpers.discord import send_message +from files.classes import * from flask import * from io import BytesIO -from drama.__main__ import app, limiter, cache +from files.__main__ import app, limiter, cache from PIL import Image as PILimage from .front import frontlist -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}") @@ -266,7 +266,7 @@ def edit_post(pid, v): BadLink.link)).first() if badlink: if badlink.autoban: - text = "Your Drama account has been suspended for 1 day for the following reason:\n\n> Too much spam!" + text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" send_notification(1046, v, text) v.ban(days=1, reason="spam") @@ -422,7 +422,6 @@ def thumbs(new_post): #iterate through desired meta tags meta_tags = [ - "drama:thumbnail", "twitter:image", "og:image", "thumbnail" @@ -508,6 +507,22 @@ def archiveorg(url): except Exception as e: print(e) +@app.route("/embed/post/", methods=["GET"]) +def embed_post_pid(pid): + + post = get_post(pid) + + return render_template("embeds/post.html", p=post) + + +@app.route("/embed/comment/", methods=["GET"]) +def embed_comment_cid(cid, pid=None): + + comment = get_comment(cid) + + return render_template("embeds/comment.html", c=comment) + + @app.post("/submit") @limiter.limit("6/minute") @is_not_banned @@ -604,8 +619,9 @@ def submit_post(v): else: return render_template("submit.html", v=v, error="ToS Violation", title=title, url=url, body=request.form.get("body", "")), 400 if "twitter.com" in domain: - embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}).json()["html"] - + try: embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}).json()["html"] + except: embed = None + elif "youtu" in domain: yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2) if not yt_id or len(yt_id) != 11: embed = None @@ -616,7 +632,7 @@ def submit_post(v): else: embed = f"https://youtube.com/embed/{yt_id}" elif "instagram.com" in domain: - embed = requests.get("https://graph.facebook.com/v9.0/instagram_oembed", params={"url":url,"access_token":environ.get("FACEBOOK_TOKEN","").strip(),"omitscript":'true'}, headers={"User-Agent":"Instagram embedder for Drama"}).json()["html"] + embed = requests.get("https://graph.facebook.com/v9.0/instagram_oembed", params={"url":url,"access_token":environ.get("FACEBOOK_TOKEN","").strip(),"omitscript":'true'}, headers={"User-Agent": app.config["UserAgent"]}).json()["html"] elif app.config['SERVER_NAME'] in domain: try: @@ -681,7 +697,7 @@ def submit_post(v): if max(len(similar_urls), len(similar_posts)) >= threshold: - text = "Your Drama account has been suspended for 1 day for the following reason:\n\n> Too much spam!" + text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" send_notification(1046, v, text) v.ban(reason="Spamming.", @@ -761,7 +777,7 @@ def submit_post(v): BadLink.link)).first() if badlink: if badlink.autoban: - text = "Your Drama account has been suspended for 1 day for the following reason:\n\n> Too much spam!" + text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" send_notification(1046, v, text) v.ban(days=1, reason="spam") @@ -789,7 +805,7 @@ def submit_post(v): url = url.replace("https://mobile.twitter.com", "https://twitter.com") - if url.startswith("https://old.reddit.com/") and '/comments/' in url and '?sort=' not in url: url += "?sort=controversial" + # if url.startswith("https://old.reddit.com/") and '/comments/' in url and '?' not in url: url += "?sort=controversial" title_html = sanitize(title, linkgen=True, flair=True) diff --git a/drama/routes/search.py b/files/routes/search.py similarity index 98% rename from drama/routes/search.py rename to files/routes/search.py index 31cd8dc76..ee3cca08d 100644 --- a/drama/routes/search.py +++ b/files/routes/search.py @@ -1,8 +1,8 @@ -from drama.helpers.wrappers import * +from files.helpers.wrappers import * import re from sqlalchemy import * from flask import * -from drama.__main__ import app, cache +from files.__main__ import app, cache import random query_regex=re.compile("(\w+):(\S+)") diff --git a/drama/routes/settings.py b/files/routes/settings.py similarity index 96% rename from drama/routes/settings.py rename to files/routes/settings.py index 78a20e73c..b9436d6ae 100644 --- a/drama/routes/settings.py +++ b/files/routes/settings.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals -from drama.helpers.alerts import * -from drama.helpers.sanitize import * -from drama.helpers.filters import filter_comment_html -from drama.helpers.markdown import * -from drama.helpers.discord import remove_user, set_nick -from drama.mail import * -from drama.__main__ import app, cache +from files.helpers.alerts import * +from files.helpers.sanitize import * +from files.helpers.filters import filter_comment_html +from files.helpers.markdown import * +from files.helpers.discord import remove_user, set_nick +from files.mail import * +from files.__main__ import app, cache import youtube_dl from .front import frontlist @@ -13,7 +13,8 @@ valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") valid_title_regex = re.compile("^((?!<).){3,100}$") valid_password_regex = re.compile("^.{8,100}$") -youtubekey = environ.get("youtubekey").strip() +YOUTUBE_KEY = environ.get("YOUTUBE_KEY").strip() +COINS_NAME = environ.get("COINS_NAME").strip() @app.post("/settings/profile") @auth_required @@ -51,7 +52,7 @@ def settings_profile_post(v): if request.values.get("animatedname", v.animatedname) != v.animatedname: if v.animatedname == False: - users = g.db.query(User.id).options(lazyload('*')).order_by(User.dramacoins.desc()).limit(25).all() + users = g.db.query(User.id).options(lazyload('*')).order_by(User.coins.desc()).limit(25).all() users = [x[0] for x in users] if v.id not in users: return {"error": "You must be in the top 25 leaderboard or be a patron to apply an animated name!"}, 403 updated = True @@ -425,13 +426,13 @@ def settings_css(v): @auth_required def settings_profilecss_get(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") - if v.dramacoins < 1000 and not v.patron: return "You must have +1000 dramacoins or be a patron to set profile css." + if v.coins < 1000 and not v.patron: return f"You must have +1000 {COINS_NAME} or be a patron to set profile css." return render_template("settings_profilecss.html", v=v) @app.post("/settings/profilecss") @auth_required def settings_profilecss(v): - if v.dramacoins < 1000 and not v.patron: return "You must have +1000 dramacoins or be a patron to set profile css." + if v.coins < 1000 and not v.patron: return f"You must have +1000 {COINS_NAME} or be a patron to set profile css." profilecss = request.form.get("profilecss").replace('\\', '')[:50000] v.profilecss = profilecss g.db.add(v) @@ -454,7 +455,7 @@ def settings_block_user(v): return {"error": f"You have already blocked @{user.username}."}, 409 if user.id == 1046: - return {"error": "You can't block @Drama."}, 409 + return {"error": "You can't block @files."}, 409 new_block = UserBlock(user_id=v.id, target_id=user.id, @@ -613,7 +614,7 @@ def settings_song_change(v): return redirect("/settings/profile") - req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={youtubekey}&part=contentDetails").json() + req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails").json() try: duration = req['items'][0]['contentDetails']['duration'] except: print(req) diff --git a/drama/routes/static.py b/files/routes/static.py similarity index 97% rename from drama/routes/static.py rename to files/routes/static.py index f84aec5ae..bf1c99925 100644 --- a/drama/routes/static.py +++ b/files/routes/static.py @@ -1,8 +1,8 @@ -from drama.mail import * -from drama.__main__ import app, limiter -from drama.helpers.alerts import * +from files.mail import * +from files.__main__ import app, limiter +from files.helpers.alerts import * -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() @app.get("/patrons") @auth_desired @@ -14,7 +14,7 @@ def patrons(v): @app.get("/badmins") @auth_desired def badmins(v): - badmins = g.db.query(User).filter_by(admin_level=6).order_by(User.dramacoins.desc()).all() + badmins = g.db.query(User).filter_by(admin_level=6).order_by(User.coins.desc()).all() return render_template("badmins.html", v=v, badmins=badmins) @app.get("/log") diff --git a/drama/routes/users.py b/files/routes/users.py similarity index 88% rename from drama/routes/users.py rename to files/routes/users.py index 8d39af87b..2790ef440 100644 --- a/drama/routes/users.py +++ b/files/routes/users.py @@ -4,16 +4,16 @@ import time import traceback import sys -from drama.classes.user import ViewerRelationship -from drama.helpers.alerts import * -from drama.helpers.sanitize import * -from drama.helpers.markdown import * -from drama.mail import * +from files.classes.user import ViewerRelationship +from files.helpers.alerts import * +from files.helpers.sanitize import * +from files.helpers.markdown import * +from files.mail import * from flask import * -from drama.__main__ import app, limiter +from files.__main__ import app, limiter from pusher_push_notifications import PushNotifications, PusherAuthError -site = environ.get("domain").strip() +site = environ.get("DOMAIN").strip() PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() @@ -28,7 +28,7 @@ def suicide(v, username): t = int(time.time()) if v.admin_level == 0 and t - v.suicide_utc < 86400: return "", 204 user = get_user(username) - suicide = f"Hi there,\n\nA [concerned dramatard]({v.url}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators at r/SuicideWatch keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow dramatards care about you and there are people who want to help." + suicide = f"Hi there,\n\nA [concerned user]({v.url}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators at r/SuicideWatch keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow users care about you and there are people who want to help." send_notification(1046, user, suicide) v.suicide_utc = t g.db.add(v) @@ -39,7 +39,7 @@ def suicide(v, username): def leaderboard(v): if v and v.is_banned and not v.unban_utc:return render_template("seized.html") users = g.db.query(User).options(lazyload('*')) - users1 = users.order_by(User.dramacoins.desc()).limit(25).all() + users1 = users.order_by(User.coins.desc()).limit(25).all() users2 = users.order_by(User.stored_subscriber_count.desc()).limit(10).all() users3 = users.order_by(User.post_count.desc()).limit(10).all() users4 = users.order_by(User.comment_count.desc()).limit(10).all() @@ -159,7 +159,7 @@ def message2(v, username): }, ) except PusherAuthError as e: - traceback.print_tb(e.__traceback__) + sys.stderr.write(traceback.format_exc()) sys.stderr.flush() return redirect('/notifications?all=true') @@ -171,7 +171,7 @@ def mfa_qr(secret, v): qr = qrcode.QRCode( error_correction=qrcode.constants.ERROR_CORRECT_L ) - qr.add_data(x.provisioning_uri(v.username, issuer_name="Drama")) + qr.add_data(x.provisioning_uri(v.username, issuer_name=app.config["SITE_NAME"])) img = qr.make_image(fill_color="#000000", back_color="white") mem = io.BytesIO() @@ -284,11 +284,11 @@ def u_username(username, v=None): # paidrent = False # if v and u.id == 253: # if int(time.time()) - v.rent_utc < 600: paidrent = True - # elif request.args.get("rent") == "true" and v.dramacoins > 500: - # v.dramacoins -= 500 + # elif request.args.get("rent") == "true" and v.coins > 500: + # v.coins -= 500 # v.rent_utc = int(time.time()) # g.db.add(v) - # u.dramacoins += 500 + # u.coins += 500 # g.db.add(u) # send_notification(1046, u, f"@{v.username} has paid rent!") # paidrent = True @@ -386,11 +386,11 @@ def u_username_comments(username, v=None): # paidrent = False # if v and u.id == 253: # if int(time.time()) - v.rent_utc < 600: paidrent = True - # elif request.args.get("rent") == "true" and v.dramacoins > 500: - # v.dramacoins -= 500 + # elif request.args.get("rent") == "true" and v.coins > 500: + # v.coins -= 500 # v.rent_utc = int(time.time()) # g.db.add(v) - # u.dramacoins += 500 + # u.coins += 500 # g.db.add(u) # send_notification(1046, u, f"@{v.username} has paid rent!") # paidrent = True diff --git a/drama/routes/votes.py b/files/routes/votes.py similarity index 90% rename from drama/routes/votes.py rename to files/routes/votes.py index 59581ef52..0f39ae239 100644 --- a/drama/routes/votes.py +++ b/files/routes/votes.py @@ -1,8 +1,8 @@ -from drama.helpers.wrappers import * -from drama.helpers.get import * -from drama.classes import * +from files.helpers.wrappers import * +from files.helpers.get import * +from files.classes import * from flask import * -from drama.__main__ import app +from files.__main__ import app @app.get("/votes") @@ -73,16 +73,16 @@ def api_vote_post(post_id, new, v): if existing: if existing.vote_type == 0 and new != 0: - post.author.dramacoins += 1 + post.author.coins += 1 g.db.add(post.author) elif existing.vote_type != 0 and new == 0: - post.author.dramacoins -= 1 + post.author.coins -= 1 g.db.add(post.author) existing.vote_type = new g.db.add(existing) else: if new != 0: - post.author.dramacoins += 1 + post.author.coins += 1 g.db.add(post.author) vote = Vote(user_id=v.id, vote_type=new, @@ -121,16 +121,16 @@ def api_vote_comment(comment_id, new, v): if existing: if existing.vote_type == 0 and new != 0: - comment.author.dramacoins += 1 + comment.author.coins += 1 g.db.add(comment.author) elif existing.vote_type != 0 and new == 0: - comment.author.dramacoins -= 1 + comment.author.coins -= 1 g.db.add(comment.author) existing.vote_type = new g.db.add(existing) else: if new != 0: - comment.author.dramacoins += 1 + comment.author.coins += 1 g.db.add(comment.author) vote = CommentVote(user_id=v.id, vote_type=new, diff --git a/drama/static/index.js b/files/static/index.js similarity index 100% rename from drama/static/index.js rename to files/static/index.js diff --git a/drama/templates/2fa_modal.html b/files/templates/2fa_modal.html similarity index 100% rename from drama/templates/2fa_modal.html rename to files/templates/2fa_modal.html diff --git a/drama/templates/admin/admin_home.html b/files/templates/admin/admin_home.html similarity index 100% rename from drama/templates/admin/admin_home.html rename to files/templates/admin/admin_home.html diff --git a/drama/templates/admin/alt_votes.html b/files/templates/admin/alt_votes.html similarity index 100% rename from drama/templates/admin/alt_votes.html rename to files/templates/admin/alt_votes.html diff --git a/drama/templates/admin/app.html b/files/templates/admin/app.html similarity index 100% rename from drama/templates/admin/app.html rename to files/templates/admin/app.html diff --git a/drama/templates/admin/apps.html b/files/templates/admin/apps.html similarity index 100% rename from drama/templates/admin/apps.html rename to files/templates/admin/apps.html diff --git a/drama/templates/admin/badge_grant.html b/files/templates/admin/badge_grant.html similarity index 100% rename from drama/templates/admin/badge_grant.html rename to files/templates/admin/badge_grant.html diff --git a/drama/templates/admin/banned_domains.html b/files/templates/admin/banned_domains.html similarity index 100% rename from drama/templates/admin/banned_domains.html rename to files/templates/admin/banned_domains.html diff --git a/drama/templates/admin/content_stats.html b/files/templates/admin/content_stats.html similarity index 100% rename from drama/templates/admin/content_stats.html rename to files/templates/admin/content_stats.html diff --git a/drama/templates/admin/flagged_comments.html b/files/templates/admin/flagged_comments.html similarity index 100% rename from drama/templates/admin/flagged_comments.html rename to files/templates/admin/flagged_comments.html diff --git a/drama/templates/admin/flagged_posts.html b/files/templates/admin/flagged_posts.html similarity index 100% rename from drama/templates/admin/flagged_posts.html rename to files/templates/admin/flagged_posts.html diff --git a/drama/templates/admin/image_ban.html b/files/templates/admin/image_ban.html similarity index 100% rename from drama/templates/admin/image_ban.html rename to files/templates/admin/image_ban.html diff --git a/drama/templates/admin/image_posts.html b/files/templates/admin/image_posts.html similarity index 100% rename from drama/templates/admin/image_posts.html rename to files/templates/admin/image_posts.html diff --git a/drama/templates/admin/image_purge.html b/files/templates/admin/image_purge.html similarity index 100% rename from drama/templates/admin/image_purge.html rename to files/templates/admin/image_purge.html diff --git a/drama/templates/admin/new_users.html b/files/templates/admin/new_users.html similarity index 100% rename from drama/templates/admin/new_users.html rename to files/templates/admin/new_users.html diff --git a/drama/templates/admin/removed_posts.html b/files/templates/admin/removed_posts.html similarity index 100% rename from drama/templates/admin/removed_posts.html rename to files/templates/admin/removed_posts.html diff --git a/drama/templates/admin/user_award.html b/files/templates/admin/user_award.html similarity index 100% rename from drama/templates/admin/user_award.html rename to files/templates/admin/user_award.html diff --git a/drama/templates/api.html b/files/templates/api.html similarity index 95% rename from drama/templates/api.html rename to files/templates/api.html index 2663cd9bf..c97a27236 100644 --- a/drama/templates/api.html +++ b/files/templates/api.html @@ -43,7 +43,7 @@ Python example: headers={"Authorization": "access_token_goes_here", "User-Agent": "sex"} - url="https://rdrama.net/@carpathianflorist" + url="{{request.host_url}}@carpathianflorist" r=requests.get(url, headers=headers) @@ -93,7 +93,7 @@ DO NOT reveal your Client ID or Access Token. Anyone with these information will ## Step 2: Prompt Your User for Authorization -Send your user to `https://rdrama.net/authorize/?client_id=YOUR_CLIENT_ID` +Send your user to `{{request.host_url}}authorize/?client_id=YOUR_CLIENT_ID` If done correctly, the user will see that your application wants to access their {{"SITE_NAME" | app_config}} account, and be prompted to approve or deny the request. @@ -112,7 +112,7 @@ Python example: headers={"Authorization": "access_token_goes_here", "User-Agent": "sex"} - url="https://rdrama.net/@carpathianflorist" + url="{{request.host_url}}@carpathianflorist" r=requests.get(url, headers=headers) diff --git a/drama/templates/authforms.html b/files/templates/authforms.html similarity index 95% rename from drama/templates/authforms.html rename to files/templates/authforms.html index 0bc0c834c..3a19f3da5 100644 --- a/drama/templates/authforms.html +++ b/files/templates/authforms.html @@ -5,10 +5,10 @@ - + - {% block pagetitle %}{{"SITE_NAME" | app_config}} - the open, free-speech social platform{% endblock %} + {% block pagetitle %}{{"SITE_NAME" | app_config}}{% endblock %} diff --git a/drama/templates/award_modal.html b/files/templates/award_modal.html similarity index 100% rename from drama/templates/award_modal.html rename to files/templates/award_modal.html diff --git a/drama/templates/badges.html b/files/templates/badges.html similarity index 100% rename from drama/templates/badges.html rename to files/templates/badges.html diff --git a/drama/templates/badmins.html b/files/templates/badmins.html similarity index 89% rename from drama/templates/badmins.html rename to files/templates/badmins.html index fe0bf7c7b..87e791c50 100644 --- a/drama/templates/badmins.html +++ b/files/templates/badmins.html @@ -16,7 +16,7 @@ {% for user in badmins %} {{user.username}} - {{user.dramacoins}} + {{user.coins}} {% endfor %} diff --git a/drama/templates/banned.html b/files/templates/banned.html similarity index 100% rename from drama/templates/banned.html rename to files/templates/banned.html diff --git a/drama/templates/blocks.html b/files/templates/blocks.html similarity index 100% rename from drama/templates/blocks.html rename to files/templates/blocks.html diff --git a/drama/templates/bootstrap.html b/files/templates/bootstrap.html similarity index 100% rename from drama/templates/bootstrap.html rename to files/templates/bootstrap.html diff --git a/drama/templates/changelog.html b/files/templates/changelog.html similarity index 100% rename from drama/templates/changelog.html rename to files/templates/changelog.html diff --git a/drama/templates/comment_failed.html b/files/templates/comment_failed.html similarity index 85% rename from drama/templates/comment_failed.html rename to files/templates/comment_failed.html index ebeb3beb6..f702d692f 100644 --- a/drama/templates/comment_failed.html +++ b/files/templates/comment_failed.html @@ -9,15 +9,6 @@ {% block content %}
-

Whoops!

-

Although {{"SITE_NAME" | app_config}} puts your freedom of speech first, there are a few things that we don't allow here:

-
    -
  • Digitally malicious content
  • -
  • URL shorteners
  • -
  • Copyright infringement
  • -
  • Spam
  • -
-

Please remove the following link(s) from your comment, and then you will be able to post it:

    diff --git a/drama/templates/comments.html b/files/templates/comments.html similarity index 100% rename from drama/templates/comments.html rename to files/templates/comments.html diff --git a/drama/templates/contact.html b/files/templates/contact.html similarity index 100% rename from drama/templates/contact.html rename to files/templates/contact.html diff --git a/drama/templates/default.html b/files/templates/default.html similarity index 99% rename from drama/templates/default.html rename to files/templates/default.html index 16d18d6e5..870a61503 100644 --- a/drama/templates/default.html +++ b/files/templates/default.html @@ -807,13 +807,13 @@ - + - + - + diff --git a/drama/templates/delete_comment_modal.html b/files/templates/delete_comment_modal.html similarity index 100% rename from drama/templates/delete_comment_modal.html rename to files/templates/delete_comment_modal.html diff --git a/drama/templates/delete_post_modal.html b/files/templates/delete_post_modal.html similarity index 100% rename from drama/templates/delete_post_modal.html rename to files/templates/delete_post_modal.html diff --git a/drama/templates/email/2fa_remove.html b/files/templates/email/2fa_remove.html similarity index 100% rename from drama/templates/email/2fa_remove.html rename to files/templates/email/2fa_remove.html diff --git a/drama/templates/email/default.html b/files/templates/email/default.html similarity index 100% rename from drama/templates/email/default.html rename to files/templates/email/default.html diff --git a/drama/templates/email/email_change.html b/files/templates/email/email_change.html similarity index 100% rename from drama/templates/email/email_change.html rename to files/templates/email/email_change.html diff --git a/drama/templates/email/email_verify.html b/files/templates/email/email_verify.html similarity index 100% rename from drama/templates/email/email_verify.html rename to files/templates/email/email_verify.html diff --git a/drama/templates/email/password_reset.html b/files/templates/email/password_reset.html similarity index 100% rename from drama/templates/email/password_reset.html rename to files/templates/email/password_reset.html diff --git a/files/templates/embeds/comment.html b/files/templates/embeds/comment.html new file mode 100644 index 000000000..b8391e399 --- /dev/null +++ b/files/templates/embeds/comment.html @@ -0,0 +1,122 @@ +{% extends "embeds/embed_default.html" %} + +{% set score=c.score_fuzzed %} + +{% block title %} +@{{ c.author.username }} comments on "{{ c.post.title }}" + +{% endblock %} + + +{% block content %} + + +
    + + + + + +
    + +
    + + + +
    + {{ c.body_html | safe }} +
    + + +
    +
      + + + +
    • +
    • + + +
    • + {{ score }}
    • + +
    • Copy link +
    • +
    • + +
    • +
    • + +
    • + +
    • +
    • +
    • +{{ score }} +
    • + +
    • +
    • +
    + +
    +
    + + + + + +
    +{% endblock %} \ No newline at end of file diff --git a/files/templates/embeds/embed_default.html b/files/templates/embeds/embed_default.html new file mode 100644 index 000000000..06d574e64 --- /dev/null +++ b/files/templates/embeds/embed_default.html @@ -0,0 +1,111 @@ + + + + + + + + + + {% block title %} + {% endblock %} + + + + + + {% block stylesheets %} + + {% if v %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} + {% else %} + + {% endif %} + + {% endblock %} + + + + + + + + + + + +
    +
    + +
    + + + {% block content %} + {% endblock %} + + +
    + + + + + + + + +{% include "bootstrap.html" %} + + + + + + + + + + + +{% block enlargeThumbJS %} +{% endblock %} + +{% block toggleView %} +{% endblock %} + +{% block embedJS %} +{% endblock %} + +{% block formatJS %} +{% endblock %} + + + + + + + \ No newline at end of file diff --git a/drama/templates/site_embeds/instagram.html b/files/templates/embeds/instagram.html similarity index 100% rename from drama/templates/site_embeds/instagram.html rename to files/templates/embeds/instagram.html diff --git a/files/templates/embeds/post.html b/files/templates/embeds/post.html new file mode 100644 index 000000000..20edfe130 --- /dev/null +++ b/files/templates/embeds/post.html @@ -0,0 +1,21 @@ +{% extends "embeds/embed_default.html" %} + +{% block title %} +{{ p.title | safe}} + +{% endblock %} + +{% block pagetype %}thread{% endblock %} + + +{% block content %} +
    +
    +
    + {% with listing = [p] %} + {% include "submission_listing.html" %} + {% endwith %} +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/drama/templates/site_embeds/twitter.html b/files/templates/embeds/twitter.html similarity index 100% rename from drama/templates/site_embeds/twitter.html rename to files/templates/embeds/twitter.html diff --git a/drama/templates/site_embeds/twitterlight.html b/files/templates/embeds/twitterlight.html similarity index 100% rename from drama/templates/site_embeds/twitterlight.html rename to files/templates/embeds/twitterlight.html diff --git a/drama/templates/site_embeds/youtube.html b/files/templates/embeds/youtube.html similarity index 100% rename from drama/templates/site_embeds/youtube.html rename to files/templates/embeds/youtube.html diff --git a/drama/templates/emoji_modal.html b/files/templates/emoji_modal.html similarity index 100% rename from drama/templates/emoji_modal.html rename to files/templates/emoji_modal.html diff --git a/drama/templates/errors/400.html b/files/templates/errors/400.html similarity index 100% rename from drama/templates/errors/400.html rename to files/templates/errors/400.html diff --git a/drama/templates/errors/401.html b/files/templates/errors/401.html similarity index 100% rename from drama/templates/errors/401.html rename to files/templates/errors/401.html diff --git a/drama/templates/errors/403.html b/files/templates/errors/403.html similarity index 100% rename from drama/templates/errors/403.html rename to files/templates/errors/403.html diff --git a/drama/templates/errors/404.html b/files/templates/errors/404.html similarity index 100% rename from drama/templates/errors/404.html rename to files/templates/errors/404.html diff --git a/drama/templates/errors/405.html b/files/templates/errors/405.html similarity index 100% rename from drama/templates/errors/405.html rename to files/templates/errors/405.html diff --git a/drama/templates/errors/409.html b/files/templates/errors/409.html similarity index 100% rename from drama/templates/errors/409.html rename to files/templates/errors/409.html diff --git a/drama/templates/errors/410.html b/files/templates/errors/410.html similarity index 100% rename from drama/templates/errors/410.html rename to files/templates/errors/410.html diff --git a/drama/templates/errors/413.html b/files/templates/errors/413.html similarity index 100% rename from drama/templates/errors/413.html rename to files/templates/errors/413.html diff --git a/drama/templates/errors/418.html b/files/templates/errors/418.html similarity index 100% rename from drama/templates/errors/418.html rename to files/templates/errors/418.html diff --git a/drama/templates/errors/422.html b/files/templates/errors/422.html similarity index 100% rename from drama/templates/errors/422.html rename to files/templates/errors/422.html diff --git a/drama/templates/errors/429.html b/files/templates/errors/429.html similarity index 100% rename from drama/templates/errors/429.html rename to files/templates/errors/429.html diff --git a/drama/templates/errors/451.html b/files/templates/errors/451.html similarity index 100% rename from drama/templates/errors/451.html rename to files/templates/errors/451.html diff --git a/drama/templates/errors/500.html b/files/templates/errors/500.html similarity index 100% rename from drama/templates/errors/500.html rename to files/templates/errors/500.html diff --git a/drama/templates/errors/502.html b/files/templates/errors/502.html similarity index 98% rename from drama/templates/errors/502.html rename to files/templates/errors/502.html index 342736568..ccbde8f27 100644 --- a/drama/templates/errors/502.html +++ b/files/templates/errors/502.html @@ -37,7 +37,7 @@
diff --git a/drama/templates/errors/banaward.html b/files/templates/errors/banaward.html similarity index 100% rename from drama/templates/errors/banaward.html rename to files/templates/errors/banaward.html diff --git a/drama/templates/errors/default.html b/files/templates/errors/default.html similarity index 100% rename from drama/templates/errors/default.html rename to files/templates/errors/default.html diff --git a/drama/templates/errors/nsfw.html b/files/templates/errors/nsfw.html similarity index 100% rename from drama/templates/errors/nsfw.html rename to files/templates/errors/nsfw.html diff --git a/drama/templates/errors/patron.html b/files/templates/errors/patron.html similarity index 100% rename from drama/templates/errors/patron.html rename to files/templates/errors/patron.html diff --git a/drama/templates/expanded_image_modal.html b/files/templates/expanded_image_modal.html similarity index 100% rename from drama/templates/expanded_image_modal.html rename to files/templates/expanded_image_modal.html diff --git a/drama/templates/flag_comment_modal.html b/files/templates/flag_comment_modal.html similarity index 100% rename from drama/templates/flag_comment_modal.html rename to files/templates/flag_comment_modal.html diff --git a/drama/templates/flag_post_modal.html b/files/templates/flag_post_modal.html similarity index 100% rename from drama/templates/flag_post_modal.html rename to files/templates/flag_post_modal.html diff --git a/drama/templates/followers.html b/files/templates/followers.html similarity index 100% rename from drama/templates/followers.html rename to files/templates/followers.html diff --git a/drama/templates/forgot_password.html b/files/templates/forgot_password.html similarity index 100% rename from drama/templates/forgot_password.html rename to files/templates/forgot_password.html diff --git a/drama/templates/formatting.html b/files/templates/formatting.html similarity index 100% rename from drama/templates/formatting.html rename to files/templates/formatting.html diff --git a/drama/templates/gif_modal.html b/files/templates/gif_modal.html similarity index 100% rename from drama/templates/gif_modal.html rename to files/templates/gif_modal.html diff --git a/drama/templates/header.html b/files/templates/header.html similarity index 93% rename from drama/templates/header.html rename to files/templates/header.html index 54c34b9a7..47c5dc4e1 100644 --- a/drama/templates/header.html +++ b/files/templates/header.html @@ -2,7 +2,7 @@
diff --git a/drama/templates/settings_profilecss.html b/files/templates/settings_profilecss.html similarity index 100% rename from drama/templates/settings_profilecss.html rename to files/templates/settings_profilecss.html diff --git a/drama/templates/settings_security.html b/files/templates/settings_security.html similarity index 100% rename from drama/templates/settings_security.html rename to files/templates/settings_security.html diff --git a/drama/templates/sign_up.html b/files/templates/sign_up.html similarity index 96% rename from drama/templates/sign_up.html rename to files/templates/sign_up.html index 21a67faf8..d40c8c306 100644 --- a/drama/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -33,11 +33,11 @@ var id = document.getElementById("usernameHelpRegister"); var successID = document.getElementById("usernameHelpSuccess"); - var dramaAPI = '/is_available/' + charCount; + var API = '/is_available/' + charCount; if (charCount.length >= 3) { - $.getJSON(dramaAPI, function(result) { + $.getJSON(API, function(result) { $.each(result, function(i, field) { if (field == false) { id.innerHTML = 'Username already taken :('; @@ -74,13 +74,13 @@ - + - + - + diff --git a/drama/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html similarity index 94% rename from drama/templates/sign_up_failed_ref.html rename to files/templates/sign_up_failed_ref.html index 088cbc54f..30ed96098 100644 --- a/drama/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -14,18 +14,18 @@ - + - + - + - {% if ref_user %}{{ref_user.username}} invites you to {{"SITE_NAME" | app_config}}{% else %}{{"SITE_NAME" | app_config}}: the open, free-speech social platform{% endif %} + {% if ref_user %}{{ref_user.username}} invites you to {{"SITE_NAME" | app_config}}{% else %}{{"SITE_NAME" | app_config}}{% endif %} @@ -69,7 +69,7 @@
diff --git a/drama/templates/submission.html b/files/templates/submission.html similarity index 99% rename from drama/templates/submission.html rename to files/templates/submission.html index d2722539a..a53406c59 100644 --- a/drama/templates/submission.html +++ b/files/templates/submission.html @@ -40,7 +40,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -267,13 +267,13 @@ {{p.realbody(v) | safe}} {% if p.domain == "twitter.com" and (v and v.theme.split("_")[0] in ["light", "coffee", "4chan"]) %} - {% include "site_embeds/twitterlight.html" %} + {% include "embeds/twitterlight.html" %} {% elif "twitter.com" in p.domain %} - {% include "site_embeds/twitter.html" %} + {% include "embeds/twitter.html" %} {% elif "youtu" in p.domain %} - {% include "site_embeds/youtube.html" %} + {% include "embeds/youtube.html" %} {% elif "instagram.com" in p.domain %} - {% include "site_embeds/instagram.html" %} + {% include "embeds/instagram.html" %} {% endif %}
@@ -566,7 +566,7 @@
Jump in the discussion.
-

Become a dramatard, no email address required.

+

No email address required.

Sign up Sign in diff --git a/drama/templates/submission_banned.html b/files/templates/submission_banned.html similarity index 100% rename from drama/templates/submission_banned.html rename to files/templates/submission_banned.html diff --git a/drama/templates/submission_listing.html b/files/templates/submission_listing.html similarity index 100% rename from drama/templates/submission_listing.html rename to files/templates/submission_listing.html diff --git a/drama/templates/submit.html b/files/templates/submit.html similarity index 100% rename from drama/templates/submit.html rename to files/templates/submit.html diff --git a/drama/templates/user_listing.html b/files/templates/user_listing.html similarity index 100% rename from drama/templates/user_listing.html rename to files/templates/user_listing.html diff --git a/drama/templates/userpage.html b/files/templates/userpage.html similarity index 94% rename from drama/templates/userpage.html rename to files/templates/userpage.html index 0bd3b77d5..e1fd4fdf2 100644 --- a/drama/templates/userpage.html +++ b/files/templates/userpage.html @@ -25,7 +25,7 @@ -=1 and not u.is_private and not u.is_nofollow %}{{u.stored_subscriber_count}} Followers - {% endif %}{% if not u.is_private %}{{u.post_count}} Posts - {{u.comment_count}} Comments - {% endif %}{{u.bio}}" /> +=1 and not u.is_private and not u.is_nofollow %}{{u.stored_subscriber_count}} Followers - {% endif %}{% if not u.is_private %}{{u.post_count}} Posts - {{u.comment_count}} Comments - {% endif %}{{u.bio}}" /> @@ -33,10 +33,10 @@ - + -=1 and not u.is_private and not u.is_nofollow %}{{u.stored_subscriber_count}} Followers -{% endif %} {% if not u.is_private %} {{u.post_count}} Posts - {{u.comment_count}} Comments -{% endif %} {{u.bio}}" /> +=1 and not u.is_private and not u.is_nofollow %}{{u.stored_subscriber_count}} Followers -{% endif %} {% if not u.is_private %} {{u.post_count}} Posts - {{u.comment_count}} Comments -{% endif %} {{u.bio}}" /> {% endblock %} @@ -119,7 +119,7 @@ {% if u.customtitle %}

{{u.customtitle | safe}}

{% endif %}
- {{u.dramacoins}} {{"SITE_NAME" | app_config}}coins   {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %}joined {{u.created_date}} + {{u.coins}} {{"SITE_NAME" | app_config}}coins   {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %}joined {{u.created_date}}
{% if u.bio_html %}

@@ -306,7 +306,7 @@
 				{% endif %}
 				{% if u.customtitle %}

{{u.customtitle | safe}}

{% endif %}
- {{u.dramacoins}} {{"SITE_NAME" | app_config}}coins  {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %}
joined {{u.created_date}} + {{u.coins}} {{"SITE_NAME" | app_config}}coins  {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %}
joined {{u.created_date}}
{% if u.bio_html %}

{{u.bio_html | safe}}

@@ -360,7 +360,7 @@    
- +
    diff --git a/drama/templates/userpage_blocked.html b/files/templates/userpage_blocked.html similarity index 100% rename from drama/templates/userpage_blocked.html rename to files/templates/userpage_blocked.html diff --git a/drama/templates/userpage_blocking.html b/files/templates/userpage_blocking.html similarity index 100% rename from drama/templates/userpage_blocking.html rename to files/templates/userpage_blocking.html diff --git a/drama/templates/userpage_comments.html b/files/templates/userpage_comments.html similarity index 100% rename from drama/templates/userpage_comments.html rename to files/templates/userpage_comments.html diff --git a/drama/templates/userpage_private.html b/files/templates/userpage_private.html similarity index 86% rename from drama/templates/userpage_private.html rename to files/templates/userpage_private.html index 49992e0ee..6988b9252 100644 --- a/drama/templates/userpage_private.html +++ b/files/templates/userpage_private.html @@ -11,7 +11,7 @@

This account is private

This user has enabled private mode to cloak their posting history.

- +
diff --git a/drama/templates/userpage_reserved.html b/files/templates/userpage_reserved.html similarity index 100% rename from drama/templates/userpage_reserved.html rename to files/templates/userpage_reserved.html diff --git a/drama/templates/viewers.html b/files/templates/viewers.html similarity index 100% rename from drama/templates/viewers.html rename to files/templates/viewers.html diff --git a/drama/templates/votes.html b/files/templates/votes.html similarity index 97% rename from drama/templates/votes.html rename to files/templates/votes.html index 1c070e5e7..0ee395703 100644 --- a/drama/templates/votes.html +++ b/files/templates/votes.html @@ -19,7 +19,7 @@

Info

{{thing.permalink}}

Author: @{{thing.author.username}}

-

Author Created At: {{thing.author.created_utc}} ({{thing.author.created_datetime}} UTC)

+

Author Created At: {{thing.author.created_utc}} ({{thing.author.created_datetime}})

Upvotes:{{ups | length}}

Downvotes:{{downs | length}}

diff --git a/image.png b/image.png deleted file mode 100644 index 1b9837ed0..000000000 Binary files a/image.png and /dev/null differ diff --git a/push.sh b/push.sh index b2b89d1bd..25c9cfdf0 100644 --- a/push.sh +++ b/push.sh @@ -4,12 +4,12 @@ git commit -m "sneed" git push apt install ruby-sass -sass ./drama/assets/style/midnight.scss ./drama/assets/style/midnight_ff66ac.css -sass ./drama/assets/style/dark.scss ./drama/assets/style/dark_ff66ac.css -sass ./drama/assets/style/light.scss ./drama/assets/style/light_ff66ac.css -sass ./drama/assets/style/coffee.scss ./drama/assets/style/coffee_ff66ac.css -sass ./drama/assets/style/tron.scss ./drama/assets/style/tron_ff66ac.css -sass ./drama/assets/style/4chan.scss ./drama/assets/style/4chan_ff66ac.css +sass ./files/assets/style/midnight.scss ./files/assets/style/midnight_ff66ac.css +sass ./files/assets/style/dark.scss ./files/assets/style/dark_ff66ac.css +sass ./files/assets/style/light.scss ./files/assets/style/light_ff66ac.css +sass ./files/assets/style/coffee.scss ./files/assets/style/coffee_ff66ac.css +sass ./files/assets/style/tron.scss ./files/assets/style/tron_ff66ac.css +sass ./files/assets/style/4chan.scss ./files/assets/style/4chan_ff66ac.css python ./compilecss.py python3 ./compilecss.py git add . diff --git a/schema.sql b/schema.sql index 48bcc63e0..0c6a92dab 100644 --- a/schema.sql +++ b/schema.sql @@ -168,7 +168,7 @@ CREATE TABLE public.users ( oldreddit boolean, css text, profilecss text, - dramacoins integer, + coins integer, agendaposter boolean, agendaposter_expires_utc integer DEFAULT 0, resized boolean, diff --git a/supervisord.conf b/supervisord.conf index e64eb1211..755158107 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -3,9 +3,9 @@ nodaemon=true pidfile=/tmp/supervisord.pid logfile=/tmp/supervisord.log -[program:dramaservice] -directory=/drama/service -command=gunicorn drama.__main__:app -k gevent -w 5 --max-requests 10000 --max-requests-jitter 500 --reload --bind 0.0.0.0:80 +[program:service] +directory=/service +command=gunicorn files.__main__:app -k gevent -w 5 --max-requests 10000 --max-requests-jitter 500 --reload --bind 0.0.0.0:80 stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr