forked from MarseyWorld/MarseyWorld
master
parent
6917cc3a8f
commit
2af6c69661
|
@ -22,6 +22,15 @@ def post_embed(id, v):
|
|||
|
||||
return render_template("submission_listing.html", listing=[p], v=v)
|
||||
|
||||
@app.template_filter("favorite_emojis")
|
||||
def favorite_emojis():
|
||||
str = ""
|
||||
emojis = session["favorite_emojis"]
|
||||
emojis = sorted(emojis.items(), key=lambda x: x[1], reverse=True)
|
||||
for k, v in emojis:
|
||||
str += f'<button class="btn m-1 px-0" onclick="getEmoji(\'{k}\', \'@form@\')" style="background: None!important; width:60px; overflow: hidden; border: none;" data-toggle="tooltip" title=":{k}:" delay:="0"><img loading="lazy" width=50 src="/assets/images/emojis/{k}.gif" alt="{k}-emoji"/></button>'
|
||||
return str
|
||||
|
||||
@app.context_processor
|
||||
def inject_constants():
|
||||
constants = [c for c in dir(const) if not c.startswith("_")]
|
||||
|
|
|
@ -209,21 +209,24 @@ def sanitize(sanitized, noimages=False):
|
|||
|
||||
start = '<s>'
|
||||
end = '</s>'
|
||||
|
||||
if not session.get("favorite_emojis"): session["favorite_emojis"] = {}
|
||||
|
||||
if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '<span class="spoiler">').replace(end, '</span>')
|
||||
|
||||
for i in re.finditer('<p>:([^ ]{1,30}?):</p>', sanitized):
|
||||
if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'):
|
||||
sanitized = sanitized.replace(f'<p>:{i.group(1)}:</p>', f'<p><img loading="lazy" data-toggle="tooltip" title="{i.group(1)}" delay="0" height=60 src="https://{site}/assets/images/emojis/{i.group(1)}.gif"</p>')
|
||||
|
||||
# if session.get(i.group(1)): session[i.group(1)] += 1
|
||||
# else: session[i.group(1)] = 1
|
||||
if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1
|
||||
else: session["favorite_emojis"][i.group(1)] = 1
|
||||
|
||||
for i in re.finditer(':([^ ]{1,30}?):', sanitized):
|
||||
if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'):
|
||||
sanitized = sanitized.replace(f':{i.group(1)}:', f'<img loading="lazy" data-toggle="tooltip" title="{i.group(1)}" delay="0" height=30 src="https://{site}/assets/images/emojis/{i.group(1)}.gif"<span>')
|
||||
|
||||
# if session.get(i.group(1)): session[i.group(1)] += 1
|
||||
# else: session[i.group(1)] = 1
|
||||
|
||||
if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1
|
||||
else: session["favorite_emojis"][i.group(1)] = 1
|
||||
|
||||
|
||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.", "https://").replace("https://m.", "https://")
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
<div>
|
||||
<ul class="nav nav-pills py-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active btn-sm" data-toggle="tab" href="#emoji-tab-marsey">Marsey</a>
|
||||
<a class="nav-link active btn-sm" data-toggle="tab" href="#emoji-tab-favorite">Favorite</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link btn-sm" data-toggle="tab" href="#emoji-tab-marsey">Marsey</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link btn-sm" data-toggle="tab" href="#emoji-tab-platy">Platy</a>
|
||||
|
@ -40,7 +43,12 @@
|
|||
<div id="emoji-tab-search"></div>
|
||||
<div id="no-emojis-found"></div>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="emoji-tab-marsey">
|
||||
<div class="tab-pane fade show active" id="emoji-tab-favorite">
|
||||
<div class="d-flex flex-wrap py-3 pl-2" id="EMOJIS_favorite">
|
||||
{{favorite_emojis}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="emoji-tab-marsey">
|
||||
<div class="d-flex flex-wrap py-3 pl-2" id="EMOJIS_marsey"></div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="emoji-tab-platy">
|
||||
|
|
Loading…
Reference in New Issue