xvc
This commit is contained in:
parent
c496fca8cc
commit
4ef444711a
4 changed files with 83 additions and 1 deletions
|
@ -22,6 +22,40 @@ GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
|
|||
|
||||
month = datetime.now().strftime('%B')
|
||||
|
||||
if SITE_NAME == 'PCM':
|
||||
@app.get('/admin/sidebar')
|
||||
@admin_level_required(3)
|
||||
def get_sidebar(v):
|
||||
|
||||
try:
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||
except:
|
||||
sidebar = None
|
||||
|
||||
return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
|
||||
|
||||
|
||||
@app.post('/admin/sidebar')
|
||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||
@admin_level_required(3)
|
||||
def post_sidebar(v):
|
||||
|
||||
text = request.values.get('sidebar', '').strip()
|
||||
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
|
||||
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||
|
||||
ma = ModAction(
|
||||
kind="change_sidebar",
|
||||
user_id=v.id,
|
||||
)
|
||||
g.db.add(ma)
|
||||
|
||||
g.db.commit()
|
||||
|
||||
return render_template('admin/sidebar.html', v=v, sidebar=sidebar, msg='Sidebar edited successfully!')
|
||||
|
||||
|
||||
@app.post("/@<username>/make_admin")
|
||||
@limiter.limit("1/second;5/day")
|
||||
|
|
|
@ -862,7 +862,7 @@ def submit_post(v, sub=None):
|
|||
|
||||
sub = request.values.get("sub")
|
||||
|
||||
if sub:
|
||||
if sub and sub != 'none':
|
||||
sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none()
|
||||
if not sub: abort(404)
|
||||
sub = sub[0]
|
||||
|
|
42
files/templates/admin/sidebar.html
Normal file
42
files/templates/admin/sidebar.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block pagetitle %}Edit {{SITE_NAME}} sidebar{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if msg %}
|
||||
<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
|
||||
<span>
|
||||
{{msg}}
|
||||
</span>
|
||||
<button class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row my-5">
|
||||
<div class="col col-md-8">
|
||||
<div class="settings">
|
||||
<div id="description">
|
||||
<h2>Edit Sidebar</h2>
|
||||
<br>
|
||||
</div>
|
||||
<div class="body d-lg-flex">
|
||||
<div class="w-lg-100">
|
||||
<form id="profile-settings" action="/admin/sidebar" method="post">
|
||||
<input autocomplete="off" type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<textarea autocomplete="off" maxlength="10000" class="form-control rounded" id="bio-text" aria-label="With textarea" placeholder="Enter sidebar here..." rows="50" name="sidebar" form="profile-settings">{% if sidebar %}{{sidebar}}{% endif %}</textarea>
|
||||
|
||||
<div class="d-flex mt-2">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" value="Save">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -88,6 +88,12 @@
|
|||
{% set SUBS = toomuch_subs %}
|
||||
{% endif %}
|
||||
|
||||
{% if SITE_NAME == 'PCM' %}
|
||||
<option value="none" selected>
|
||||
None
|
||||
</option>
|
||||
{% endif %}
|
||||
|
||||
{% for s in SUBS %}
|
||||
<option value="{{s}}" {% if sub and sub.name == s %}selected{% endif %}>
|
||||
/s/{{s}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue