forked from rDrama/rDrama
remove categories
parent
f7727f1029
commit
f54791cc4c
|
@ -4625,13 +4625,6 @@ span.green {
|
||||||
.patron[style="background-color:#FFFFFF;"] {
|
.patron[style="background-color:#FFFFFF;"] {
|
||||||
color: black !important;
|
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 {
|
.container, .container-fluid {
|
||||||
background-color: var(--background) !important;
|
background-color: var(--background) !important;
|
||||||
}
|
}
|
||||||
|
@ -5684,19 +5677,6 @@ g {
|
||||||
border-radius:.35rem;
|
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 Awesome ------- */
|
||||||
@font-face{
|
@font-face{
|
||||||
font-family:"Font Awesome 6 Pro";
|
font-family:"Font Awesome 6 Pro";
|
||||||
|
@ -6070,7 +6050,7 @@ g {
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 767.98px) {
|
@media (max-width: 767.98px) {
|
||||||
.pronouns, .patron, .post--category-tag, .mod {
|
.pronouns, .patron, .mod {
|
||||||
padding: 2px 5px !important;
|
padding: 2px 5px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
|
@ -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) => {
|
document.addEventListener('keydown', (e) => {
|
||||||
if(!((e.ctrlKey || e.metaKey) && e.key === "Enter"))
|
if(!((e.ctrlKey || e.metaKey) && e.key === "Enter"))
|
||||||
return;
|
return;
|
||||||
|
@ -215,5 +189,4 @@ document.addEventListener('keydown', (e) => {
|
||||||
submitButton.click();
|
submitButton.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
checkRepost();
|
checkRepost();
|
||||||
updateCategories();
|
|
|
@ -8,7 +8,6 @@ from .badges import *
|
||||||
from .userblock import *
|
from .userblock import *
|
||||||
from .submission import *
|
from .submission import *
|
||||||
from .votes import *
|
from .votes import *
|
||||||
from .category import *
|
|
||||||
from .domains import *
|
from .domains import *
|
||||||
from .subscriptions import *
|
from .subscriptions import *
|
||||||
from files.__main__ import app
|
from files.__main__ import app
|
||||||
|
|
|
@ -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
|
|
|
@ -314,11 +314,6 @@ ACTIONTYPES = {
|
||||||
"icon": 'fa-thumbtack fa-rotate--45',
|
"icon": 'fa-thumbtack fa-rotate--45',
|
||||||
"color": 'bg-success'
|
"color": 'bg-success'
|
||||||
},
|
},
|
||||||
'post_recategorize': {
|
|
||||||
"str": 'changed category of {self.target_link}',
|
|
||||||
"icon": 'fa-grid',
|
|
||||||
"color": 'bg-primary'
|
|
||||||
},
|
|
||||||
'purge_cache': {
|
'purge_cache': {
|
||||||
"str": 'purged cache',
|
"str": 'purged cache',
|
||||||
"icon": 'fa-memory',
|
"icon": 'fa-memory',
|
||||||
|
|
|
@ -53,7 +53,6 @@ class Submission(Base):
|
||||||
body = Column(String)
|
body = Column(String)
|
||||||
body_html = Column(String)
|
body_html = Column(String)
|
||||||
flair = Column(String)
|
flair = Column(String)
|
||||||
category_id = Column(Integer, ForeignKey("category.id"))
|
|
||||||
ban_reason = Column(String)
|
ban_reason = Column(String)
|
||||||
embed_url = Column(String)
|
embed_url = Column(String)
|
||||||
new = Column(Boolean)
|
new = Column(Boolean)
|
||||||
|
@ -67,7 +66,6 @@ class Submission(Base):
|
||||||
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", back_populates="post")
|
comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", back_populates="post")
|
||||||
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)")
|
subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)")
|
||||||
options = relationship("SubmissionOption", order_by="SubmissionOption.id")
|
options = relationship("SubmissionOption", order_by="SubmissionOption.id")
|
||||||
category = relationship("Category", primaryjoin="Submission.category_id==Category.id")
|
|
||||||
|
|
||||||
bump_utc = deferred(Column(Integer, server_default=FetchedValue()))
|
bump_utc = deferred(Column(Integer, server_default=FetchedValue()))
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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,
|
'HOLE_CREATE': 0,
|
||||||
'FLAGS_REMOVE': 2,
|
'FLAGS_REMOVE': 2,
|
||||||
'VOTES_VISIBLE': 0,
|
'VOTES_VISIBLE': 0,
|
||||||
|
@ -137,7 +135,6 @@ PERMS = { # Minimum admin_level to perform action.
|
||||||
FEATURES = {
|
FEATURES = {
|
||||||
'PROCOINS': True,
|
'PROCOINS': True,
|
||||||
'AWARDS': True,
|
'AWARDS': True,
|
||||||
'CATEGORIES': False,
|
|
||||||
'CHAT': True,
|
'CHAT': True,
|
||||||
'PINS': True,
|
'PINS': True,
|
||||||
'COUNTRY_CLUB': True,
|
'COUNTRY_CLUB': True,
|
||||||
|
|
|
@ -87,7 +87,6 @@ def sub_inactive_purge_task():
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
to_delete = mods \
|
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(Exile).filter(Exile.sub.in_(names)).all() \
|
||||||
+ g.db.query(SubBlock).filter(SubBlock.sub.in_(names)).all() \
|
+ g.db.query(SubBlock).filter(SubBlock.sub.in_(names)).all() \
|
||||||
+ g.db.query(SubJoin).filter(SubJoin.sub.in_(names)).all() \
|
+ g.db.query(SubJoin).filter(SubJoin.sub.in_(names)).all() \
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from files.classes import *
|
from files.classes import *
|
||||||
from flask import g
|
from flask import g
|
||||||
from sqlalchemy.orm import joinedload
|
|
||||||
|
|
||||||
def get_id(username, v=None, graceful=False):
|
def get_id(username, v=None, graceful=False):
|
||||||
|
|
||||||
|
@ -136,8 +135,6 @@ def get_post(i, v=None, graceful=False):
|
||||||
Submission,
|
Submission,
|
||||||
vt.c.vote_type,
|
vt.c.vote_type,
|
||||||
blocking.c.target_id,
|
blocking.c.target_id,
|
||||||
).options(
|
|
||||||
joinedload(Submission.category)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
post=post.filter(Submission.id == i
|
post=post.filter(Submission.id == i
|
||||||
|
@ -191,8 +188,6 @@ def get_posts(pids, v=None):
|
||||||
blocked.c.target_id,
|
blocked.c.target_id,
|
||||||
).filter(
|
).filter(
|
||||||
Submission.id.in_(pids)
|
Submission.id.in_(pids)
|
||||||
).options(
|
|
||||||
joinedload(Submission.category)
|
|
||||||
).join(
|
).join(
|
||||||
vt, vt.c.submission_id==Submission.id, isouter=True
|
vt, vt.c.submission_id==Submission.id, isouter=True
|
||||||
).join(
|
).join(
|
||||||
|
|
|
@ -1459,86 +1459,6 @@ def admin_toggle_ban_domain(v):
|
||||||
|
|
||||||
return redirect("/admin/banned_domains/")
|
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")
|
@app.post("/admin/nuke_user")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
|
|
|
@ -709,14 +709,6 @@ def submit_post(v, sub=None):
|
||||||
if not sub and HOLE_REQUIRED:
|
if not sub and HOLE_REQUIRED:
|
||||||
return error(f"You must choose a {HOLE_NAME} for your post!")
|
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.is_suspended: return error("You can't perform this action while banned.")
|
||||||
|
|
||||||
torture = (v.agendaposter and not v.marseyawarded and sub != 'chudrama')
|
torture = (v.agendaposter and not v.marseyawarded and sub != 'chudrama')
|
||||||
|
@ -933,7 +925,6 @@ def submit_post(v, sub=None):
|
||||||
title=title[:500],
|
title=title[:500],
|
||||||
title_html=title_html,
|
title_html=title_html,
|
||||||
sub=sub,
|
sub=sub,
|
||||||
category_id=category,
|
|
||||||
ghost=ghost
|
ghost=ghost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1168,42 +1159,6 @@ def toggle_post_nsfw(pid, v):
|
||||||
if post.over_18: return {"message": "Post has been marked as +18!"}
|
if post.over_18: return {"message": "Post has been marked as +18!"}
|
||||||
else: return {"message": "Post has been unmarked 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 = '<none>'
|
|
||||||
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>")
|
@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")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
|
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
|
||||||
|
|
|
@ -435,16 +435,4 @@ def knowledgebase(v, page):
|
||||||
if not os.path.exists('files/templates/' + template_path):
|
if not os.path.exists('files/templates/' + template_path):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
return render_template(template_path, v=v)
|
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)
|
|
|
@ -94,9 +94,6 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/create_hole">Create {{ HOLE_NAME | capitalize }}</a></li>
|
<li><a href="/create_hole">Create {{ HOLE_NAME | capitalize }}</a></li>
|
||||||
<li><a href="/admin/apps">Apps</a></li>
|
<li><a href="/admin/apps">Apps</a></li>
|
||||||
{% if FEATURES['CATEGORIES'] -%}
|
|
||||||
<li><a href="/admin/categories">Categories</a></li>
|
|
||||||
{%- endif %}
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% if v.admin_level > 2 %}
|
{% if v.admin_level > 2 %}
|
||||||
|
|
|
@ -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> </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 '—'|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 %}
|
|
|
@ -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>
|
|
|
@ -756,9 +756,6 @@
|
||||||
{% include "emoji_modal.html" %}
|
{% include "emoji_modal.html" %}
|
||||||
{% if v.admin_level > 1 %}
|
{% if v.admin_level > 1 %}
|
||||||
{% include "ban_modal.html" %}
|
{% include "ban_modal.html" %}
|
||||||
{% if FEATURES['CATEGORIES'] -%}
|
|
||||||
{% include "category_modal.html" %}
|
|
||||||
{%- endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="modal fade" id="deleteCommentModal" tabindex="-1" role="dialog" aria-labelledby="deleteCommentModalTitle" aria-hidden="true">
|
<div class="modal fade" id="deleteCommentModal" tabindex="-1" role="dialog" aria-labelledby="deleteCommentModalTitle" aria-hidden="true">
|
||||||
|
|
|
@ -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>
|
<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 %}
|
{% 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 v.admin_level > 1 %}
|
||||||
{% if "/reported/" in request.path %}
|
{% 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 %}
|
{% 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 %}
|
||||||
|
|
|
@ -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>
|
<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 %}
|
{%- 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="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>
|
<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>
|
||||||
|
|
|
@ -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 %}">
|
<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)}}">
|
<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.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 %}
|
{% 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}}
|
{{p.realtitle(v) | safe}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -717,7 +716,6 @@
|
||||||
{% else %}
|
{% 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 %}">
|
<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.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 %}
|
{% 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}}
|
{{p.realtitle(v) | safe}}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
@ -196,7 +196,6 @@
|
||||||
<h5 class="card-title post-title text-left w-lg-95 mb-0 pb-0 pb-md-1">
|
<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 %}">
|
<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.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 %}
|
{% 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}}
|
{{p.realtitle(v) | safe}}
|
||||||
</a></h5>
|
</a></h5>
|
||||||
|
@ -422,9 +421,6 @@
|
||||||
{% include "report_post_modal.html" %}
|
{% include "report_post_modal.html" %}
|
||||||
{% if v.admin_level > 1 %}
|
{% if v.admin_level > 1 %}
|
||||||
{% include "ban_modal.html" %}
|
{% include "ban_modal.html" %}
|
||||||
{% if FEATURES['CATEGORIES'] -%}
|
|
||||||
{% include "category_modal.html" %}
|
|
||||||
{%- endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "expanded_image_modal.html" %}
|
{% include "expanded_image_modal.html" %}
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
|
|
||||||
<div class="input-group mb2">
|
<div class="input-group mb2">
|
||||||
{%- set hole_placeholder = 'Required' if HOLE_REQUIRED else 'Optional' -%}
|
{%- 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">
|
<datalist id="subs">
|
||||||
{% for s in SUBS %}
|
{% for s in SUBS %}
|
||||||
<option value="{{s}}"></option>
|
<option value="{{s}}"></option>
|
||||||
|
@ -94,11 +94,6 @@
|
||||||
|
|
||||||
</div>
|
</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>
|
<label class='mt-4' for="title">Post Title</label>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{%-
|
{%-
|
||||||
set CACHE_VER = {
|
set CACHE_VER = {
|
||||||
'css/main.css': 4031,
|
'css/main.css': 4032,
|
||||||
'css/catalog.css': 4007,
|
'css/catalog.css': 4007,
|
||||||
'css/4chan.css': 4007,
|
'css/4chan.css': 4007,
|
||||||
'css/classic.css': 4030,
|
'css/classic.css': 4030,
|
||||||
|
@ -17,7 +17,6 @@ set CACHE_VER = {
|
||||||
|
|
||||||
'js/award_modal.js': 4001,
|
'js/award_modal.js': 4001,
|
||||||
'js/bootstrap.js': 4006,
|
'js/bootstrap.js': 4006,
|
||||||
'js/category_modal.js': 4000,
|
|
||||||
'js/comments_admin.js': 4000,
|
'js/comments_admin.js': 4000,
|
||||||
'js/comments_v.js': 4002,
|
'js/comments_v.js': 4002,
|
||||||
'js/submission_listing.js': 4000,
|
'js/submission_listing.js': 4000,
|
||||||
|
@ -26,7 +25,7 @@ set CACHE_VER = {
|
||||||
'js/lottery.js': 4000,
|
'js/lottery.js': 4000,
|
||||||
'js/marked.js': 4006,
|
'js/marked.js': 4006,
|
||||||
'js/search.js': 4000,
|
'js/search.js': 4000,
|
||||||
'js/submit.js': 4000,
|
'js/submit.js': 4001,
|
||||||
'js/userpage.js': 4000,
|
'js/userpage.js': 4000,
|
||||||
'js/userpage_v.js': 4002,
|
'js/userpage_v.js': 4002,
|
||||||
'js/lozad.js': 4000,
|
'js/lozad.js': 4000,
|
||||||
|
|
|
@ -2,8 +2,4 @@
|
||||||
{%- if value != 1 -%}
|
{%- if value != 1 -%}
|
||||||
{{ suffix }}
|
{{ suffix }}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endmacro -%}
|
{%- 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 -%}
|
|
|
@ -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;
|
|
|
@ -1,7 +1,6 @@
|
||||||
alter table alts add column created_utc int;
|
alter table alts add column created_utc int;
|
||||||
alter table award_relationships 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 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 oauth_apps add column created_utc int;
|
||||||
alter table client_auths add column created_utc int;
|
alter table client_auths add column created_utc int;
|
||||||
alter table banneddomains add column created_utc int;
|
alter table banneddomains add column created_utc int;
|
||||||
|
|
Loading…
Reference in New Issue