From 1ed3410beec970d0a4b0c5cf5d91712dd9452a73 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 12 Jan 2022 03:46:16 +0200 Subject: [PATCH] bb --- files/helpers/const.py | 4 ---- files/routes/static.py | 13 +++++++++++-- files/templates/marseys.html | 16 +++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 112c96ad5e..0c3389809c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -6,8 +6,6 @@ from json import loads SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() -import json - with open("files/assets/js/emoji_modal.js", 'r') as file: marseytext = file.read().split('emojis: ')[1].split('cops police"},')[0] + '"}}' result = loads(marseytext) @@ -19,8 +17,6 @@ for k, val in result.items(): del result -marseys = dict(sorted(marseys.items(), key=lambda x: x[1])) - AJ_REPLACEMENTS = { ' your ': " you're ", ' to ': " too ", diff --git a/files/routes/static.py b/files/routes/static.py index 4b6e9884d5..69cd4d107d 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -18,9 +18,18 @@ def privacy(v): return render_template("privacy.html", v=v) @app.get("/marseys") -@auth_required +@admin_level_required(3) def emojis(v): - return render_template("marseys.html", v=v, marseys=marseys.items()) + sorted_marseys = [] + for k, val in marseys.items(): + count = g.db.query(Comment.id).where(Comment.body.like(f'%:{k}:%')).count() + sorted_marseys.append((k, val, count)) + + sorted_marseys = sorted(sorted_marseys, key=lambda x: x[2]) + + text = render_template("marseys.html", v=v, marseys=sorted_marseys) + with open(f'files/templates/marseys.html', 'w+') as f: f.write(text) + return text @app.get("/terms") @auth_required diff --git a/files/templates/marseys.html b/files/templates/marseys.html index fce0e51718..d8b333c173 100644 --- a/files/templates/marseys.html +++ b/files/templates/marseys.html @@ -1,5 +1,3 @@ -{% extends "default.html" %} -{% block content %}
 
 	
@@ -10,19 +8,19 @@
 		#
 		Name
 		Marsey
+		Usage
 		Author
 	
 
 
-{% for marsey, author in marseys %}
+{% for k in marseys %}
 	
 		{{loop.index}}
-		{{marsey}}
-		:{{marsey}}:
-		{% if author in ('anton-d','unknown') %}{{author}}{% else %}@{{author}}'s profile picture{{author}}{% endif %}
+		{{k[0]}}
+		:{{k[0]}}:
+		{{k[2]}}
+		{% if k[1] in ('anton-d','unknown') %}{{k[1]}}{% else %}@{{k[1]}}'s profile picture{{k[1]}}{% endif %}
 	
 {% endfor %}
 
-
-
-{% endblock %}
\ No newline at end of file
+
\ No newline at end of file