vxc
This commit is contained in:
parent
12e600028c
commit
9719a0b9ee
6 changed files with 12 additions and 21 deletions
|
@ -6,18 +6,15 @@ from flask import *
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
from flask_limiter import Limiter
|
from flask_limiter import Limiter
|
||||||
from flask_compress import Compress
|
from flask_compress import Compress
|
||||||
from flask_limiter.util import get_remote_address
|
|
||||||
from flask_mail import Mail
|
from flask_mail import Mail
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
import gevent
|
import gevent
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
||||||
import redis
|
import redis
|
||||||
import time
|
import time
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
import faulthandler
|
import faulthandler
|
||||||
import atexit
|
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='templates')
|
app = Flask(__name__, template_folder='templates')
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
|
@ -111,13 +108,6 @@ def after_request(response):
|
||||||
response.headers.add("X-Frame-Options", "deny")
|
response.headers.add("X-Frame-Options", "deny")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
from files.routes import *
|
with open("marsey_count.json", 'r') as f: cache.set("marsey_count", loads(f.read()))
|
||||||
|
|
||||||
def close_running_threads():
|
from files.routes import *
|
||||||
with open("marsey_count.json", 'r') as f: marsey_file = loads(f.read())
|
|
||||||
print(marsey_count['marseylove'])
|
|
||||||
if marsey_file != marsey_count:
|
|
||||||
with open('marsey_count.json', 'w') as f: dump(marsey_count, f)
|
|
||||||
print("Marsey count saved!")
|
|
||||||
stdout.flush()
|
|
||||||
atexit.register(close_running_threads)
|
|
|
@ -315,7 +315,7 @@ class User(Base):
|
||||||
return f"/@{self.username}"
|
return f"/@{self.username}"
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<User(username={self.username})>"
|
return f"<User(id={self.id})>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -797,10 +797,3 @@ NOTIFIED_USERS = {
|
||||||
|
|
||||||
num_banners = len(listdir('files/assets/images/Drama/banners')) + 1
|
num_banners = len(listdir('files/assets/images/Drama/banners')) + 1
|
||||||
num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1
|
num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1
|
||||||
|
|
||||||
|
|
||||||
with open("marsey_count.json", 'r') as f: marsey_count = loads(f.read())
|
|
||||||
marsey_counted = []
|
|
||||||
for k, val in marseys.items():
|
|
||||||
marsey_counted.append((k, val, marsey_count[k]))
|
|
||||||
marsey_counted = sorted(marsey_counted, key=lambda x: x[2], reverse=True)
|
|
|
@ -178,6 +178,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
||||||
sanitized = re.sub('\|\|(.*?)\|\|', r'<span class="spoiler">\1</span>', sanitized)
|
sanitized = re.sub('\|\|(.*?)\|\|', r'<span class="spoiler">\1</span>', sanitized)
|
||||||
|
|
||||||
if comment:
|
if comment:
|
||||||
|
marsey_count = cache.get("marsey_count")
|
||||||
marseys_used = set()
|
marseys_used = set()
|
||||||
|
|
||||||
for i in re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized):
|
for i in re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized):
|
||||||
|
@ -259,6 +260,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
||||||
if comment:
|
if comment:
|
||||||
for emoji in marseys_used:
|
for emoji in marseys_used:
|
||||||
if emoji in marsey_count: marsey_count[emoji] += 1
|
if emoji in marsey_count: marsey_count[emoji] += 1
|
||||||
|
cache.set("marsey_count", marsey_count)
|
||||||
|
|
||||||
return sanitized
|
return sanitized
|
||||||
|
|
||||||
|
|
|
@ -1211,6 +1211,7 @@ def admin_distinguish_comment(c_id, v):
|
||||||
@app.get("/admin/dump_cache")
|
@app.get("/admin/dump_cache")
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
def admin_dump_cache(v):
|
def admin_dump_cache(v):
|
||||||
|
with open('marsey_count.json', 'w') as f: dump(cache.get("marsey_count"), f)
|
||||||
cache.clear()
|
cache.clear()
|
||||||
return {"message": "Internal cache cleared."}
|
return {"message": "Internal cache cleared."}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,11 @@ def privacy(v):
|
||||||
@app.get("/marseys")
|
@app.get("/marseys")
|
||||||
@auth_required
|
@auth_required
|
||||||
def emojis(v):
|
def emojis(v):
|
||||||
|
marsey_count = cache.get("marsey_count")
|
||||||
|
marsey_counted = []
|
||||||
|
for k, val in marseys.items():
|
||||||
|
marsey_counted.append((k, val, marsey_count[k]))
|
||||||
|
marsey_counted = sorted(marsey_counted, key=lambda x: x[2], reverse=True)
|
||||||
return render_template("marseys.html", v=v, marseys=marsey_counted)
|
return render_template("marseys.html", v=v, marseys=marsey_counted)
|
||||||
|
|
||||||
@app.get("/terms")
|
@app.get("/terms")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue