diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py
index e2ec233f6..04c312f70 100644
--- a/files/classes/mod_logs.py
+++ b/files/classes/mod_logs.py
@@ -153,6 +153,11 @@ ACTIONTYPES={
"icon": "fa-balance-scale",
"color": "bg-muted",
},
+ "change_sidebar": {
+ "str": "changed the sidebar",
+ "icon": "fa-columns",
+ "color": "bg-muted",
+ },
"ban_user":{
"str":'banned user {self.target_link}',
"icon":"fa-user-slash",
@@ -291,6 +296,11 @@ ACTIONTYPES2={
"icon": "fa-balance-scale",
"color": "bg-muted",
},
+ "change_sidebar": {
+ "str": "changed the sidebar",
+ "icon": "fa-columns",
+ "color": "bg-muted",
+ },
"ban_user":{
"str":'banned user {self.target_link}',
"icon":"fa-user-slash",
diff --git a/files/classes/submission.py b/files/classes/submission.py
index 5b2dea18a..7f88a0e52 100644
--- a/files/classes/submission.py
+++ b/files/classes/submission.py
@@ -213,6 +213,7 @@ class Submission(Base):
@property
@lazy
def domain(self):
+ if not self.url: return None
if self.url.startswith('/'): return site
domain = urlparse(self.url).netloc
if domain.startswith("www."): domain = domain.split("www.")[1]
diff --git a/files/helpers/markdown.py b/files/helpers/markdown.py
index aead81860..7ce47e8fc 100644
--- a/files/helpers/markdown.py
+++ b/files/helpers/markdown.py
@@ -118,8 +118,28 @@ class Renderer(HTMLRenderer):
class Renderer2(HTMLRenderer):
def __init__(self, **kwargs):
- super().__init__(UserMention2)
+ super().__init__(UserMention2,
+ UserMention,
+ SubMention,
+ RedditorMention,
+ SubMention2,
+ RedditorMention2)
for i in kwargs: self.__dict__[i] = kwargs[i]
+ def render_user_mention2(self, token):
+ return f'@{token.target}'
+
def render_user_mention(self, token):
- return f'
@{token.target}'
\ No newline at end of file
+ space = token.target[0]
+ target = token.target[1]
+ return f"{space}@{target}"
+
+ def render_sub_mention(self, token):
+ space = token.target[0]
+ target = token.target[1]
+ return f"{space}r/{target}"
+
+ def render_redditor_mention(self, token):
+ space = token.target[0]
+ target = token.target[1]
+ return f"{space}u/{target}"
\ No newline at end of file
diff --git a/files/routes/admin.py b/files/routes/admin.py
index d167991ec..80dc28bf3 100644
--- a/files/routes/admin.py
+++ b/files/routes/admin.py
@@ -218,39 +218,39 @@ def monthly(v):
return {"message": "Monthly coins granted"}
-@app.get('/admin/rules')
+@app.get('/admin/sidebar')
@admin_level_required(2)
-def get_rules(v):
+def get_sidebar(v):
try:
- with open(f'rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
+ with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r') as f: sidebar = f.read()
except Exception:
- rules = None
+ sidebar = None
- return render_template('admin/rules.html', v=v, rules=rules)
+ return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
-@app.post('/admin/rules')
+@app.post('/admin/sidebar')
@limiter.limit("1/second")
@admin_level_required(2)
@validate_formkey
-def post_rules(v):
+def post_sidebar(v):
- text = request.values.get('rules', '').strip()
+ text = request.values.get('sidebar', '').strip()
- with open(f'rules_{SITE_NAME}.html', 'w+') as f: f.write(text)
+ with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+') as f: f.write(text)
- with open(f'rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
+ with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r') as f: sidebar = f.read()
ma = ModAction(
- kind="change_rules",
+ kind="change_sidebar",
user_id=v.id,
)
g.db.add(ma)
g.db.commit()
- return render_template('admin/rules.html', v=v, rules=rules)
+ return render_template('admin/sidebar.html', v=v, sidebar=sidebar)
@app.get("/admin/shadowbanned")
@@ -626,6 +626,8 @@ def admin_removed_comments(v):
def agendaposter(user_id, v):
user = g.db.query(User).filter_by(id=user_id).first()
+ if user.username == '911roofer': abort(403)
+
expiry = request.values.get("days", 0)
if expiry:
expiry = float(expiry)
diff --git a/files/routes/awards.py b/files/routes/awards.py
index dce01b509..f4b2fd60d 100644
--- a/files/routes/awards.py
+++ b/files/routes/awards.py
@@ -259,6 +259,7 @@ def award_post(pid, v):
else: post.stickied_utc = t
g.db.add(post)
elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter_expires_utc == 0):
+ if author.username == "911roofer": abort(403)
if author.agendaposter_expires_utc and time.time() < author.agendaposter_expires_utc: author.agendaposter_expires_utc += 86400
else: author.agendaposter_expires_utc = time.time() + 86400
@@ -435,6 +436,7 @@ def award_comment(cid, v):
else: c.is_pinned_utc = t
g.db.add(c)
elif kind == "agendaposter" and not (author.agendaposter and author.agendaposter_expires_utc == 0):
+ if author.username == "911roofer": abort(403)
if author.agendaposter_expires_utc and time.time() < author.agendaposter_expires_utc: author.agendaposter_expires_utc += 86400
else: author.agendaposter_expires_utc = time.time() + 86400
diff --git a/files/routes/discord.py b/files/routes/discord.py
index daa019baa..90757270f 100644
--- a/files/routes/discord.py
+++ b/files/routes/discord.py
@@ -17,7 +17,7 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
@auth_required
def join_discord(v):
- if v.is_suspended != 0 and v.admin_level == 0: return {"error": "Banned users cannot join the discord server!"}
+ if v.is_banned and not v.unban_utc: return {"error": "Permabanned users cannot join the discord server!"}
if SITE_NAME == 'Drama' and v.admin_level == 0 and v.patron == 0 and v.truecoins < 150: return f"You must receive 150 upvotes/downvotes from other users before being able to join the Discord server."
diff --git a/files/routes/posts.py b/files/routes/posts.py
index c69d0da01..9842ca830 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -590,10 +590,12 @@ def thumbnail_thread(pid):
post = db.query(Submission).filter_by(id=pid).first()
- if not post:
+ if not post or not post.url:
time.sleep(5)
post = db.query(Submission).filter_by(id=pid).first()
+ if not post or not post.url: return
+
fetch_url = post.url
if fetch_url.startswith('/'): fetch_url = f"https://{site}{fetch_url}"
diff --git a/files/routes/static.py b/files/routes/static.py
index f65b93048..3a7f0d386 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -26,20 +26,15 @@ def emojis(v):
else: template = 'CHRISTMAS/'
return render_template(f"{template}emojis.html", v=v, emojis=emojis)
-@app.get('/rules')
+@app.get('/sidebar')
@auth_desired
-def static_rules(v):
+def sidebar(v):
- if not path.exists(f'rules_{site_name}.html'):
- if v and v.admin_level > 1:
- return render_template('norules.html', v=v)
- else:
- abort(404)
+ if not path.exists(f'files/templates/sidebar_{site_name}.html'): abort(404)
- with open(f'rules_{site_name}.html', 'r') as f:
- rules = f.read()
+ with open(f'files/templates/sidebar_{site_name}.html', 'r') as f: sidebar = f.read()
- return render_template('rules.html', rules=rules, v=v)
+ return render_template('sidebar.html', sidebar=sidebar, v=v)
@app.get("/stats")
diff --git a/files/routes/users.py b/files/routes/users.py
index 6fe3bc2c8..58d8e594e 100644
--- a/files/routes/users.py
+++ b/files/routes/users.py
@@ -741,7 +741,7 @@ def u_username_comments(username, v=None):
return render_template(f"{template}userpage_blocked.html", u=u, v=v)
- page = int(request.values.get("page", "1"))
+ page = max(int(request.values.get("page", "1")), 1)
sort=request.values.get("sort","new")
t=request.values.get("t","all")
diff --git a/files/templates/CHRISTMAS/sidebars/HomeSidebar.html b/files/templates/CHRISTMAS/sidebars/HomeSidebar.html
index 5a7d285bb..75955a30c 100644
--- a/files/templates/CHRISTMAS/sidebars/HomeSidebar.html
+++ b/files/templates/CHRISTMAS/sidebars/HomeSidebar.html
@@ -4,59 +4,59 @@
set banner = [
{
'username': 'Bartholomew_1',
- 'image': '/static/assets/images/banners/1.webp?a=1'
+ 'image': '1'
},
{
'username': 'Yui',
- 'image': '/static/assets/images/banners/2.webp?a=1'
+ 'image': '2'
},
{
'username': 'Bartholomew_1',
- 'image': '/static/assets/images/banners/3.webp?a=1'
+ 'image': '3'
},
{
'username': 'chiobu',
- 'image': '/static/assets/images/banners/4.webp?a=1'
+ 'image': '4'
},
{
'username': 'chiobu',
- 'image': '/static/assets/images/banners/5.webp?a=1'
+ 'image': '5'
},
{
'username': 'geese_suck',
- 'image': '/static/assets/images/banners/6.webp?a=1'
+ 'image': '6'
},
{
'username': 'Bartholomew_1',
- 'image': '/static/assets/images/banners/7.webp?a=1'
+ 'image': '7'
},
{
'username': 'drama_enthusiast',
- 'image': '/static/assets/images/banners/8.webp?a=1'
+ 'image': '8'
},
{
'username': 'dramarama',
- 'image': '/static/assets/images/banners/9.webp?a=1'
+ 'image': '9'
},
{
'username': 'geese_suck',
- 'image': '/static/assets/images/banners/10.webp?a=1'
+ 'image': '10'
},
{
'username': 'ThreeLetterAgent',
- 'image': '/static/assets/images/banners/11.webp?a=1'
+ 'image': '11'
},
{
'username': 'geese_suck',
- 'image': '/static/assets/images/banners/12.webp?a=1'
+ 'image': '12'
},
{
'username': 'geese_suck',
- 'image': '/static/assets/images/banners/13.webp?a=1'
+ 'image': '13'
},
{
'username': 'geese_suck',
- 'image': '/static/assets/images/banners/14.webp?a=1'
+ 'image': '14'
}
]
%}
@@ -119,7 +119,7 @@
Two accounts controlled by different people should have most uniqueness percentages at or above 70-80%
A sockpuppet account will have its uniqueness percentages significantly lower.
-Link Accounts +Link Accounts