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

master
Aevann1 2022-09-19 18:54:32 +00:00
commit 3ad2384b65
38 changed files with 1531 additions and 2106 deletions

View File

@ -4625,13 +4625,6 @@ span.green {
.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;
}
@ -5684,19 +5677,6 @@ 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";
@ -6070,7 +6050,7 @@ g {
}
@media (max-width: 767.98px) {
.pronouns, .patron, .post--category-tag, .mod {
.pronouns, .patron, .mod {
padding: 2px 5px !important;
}
}

View File

@ -1,41 +0,0 @@
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

@ -180,32 +180,6 @@ 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"))
return;
@ -216,4 +190,3 @@ document.addEventListener('keydown', (e) => {
});
checkRepost();
updateCategories();

View File

@ -8,7 +8,6 @@ from .badges import *
from .userblock import *
from .submission import *
from .votes import *
from .category import *
from .domains import *
from .subscriptions import *
from files.__main__ import app

View File

@ -1,31 +0,0 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
import time
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))
created_utc = Column(Integer)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
return f"<Category(id={self.id})>"
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

@ -383,7 +383,7 @@ class Comment(Base):
body += f'''><label class="custom-control-label" for="comment-{o.id}">{o.body_html} -
<a href="/votes/comment/option/{o.id}"><span id="score-comment-{o.id}">{o.upvotes}</span> votes</a></label></div>'''
if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and (v.sigs_disabled or v.poor)))):
if not self.ghost and self.author.show_sig(v):
body += f"<hr>{self.author.sig_html}"
return body

View File

