Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-11 06:05:26 +02:00
commit 1000f9c45e
37 changed files with 565 additions and 59 deletions

View File

@ -530,4 +530,13 @@ a.nav-link:hover {
background-color: #f3f3f3 !important;
border-radius: 0px;
margin-top: 5px;
}
}
/* award modal text legibility */
#awardModalBody .text-muted {
color: var(--black3) !important;
}
#awardModalBody .card .pt-2 {
color: var(--black3) !important;
}

View File

@ -4582,6 +4582,13 @@ div.deleted.banned {
.patron[style="background-color:#FFFFFF;"] {
color: black !important;
}
.post--category-tag {
padding: 2px 5px 3px 5px;
border-radius: 5px;
font-size: 12px;
font-weight: 700;
margin-right: 0.25rem;
}
.container, .container-fluid {
background-color: var(--background) !important;
}
@ -5267,6 +5274,10 @@ li > .sidebar {
width: 13rem;
}
.shop-table-actions a {
display: flex;
}
.userbanner {
object-fit: cover !important;
}
@ -5686,6 +5697,19 @@ g {
border-radius:.35rem;
}
.category--tag-button {
display: inline-block;
cursor: pointer;
}
#submit-categories input {
display: none;
}
#submit-categories input:checked + label {
border: 5px var(--black) double;
}
/* ------- Font Awesome ------- */
@font-face{
font-family:"Font Awesome 6 Pro";
@ -6038,6 +6062,7 @@ g {
.fa-circle-info:before{content:"\f05a"}
.fa-comment-question:before{content:"\e14b"}
.fa-sitemap:before{content:"\f0e8"}
.fa-grid:before{content:"\e195"}
.pronouns {
font-size: 9px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -178,7 +178,9 @@ if (document.readyState === "complete" ||
}
function post_toast(t, url, button1, button2, classname) {
if (t.id != "buy1-go" && t.id != "buy2-go")
let isShopConfirm = t.id.startsWith('buy1-go') || t.id.startsWith('buy2-go');
if (!isShopConfirm)
{
t.disabled = true;
t.classList.add("disabled");
@ -212,7 +214,7 @@ function post_toast(t, url, button1, button2, classname) {
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show();
}
if (t.id != "buy1-go" && t.id != "buy2-go")
if (!isShopConfirm)
{
setTimeout(() => {
t.disabled = false;

View File

@ -0,0 +1,41 @@
function category_modal(id, title, sub) {
document.getElementById("category-modal-title").innerHTML = `Category: ${title}`;
xhrCategories = new XMLHttpRequest();
xhrCategories.open("GET", "/categories.json");
xhrCategories.onload = function () {
let data;
try {
data = JSON.parse(xhrCategories.response);
} catch(e) { console.log(e) }
categories = [{id: '', name: 'None', sub: sub, color_text: '#000', color_bg: '#FFF'}];
categories = [].concat(categories, data[sub]);
document.getElementById("category-modal-body").innerHTML = '';
categories.forEach(function (c) {
document.getElementById("category-modal-body").innerHTML +=
`<div class="category--tag-button" data-category="${c.id}">` +
`<span class="post--category-tag" style="color:${c.color_text}; ` +
`background-color:${c.color_bg};">${c.name}</span>` +
`</div>`;
});
document.querySelectorAll('.category--tag-button').forEach(tag =>
tag.addEventListener('click', function (e) {
reqBody = new FormData();
reqBody.append('formkey', formkey());
reqBody.append('post_id', id);
reqBody.append('category_id', tag.dataset.category);
xhrSubmit = new XMLHttpRequest();
xhrSubmit.open('POST', `/post_recategorize`);
xhrSubmit.onload = function () {
window.location.reload();
}
xhrSubmit.send(reqBody);
})
);
}
xhrCategories.send();
}

View File

@ -169,6 +169,31 @@ function checkRepost() {
}
}
function updateCategories() {
if (document.getElementById("submit-categories") == null) {
return;
}
sub = document.getElementById("sub").value;
xhrCategories = new XMLHttpRequest();
xhrCategories.open("GET", "/categories.json");
xhrCategories.onload = function () {
let data;
try {
data = JSON.parse(xhrCategories.response);
} catch(e) { console.log(e) }
document.getElementById("submit-categories").innerHTML = '';
data[sub].forEach(function (c) {
document.getElementById("submit-categories").innerHTML +=
`<input type="radio" id="category-${c.id}" name="category" value="${c.id}">` +
`<label for="category-${c.id}" class="post--category-tag" ` +
`style="color:${c.color_text}; background-color:${c.color_bg};">` +
`${c.name}</label>`;
});
}
xhrCategories.send();
}
document.addEventListener('keydown', (e) => {
if(!((e.ctrlKey || e.metaKey) && e.key === "Enter"))
@ -179,4 +204,5 @@ document.addEventListener('keydown', (e) => {
submitButton.click();
});
checkRepost()
checkRepost();
updateCategories();

View File

@ -8,6 +8,7 @@ from .user import *
from .userblock import *
from .submission import *
from .votes import *
from .category import *
from .domains import *
from .subscriptions import *
from files.__main__ import app
@ -20,4 +21,4 @@ from .saves import *
from .views import *
from .notifications import *
from .follows import *
from .lottery import *
from .lottery import *

View File

@ -0,0 +1,22 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
class Category(Base):
__tablename__ = "category"
id = Column(Integer, primary_key=True, nullable=False)
name = Column(String(128), nullable=False)
sub = Column(String(20), ForeignKey("subs.name"))
color_text = Column(String(6))
color_bg = Column(String(6))
def as_json(self):
data = {
'id': self.id,
'name': self.name,
'sub': self.sub if self.sub else '',
'color_text': '#' + self.color_text,
'color_bg': '#' + self.color_bg,
}
return data

View File

@ -303,6 +303,11 @@ ACTIONTYPES = {
"icon": 'fa-thumbtack fa-rotate--45',
"color": 'bg-success'
},
'post_recategorize': {
"str": 'changed category of {self.target_link}',
"icon": 'fa-grid',
"color": 'bg-primary'
},
'purge_cache': {
"str": 'purged cache',
"icon": 'fa-memory',

View File

@ -53,6 +53,7 @@ class Submission(Base):
body = Column(String)
body_html = Column(String)
flair = Column(String)
category_id = Column(Integer, ForeignKey("category.id"))
ban_reason = Column(String)
embed_url = Column(String)
new = Column(Boolean)
@ -65,6 +66,7 @@ class Submission(Base):
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", back_populates="post")
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)")
options = relationship("SubmissionOption", order_by="SubmissionOption.id")
category = relationship("Category", primaryjoin="Submission.category_id==Category.id")
bump_utc = deferred(Column(Integer, server_default=FetchedValue()))

View File

@ -100,6 +100,20 @@ if SITE_NAME == 'rDrama':
" pedo ": " libertarian ",
" pedos ": " libertarians ",
}
elif SITE_NAME == 'WPD':
SLURS = {
"nigger": "BIPOC",
"niglet": "young BIPOC",
"faggot": "cute twink",
"fag": "cute twink",
"spic ": "hard-working American ",
"tranny": "valid woman",
"trannie": "valid woman",
"dyke": "cute lesbian",
"gook": "superior IQ Asian",
"kike": "jewish chad",
"daisy's destruction": "Cars 2",
}
else:
SLURS = {
"faggot": "cute twink",
@ -132,6 +146,8 @@ AGENDAPOSTER_MSG_HTML = """<p>Hi <a href="/id/{id}"><img loading="lazy" src="/pp
################################################################################
PERMS = { # Minimum admin_level to perform action.
'ADMIN_CATEGORIES_CHANGE': 2, # change category on post ("recategorize")
'ADMIN_CATEGORIES_MANAGE': 3, # create/update/delete categories
'HOLE_CREATE': 0,
'CONTENT_THREADS': 3,
'FLAGS_VISIBLE': 0,
@ -146,6 +162,7 @@ PERMS = { # Minimum admin_level to perform action.
FEATURES = {
'PROCOINS': True,
'AWARDS': True,
'CATEGORIES': False,
'CHAT': True,
'PINS': True,
'COUNTRY_CLUB': True,
@ -234,7 +251,11 @@ if SITE in ('rdrama.net', 'devrama.xyz'):
MARSEY_THREAD = 37838
GAMBLING_THREAD = 39413
elif SITE == 'deuxrama.net':
PERMS['HOLE_CREATE'] = 3
PERMS['CONTENT_THREADS'] = 2
FEATURES['PROCOINS'] = False
SIDEBAR_THREAD = 175
BADGE_THREAD = 142
@ -334,7 +355,9 @@ elif SITE == 'lgbdropthet.com':
PERMS['USER_FOLLOWS_VISIBLE'] = 2
PERMS['USER_VOTERS_VISIBLE'] = 2
FEATURES['PROCOINS'] = False
FEATURES['AWARDS'] = False
FEATURES['CATEGORIES'] = True
FEATURES['CHAT'] = False
FEATURES['COUNTRY_CLUB'] = False
FEATURES['BADGES'] = False
@ -369,11 +392,7 @@ elif SITE == 'lgbdropthet.com':
else: # localhost or testing environment implied
FEATURES['PRONOUNS'] = True
FEATURES['HOUSES'] = True
#FEATURES['REPOST_DETECTION'] = False
if SITE == 'deuxrama.net':
PERMS['HOLE_CREATE'] = 3
PERMS['CONTENT_THREADS'] = 2
FEATURES['REPOST_DETECTION'] = False
bots = {AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, BASEDBOT_ID}
@ -842,6 +861,12 @@ NOTIFIED_USERS = {
'geese': GEESE_ID
}
if SITE_NAME == 'LGBDropTheT':
NOTIFIED_USERS.update({
'ipd': 12, # Im-Probably-Drinking
'@rc ': 15, # reluctant_commenter
})
FORTUNE_REPLIES = ('<b style="color:#6023f8">Your fortune: Allah Wills It</b>','<b style="color:#d302a7">Your fortune: Inshallah, Only Good Things Shall Come To Pass</b>','<b style="color:#e7890c">Your fortune: Allah Smiles At You This Day</b>','<b style="color:#7fec11">Your fortune: Your Bussy Is In For A Blasting</b>','<b style="color:#43fd3b">Your fortune: You Will Be Propositioned By A High-Tier Twink</b>','<b style="color:#9d05da">Your fortune: Repent, You Have Displeased Allah And His Vengeance Is Nigh</b>','<b style="color:#f51c6a">Your fortune: Reply Hazy, Try Again</b>','<b style="color:#00cbb0">Your fortune: lmao you just lost 100 coins</b>','<b style="color:#2a56fb">Your fortune: Yikes 😬</b>','<b style="color:#0893e1">Your fortune: You Will Be Blessed With Many Black Bulls</b>','<b style="color:#16f174">Your fortune: NEETmax, The Day Is Lost If You Venture Outside</b>','<b style="color:#fd4d32">Your fortune: A Taste Of Jannah Awaits You Today</b>','<b style="color:#bac200">Your fortune: Watch Your Back</b>','<b style="color:#6023f8">Your fortune: Outlook good</b>','<b style="color:#d302a7">Your fortune: Godly Luck</b>','<b style="color:#e7890c">Your fortune: Good Luck</b>','<b style="color:#7fec11">Your fortune: Bad Luck</b>','<b style="color:#43fd3b">Your fortune: Good news will come to you by mail</b>','<b style="color:#9d05da">Your fortune: Very Bad Luck</b>','<b style="color:#00cbb0">Your fortune: キタ━━━━━━(゚∀゚)━━━━━━ !!!!</b>','<b style="color:#2a56fb">Your fortune: Better not tell you now</b>','<b style="color:#0893e1">Your fortune: You will meet a dark handsome stranger</b>','<b style="color:#16f174">Your fortune:  ´_ゝ`)フーン</b>','<b style="color:#fd4d32">Your fortune: Excellent Luck</b>','<b style="color:#bac200">Your fortune: Average Luck</b>')
FACTCHECK_REPLIES = ('<b style="color:#6023f8">Factcheck: This claim has been confirmed as correct by experts. </b>','<b style="color:#d302a7">Factcheck: This claim has been classified as misogynistic.</b>','<b style="color:#e7890c">Factcheck: This claim is currently being debunked.</b>','<b style="color:#7fec11">Factcheck: This claim is 100% true.</b>','<b style="color:#9d05da">Factcheck: This claim hurts trans lives.</b>','<b style="color:#f51c6a">Factcheck: [REDACTED].</b>','<b style="color:#00cbb0">Factcheck: This claim is both true and false.</b>','<b style="color:#2a56fb">Factcheck: You really believe that shit? Lmao dumbass nigga 🤣</b>','<b style="color:#0893e1">Factcheck: None of this is real.</b>','<b style="color:#16f174">Factcheck: Yes.</b>','<b style="color:#fd4d32">Factcheck: This claim has not been approved by experts.</b>','<b style="color:#bac200">Factcheck: This claim is a gross exageration of reality.</b>','<b style="color:#ff2200">Factcheck: WARNING! THIS CLAIM HAS BEEN CLASSIFIED AS DANGEROUS. PLEASE REMAIN STILL, AN AGENT WILL COME TO MEET YOU SHORTLY.</b>')
@ -1049,5 +1074,6 @@ DISCORD_WELCOME_CHANNEL = "846509313941700618"
has_sidebar = path.exists(f'files/templates/sidebar_{SITE_NAME}.html')
has_logo = path.exists(f'files/assets/images/{SITE_NAME}/logo.webp')
has_app = path.exists(f'files/assets/app_{SITE_NAME}_v2.4.apk')
GLOBAL = environ.get("GLOBAL")
GLOBAL = environ.get("GLOBAL")

View File

@ -1,5 +1,6 @@
from files.classes import *
from flask import g
from sqlalchemy.orm import joinedload
def get_id(username, v=None, graceful=False):
@ -136,6 +137,8 @@ def get_post(i, v=None, graceful=False):
Submission,
vt.c.vote_type,
blocking.c.target_id,
).options(
joinedload(Submission.category)
)
post=post.filter(Submission.id == i
@ -189,6 +192,8 @@ def get_posts(pids, v=None):
blocked.c.target_id,
).filter(
Submission.id.in_(pids)
).options(
joinedload(Submission.category)
).join(
vt, vt.c.submission_id==Submission.id, isouter=True
).join(

View File

@ -57,5 +57,5 @@ def inject_constants():
"HOLE_NAME": HOLE_NAME, "HOLE_STYLE_FLAIR": HOLE_STYLE_FLAIR, "HOLE_REQUIRED": HOLE_REQUIRED,
"LOTTERY_ENABLED": LOTTERY_ENABLED, "GUMROAD_LINK": GUMROAD_LINK,
"DEFAULT_THEME": DEFAULT_THEME, "DESCRIPTION": DESCRIPTION,
"has_sidebar": has_sidebar, "has_logo": has_logo,
"has_sidebar": has_sidebar, "has_logo": has_logo, "has_app": has_app,
"FP": FP, "NOTIF_MODACTION_JL_MIN": NOTIF_MODACTION_JL_MIN}

View File

@ -214,7 +214,7 @@ def with_sigalrm_timeout(timeout: int):
@with_sigalrm_timeout(2)
def sanitize(sanitized, edit=False, limit_pings=False):
def sanitize(sanitized, edit=False, limit_pings=False, showmore=True):
sanitized = sanitized.strip()
sanitized = normalize_url(sanitized)
@ -388,7 +388,7 @@ def sanitize(sanitized, edit=False, limit_pings=False):
if '<pre>' not in sanitized:
sanitized = sanitized.replace('\n','')
if len(sanitized) > 5000:
if showmore and len(sanitized) > 5000:
sanitized = showmore_regex.sub(r'\1<p><button class="showmore" onclick="showmore()">SHOW MORE</button></p><d class="d-none">\2</d>', sanitized)
return sanitized.strip()

View File

@ -1428,6 +1428,85 @@ def admin_toggle_ban_domain(v):
return redirect("/admin/banned_domains/")
@app.get("/admin/categories")
@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE'])
def admin_categories(v):
if not FEATURES['CATEGORIES']:
abort(404)
categories = g.db.query(Category).order_by(nullsfirst(Category.sub), Category.name).all()
return render_template("admin/categories.html", v=v, categories=categories)
@app.post("/admin/categories/add")
@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE'])
def admin_categories_add(v):
if not FEATURES['CATEGORIES']:
abort(404)
cat_name = request.values.get("name").strip()
cat_sub = request.values.get("sub").strip().lower()
cat_color_text = request.values.get("color_text").strip().strip('#').lower()
cat_color_bg = request.values.get("color_bg").strip().strip('#').lower()
if cat_sub == '':
cat_sub = None
cat = Category(
name=cat_name,
sub=cat_sub,
color_text=cat_color_text,
color_bg=cat_color_bg
)
g.db.add(cat)
g.db.commit()
return redirect("/admin/categories")
@app.post("/admin/categories/update/<cid>")
@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE'])
def admin_categories_update(v, cid):
if not FEATURES['CATEGORIES']:
abort(404)
cat_name = request.values.get("name").strip()
cat_color_text = request.values.get("color_text").strip().strip('#').lower()
cat_color_bg = request.values.get("color_bg").strip().strip('#').lower()
try:
cat_id = int(cid)
except:
abort(400)
cat = g.db.query(Category).filter(Category.id == cat_id).one_or_none()
if not cat:
abort(400)
cat.name = cat_name
cat.color_text = cat_color_text
cat.color_bg = cat_color_bg
g.db.add(cat)
g.db.commit()
return redirect("/admin/categories")
@app.post("/admin/categories/delete/<cid>")
@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE'])
def admin_categories_delete(v, cid):
if not FEATURES['CATEGORIES']:
abort(404)
try:
cat_id = int(cid)
except:
abort(400)
cat = g.db.query(Category).filter(Category.id == cat_id).one_or_none()
g.db.delete(cat)
g.db.commit()
return redirect("/admin/categories")
@app.post("/admin/nuke_user")
@limiter.limit("1/second;30/minute;200/hour;1000/day")

View File

@ -225,11 +225,18 @@ def post_id(pid, anything=None, v=None, sub=None):
post.views += 1
g.db.add(post)
if request.headers.get("Authorization"): return post.json
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.subr, fart=app.config['SETTINGS']['Fart mode'])
if request.headers.get("Authorization"):
return post.json
template = "submission.html"
if (post.is_banned or post.author.shadowbanned) \
and not (v and (v.admin_level >= 2 or post.author_id == v.id)):
template = "submission_banned.html"
return render_template(template, v=v, p=post, ids=list(ids),
sort=sort, render_replies=True, offset=offset, sub=post.subr,
fart=app.config['SETTINGS']['Fart mode'])
@app.get("/viewmore/<pid>/<sort>/<offset>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -432,7 +439,7 @@ def edit_post(pid, v):
g.db.add(option)
body_html = sanitize(body, edit=True, limit_pings=True)
body_html = sanitize(body, edit=True, limit_pings=True, showmore=False)
if v.id == p.author_id and v.marseyawarded and marseyaward_body_regex.search(body_html):
return {"error":"You can only type marseys!"}, 403
@ -697,6 +704,14 @@ def submit_post(v, sub=None):
if not sub and HOLE_REQUIRED:
return error(f"You must choose a {HOLE_NAME} for your post!")
category = None
if FEATURES['CATEGORIES']:
category_id = request.values.get('category', '')
try:
category = int(category_id)
except:
category = None
if v.is_suspended: return error("You can't perform this action while banned.")
if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username)
@ -875,7 +890,7 @@ def submit_post(v, sub=None):
body = body.strip()
body_html = sanitize(body, limit_pings=True)
body_html = sanitize(body, limit_pings=True, showmore=False)
if v.marseyawarded and marseyaward_body_regex.search(body_html):
return error("You can only type marseys!")
@ -912,6 +927,7 @@ def submit_post(v, sub=None):
title=title[:500],
title_html=title_html,
sub=sub,
category_id=category,
ghost=ghost
)
@ -1207,6 +1223,42 @@ def toggle_post_nsfw(pid, v):
if post.over_18: return {"message": "Post has been marked as +18!"}
else: return {"message": "Post has been unmarked as +18!"}
@app.post("/post_recategorize")
@auth_required
def post_recategorize(v):
if not FEATURES['CATEGORIES']:
abort(404)
if v.admin_level < PERMS['ADMIN_CATEGORIES_CHANGE']:
abort(403)
post_id = request.values.get("post_id")
category_id = request.values.get("category_id")
try:
pid = int(post_id)
cid = None
if category_id != '':
cid = int(category_id)
except:
abort(400)
post = g.db.get(Submission, pid)
post.category_id = cid
g.db.add(post)
category_new_name = '&lt;none&gt;'
if category_id != '':
category_new_name = g.db.get(Category, cid).name
ma = ModAction(
kind='post_recategorize',
user_id=v.id,
target_submission_id=post.id,
_note=category_new_name
)
g.db.add(ma)
g.db.commit()
return {"message": "Success!"}
@app.post("/save_post/<pid>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')

View File

@ -48,16 +48,19 @@ def searchposts(v):
criteria=searchparse(query)
posts = g.db.query(Submission.id).filter(Submission.author_id.notin_(v.userblocks))
posts = g.db.query(Submission.id) \
.join(Submission.author) \
.filter(Submission.author_id.notin_(v.userblocks))
if not v.paid_dues: posts = posts.filter_by(club=False)
if not v.paid_dues:
posts = posts.filter(Submission.club == False)
if v.admin_level < 2:
posts = posts.filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False)
posts = posts.filter(
Submission.deleted_utc == 0,
Submission.is_banned == False,
Submission.private == False,
User.shadowbanned == None)
if 'author' in criteria:
posts = posts.filter(Submission.ghost == False)
@ -239,6 +242,9 @@ def searchusers(v):
)
)
if v.admin_level < 2:
users = users.filter(User.shadowbanned == None)
users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc())
total=users.count()

View File

@ -419,3 +419,15 @@ def knowledgebase(v, page):
abort(404)
return render_template(template_path, v=v)
@app.get("/categories.json")
def categories_json():
categories = g.db.query(Category).all()
data = {}
for c in categories:
sub = c.sub if c.sub else ''
sub_cats = (data[sub] if sub in data else []) + [c.as_json()]
data.update({sub: sub_cats})
return jsonify(data)

View File

@ -11,6 +11,7 @@ from files.mail import *
from flask import *
from files.__main__ import app, limiter, db_session
import sqlalchemy
from sqlalchemy.orm import aliased
from sqlalchemy import text
from collections import Counter
import gevent
@ -1055,14 +1056,24 @@ def u_username_comments(username, v=None):
sort=request.values.get("sort","new")
t=request.values.get("t","all")
comments = g.db.query(Comment.id).filter(Comment.author_id == u.id, Comment.parent_submission != None)
comment_post_author = aliased(User)
comments = g.db.query(Comment.id) \
.join(Comment.post) \
.join(comment_post_author, Submission.author) \
.filter(
Comment.author_id == u.id,
Comment.parent_submission != None
)
if not v or (v.id != u.id and v.admin_level < 2):
comments = comments.filter(Comment.is_banned == False, Comment.ghost == False)
comments = comments.filter(
Comment.is_banned == False,
Comment.ghost == False,
comment_post_author.shadowbanned == None
)
if not (v and v.admin_level > 1):
comments = comments.filter_by(deleted_utc=0)
comments = comments.filter(Comment.deleted_utc == 0)
comments = apply_time_filter(t, comments, Comment)

View File

@ -53,11 +53,6 @@
</ul>
{%- endif %}
<h4>API Access Control</h4>
<ul>
<li><a href="/admin/apps">Apps</a></li>
</ul>
{% if LOTTERY_ENABLED -%}
<h4>Lottery</h4>
<ul>
@ -75,6 +70,10 @@
<h4>Configuration</h4>
<ul>
<li><a href="/create_hole">Create {{ HOLE_NAME | capitalize }}</a></li>
<li><a href="/admin/apps">Apps</a></li>
{% if FEATURES['CATEGORIES'] -%}
<li><a href="/admin/categories">Categories</a></li>
{%- endif %}
</ul>
{% if v.admin_level > 2 %}

View File

@ -0,0 +1,51 @@
{% extends "default.html" %}
{% block title %}
<title>Admin — Categories</title>
{% endblock %}
{% block content %}
<div class="overflow-x-auto"><table class="table table-striped mt-3 mb-5">
<thead class="bg-primary text-white">
<tr>
<th>Category</th>
<th>{{ HOLE_NAME | capitalize }}</th>
<th>Name</th>
<th>Text Color</th>
<th>Background Color</th>
<th>Actions</th>
<th>&nbsp;</th>
</tr>
</thead>
{% for category in categories %}
<tr>
<td>{{help.submission_category_tag(category.name, category.color_text, category.color_bg)}}</td>
<td>{{category.sub if category.sub else '&mdash;'|safe}}</td>
<form action="/admin/categories/update/{{category.id}}" method="POST">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<td><input name="name" type="text" value="{{category.name}}" maxlength="128" autocomplete="off" class="form-control"></td>
<td><input name="color_text" type="text" value="#{{category.color_text}}" size="7" maxlength="7" autocomplete="off" class="form-control"></td>
<td><input name="color_bg" type="text" value="#{{category.color_bg}}" size="7" maxlength="7" autocomplete="off" class="form-control"></td>
<td><input type="submit" onclick="disable(this)" class="btn btn-primary" value="Update"></td>
</form>
<form action="/admin/categories/delete/{{category.id}}" method="POST">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<td><input type="submit" onclick="disable(this)" class="btn btn-primary" value="Delete"></td>
</form>
</tr>
{% endfor %}
<tr>
<form action="/admin/categories/add" method="POST">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<td><input name="name" type="text" placeholder="Name" maxlength="128" autocomplete="off" class="form-control"></td>
<td><input name="sub" type="text" placeholder="{{HOLE_NAME|capitalize}} (optional)" maxlength="20" autocomplete="off" class="form-control"></td>
<td></td>
<td><input name="color_text" type="text" placeholder="#000000 (Text)" size="7" maxlength="7" autocomplete="off" class="form-control"></td>
<td><input name="color_bg" type="text" placeholder="#000000 (BG)" size="7" maxlength="7" autocomplete="off" class="form-control"></td>
<td colspan="2"><input type="submit" onclick="disable(this)" class="btn btn-primary" value="Create"></td>
</form>
</tr>
</table>
{% endblock %}

View File

@ -0,0 +1,16 @@
<div class="modal fade" id="category-modal" tabindex="-1" role="dialog" aria-labelledby="category-modal-title" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header pt-3">
<h5 id="category-modal-title"></h5>
<button class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
<div class="modal-body" id="category-modal-body">
</div>
</div>
</div>
</div>
<script src="{{asset('js/category_modal.js')}}"></script>

View File

@ -795,6 +795,9 @@
{% include "emoji_modal.html" %}
{% if v.admin_level > 1 %}
{% include "ban_modal.html" %}
{% if FEATURES['CATEGORIES'] -%}
{% include "category_modal.html" %}
{%- endif %}
{% endif %}
<div class="modal fade" id="deleteCommentModal" tabindex="-1" role="dialog" aria-labelledby="deleteCommentModalTitle" aria-hidden="true">

View File

@ -226,7 +226,9 @@
<button class="dropdown-item copy-link" data-clipboard-text="{{SITE_FULL}}/signup?ref={{v.username}}"><i class="fas fa-user-friends fa-fw mr-3"></i>Invite friends</button>
</div>
<div class="px-2">
{% if has_app -%}
<a class="dropdown-item" href="/assets/app_{{SITE_NAME}}_v2.4.apk"><i class="fab fa-android fa-fw mr-3"></i>Android app</a>
{%- endif %}
<a class="dropdown-item" href="https://rdrama.net/h/changelog"><i class="fas fa-clipboard fa-fw mr-3"></i>Changelog</a>
@ -291,7 +293,9 @@
</li>
{% endif %}
<a class="nav-item nav-link" href="/assets/app_{{SITE_NAME}}_v2.4.apk"><i class="fab fa-android fa-fw mr-3"></i>Android app</a>
{% if has_app -%}
<a class="nav-item nav-link" href="/assets/app_{{SITE_NAME}}_v2.4.apk"><i class="fab fa-android fa-fw mr-3"></i>Android app</a>
{%- endif %}
<a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="https://github.com/Aevann1/rDrama"><i class="fab fa-github fa-fw mr-3"></i>Source code</a>

View File

@ -60,6 +60,10 @@
<a id="unclub-{{p.id}}" class="dropdown-item {% if not p.club %}d-none{% endif %} list-inline-item text-info" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}','d-none')"><i class="fas fa-eye"></i>Unmark club</a>
{% endif %}
{% if FEATURES['CATEGORIES'] and (v.admin_level >= PERMS['ADMIN_CATEGORIES_CHANGE']) %}
<a id="categorize-{{p.id}}" class="dropdown-item list-inline-item text-info" role="button" data-bs-toggle="modal" data-bs-target="#category-modal" onclick="category_modal('{{p.id}}', '{{p.title}}', '{{p.sub if p.sub else ''}}')"><i class="fas fa-grid text-info fa-fw"></i>Recategorize</a>
{% endif %}
{% if v.admin_level > 1 %}
{% if "/reported/" in request.path %}
{% if v.id != p.author.id %}<a class="dropdown-item list-inline-item text-danger" role="button" onclick="post_toast(this,'/remove_post/{{p.id}}')"><i class="fas fa-ban"></i>Remove</a>{% endif %}

View File

@ -18,6 +18,10 @@
<button id="unclub2-{{p.id}}" class="{% if not p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-info text-left" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye mr-3"></i>Unmark club</button>
{%- endif %}
{% if FEATURES['CATEGORIES'] and (v.admin_level >= PERMS['ADMIN_CATEGORIES_CHANGE']) %}
<button id="categorize2-{{p.id}}" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#category-modal" onclick="category_modal('{{p.id}}', '{{p.title}}', '{{p.sub if p.sub else ''}}')" class="nobackground btn btn-link btn-block btn-lg text-info text-left" role="button"><i class="fas fa-grid mr-3"></i>Recategorize</button>
{% endif %}
<button id="distinguish2-{{p.id}}" class="{% if p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" role="button" onclick="post_toast(this,'/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-crown text-center text-primary mr-3"></i>Distinguish</button>
<button id="undistinguish2-{{p.id}}" class="{% if not p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" role="button" onclick="post_toast(this,'/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-crown text-center text-primary mr-3"></i>Undistinguish</button>

View File

@ -9,6 +9,14 @@
{% block PseudoSubmitForm %}{% endblock %}
{% block navbar %}
<form class="form-inline search flex-nowrap mx-0 mx-lg-auto" action="/search/{% if '/posts' in request.path %}posts{% elif '/comments' in request.path %}comments{% else %}users{% endif %}" method="get" style="padding-top:42px">
<input autocomplete="off" class="form-control w-100" type="search" placeholder="Search" aria-label="Search" name="q" value="{{query}}">
<span class="input-group-append">
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem;">
<i class="fa fa-search" aria-hidden="true"></i>
</span>
</span>
</form>
{% if not '/users' in request.path %}
<div class="mt-5 d-flex align-items-center">
<div class="dropdown dropdown-actions">
@ -107,10 +115,10 @@
<a class="nav-link{% if sort=='bottom' %} active{% endif %}" href="?sort=bottom&q={{query | urlencode}}&t={{t}}"><i class="fas fa-arrow-alt-circle-down"></i>Bottom</a>
</li>
<li class="nav-item">
<a class="nav-link{% if sort=='new' %} active{% endif %}" href="?sort=new&q={{query | urlencode}}&t={{t}}"><i class="fas fa-sparkles"></i>New</a>
<a class="nav-link{% if sort=='new' %} active{% endif %}" href="?sort=new&q={{query | urlencode}}&t={{t}}"><i class="fas fa-sparkles"></i>New</a>
</li>
<li class="nav-item">
<a class="nav-link{% if sort=='old' %} active{% endif %}" href="?sort=old&q={{query | urlencode}}&t={{t}}"><i class="fas fa-book"></i>Old</a>
<a class="nav-link{% if sort=='old' %} active{% endif %}" href="?sort=old&q={{query | urlencode}}&t={{t}}"><i class="fas fa-book"></i>Old</a>
</li>
<li class="nav-item">
<a class="nav-link{% if sort=='fiery' %} active{% endif %}" href="?sort=fiery&q={{query | urlencode}}&t={{t}}"><i class="fas fa-bullhorn"></i>Controversial</a>
@ -173,4 +181,4 @@
</ul>
</nav>
{% endblock %}
{% endblock %}

View File

@ -27,12 +27,6 @@
{% endblock %}
{% block content %}
<style>
#buy1, #buy1-go, #buy2, #buy2-go {
display: flex;
}
</style>
{% if error %}
<div class="alert alert-danger alert-dismissible fade show my-3" role="alert">
<i class="fas fa-exclamation-circle my-auto"></i>
@ -85,14 +79,14 @@
<td class="shop-table-owned">{{a['owned']}}</td>
{% set kind = a['kind'] %}
<td class="shop-table-actions">
{% if a['kind'] != "benefactor" %}
<a id="buy1" class="btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy1-go').classList.remove('d-none')"><span class="m-auto">Buy</span></a>
<a id="buy1-go" class="d-none btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" onclick="post_toast(this,'/buy/{{kind}}')"><span class="m-auto">Are you sure?</span></a>
{% if kind != "benefactor" %}
<a id="buy1-{{loop.index}}" class="btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy1-go-{{loop.index}}').classList.remove('d-none')"><span class="m-auto">Buy</span></a>
<a id="buy1-go-{{loop.index}}" class="d-none btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" onclick="post_toast(this,'/buy/{{kind}}')"><span class="m-auto">Are you sure?</span></a>
{% endif %}
{% if FEATURES['PROCOINS'] %}
{% if a['kind'] != "grass" %}
<a id="buy2" class="marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy2-go').classList.remove('d-none')""><span class="m-auto">Buy with MBux</span></a>
<a id="buy2-go" class="d-none marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" onclick="post_toast(this,'/buy/{{kind}}?mb=true')"><span class="m-auto">Are you sure?</span></a>
{% if kind != "grass" %}
<a id="buy2-{{loop.index}}" class="marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy2-go-{{loop.index}}').classList.remove('d-none')"><span class="m-auto">Buy with MBux</span></a>
<a id="buy2-go-{{loop.index}}" class="d-none marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" onclick="post_toast(this,'/buy/{{kind}}?mb=true')"><span class="m-auto">Are you sure?</span></a>
{% endif %}
{% endif %}
</td>

View File

@ -705,12 +705,14 @@
{% if p.realurl(v) and not v_forbid_deleted %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.agendaposter %}agendaposter{% endif %}"><a {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}">
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:12px; line-height:2;">{{CC}}</span>{% endif %}
{% if p.category %}{{help.submission_category_tag(p.category.name, p.category.color_text, p.category.color_bg)}}{% endif %}
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</a></h1>
{% else %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.agendaposter %}agendaposter{% endif %}">
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:12px; line-height:2;">{{CC}}</span>{% endif %}
{% if p.category %}{{help.submission_category_tag(p.category.name, p.category.color_text, p.category.color_bg)}}{% endif %}
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</h1>

View File

@ -231,6 +231,7 @@
<h5 class="card-title post-title text-left w-lg-95 mb-0 pb-0 pb-md-1">
<a id="{{p.id}}-title" {% if v and v.newtab and not g.webview %}target="_blank"{% endif %} href="{{p.permalink}}" class="{% if p.sub %}sub{% elif voted and v.id == AEVANN_ID %}visited{% endif %} stretched-link {% if p.author.agendaposter %}agendaposter{% endif %}">
{% if p.club %}<span class="patron font-weight-bolder mr-1" style="background-color:red; font-size:12px; line-height:2;">{{CC}}</span>{% endif %}
{% if p.category %}{{help.submission_category_tag(p.category.name, p.category.color_text, p.category.color_bg)}}{% endif %}
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}}
</a></h5>
@ -454,6 +455,9 @@
{% include "report_post_modal.html" %}
{% if v.admin_level > 1 %}
{% include "ban_modal.html" %}
{% if FEATURES['CATEGORIES'] -%}
{% include "category_modal.html" %}
{%- endif %}
{% endif %}
{% endif %}
{% include "expanded_image_modal.html" %}

View File

@ -86,7 +86,7 @@
<div class="input-group mb2">
{%- set hole_placeholder = 'Required' if HOLE_REQUIRED else 'Optional' -%}
<input list="subs" autocomplete="off" id='sub' class="form-control" form="submitform" name="sub" oninput="savetext()" {% if sub %}value="{{sub.name}}"{% endif %} placeholder="{{hole_placeholder}}">
<input list="subs" autocomplete="off" id='sub' class="form-control" form="submitform" name="sub" oninput="savetext()" onchange="updateCategories()" {% if sub %}value="{{sub.name}}"{% endif %} placeholder="{{hole_placeholder}}">
<datalist id="subs">
{% for s in SUBS %}
<option value="{{s}}"></option>
@ -99,6 +99,11 @@
<div class="mt-1" style="font-size: min(3.5vw,14px)"><span style="color:#ffcccb ">WARNING</span>: Selecting a {{HOLE_NAME}} considerably reduces the number of people who will see your post. Don't select a {{HOLE_NAME}} unless that's what you want.</div>
{%- endif %}
{% if FEATURES['CATEGORIES'] -%}
<label class="mt-4" for="submit-categories">Category</label>
<div id="submit-categories"></div>
{%- endif %}
<label class='mt-4' for="title">Post Title</label>

View File

@ -1,10 +1,10 @@
{%-
set CACHE_VER = {
'css/main.css': 439,
'css/main.css': 441,
'css/catalog.css': 2,
'css/4chan.css': 61,
'css/classic.css': 65,
'css/classic.css': 66,
'css/classic_dark.css': 65,
'css/coffee.css': 61,
'css/dark.css': 63,
@ -17,14 +17,15 @@ set CACHE_VER = {
'css/win98.css': 63,
'js/award_modal.js': 254,
'js/bootstrap.js': 276,
'js/bootstrap.js': 277,
'js/category_modal.js': 200,
'js/comments+submission_listing.js': 265,
'js/submission_listing.js': 261,
'js/emoji_modal.js': 312,
'js/formatting.js': 240,
'js/lottery.js': 256,
'js/marked.js': 280,
'js/submit.js': 265,
'js/submit.js': 266,
'js/userpage.js': 242,
'js/userpage_v.js': 245,
'js/lozad.js': 260,

View File

@ -3,3 +3,7 @@
{{ suffix }}
{%- endif -%}
{%- endmacro -%}
{%- macro submission_category_tag(name, color_text, color_bg) -%}
<span class="post--category-tag" style="color:#{{color_text}}; background-color:#{{color_bg}};">{{name | safe}}</span>
{%- endmacro -%}

View File

@ -101,7 +101,8 @@ CREATE TABLE public.submissions (
ghost boolean DEFAULT false NOT NULL,
sub character varying(20),
new boolean,
hole_pinned character varying(30)
hole_pinned character varying(30),
category_id integer
);
@ -220,6 +221,39 @@ CREATE TABLE public.banneddomains (
);
--
-- Name: category; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.category (
id integer NOT NULL,
name character varying(128) NOT NULL,
sub character varying(20),
color_text character(6),
color_bg character(6)
);
--
-- Name: category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.category_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.category_id_seq OWNED BY public.category.id;
--
-- Name: client_auths; Type: TABLE; Schema: public; Owner: -
--
@ -873,6 +907,13 @@ ALTER TABLE ONLY public.award_relationships ALTER COLUMN id SET DEFAULT nextval(
ALTER TABLE ONLY public.badge_defs ALTER COLUMN id SET DEFAULT nextval('public.badge_defs_id_seq'::regclass);
--
-- Name: category id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.category ALTER COLUMN id SET DEFAULT nextval('public.category_id_seq'::regclass);
--
-- Name: comments id; Type: DEFAULT; Schema: public; Owner: -
--
@ -963,6 +1004,22 @@ ALTER TABLE ONLY public.badges
ADD CONSTRAINT badges_pkey PRIMARY KEY (user_id, badge_id);
--
-- Name: category category_name_sub_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.category
ADD CONSTRAINT category_name_sub_key UNIQUE (name, sub);
--
-- Name: category category_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.category
ADD CONSTRAINT category_pkey PRIMARY KEY (id);
--
-- Name: client_auths client_auths_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -1810,6 +1867,14 @@ ALTER TABLE ONLY public.userblocks
ADD CONSTRAINT block_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- Name: category category_sub_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.category
ADD CONSTRAINT category_sub_fkey FOREIGN KEY (sub) REFERENCES public.subs(name);
--
-- Name: client_auths client_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -2122,6 +2187,14 @@ ALTER TABLE ONLY public.submissions
ADD CONSTRAINT submissions_author_fkey FOREIGN KEY (author_id) REFERENCES public.users(id);
--
-- Name: submissions submissions_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.submissions
ADD CONSTRAINT submissions_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.category(id) ON DELETE SET NULL;
--
-- Name: subscriptions subscription_submission_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

View File

@ -0,0 +1,10 @@
CREATE TABLE category (
id serial PRIMARY KEY,
name character varying(128) NOT NULL,
sub character varying(20) REFERENCES subs(name),
color_text char(6),
color_bg char(6),
UNIQUE (name, sub)
);
ALTER TABLE submissions ADD COLUMN category_id integer REFERENCES category(id) ON DELETE SET NULL;