mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 13:14:28 +00:00
Twemoji but without JavaScript this time (fixes #48)
This commit is contained in:
parent
faaf1d83a2
commit
74a5314ec1
3 changed files with 17 additions and 11 deletions
17
app.py
17
app.py
|
@ -18,6 +18,7 @@ from urllib.parse import urlencode
|
|||
from urllib.parse import urlparse
|
||||
|
||||
import bleach
|
||||
import emoji_unicode
|
||||
import mf2py
|
||||
import requests
|
||||
import timeago
|
||||
|
@ -87,6 +88,8 @@ from utils.key import get_secret_key
|
|||
from utils.lookup import lookup
|
||||
from utils.media import Kind
|
||||
|
||||
EMOJI = '<img src="https://cdn.jsdelivr.net/npm/twemoji@12.0.0/2/svg/{filename}.svg" alt="{raw}" class="emoji">'
|
||||
|
||||
p = PousseTaches(
|
||||
os.getenv("MICROBLOGPUB_POUSSETACHES_HOST", "http://localhost:7991"),
|
||||
os.getenv("MICROBLOGPUB_INTERNAL_HOST", "http://localhost:5000"),
|
||||
|
@ -237,6 +240,14 @@ def _get_file_url(url, size, kind):
|
|||
return url
|
||||
|
||||
|
||||
@app.template_filter()
|
||||
def emojify(text):
|
||||
return emoji_unicode.replace(
|
||||
text,
|
||||
lambda e: EMOJI.format(filename=e.code_points, raw=e.unicode),
|
||||
)
|
||||
|
||||
|
||||
@app.template_filter()
|
||||
def gtone(n):
|
||||
return n > 1
|
||||
|
@ -302,7 +313,11 @@ def is_from_outbox(t):
|
|||
|
||||
@app.template_filter()
|
||||
def clean(html):
|
||||
return clean_html(html)
|
||||
out = clean_html(html)
|
||||
return emoji_unicode.replace(
|
||||
out,
|
||||
lambda e: EMOJI.format(filename=e.code_points, raw=e.unicode),
|
||||
)
|
||||
|
||||
|
||||
@app.template_filter()
|
||||
|
|
|
@ -21,3 +21,4 @@ git+https://github.com/tsileo/little-boxes.git@litepub
|
|||
pyyaml
|
||||
pillow
|
||||
cachetools
|
||||
emoji-unicode
|
||||
|
|
|
@ -43,15 +43,5 @@
|
|||
Powered by <a href="https://microblog.pub">microblog.pub</a> <small class="microblogpub-version"><code>{{ microblogpub_version }}</code></small> (<a href="https://github.com/tsileo/microblog.pub">source code</a>) and the <a href="https://activitypub.rocks/">ActivityPub</a> protocol
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/twemoji@12.0.0/2/twemoji.min.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
twemoji.base = "https://cdn.jsdelivr.net/npm/twemoji@12.0.0/2/";
|
||||
twemoji.parse(document.body, {
|
||||
folder: 'svg',
|
||||
ext: '.svg'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue