diff --git a/.gitignore b/.gitignore index 28823f5f2..d968a16f4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__/ .idea/ .vscode/ .DS_Store +emojis.zip diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 310bed080..5fbcaff14 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -203,6 +203,7 @@ .fa-images:before{content:"\f302"} .fa-lock:before{content:"\f023"} .fa-lock-open:before{content:"\f3c1"} +.fa-down:before{content:"\f354"} button { background: none; diff --git a/files/helpers/cron.py b/files/helpers/cron.py index fed1f3874..8e6f842ea 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -1,7 +1,9 @@ import datetime import time from sys import stdout - +from shutil import make_archive +from hashlib import md5 + import click import requests @@ -41,6 +43,7 @@ def cron(every_5m, every_1h, every_1d, every_1mo): _sub_inactive_purge_task() site_stats = stats.stats(SITE_NAME) cache.set(f'{SITE}_stats', site_stats) + _generate_emojis_zip() g.db.commit() g.db.close() @@ -106,3 +109,13 @@ def _sub_inactive_purge_task(): g.db.delete(x) return True + +def _generate_emojis_zip(): + make_archive('files/assets/emojis', 'zip', 'files/assets/images/emojis') + + m = md5() + with open('files/assets/emojis.zip', "rb") as f: + data = f.read() + + m.update(data) + cache.set('emojis_hash', m.hexdigest()) diff --git a/files/routes/static.py b/files/routes/static.py index a14761bbe..a4da42cbe 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -204,7 +204,8 @@ def static_megathread_index(v:User): if SITE_NAME != 'rDrama': abort(404) - return render_template("megathread_index.html", v=v) + emojis_hash = cache.get('emojis_hash') or '' + return render_template("megathread_index.html", v=v, emojis_hash=emojis_hash) @app.get("/api") @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) diff --git a/files/templates/megathread_index.html b/files/templates/megathread_index.html index a0b69a784..63e28c5d4 100644 --- a/files/templates/megathread_index.html +++ b/files/templates/megathread_index.html @@ -7,6 +7,12 @@ {%- if SITE_NAME == 'rDrama' -%} {%- do MEGATHREAD_INDEX.extend([ + ( + 'Download All Emojis', + 'Download a zip file containing all emojis.', + 'fa-down', '#38a169', + '/assets/emojis.zip?v=' + emojis_hash, + ), ( 'Bugs / Suggestions', 'Something broken? Improvements?',