mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
Fix the emojos: custom emoji will now be displayed as images (or alt text)
This commit is contained in:
parent
7ea5ecca89
commit
f2340864a4
@ -178,7 +178,7 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
|
||||
# Sanitizer settings
|
||||
SANITIZER_ALLOWED_TAGS = ['a', 'p', 'img', 'br', 'i', 'strong']
|
||||
SANITIZER_ALLOWED_ATTRIBUTES = ['href', 'src']
|
||||
SANITIZER_ALLOWED_ATTRIBUTES = ['href', 'src', 'title', 'alt', 'class']
|
||||
|
||||
# File upload settings.
|
||||
# Important: media will not work if you change this.
|
||||
|
@ -91,8 +91,9 @@ span.account-locked
|
||||
img.emoji
|
||||
{
|
||||
display: inline;
|
||||
max-height: 1.5rem;
|
||||
max-width: 1.5rem;
|
||||
max-height: 1.5em;
|
||||
max-width: 1.5em;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
emoji-link
|
||||
|
@ -293,4 +293,5 @@ img.emoji
|
||||
display: inline;
|
||||
max-height: 1.5rem;
|
||||
max-width: 1.5rem;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
@ -41,12 +41,12 @@
|
||||
<details class="toot">
|
||||
<summary><strong>{{ toot.spoiler_text }} </strong></summary>
|
||||
<div class="toot">
|
||||
{{ toot.content | relink_toot | strip_html | safe }}
|
||||
{{ toot.content | relink_toot | fix_emojos:toot.emojis | strip_html | safe }}
|
||||
</div>
|
||||
</details>
|
||||
{% else %}
|
||||
<div class="toot">
|
||||
{{ toot.content | relink_toot | strip_html | safe }}
|
||||
{{ toot.content | relink_toot | fix_emojos:toot.emojis | strip_html | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -64,3 +64,15 @@ def localuser(value):
|
||||
except:
|
||||
local = value
|
||||
return local
|
||||
|
||||
@register.filter
|
||||
def fix_emojos(value, emojos):
|
||||
'''Replace instances of recognized custom emoji :shortcodes: in value with image link tags
|
||||
'''
|
||||
for emojo in emojos:
|
||||
try:
|
||||
value = value.replace(":%(shortcode)s:" % emojo,
|
||||
'<img src="%(url)s" title=":%(shortcode)s:" alt=":%(shortcode)s:" class="emoji">' % emojo)
|
||||
except:
|
||||
pass
|
||||
return value
|
||||
|
Loading…
Reference in New Issue
Block a user