@ -314,11 +314,6 @@ 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,7 +53,6 @@ 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)
@ -67,7 +66,6 @@ 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()))
@ -396,8 +394,7 @@ class Submission(Base):
<a href="/votes/post/option/{o.id}"><span id="score-post-{o.id}">{o.upvotes}</span> votes</a></label></div>'''
if not listing and self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and (v.sigs_disabled or v.poor)))):
if not listing and not self.ghost and self.author.show_sig(v):
body += f"<hr>{self.author.sig_html}"
return body

View File

@ -231,6 +231,16 @@ class User(Base):
return random.choice(self.equipped_hats)
return None
@property
@lazy
def forced_hat(self):
user_forced_hats = []
for k, val in forced_hats.items():
if getattr(self, k):
user_forced_hats.append(val)
if user_forced_hats: return random.choice(user_forced_hats)
else: return None
@property
@lazy
def hat_active(self):
@ -240,6 +250,9 @@ class User(Base):
if self.is_cakeday:
return '/i/hats/Cakeday.webp'
if self.forced_hat:
return f'/i/hats/{self.forced_hat[0]}.webp'
if self.equipped_hat:
return f'/i/hats/{self.equipped_hat.name}.webp'
@ -253,6 +266,9 @@ class User(Base):
if self.is_cakeday:
return "I've spent another year rotting my brain with dramaposting, please ridicule me 🤓"
if self.forced_hat:
return self.forced_hat[1]
if self.equipped_hat:
return self.equipped_hat.name + ' - ' + self.equipped_hat.censored_description(v)
@ -624,7 +640,7 @@ class User(Base):
@property
@lazy
def modaction_notifications_count(self):
if not self.admin_level or self.id == AEVANN_ID: return 0
if not self.admin_level: return 0
return g.db.query(ModAction).filter(
ModAction.created_utc > self.last_viewed_log_notifs,
ModAction.user_id != self.id,
@ -935,3 +951,16 @@ class User(Base):
from_casino_value = from_casino or 0
return from_casino_value + self.total_lottery_winnings
@lazy
def show_sig(self, v):
if not self.author.sig_html:
return False
if not self.author.patron and SITE_NAME != 'WPD':
return False
if v and (v.sigs_disabled or v.poor):
return False
return True

View File

@ -124,8 +124,6 @@ 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,
'FLAGS_REMOVE': 2,
'VOTES_VISIBLE': 0,
@ -137,7 +135,6 @@ PERMS = { # Minimum admin_level to perform action.
FEATURES = {
'PROCOINS': True,
'AWARDS': True,
'CATEGORIES': False,
'CHAT': True,
'PINS': True,
'COUNTRY_CLUB': True,
@ -154,7 +151,6 @@ FEATURES = {
'MARKUP_COMMANDS': True,
'REPOST_DETECTION': True,
'PATRON_ICONS': False,
'ORDER': False
}
EMOJI_MARSEYS = True
@ -189,7 +185,6 @@ PIZZA_VOTERS = ()
IDIO_ID = 0
CARP_ID = 0
JOAN_ID = 0
MOOSE_ID = 0
AEVANN_ID = 0
SNAKES_ID = 0
HOMO_ID = 0
@ -218,7 +213,6 @@ GIFT_NOTIF_ID = 5
if SITE == 'rdrama.net':
FEATURES['PRONOUNS'] = True
FEATURES['HOUSES'] = True
FEATURES['ORDER'] = True
SIDEBAR_THREAD = 37696
BANNER_THREAD = 37697
@ -244,7 +238,6 @@ if SITE == 'rdrama.net':
IDIO_ID = 30
CARP_ID = 995
JOAN_ID = 28
MOOSE_ID = 1904
AEVANN_ID = 1
SNAKES_ID = 10288
HOMO_ID = 147
@ -318,7 +311,6 @@ elif SITE == 'watchpeopledie.co':
else: # localhost or testing environment implied
FEATURES['PRONOUNS'] = True
FEATURES['HOUSES'] = True
FEATURES['ORDER'] = True
bots = {AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, BASEDBOT_ID}
@ -1076,3 +1068,18 @@ has_app = path.exists(f'files/assets/app_{SITE_NAME}_v2.4.apk')
GLOBAL = environ.get("GLOBAL")
ONLINE_STR = f'{SITE}_online'
forced_hats = {
"rehab": ("Roulette", "I'm a recovering ludomaniac!"),
"progressivestack": ("Attention Whore", "I won the oppression olympics!"),
"longpost": ("The Pizzashill", "We need to get rid of the character limit!"),
"bird": ("Bluecheck", "Three sentences is too much for me..."),
"marseyawarded": ("Three Lil Marseys", ":marseynotes: :marseynotes: :I prefer to speak in cats:"),
"bite": ("Vampire Mask", "When other little girls wanted to be ballet dancers I kind of wanted to be a vampire."),
"rainbow": ("Globohomo", "Homosexuality is no longer optional!"),
"owoify": ("Furry Marsey", "Nuzzles, pounces on you, UwU, you're so warm!.."),
"earlylife": ("The Merchant", "SHUT IT DOWN, the goys know!"),
"marsify": ("Marsified", "I can't pick my own Marseys, help!"),
"is_banned": ("Behind Bars", "This user is banned and needs to do better!"),
"agendaposter": ("Egg_irl", "This user is getting in touch with xir identity!")
}

View File

@ -87,7 +87,6 @@ def sub_inactive_purge_task():
g.db.add(post)
to_delete = mods \
+ g.db.query(Category).filter(Category.sub.in_(names)).all() \
+ g.db.query(Exile).filter(Exile.sub.in_(names)).all() \
+ g.db.query(SubBlock).filter(SubBlock.sub.in_(names)).all() \
+ g.db.query(SubJoin).filter(SubJoin.sub.in_(names)).all() \

View File

@ -1,6 +1,5 @@
from files.classes import *
from flask import g
from sqlalchemy.orm import joinedload
def get_id(username, v=None, graceful=False):
@ -136,8 +135,6 @@ 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
@ -191,8 +188,6 @@ 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

@ -51,7 +51,7 @@ def timestamp(timestamp):
def inject_constants():
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL,
"AUTOJANNY_ID":AUTOJANNY_ID, "PUSHER_ID":PUSHER_ID,
"CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID,
"CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "AEVANN_ID":AEVANN_ID,
"PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR,
"COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES,
"HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED,

View File

@ -1459,86 +1459,6 @@ 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")
@admin_level_required(2)

View File

@ -1,5 +1,5 @@
from shutil import move, copyfile
from os import listdir, rename
from os import listdir, rename, path
from files.__main__ import app, limiter
from files.helpers.const import *
@ -373,6 +373,9 @@ def update_marsey(v):
if not existing:
return error("A marsey with this name doesn't exist!")
for x in ('png','jpeg','webp','gif'):
if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'):
os.remove(f'/asset_submissions/marseys/original/{name}.{x}')
highquality = f"/asset_submissions/marseys/{name}"
file.save(highquality)
@ -431,6 +434,11 @@ def update_hat(v):
format = i.format.lower()
new_path = f'/asset_submissions/hats/original/{name}.{format}'
for x in ('png','jpeg','webp','gif'):
if path.isfile(f'/asset_submissions/hats/original/{name}.{x}'):
os.remove(f'/asset_submissions/hats/original/{name}.{x}')
rename(highquality, new_path)
filename = f"files/assets/images/hats/{name}.webp"

View File

@ -457,7 +457,7 @@ def admin_userawards_post(v):
if value:
if int(value) > 100 or (int(value) > 10 and v.id != AEVANN_ID): abort(403)
if int(value) > 10: abort(403)
if int(value): notify_awards[key] = int(value)

View File

@ -709,14 +709,6 @@ 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.")
torture = (v.agendaposter and not v.marseyawarded and sub != 'chudrama')
@ -933,7 +925,6 @@ def submit_post(v, sub=None):
title=title[:500],
title_html=title_html,
sub=sub,
category_id=category,
ghost=ghost
)
@ -1168,42 +1159,6 @@ 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

@ -104,6 +104,9 @@ def settings_profile_post(v):
updated = True
v.marsify = int(request.values.get("marsify") == 'true')
if v.marsify: badge_grant(user=v, badge_id=170)
else:
badge = v.has_badge(170)
if badge: g.db.delete(badge)
elif request.values.get("bio") == "":
v.bio = None
@ -129,7 +132,7 @@ def settings_profile_post(v):
g.db.add(v)
return render_template("settings_profile.html", v=v, msg="Your enemies list has been updated.")
elif (v.patron or v.id == MOOSE_ID) and request.values.get("sig"):
elif v.patron and request.values.get("sig"):
sig = request.values.get("sig")[:200].replace('\n','').replace('\r','')
sig_html = sanitize(sig)

View File

@ -193,37 +193,6 @@ def static_megathread_index(v):
def api(v):
return render_template("api.html", v=v)
@app.get("/order")
@auth_desired
def order(v):
if not FEATURES['ORDER']: abort(404)
if v: return redirect("/")
return render_template("order.html", v=v)
@app.post("/order")
@limiter.limit("1/hour;2/day")
def submit_order():
if not FEATURES['ORDER']: abort(404)
body = request.values.get("message")
if not body: abort(400)
body = 'This message has been sent automatically to all admins via [/order](/order)\n\nMessage:\n\n' + body
body = body.strip()
body_html = sanitize(body)
new_comment = Comment(author_id=AUTOJANNY_ID, parent_submission=None, level=1, body_html=body_html, sentto=2)
g.db.add(new_comment)
g.db.flush()
new_comment.top_comment_id = new_comment.id
for admin in g.db.query(User).filter(User.admin_level > 2, User.id != AEVANN_ID).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
return {"success": True}
@app.get("/contact")
@app.get("/contactus")
@app.get("/contact_us")
@ -262,7 +231,7 @@ def submit_contact(v):
g.db.flush()
new_comment.top_comment_id = new_comment.id
for admin in g.db.query(User).filter(User.admin_level > 2, User.id != AEVANN_ID).all():
for admin in g.db.query(User).filter(User.admin_level > 2).all():
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
@ -467,15 +436,3 @@ 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

@ -826,7 +826,7 @@ def messagereply(v):
if c.top_comment.sentto == 2:
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 2, User.id != v.id, User.id != AEVANN_ID).all()]
admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 2, User.id != v.id).all()]
if parent.author.id not in admins:
admins.append(parent.author.id)

View File

@ -94,9 +94,6 @@
<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

@ -53,7 +53,7 @@
<tr>
<td><i class="{{a['icon']}} {{a['color']}}" style="font-size: 30px"></i></td>
<td>{{a['title']}}</td>
<td><input autocomplete="off" type="number" class="form-control" name="{{a['kind']}}" min="0" {% if v.id != AEVANN_ID %}max="10"{% endif %} placeholder="Enter number..."></td>
<td><input autocomplete="off" type="number" class="form-control" name="{{a['kind']}}" min="0" max="10" placeholder="Enter number..."></td>
</tr>
{% endfor %}
</table>

View File

@ -1,51 +0,0 @@
{% 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

@ -1,16 +0,0 @@
<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 defer src="{{asset('js/category_modal.js')}}"></script>

View File

@ -756,9 +756,6 @@
{% 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

@ -8,16 +8,24 @@
{% block Banner %}
<style>
.shop-tabs {
padding-top: 50px;
}
@media (max-width: 768px) {
#hats-banner {
width: 80%;
}
.shop-tabs {
padding-top: 30px;
}
}
.shop-tab {
display: inline-flex;
max-width: 46.6%;
letter-spacing: 3px;
border-radius: 0;
}
.shop-tab.active {
@ -27,15 +35,15 @@
}
</style>
<div class="container-fluid bg-white sticky" style="padding-top: 30px; padding-bottom: 0 !important;">
<div class="container-fluid bg-white sticky shop-tabs" style="padding-bottom: 0 !important;">
<div class="row box-shadow-bottom">
<div class="col">
<div class="col p-0">
<div class="container" style="padding-bottom: 0;">
<div class="row box-shadow-bottom bg-white" style="justify-content: center;">
<a class="btn btn-primary btn-block py-2 m-0 mr-3 shop-tab" href="/shop">
<a class="btn btn-primary btn-block m-0 shop-tab" href="/shop">
<span class="mr-auto ml-auto"><i class="fas fa-gift mr-2"></i>AWARDS</span>
</a>
<a class="btn btn-primary btn-block py-2 m-0 shop-tab active" href="/hats">
<a class="btn btn-primary btn-block m-0 shop-tab active" href="/hats">
<span class="mr-auto ml-auto"><i class="fas fa-hat-cowboy mr-2"></i>HATS</span>
</a>
</div>

View File

@ -259,11 +259,6 @@
</div>
</li>
{% else %}
{% if FEATURES['ORDER'] %}
<li class="nav-item d-flex align-items-center justify-content-center mx-1 mr-2">
<a class="btn btn-primary" href="/order">Request a quote</a>
</li>
{% endif %}
<li class="nav-item d-flex align-items-center justify-content-center mx-1 mr-2">
<a class="btn btn-primary" href="/contact">Contact us</a>
</li>
@ -332,11 +327,6 @@
<a class="nav-link" role="button", onclick="post_toast(this,'/logout', true)"><i class="fas fa-sign-out fa-fw mr-3 text-danger"></i>Log out</a>
</li>
{% else %}
{% if FEATURES['ORDER'] %}
<li class="nav-item d-flex align-items-center justify-content-center pb-3">
<a class="btn btn-primary btn-block" href="/order">Request a quote</a>
</li>
{% endif %}
<li class="nav-item d-flex align-items-center justify-content-center pb-3">
<a class="btn btn-primary btn-block" href="/contact">Contact us</a>
</li>

View File

@ -1,218 +0,0 @@
{% extends "default.html" %}
{% block content %}
<style>
.order-form {
margin: 0 auto;
margin-top: 2rem;
max-width: 500px;
}
.order-form h2 {
display: flex;
align-items: center;
justify-content: center;
}
.order-form h2 hr {
flex: 1;
}
.order-form h2 span {
flex: 3;
text-align: center;
}
.order-form--heading,
.form-check {
text-transform: uppercase;
letter-spacing: 2px;
}
#orderSuccess {
display: flex;
align-items: center;
justify-content: center;
display: none;
padding-top: 5rem;
text-align: center;
}
.order-toast {
position: fixed;
bottom: 1.5rem;
margin: 0 auto;
left: 0;
right: 0;
width: unset;
z-index: 1000;
height: auto !important;
}
</style>
<form class="order-form" id="orderForm" action="#" onsubmit="submitForm(event)">
<h2 class="order-form--heading">
<hr /><span>Request a quote</span>
<hr />
</h2>
<!-- Platforms -->
<div class="mb-3">
<label class="order-form--heading">Platforms to target</label>
<div class="form-check">
<input name="platform" class="form-check-input" type="checkbox" id="defaultCheck1" value="twitter">
<label class="form-check-label" for="defaultCheck1">
Twitter
</label>
</div>
<div class="form-check">
<input name="platform" class="form-check-input" type="checkbox" id="defaultCheck2" value="instagram">
<label class="form-check-label" for="defaultCheck2">
Instagram
</label>
</div>
<div class="form-check">
<input name="platform" class="form-check-input" type="checkbox" id="defaultCheck3" value="tiktok">
<label class="form-check-label" for="defaultCheck3">
TikTok
</label>
</div>
<div class="form-check">
<input name="platform" class="form-check-input" type="checkbox" id="defaultCheck3" value="facebook">
<label class="form-check-label" for="defaultCheck4">
Facebook
</label>
</div>
<div class="form-check">
<input name="platform" class="form-check-input" type="checkbox" id="defaultCheck5" value="reddit">
<label class="form-check-label" for="defaultCheck5">
Reddit
</label>
</div>
</div>
<!-- Narrative -->
<div class="mb-3">
<label for="exampleInputPassword1" class="order-form--heading">Narrative to push</label>
<textarea form="orderForm" class="textarea form-control" id="narrativeToPush" name="narrative"
rows="5"></textarea>
</div>
<!-- Additional Information -->
<div class="mb-3">
<label for="exampleInputPassword1" class="order-form--heading">Additional information</label>
<textarea form="orderForm" class="textarea form-control" id="additionalInformation" name="info"
rows="5"></textarea>
</div>
<!-- Customer Email -->
<div class="mb-3">
<label for="exampleInputEmail1" class="order-form--heading">Your Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" name="email" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text"><small>We respect your privacy. <a href="https://wikipedia.org/">Learn
more.</a></small></div>
</div>
<!-- Actions -->
<button type="submit" class="btn btn-primary">Request Quote</button>
</form>
<div id="orderSuccess">
<div class="order-form--heading">
<h1>Order Received</h1>
<p>We will get back to you as quickly as possible with a quote.</p>
</div>
</div>
<div class="toast order-toast" id="order-post-success" role="alert" aria-live="assertive" aria-atomic="true" data-bs-animation="true" data-bs-autohide="true"
data-bs-delay="5000">
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i> We have received your order.
</div>
</div>
<div class="toast order-toast" id="order-post-error" role="alert" aria-live="assertive" aria-atomic="true"
data-bs-animation="true" data-bs-autohide="true" data-bs-delay="5000">
<div class="toast-body bg-danger text-center text-white">
<i class="fas fa-exclamation-circle mr-2"></i>
rDrama is very busy right now -- please try your request again later.
</span>
</div>
</div>
<script>
function submitForm(e) {
e.preventDefault();
const formElement = document.getElementById('orderForm');
const formData = new FormData(formElement);
const structure = {
platforms: [],
narrative: "",
info: "",
email: ""
};
for (const [key, value] of formData.entries()) {
if (key === "platform") {
structure.platforms.push(value);
} else {
structure[key] = value;
}
}
const capitalize = word => `${word[0].toUpperCase()}${word.slice(1)}`
let platformText = capitalize(structure.platforms[0]);
if (structure.platforms.length === 2) {
platformText += ` and ${capitalize(structure.platforms[1])}`;
} else if (structure.platforms.length === 3) {
platformText += `, ${capitalize(structure.platforms[1])} and ${capitalize(structure.platforms[2])}`;
} else {
platformText += "all of your platforms"
}
const messageToSend = `
I am looking to push the following narrative on ${platformText}:
${structure.narrative}
${structure.info.length > 0 ? `Additionally, ${structure.info}` : ""}
You can contact me at ${structure.email}.
`;
const xhr = new XMLHttpRequest();
xhr.open("post", `/order`);
xhr.onload = function () {
try {
const response = JSON.parse(xhr.response);
const succeeded = xhr.status >= 200 &&
xhr.status < 300 &&
response &&
!response.error;
if (succeeded) {
const successElement = document.getElementById("orderSuccess");
const toast = document.getElementById("order-post-success");
bootstrap.Toast.getOrCreateInstance(toast).show();
formElement.style.display = "none";
successElement.style.display = "flex";
} else {
const toast = document.getElementById("order-post-error");
bootstrap.Toast.getOrCreateInstance(toast).show();
}
} catch (error) {
const toast = document.getElementById("order-post-error");
bootstrap.Toast.getOrCreateInstance(toast).show();
}
};
const form = new FormData();
form.append("formkey", formkey());
form.append("message", messageToSend);
xhr.send(form);
}
</script>
{% endblock %}

View File

@ -60,10 +60,6 @@
<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,10 +18,6 @@
<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-2"></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-2"></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-2"></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-2"></i>Undistinguish</button>

View File

@ -14,16 +14,24 @@
{% block Banner %}
<style>
.shop-tabs {
padding-top: 50px;
}
@media (max-width: 768px) {
#shop-banner {
width: 80%;
}
.shop-tabs {
padding-top: 30px;
}
}
.shop-tab {
display: inline-flex;
max-width: 46.6%;
letter-spacing: 3px;
border-radius: 0;
}
.shop-tab.active {
@ -33,12 +41,12 @@
}
</style>
<div class="container-fluid bg-white sticky" style="padding-top: 30px; padding-bottom: 0 !important;">
<div class="container-fluid bg-white sticky shop-tabs" style="padding-bottom: 0 !important;">
<div class="row box-shadow-bottom">
<div class="col">
<div class="col p-0">
<div class="container" style="padding-bottom: 0;">
<div class="row box-shadow-bottom bg-white pt-3" style="justify-content: center;">
<a class="btn btn-primary btn-block m-0 mr-3 shop-tab active" href="/shop">
<div class="row box-shadow-bottom bg-white" style="justify-content: center;">
<a class="btn btn-primary btn-block m-0 shop-tab active" href="/shop">
<span class="mr-auto ml-auto"><i class="fas fa-gift mr-2"></i>AWARDS</span>
</a>
<a class="btn btn-primary btn-block m-0 shop-tab" href="/hats">

View File

@ -709,7 +709,6 @@
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.agendaposter and p.sub != 'chudrama' %}agendaposter{% endif %}">
<a {% if p.author.rainbow %}class="rainbow-text"{% endif %} {% 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>
@ -717,7 +716,6 @@
{% else %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.agendaposter and p.sub != 'chudrama' %}agendaposter{% endif %} {% if p.author.rainbow %}rainbow-text{% 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

@ -196,7 +196,6 @@
<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{% endif %} stretched-link {% if p.author.agendaposter and p.sub != 'chudrama' %}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>
@ -422,9 +421,6 @@
{% 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

@ -85,7 +85,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()" onchange="updateCategories()" {% if sub %}value="{{sub}}"{% endif %} placeholder="{{hole_placeholder}}">
<input list="subs" autocomplete="off" id='sub' class="form-control" form="submitform" name="sub" oninput="savetext()" {% if sub %}value="{{sub}}"{% endif %} placeholder="{{hole_placeholder}}">
<datalist id="subs">
{% for s in SUBS %}
<option value="{{s}}"></option>
@ -94,11 +94,6 @@
</div>
{% 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,6 +1,6 @@
{%-
set CACHE_VER = {
'css/main.css': 4031,
'css/main.css': 4032,
'css/catalog.css': 4007,
'css/4chan.css': 4007,
'css/classic.css': 4030,
@ -17,7 +17,6 @@ set CACHE_VER = {
'js/award_modal.js': 4001,
'js/bootstrap.js': 4006,
'js/category_modal.js': 4000,
'js/comments_admin.js': 4000,
'js/comments_v.js': 4002,
'js/submission_listing.js': 4000,
@ -26,7 +25,7 @@ set CACHE_VER = {
'js/lottery.js': 4000,
'js/marked.js': 4006,
'js/search.js': 4000,
'js/submit.js': 4000,
'js/submit.js': 4001,
'js/userpage.js': 4000,
'js/userpage_v.js': 4002,
'js/lozad.js': 4000,

View File

@ -3,7 +3,3 @@
{{ 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

@ -1,10 +0,0 @@
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;

View File

@ -1,7 +1,6 @@
alter table alts add column created_utc int;
alter table award_relationships add column created_utc int;
alter table badge_defs add column created_utc int;
alter table category add column created_utc int;
alter table oauth_apps add column created_utc int;
alter table client_auths add column created_utc int;
alter table banneddomains add column created_utc int;