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 settings
|
||||||
SANITIZER_ALLOWED_TAGS = ['a', 'p', 'img', 'br', 'i', 'strong']
|
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.
|
# File upload settings.
|
||||||
# Important: media will not work if you change this.
|
# Important: media will not work if you change this.
|
||||||
|
|
|
@ -91,8 +91,9 @@ span.account-locked
|
||||||
img.emoji
|
img.emoji
|
||||||
{
|
{
|
||||||
display: inline;
|
display: inline;
|
||||||
max-height: 1.5rem;
|
max-height: 1.5em;
|
||||||
max-width: 1.5rem;
|
max-width: 1.5em;
|
||||||
|
vertical-align: text-bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
emoji-link
|
emoji-link
|
||||||
|
|
|
@ -293,4 +293,5 @@ img.emoji
|
||||||
display: inline;
|
display: inline;
|
||||||
max-height: 1.5rem;
|
max-height: 1.5rem;
|
||||||
max-width: 1.5rem;
|
max-width: 1.5rem;
|
||||||
|
vertical-align: text-bottom;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
<details class="toot">
|
<details class="toot">
|
||||||
<summary><strong>{{ toot.spoiler_text }} </strong></summary>
|
<summary><strong>{{ toot.spoiler_text }} </strong></summary>
|
||||||
<div class="toot">
|
<div class="toot">
|
||||||
{{ toot.content | relink_toot | strip_html | safe }}
|
{{ toot.content | relink_toot | fix_emojos:toot.emojis | strip_html | safe }}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="toot">
|
<div class="toot">
|
||||||
{{ toot.content | relink_toot | strip_html | safe }}
|
{{ toot.content | relink_toot | fix_emojos:toot.emojis | strip_html | safe }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -64,3 +64,15 @@ def localuser(value):
|
||||||
except:
|
except:
|
||||||
local = value
|
local = value
|
||||||
return local
|
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