forked from rDrama/rDrama
move emoji download buttons to /emojis
parent
47008c53c5
commit
3b24eca320
|
@ -135,32 +135,12 @@ def _generate_emojis_zip():
|
|||
m = md5()
|
||||
with open('files/assets/emojis.zip', "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
m.update(data)
|
||||
cache.set('emojis_hash', m.hexdigest(), timeout=CRON_CACHE_TIMEOUT)
|
||||
|
||||
count = str(len(os.listdir('files/assets/images/emojis')))
|
||||
cache.set('emojis_count', count, timeout=CRON_CACHE_TIMEOUT)
|
||||
|
||||
size = str(int(os.stat('files/assets/emojis.zip').st_size/1024/1024)) + ' MB'
|
||||
cache.set('emojis_size', size, timeout=CRON_CACHE_TIMEOUT)
|
||||
|
||||
def _generate_emojis_original_zip():
|
||||
make_archive('files/assets/emojis_original', 'zip', '/asset_submissions/emojis/original')
|
||||
|
||||
m = md5()
|
||||
with open('files/assets/emojis_original.zip', "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
m.update(data)
|
||||
cache.set('emojis_original_hash', m.hexdigest(), timeout=CRON_CACHE_TIMEOUT)
|
||||
|
||||
count = str(len(os.listdir('/asset_submissions/emojis/original')))
|
||||
cache.set('emojis_original_count', count, timeout=CRON_CACHE_TIMEOUT)
|
||||
|
||||
size = str(int(os.stat('files/assets/emojis_original.zip').st_size/1024/1024)) + ' MB'
|
||||
cache.set('emojis_original_size', size, timeout=CRON_CACHE_TIMEOUT)
|
||||
|
||||
def _leaderboard_task():
|
||||
votes1 = g.db.query(Vote.user_id, func.count(Vote.user_id)).filter(Vote.vote_type==1).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
|
||||
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).filter(CommentVote.vote_type==1).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
|
||||
|
|
|
@ -74,7 +74,9 @@ def emoji_list(v, kind):
|
|||
for emoji in emojis:
|
||||
emoji.user = authors.get(emoji.author_id)
|
||||
|
||||
return render_template("emojis.html", v=v, emojis=emojis, kind=kind)
|
||||
emojis_hash = cache.get('emojis_hash') or ''
|
||||
|
||||
return render_template("emojis.html", v=v, emojis=emojis, kind=kind, emojis_hash=emojis_hash)
|
||||
|
||||
|
||||
|
||||
|
@ -239,15 +241,8 @@ def directory(v):
|
|||
if SITE_NAME != 'rDrama':
|
||||
abort(404)
|
||||
|
||||
emojis_hash = cache.get('emojis_hash') or ''
|
||||
emojis_count = cache.get('emojis_count') or ''
|
||||
emojis_size = cache.get('emojis_size') or ''
|
||||
|
||||
emojis_original_hash = cache.get('emojis_original_hash') or ''
|
||||
emojis_original_count = cache.get('emojis_original_count') or ''
|
||||
emojis_original_size = cache.get('emojis_original_size') or ''
|
||||
|
||||
return render_template("directory.html", v=v, emojis_hash=emojis_hash, emojis_count=emojis_count, emojis_size=emojis_size, emojis_original_hash=emojis_original_hash, emojis_original_count=emojis_original_count, emojis_original_size=emojis_original_size)
|
||||
return render_template("directory.html", v=v)
|
||||
|
||||
@app.get("/api")
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
|
|
|
@ -7,18 +7,6 @@
|
|||
|
||||
{%- if SITE_NAME == 'rDrama' -%}
|
||||
{%- do DIRECTORY.extend([
|
||||
(
|
||||
'Download All Emojis',
|
||||
'Download a zip containing all emojis.<br>' ~ emojis_count ~ ' emojis - ' ~ emojis_size,
|
||||
'fa-down', '#38a169',
|
||||
'/assets/emojis.zip?v=' + emojis_hash,
|
||||
),
|
||||
(
|
||||
'Download Original Emoji Files',
|
||||
'Download a zip containing all original emoji files.<br>' ~ emojis_original_count ~ ' files - ' ~ emojis_original_size,
|
||||
'fa-down', '#38a169',
|
||||
'/assets/emojis_original.zip?v=' + emojis_original_hash,
|
||||
),
|
||||
(
|
||||
'Bugs / Suggestions',
|
||||
'Something broken? Improvements?',
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
{% block pagetitle %}Emojis{% endblock %}
|
||||
{% block pagetype %}emojis{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<a class="btn btn-primary btn-block mt-3" href="/assets/emojis.zip?v={{emojis_hash}}"><i class="fas fa-down mr-2"></i>Download All Emojis</a>
|
||||
|
||||
<a class="btn btn-primary btn-block mt-3" href="/assets/emojis_original.zip?v={{emojis_hash}}"><i class="fas fa-down mr-2"></i>Download All Original Files</a>
|
||||
|
||||
<div class="d-flex align-items-center mt-3 mb-4">
|
||||
<div class="dropdown dropdown-actions mx-auto">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown" style="width:min(95vw, 900px)">
|
||||
|
|
Loading…
Reference in New Issue