Merge branch 'frost' into blitzen
This commit is contained in:
commit
8d53042e2a
12 changed files with 98 additions and 47 deletions
BIN
chart.png
BIN
chart.png
Binary file not shown.
Before Width: | Height: | Size: 77 KiB |
|
@ -33,7 +33,7 @@ app.config['DATABASE_URL'] = environ.get("DATABASE_URL")
|
||||||
app.config['SECRET_KEY'] = environ.get('MASTER_KEY')
|
app.config['SECRET_KEY'] = environ.get('MASTER_KEY')
|
||||||
app.config["SERVER_NAME"] = environ.get("DOMAIN").strip()
|
app.config["SERVER_NAME"] = environ.get("DOMAIN").strip()
|
||||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 86400
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 86400
|
||||||
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("DOMAIN")
|
app.config["SESSION_COOKIE_NAME"] = f'session_{environ.get("DOMAIN")}'.strip().lower()
|
||||||
app.config["VERSION"] = "1.0.0"
|
app.config["VERSION"] = "1.0.0"
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 8 * 1024 * 1024
|
app.config['MAX_CONTENT_LENGTH'] = 8 * 1024 * 1024
|
||||||
app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1)))
|
app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1)))
|
||||||
|
|
|
@ -215,12 +215,15 @@ document.onpaste = function(event) {
|
||||||
var fullname = focused.dataset.fullname;
|
var fullname = focused.dataset.fullname;
|
||||||
f=document.getElementById('file-upload-reply-' + fullname);
|
f=document.getElementById('file-upload-reply-' + fullname);
|
||||||
files = event.clipboardData.files
|
files = event.clipboardData.files
|
||||||
filename = files[0].name.toLowerCase()
|
try {
|
||||||
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".gif"))
|
filename = files[0].name.toLowerCase()
|
||||||
{
|
if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".gif"))
|
||||||
f.files = files;
|
{
|
||||||
document.getElementById('filename-show-reply-' + fullname).textContent = filename;
|
f.files = files;
|
||||||
|
document.getElementById('filename-show-reply-' + fullname).textContent = filename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch(e) {}
|
||||||
}
|
}
|
||||||
else if (focused.id.includes('comment-edit-body-')) {
|
else if (focused.id.includes('comment-edit-body-')) {
|
||||||
var id = focused.dataset.id;
|
var id = focused.dataset.id;
|
||||||
|
|
|
@ -860,8 +860,8 @@ function loadEmojis(form) {
|
||||||
let search_bar = document.getElementById("emoji_search");
|
let search_bar = document.getElementById("emoji_search");
|
||||||
let search_container = document.getElementById('emoji-tab-search')
|
let search_container = document.getElementById('emoji-tab-search')
|
||||||
|
|
||||||
let container = document.getElementById(EMOJI_BOX_ID)
|
let fav = document.getElementById(EMOJI_BOX_ID)
|
||||||
container.setAttribute(EMOJI_FORM_DESTINATION_ATTR, form)
|
fav.setAttribute(EMOJI_FORM_DESTINATION_ATTR, form)
|
||||||
|
|
||||||
const commentBox = document.getElementById(form);
|
const commentBox = document.getElementById(form);
|
||||||
commentBox.setAttribute(TEXTAREA_POS_ATTR, commentBox.selectionStart);
|
commentBox.setAttribute(TEXTAREA_POS_ATTR, commentBox.selectionStart);
|
||||||
|
|
|
@ -6,31 +6,37 @@ from .markdown import *
|
||||||
from .sanitize import *
|
from .sanitize import *
|
||||||
from .const import *
|
from .const import *
|
||||||
|
|
||||||
def send_repeatable_notification(uid, text, autojanny=False):
|
def create_comment(text, autojanny=False):
|
||||||
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
||||||
|
text_html = sanitize(CustomRenderer().render(mistletoe.Document(text)))
|
||||||
|
new_comment = Comment(author_id=author_id,
|
||||||
|
parent_submission=None,
|
||||||
|
distinguish_level=6,
|
||||||
|
body=text,
|
||||||
|
created_utc=0,
|
||||||
|
body_html=text_html)
|
||||||
|
g.db.add(new_comment)
|
||||||
|
g.db.flush()
|
||||||
|
return new_comment.id
|
||||||
|
|
||||||
|
def send_repeatable_notification(uid, text, autojanny=False):
|
||||||
|
|
||||||
if autojanny: author_id = AUTOJANNY_ID
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
else: author_id = NOTIFICATIONS_ID
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
existing_comment = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
||||||
if existing:
|
|
||||||
existing2 = g.db.query(Notification.id).filter_by(user_id=uid, comment_id=existing[0]).first()
|
|
||||||
if existing2:
|
|
||||||
text_html = sanitize(CustomRenderer().render(mistletoe.Document(text)))
|
|
||||||
new_comment = Comment(author_id=author_id,
|
|
||||||
parent_submission=None,
|
|
||||||
distinguish_level=6,
|
|
||||||
body=text,
|
|
||||||
body_html=text_html,
|
|
||||||
created_utc=0)
|
|
||||||
g.db.add(new_comment)
|
|
||||||
g.db.flush()
|
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=uid)
|
|
||||||
g.db.add(notif)
|
|
||||||
return
|
|
||||||
|
|
||||||
send_notification(uid, text, autojanny)
|
if existing_comment:
|
||||||
|
cid = existing_comment[0]
|
||||||
|
existing_notif = g.db.query(Notification.id).filter_by(user_id=uid, comment_id=cid).first()
|
||||||
|
if existing_notif: cid = create_comment(text, autojanny)
|
||||||
|
else: cid = create_comment(text, autojanny)
|
||||||
|
|
||||||
|
notif = Notification(comment_id=cid, user_id=uid)
|
||||||
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
def send_notification(uid, text, autojanny=False):
|
def send_notification(uid, text, autojanny=False):
|
||||||
|
@ -41,27 +47,14 @@ def send_notification(uid, text, autojanny=False):
|
||||||
|
|
||||||
def notif_comment(text, autojanny=False):
|
def notif_comment(text, autojanny=False):
|
||||||
|
|
||||||
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
|
||||||
|
|
||||||
if autojanny: author_id = AUTOJANNY_ID
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
else: author_id = NOTIFICATIONS_ID
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
||||||
|
|
||||||
if existing: cid = existing[0]
|
if existing: return existing[0]
|
||||||
else:
|
else: return create_comment(text, autojanny)
|
||||||
text_html = sanitize(CustomRenderer().render(mistletoe.Document(text)))
|
|
||||||
new_comment = Comment(author_id=author_id,
|
|
||||||
parent_submission=None,
|
|
||||||
distinguish_level=6,
|
|
||||||
body=text,
|
|
||||||
body_html=text_html,
|
|
||||||
created_utc=0)
|
|
||||||
g.db.add(new_comment)
|
|
||||||
g.db.flush()
|
|
||||||
cid = new_comment.id
|
|
||||||
|
|
||||||
return cid
|
|
||||||
|
|
||||||
def add_notif(cid, uid):
|
def add_notif(cid, uid):
|
||||||
existing = g.db.query(Notification.id).filter_by(comment_id=cid, user_id=uid).first()
|
existing = g.db.query(Notification.id).filter_by(comment_id=cid, user_id=uid).first()
|
||||||
|
@ -69,6 +62,7 @@ def add_notif(cid, uid):
|
||||||
notif = Notification(comment_id=cid, user_id=uid)
|
notif = Notification(comment_id=cid, user_id=uid)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
def send_admin(vid, text):
|
def send_admin(vid, text):
|
||||||
|
|
||||||
text_html = Renderer().render(mistletoe.Document(text))
|
text_html = Renderer().render(mistletoe.Document(text))
|
||||||
|
@ -89,6 +83,7 @@ def send_admin(vid, text):
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
def NOTIFY_USERS(text, vid):
|
def NOTIFY_USERS(text, vid):
|
||||||
text = text.lower()
|
text = text.lower()
|
||||||
notify_users = set()
|
notify_users = set()
|
||||||
|
|
|
@ -23,6 +23,15 @@ if SITE_NAME == 'PCM': cc = "splash mountain"
|
||||||
else: cc = "country club"
|
else: cc = "country club"
|
||||||
month = datetime.now().strftime('%B')
|
month = datetime.now().strftime('%B')
|
||||||
|
|
||||||
|
@app.get("/admin/grassed")
|
||||||
|
@admin_level_required(3)
|
||||||
|
def grassed(v):
|
||||||
|
users = g.db.query(User).filter(User.ban_reason.like('grass award used by @%')).all()
|
||||||
|
|
||||||
|
if not v or v.oldsite: template = ''
|
||||||
|
else: template = 'CHRISTMAS/'
|
||||||
|
return render_template(f"{template}grassed.html", v=v, users=users)
|
||||||
|
|
||||||
@app.get("/distribute/<cid>")
|
@app.get("/distribute/<cid>")
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
def distribute(v, cid):
|
def distribute(v, cid):
|
||||||
|
@ -262,7 +271,6 @@ def shadowbanned(v):
|
||||||
else: template = 'CHRISTMAS/'
|
else: template = 'CHRISTMAS/'
|
||||||
return render_template(f"{template}shadowbanned.html", v=v, users=users)
|
return render_template(f"{template}shadowbanned.html", v=v, users=users)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/admin/agendaposters")
|
@app.get("/admin/agendaposters")
|
||||||
@auth_required
|
@auth_required
|
||||||
def agendaposters(v):
|
def agendaposters(v):
|
||||||
|
@ -887,6 +895,7 @@ def unban_user(user_id, v):
|
||||||
user.is_banned = 0
|
user.is_banned = 0
|
||||||
user.unban_utc = 0
|
user.unban_utc = 0
|
||||||
user.ban_evade = 0
|
user.ban_evade = 0
|
||||||
|
user.ban_reason = None
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
if request.values.get("alts", ""):
|
if request.values.get("alts", ""):
|
||||||
|
|
|
@ -240,6 +240,7 @@ def award_post(pid, v):
|
||||||
author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}"
|
author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}"
|
||||||
link = f"[this post]({post.permalink})"
|
link = f"[this post]({post.permalink})"
|
||||||
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
||||||
|
send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award on [{post.shortlink}]({post.shortlink})")
|
||||||
elif kind == "pin":
|
elif kind == "pin":
|
||||||
if post.stickied and post.stickied.startswith("t:"): t = int(post.stickied[2:]) + 3600
|
if post.stickied and post.stickied.startswith("t:"): t = int(post.stickied[2:]) + 3600
|
||||||
else: t = int(time.time()) + 3600
|
else: t = int(time.time()) + 3600
|
||||||
|
@ -411,6 +412,7 @@ def award_comment(cid, v):
|
||||||
author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}"
|
author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}"
|
||||||
link = f"[this comment]({c.permalink})"
|
link = f"[this comment]({c.permalink})"
|
||||||
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
||||||
|
send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award on [{c.shortlink}]({c.shortlink})")
|
||||||
elif kind == "pin":
|
elif kind == "pin":
|
||||||
if c.is_pinned and c.is_pinned.startswith("t:"): t = int(c.is_pinned[2:]) + 3600
|
if c.is_pinned and c.is_pinned.startswith("t:"): t = int(c.is_pinned[2:]) + 3600
|
||||||
else: t = int(time.time()) + 3600
|
else: t = int(time.time()) + 3600
|
||||||
|
|
|
@ -104,10 +104,10 @@ def cached_chart(days):
|
||||||
days = int((nowstamp - firstsignup) / 86400)
|
days = int((nowstamp - firstsignup) / 86400)
|
||||||
|
|
||||||
if days > 31:
|
if days > 31:
|
||||||
file = "/weekly_chart.png"
|
file = "/weekly_chart.webp"
|
||||||
day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(31)][1:]
|
day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(31)][1:]
|
||||||
else:
|
else:
|
||||||
file = "/daily_chart.png"
|
file = "/daily_chart.webp"
|
||||||
day_cutoffs = [today_cutoff - 86400 * i for i in range(31)][1:]
|
day_cutoffs = [today_cutoff - 86400 * i for i in range(31)][1:]
|
||||||
|
|
||||||
day_cutoffs.insert(0, calendar.timegm(now))
|
day_cutoffs.insert(0, calendar.timegm(now))
|
||||||
|
|
21
files/templates/CHRISTMAS/grassed.html
Normal file
21
files/templates/CHRISTMAS/grassed.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends "CHRISTMAS/settings2.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<table class="table table-striped mb-5">
|
||||||
|
<thead class="bg-primary text-white">
|
||||||
|
<tr>
|
||||||
|
<th style="font-weight:bold;">#</th>
|
||||||
|
<th style="font-weight:bold;">Name</th>
|
||||||
|
<th style="font-weight:bold;">Grasser</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for user in users %}
|
||||||
|
<tr>
|
||||||
|
<td style="font-weight:bold;">{{loop.index}}</td>
|
||||||
|
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}"><img loading="lazy" src="/uid/{{user.id}}/pic" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a></td>
|
||||||
|
<td style="font-weight:bold;">{{user.ban_reason.split('by ')[1]}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -807,7 +807,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<script src="/assets/js/marked.js?v=191"></script>
|
<script src="/assets/js/marked.js?v=191"></script>
|
||||||
<script src="/assets/js/comments_v.js?v=191"></script>
|
<script src="/assets/js/comments_v.js?v=192"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script src="/assets/js/clipboard.js?v=190"></script>
|
<script src="/assets/js/clipboard.js?v=190"></script>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/js/emoji_modal.js?v=195"></script>
|
<script src="/assets/js/emoji_modal.js?v=196"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
a.emojitab {
|
a.emojitab {
|
||||||
|
|
21
files/templates/grassed.html
Normal file
21
files/templates/grassed.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends "settings2.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<table class="table table-striped mb-5">
|
||||||
|
<thead class="bg-primary text-white">
|
||||||
|
<tr>
|
||||||
|
<th style="font-weight:bold;">#</th>
|
||||||
|
<th style="font-weight:bold;">Name</th>
|
||||||
|
<th style="font-weight:bold;">Grasser</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for user in users %}
|
||||||
|
<tr>
|
||||||
|
<td style="font-weight:bold;">{{loop.index}}</td>
|
||||||
|
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}"><img loading="lazy" src="/uid/{{user.id}}/pic" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a></td>
|
||||||
|
<td style="font-weight:bold;">{{user.ban_reason.split('by ')[1]}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue