remotes/1693045480750635534/spooky-22
Aevann1 2022-02-05 23:09:17 +02:00
parent c2748736fe
commit 1eeebf9400
19 changed files with 130 additions and 95 deletions

View File

@ -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.<br><br>
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.<br><br>
You must be at least 18 years of age to use this site.<br><br>
<h3>Content Policy:</h3>
This website follows all of <a href="https://cloudflare.com/website-terms/">Cloudflare's Terms of Service</a> policies for content regulation.<br><br>
Things you cannot do ever on this website under any circumstances:<br><br><ul>
<li>Cheese pizza</li>
<li>Threats of violence</li>
<li>Human trafficking</li>
<li>Spam</li>
<li>Doxxing Site Users</li></ul>
All content posted to this website is subject to protection under <a href="https://law.cornell.edu/uscode/text/47/230">Section 230</a>. All media posted to this website is done so in a transformative nature for the purpose of critique/ridicule.
<h3>General Moderation:</h3>
We reserve the right to remove anything and everything you post here at any time for any reason. Nazi shit is not tolerated here.<br><br>
<h5>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.</h5>

View File

@ -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"<Mod(user_id={self.user_id}, sub={self.sub})>"

View File

@ -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"<Sub(name={self.name})>"

View File

@ -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)

View File

@ -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):

View File

@ -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 = ('<b style="color:#6023f8">Your fortune: Allah Wills It</b>','
no_pass_phrase = """<p>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 <a href="/shop">shop</a>) \n\n<em>This is an automated message; if you need help, you can message us <a href="/contact">here</a>.</em></p>"""
if True: subs = ('2balkan4you','2middleeast4you','2asia4you','2visegrad4you')
else: subs = ()
db = db_session()
SUBS = [x[0] for x in db.query(Sub.name).all()]
db.close()

View File

@ -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}

View File

@ -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/<sub>/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/<sub>/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):

View File

@ -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")

View File

@ -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()]

View File

@ -91,7 +91,10 @@ def publish(pid, v):
@app.get("/s/<sub>/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/<pid>")
@ -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/<pid>/<sort>/<offset>")
@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/<pid>")

View File

@ -20,14 +20,14 @@
<div class="col col-md-8">
<div class="settings">
<div id="description">
<h2>Edit sidebar</h2>
<h2>Edit {% if sub %}/s/{{sub.name}}{% endif %} sidebar</h2>
<br>
</div>
<div class="body d-lg-flex">
<div class="w-lg-100">
<form id="profile-settings" action="/admin/sidebar" method="post">
<form id="profile-settings" action="{% if sub %}/s/{{sub.name}}{% else %}/admin{% endif %}/sidebar" method="post">
<input autocomplete="off" type="hidden" name="formkey" value="{{v.formkey}}">
<textarea autocomplete="off" maxlength="10000" class="form-control rounded" id="bio-text" aria-label="With textarea" placeholder="Site sidebar" rows="50" name="sidebar" form="profile-settings">{% if sidebar %}{{sidebar}}{% endif %}</textarea>
<textarea autocomplete="off" maxlength="10000" class="form-control rounded" id="bio-text" aria-label="With textarea" placeholder="Enter sidebar here..." rows="50" name="sidebar" form="profile-settings">{% if sidebar %}{{sidebar}}{% endif %}</textarea>
<div class="d-flex mt-2">
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" value="Save">

View File

@ -1,44 +0,0 @@
{% extends "default.html" %}
{% block title %}
<title>Unable to post comment</title>
{% endblock %}
{% block pagetype %}message{% endblock %}
{% block content %}
<div class="">
<p>Please remove the following link(s) from your comment, and then you will be able to post it:</p>
<ul>
{% for s in badlinks %}
<li>{{s}}</li>
{% endfor %}
</ul>
<div>
<div class="comment-write collapsed child p-4">
<form id="reply" action="{{action}}" method="post" class="input-group">
<input autocomplete="off" type="hidden" name="formkey" value="{{v.formkey}}">
{% if parent_fullname %}<input autocomplete="off" type="hidden" name="parent_fullname" value="{{parent_fullname}}">{% endif %}
{% if parent_submission %}<input autocomplete="off" type="hidden" name="submission" value="{{parent_submission}}">{% endif %}
<textarea autocomplete="off" name="body" form="reply" class="comment-box form-control rounded" id="reply-form" aria-label="With textarea" placeholder="Add your comment..." {% if v.longpost %}minlength="280"{% endif %} maxlength="{% if v.bird %}140{% else %}10000{% endif %}" rows="10">{{body}}</textarea>
<div class="comment-format">
<small class="format pl-0"><i class="fas fa-bold" aria-hidden="true" onclick="makeReplyBold()" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Bold"></i></small>
<a class="format" role="button"><i class="fas fa-italic" aria-hidden="true" onclick="makeReplyItalics()" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Italicize"></i></a>
<a class="format" role="button"><i class="fas fa-quote-right" aria-hidden="true" onclick="makeReplyQuote()" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Quote"></i></a>
<a class="format" role="button"><i class="fas fa-link" aria-hidden="true"></i></small>
</div>
<button form="reply" class="btn btn-primary ml-auto fl-r">Comment</a>
</form>
</div>
</div>
</div>
{% endblock %}

View File

@ -272,7 +272,7 @@
{% endblock %}
</div>
{% 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 %}

View File

@ -12,8 +12,8 @@
body {padding-top: 90px !important}
</style>
<div id="srd" style="width: 100%; background-color: var(--primary); padding: 2px; text-align: left; font-weight: bold;white-space:nowrap">
{% for s in subs %}
<a style="color: white" class="text-small-mobile ml-2" href="/s/{{s}}">/s/{{s}}</a>
{% for s in SUBS %}
<a {% if sub and s == sub.name %} style="color: var(--secondary)" {% else %} style="color: white"{% endif %} class="text-small-mobile ml-2 px-2" href="/s/{{s}}">/s/{{s}}</a>
{% endfor %}
</div>
{% else %}
@ -34,7 +34,7 @@
{% if SITE_NAME == 'Drama' %}
<img alt="logo" src="/static/assets/images/{{SITE_NAME}}/logo.webp?a=1010" height=20 width=77>
{% elif sub %}
<a href="/s/{{sub}}" class="font-weight-bold ml-4 mt-2" style="font-size:25px;position:absolute">{{sub}}</a>
<a href="/s/{{sub.name}}" class="font-weight-bold ml-4 mt-2" style="font-size:25px;position:absolute">/s/{{sub.name}}</a>
{% else %}
<a href="/" class="font-weight-bold ml-4 mt-2" style="font-size:25px;position:absolute">{{SITE_NAME}}</a>
{% endif %}
@ -56,7 +56,7 @@
<a class="mobile-nav-icon d-md-none" href="/admin"><i class="fas fa-crown align-middle text-gray-500 black"></i></a>
{% endif %}
{% if v %}
<a class="mobile-nav-icon d-md-none" href="{% if sub %}/s/{{sub}}{% endif %}/submit"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
<a class="mobile-nav-icon d-md-none" href="{% if sub %}/s/{{sub.name}}{% endif %}/submit"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
{% else %}
<a class="mobile-nav-icon d-md-none" href="/login"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
{% endif %}
@ -98,7 +98,7 @@
{% endif %}
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
<a class="nav-link" href="{% if sub %}/s/{{sub}}{% endif %}/submit" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Create post"><i class="fas fa-feather-alt"></i></a>
<a class="nav-link" href="{% if sub %}/s/{{sub.name}}{% endif %}/submit" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Create post"><i class="fas fa-feather-alt"></i></a>
</li>
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">

View File

@ -114,7 +114,7 @@
</div>
<div class="card-body">
{% if v %}
<a href="{% if sub %}/s/{{sub}}{% endif %}/submit">
<a href="{% if sub %}/s/{{sub.name}}{% endif %}/submit">
<input autocomplete="off" type="text" class="form-control"
aria-label="Username"
aria-describedby="basic-addon1">

View File

@ -0,0 +1,28 @@
<div class="col sidebar text-left d-none d-lg-block pt-3 bg-white" style="max-width:300px">
{% if sub %}
{% set image='/static/assets/images/subs/' + sub.name + '.webp?a=1008' %}
{% else %}
{% set image='/static/assets/images/2Much4You/sidebar.webp?a=1008' %}
{% endif %}
<img role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{image}}')" loading="lazy" src="{{image}}" width=100%>
{% if sub %}
{{sub.sidebar_html|safe}}
<a class="btn btn-primary btn-block mt-4" href="/s/{{sub.name}}/mods">MODS</a>
{% if v and v.mods(sub.name) %}
<a class="btn btn-primary btn-block" href="/s/{{sub.name}}/sidebar">EDIT SIDEBAR</a>
{% endif %}
{% else %}
<p class="mt-4">Rules: No doxxing, No CP or other clearly illegal shit. Thanks.</p>
{% endif %}
<pre>
</pre>
</div>

View File

@ -553,7 +553,7 @@
</span>
<h2 class="h5">You haven't {% if "saved" in request.full_path %}saved{% else %}made{% endif %} a post yet</h2>
<p class="text-muted mb-md-5">Your {% if "saved" in request.full_path %}saved posts{% else %}posting history{% endif %} will show here.</p>
{% if "saved" not in request.full_path %}<a href="{% if sub %}/s/{{sub}}{% endif %}/submit" class="btn btn-primary">Create a post</a>{% endif %}
{% if "saved" not in request.full_path %}<a href="{% if sub %}/s/{{sub.name}}{% endif %}/submit" class="btn btn-primary">Create a post</a>{% endif %}
</div>
</div>
</div>

View File

@ -84,11 +84,11 @@
<div class="input-group mb2">
<select autocomplete="off" id='sub' class="form-control" form="submitform" name="sub">
<option {% if not sub %} selected {% endif %}>
<option {% if not sub %}selected{% endif %}>
general
</option>
{% for s in subs %}
<option value="{{s}}" {% if sub==s %} selected {% endif %}>
{% for s in SUBS %}
<option value="{{s}}" {% if sub == s %}selected{% endif %}>
/s/{{s}}
</option>
{% endfor %}