diff --git a/Drama rules.html b/Drama rules.html deleted file mode 100644 index c45e601cca..0000000000 --- a/Drama rules.html +++ /dev/null @@ -1,25 +0,0 @@ -The providers ("we", "us", "our") of the service provided by this web site ("rDrama.net") are not responsible for any user-generated content and accounts. Content submitted express the views of their author only.

- -You agree to not use rDrama.net to submit or link to any content which violates any laws. You are entirely responsible for the content of, and any harm resulting from, that content or your conduct.

- -You must be at least 18 years of age to use this site.

- -

Content Policy:

- -This website follows all of Cloudflare's Terms of Service policies for content regulation.

- -Things you cannot do ever on this website under any circumstances:

- -All content posted to this website is subject to protection under Section 230. All media posted to this website is done so in a transformative nature for the purpose of critique/ridicule. - -

General Moderation:

- -We reserve the right to remove anything and everything you post here at any time for any reason. Nazi shit is not tolerated here.

- -
If you do not agree with these terms, please do not register or use rDrama.net. Use of rDrama.net constitutes acceptance of these terms.
\ No newline at end of file diff --git a/files/classes/mod.py b/files/classes/mod.py new file mode 100644 index 0000000000..1d5aafcdd8 --- /dev/null +++ b/files/classes/mod.py @@ -0,0 +1,12 @@ +from sqlalchemy import * +from sqlalchemy.orm import relationship +from files.__main__ import Base + +class Mod(Base): + + __tablename__ = "mods" + user_id = Column(Integer, ForeignKey("users.id"), primary_key=True) + sub = Column(String, ForeignKey("subs.name"), primary_key=True) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/files/classes/sub.py b/files/classes/sub.py new file mode 100644 index 0000000000..aef5b82179 --- /dev/null +++ b/files/classes/sub.py @@ -0,0 +1,13 @@ +from sqlalchemy import * +from sqlalchemy.orm import relationship +from files.__main__ import Base + +class Sub(Base): + + __tablename__ = "subs" + name = Column(String, primary_key=True) + sidebar = Column(String) + sidebar_html = Column(String) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/files/classes/submission.py b/files/classes/submission.py index dcd10be6d4..1c6797b45b 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -12,6 +12,7 @@ from files.helpers.lazy import lazy from .flags import Flag from .comment import Comment from flask import g +from .sub import * class Submission(Base): __tablename__ = "submissions" @@ -56,6 +57,7 @@ class Submission(Base): awards = relationship("AwardRelationship", viewonly=True) reports = relationship("Flag", viewonly=True) comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id") + subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)", viewonly=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/files/classes/user.py b/files/classes/user.py index a8daff557c..4ba16ff483 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -13,6 +13,7 @@ from .userblock import * from .badges import * from .clients import * from .mod_logs import * +from .mod import * from files.__main__ import Base, cache from files.helpers.security import * import random @@ -149,6 +150,10 @@ class User(Base): super().__init__(**kwargs) + @lazy + def mods(self, sub): + return g.db.query(Mod.user_id).filter_by(user_id=self.id, sub=sub).one_or_none() + @property @lazy def csslazy(self): diff --git a/files/helpers/const.py b/files/helpers/const.py index 46ac335aae..c2f8e0ee88 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -2,6 +2,8 @@ from os import environ, listdir import re from copy import deepcopy from json import loads +from files.__main__ import db_session +from files.classes.sub import Sub SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() @@ -566,5 +568,6 @@ FORTUNE_REPLIES = ('Your fortune: Allah Wills It',' no_pass_phrase = """

Sorry whiteboy, we're gonna need to see some ID before you start throwin that word around like it's nothing.\n\nTake a 10 minute time-out and come back when you've learned your lesson and/or paid reparations (by purchasing a BIPOC Approved™ Rdrama NWord Pass© from the shop) \n\nThis is an automated message; if you need help, you can message us here.

""" -if True: subs = ('2balkan4you','2middleeast4you','2asia4you','2visegrad4you') -else: subs = () \ No newline at end of file +db = db_session() +SUBS = [x[0] for x in db.query(Sub.name).all()] +db.close() \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 140c71f0af..e409ac5a69 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -16,4 +16,4 @@ def post_embed(id, v): @app.context_processor def inject_constants(): - return {"environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "subs":subs} + return {"environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "SUBS": SUBS} diff --git a/files/routes/admin.py b/files/routes/admin.py index 65c5b75c55..363dcd8db4 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -343,6 +343,43 @@ def post_sidebar(v): return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!') +@app.get('/s//sidebar') +@auth_required +def get_sub_sidebar(v, sub): + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() + if not sub: abort(404) + + mod = g.db.query(Mod).filter_by(user_id=v.id, sub=sub.name).one_or_none() + if not mod: abort(403) + + return render_template('admin/sidebar.html', v=v, sidebar=sub.sidebar, sub=sub) + + +@app.post('/s//sidebar') +@limiter.limit("1/second;30/minute;200/hour;1000/day") +@auth_required +def post_sub_sidebar(v, sub): + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() + if not sub: abort(404) + + mod = g.db.query(Mod).filter_by(user_id=v.id, sub=sub.name).one_or_none() + if not mod: abort(403) + + sub.sidebar = request.values.get('sidebar', '').strip() + sub.sidebar_html = sanitize(sub.sidebar) + g.db.add(sub) + + ma = ModAction( + kind="change_sidebar", + user_id=v.id + ) + g.db.add(ma) + + g.db.commit() + + return render_template('admin/sidebar.html', v=v, sidebar=sub.sidebar, msg='Sidebar edited successfully!', sub=sub) + + @app.get("/admin/shadowbanned") @auth_required def shadowbanned(v): diff --git a/files/routes/comments.py b/files/routes/comments.py index c92edd62f8..bfbc83bf92 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -131,7 +131,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): else: if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" - return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.sub) + return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.subr) @app.post("/comment") @limiter.limit("1/second;20/minute;200/hour;1000/day") diff --git a/files/routes/front.py b/files/routes/front.py index f11447f155..a642a0d5c9 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -133,7 +133,8 @@ def notifications(v): @limiter.limit("3/second;30/minute;400/hour;2000/day") @auth_desired def front_all(v, sub=None): - if sub and sub not in subs: sub = None + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() + if g.webview and not session.get("session_id"): session.permanent = True session["session_id"] = secrets.token_hex(49) @@ -256,7 +257,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" posts = g.db.query(Submission) - if sub: posts = posts.filter_by(sub=sub) + if sub: posts = posts.filter_by(sub=sub.name) if t == 'all': cutoff = 0 else: @@ -326,7 +327,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false": pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) - if sub: pins = pins.filter_by(sub=sub) + if sub: pins = pins.filter_by(sub=sub.name) if v and v.admin_level == 0: blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()] blocked = [x[0] for x in g.db.query(UserBlock.user_id).filter_by(target_id=v.id).all()] diff --git a/files/routes/posts.py b/files/routes/posts.py index fac90656f1..aa32b46c33 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -91,7 +91,10 @@ def publish(pid, v): @app.get("/s//submit") @auth_required def submit_get(v, sub=None): - if sub and sub not in subs: sub = None + sub = g.db.query(Sub.name).filter_by(name=sub).one_or_none() + if sub: sub = sub[0] + else: sub = None + return render_template("submit.html", v=v, sub=sub) @app.get("/post/") @@ -248,7 +251,7 @@ def post_id(pid, anything=None, v=None, sub=None): else: if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html" else: template = "submission.html" - return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset, sub=post.sub) + return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset, sub=post.subr) @app.post("/viewmore///") @limiter.limit("1/second;30/minute;200/hour;1000/day") @@ -761,7 +764,7 @@ def thumbnail_thread(pid): @auth_required def submit_post(v, sub=None): if not sub: sub = request.values.get("sub") - if sub and sub not in subs: sub = None + sub = g.db.query(Sub).filter_by(name=sub).one_or_none() if v.is_suspended: return {"error": "You can't perform this action while banned."}, 403 @@ -1016,7 +1019,7 @@ def submit_post(v, sub=None): title=title[:500], title_html=title_html, created_utc=int(time.time()), - sub=sub + sub=sub.name ) g.db.add(new_post) @@ -1245,7 +1248,7 @@ def submit_post(v, sub=None): if 'megathread' in new_post.title.lower(): sort = 'new' else: sort = v.defaultsortingcomments if len(body_html) < 40000: new_post.replies = [c] - return render_template('submission.html', v=v, p=new_post, sort=sort, render_replies=True, offset=0, success=True, sub=new_post.sub) + return render_template('submission.html', v=v, p=new_post, sort=sort, render_replies=True, offset=0, success=True, sub=new_post.subr) @app.post("/delete_post/") diff --git a/files/templates/admin/sidebar.html b/files/templates/admin/sidebar.html index 1a0d66569e..27650b6046 100644 --- a/files/templates/admin/sidebar.html +++ b/files/templates/admin/sidebar.html @@ -20,14 +20,14 @@
-

Edit sidebar

+

Edit {% if sub %}/s/{{sub.name}}{% endif %} sidebar


-
+ - +
diff --git a/files/templates/comment_failed.html b/files/templates/comment_failed.html deleted file mode 100644 index 955cb60afc..0000000000 --- a/files/templates/comment_failed.html +++ /dev/null @@ -1,44 +0,0 @@ -{% extends "default.html" %} - -{% block title %} -Unable to post comment -{% endblock %} - -{% block pagetype %}message{% endblock %} - -{% block content %} -
- -

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

- -
    - {% for s in badlinks %} -
  • {{s}}
  • - {% endfor %} -
- -
- -
- -
-{% endblock %} diff --git a/files/templates/default.html b/files/templates/default.html index 63907c73e9..03b6a22b4e 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -272,7 +272,7 @@ {% endblock %}
- {% if request.path in ('/', '/logged_out', '/logged_out/') %} + {% if request.path in ('/', '/logged_out', '/logged_out/') or SITE_NAME == '2Much4You' %} {% block sidebar %} {% include "sidebar_" + SITE_NAME + ".html" %} {% endblock %} diff --git a/files/templates/header.html b/files/templates/header.html index 473d968fd7..e94d634fd8 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -12,8 +12,8 @@ body {padding-top: 90px !important}
- {% for s in subs %} - /s/{{s}} + {% for s in SUBS %} + /s/{{s}} {% endfor %}
{% else %} @@ -34,7 +34,7 @@ {% if SITE_NAME == 'Drama' %} logo {% elif sub %} - {{sub}} + /s/{{sub.name}} {% else %} {{SITE_NAME}} {% endif %} @@ -56,7 +56,7 @@ {% endif %} {% if v %} - + {% else %} {% endif %} @@ -98,7 +98,7 @@ {% endif %}
{% if v %} - + diff --git a/files/templates/sidebar_2Much4You.html b/files/templates/sidebar_2Much4You.html index e69de29bb2..542a4b10b5 100644 --- a/files/templates/sidebar_2Much4You.html +++ b/files/templates/sidebar_2Much4You.html @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 99f9bd83ae..8770eaaaa1 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -553,7 +553,7 @@

You haven't {% if "saved" in request.full_path %}saved{% else %}made{% endif %} a post yet

Your {% if "saved" in request.full_path %}saved posts{% else %}posting history{% endif %} will show here.

- {% if "saved" not in request.full_path %}Create a post{% endif %} + {% if "saved" not in request.full_path %}Create a post{% endif %}
diff --git a/files/templates/submit.html b/files/templates/submit.html index a0c04e2c32..6c4a35e301 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -84,11 +84,11 @@