feat: support custom emojis on content body
This commit is contained in:
parent
5cd45f7cf2
commit
a7d8e3c7e0
2 changed files with 41 additions and 24 deletions
|
@ -38,9 +38,6 @@
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
.card.descendant {
|
|
||||||
padding-bottom: 1em;
|
|
||||||
}
|
|
||||||
.card {
|
.card {
|
||||||
border-bottom: 1px solid rgba(34, 34, 34, 0.15);
|
border-bottom: 1px solid rgba(34, 34, 34, 0.15);
|
||||||
margin-left: -40px;
|
margin-left: -40px;
|
||||||
|
@ -58,12 +55,19 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& .emoji {
|
||||||
|
display: inline;
|
||||||
|
height: calc(1rem + 6px);
|
||||||
|
margin-bottom: -4px;
|
||||||
|
}
|
||||||
|
|
||||||
& .ellipsis::after {
|
& .ellipsis::after {
|
||||||
content: '...'
|
content: '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
& .body {
|
& .body {
|
||||||
|
|
||||||
& img, & video {
|
& img:not(.emoji), & video, & .link_card {
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +75,7 @@
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
& img, & video, & .link_card {
|
& img:not(.emoji), & video, & .link_card {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
@ -86,10 +90,6 @@
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
& .emoji {
|
|
||||||
display: inline;
|
|
||||||
width: 1rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
& .meta {
|
& .meta {
|
||||||
|
@ -112,11 +112,24 @@
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& .link_card:hover {
|
||||||
|
color: blue;
|
||||||
|
text-decoration-color: blue;
|
||||||
|
border-color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
& .link_card {
|
& .link_card {
|
||||||
& strong, & em, & small {
|
color: #555;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-decoration-color; #888;
|
||||||
|
box-shadow: 5px 25px 10px -25px rgba(34, 34, 34, 0.15);
|
||||||
|
|
||||||
|
& strong, & small {
|
||||||
|
text-decoration-thickness: 1px;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
padding: 1em;
|
|
||||||
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,20 +177,22 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
{{thread.content | safe}}
|
{{thread.content | safe}}
|
||||||
|
|
||||||
{% for media in thread.media_attachments %}
|
{% if thread.descendants is defined %}
|
||||||
{% if media.type == 'image'%}
|
{% for media in thread.media_attachments %}
|
||||||
<img src="{{media.url}}" />
|
{% if media.type == 'image'%}
|
||||||
{% elif media.type == 'gifv' %}
|
<img src="{{media.preview_url}}" />
|
||||||
<video controls autoplay="autoplay" muted loop>
|
{% elif media.type == 'gifv' %}
|
||||||
<source src="{{media.url}}" type="video/mp4">
|
<video controls autoplay="autoplay" muted loop>
|
||||||
Your browser does not support the video tag.
|
<source src="{{media.url}}" type="video/mp4">
|
||||||
</video>
|
Your browser does not support the video tag.
|
||||||
{% endif %}
|
</video>
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% if thread.descendants %}
|
{% if thread.descendants is defined %}
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<a href="{{thread.url}}" target="_blank">{{ thread.created_at }}</a>
|
<a href="{{thread.url}}" target="_blank">{{ thread.created_at }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -196,7 +211,7 @@
|
||||||
{{ descendant.content | safe }}
|
{{ descendant.content | safe }}
|
||||||
{% for media in descendant.media_attachments%}
|
{% for media in descendant.media_attachments%}
|
||||||
{% if media.type == 'image'%}
|
{% if media.type == 'image'%}
|
||||||
<img src="{{media.url}}" />
|
<img src="{{media.preview_url}}" />
|
||||||
{% elif media.type == 'gifv' %}
|
{% elif media.type == 'gifv' %}
|
||||||
<video controls autoplay="autoplay" muted loop>
|
<video controls autoplay="autoplay" muted loop>
|
||||||
<source src="{{media.url}}" type="video/mp4">
|
<source src="{{media.url}}" type="video/mp4">
|
||||||
|
@ -213,7 +228,7 @@
|
||||||
{{ descendant.card.provider_name or descendant.card.provider_url }}
|
{{ descendant.card.provider_name or descendant.card.provider_url }}
|
||||||
</small>
|
</small>
|
||||||
<strong>{{ descendant.card.title }}</strong>
|
<strong>{{ descendant.card.title }}</strong>
|
||||||
<em>{{descendant.card.description}}</em>
|
<small>{{descendant.card.description}}</small>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -85,6 +85,8 @@ def clean_author(account):
|
||||||
def clean_status(status):
|
def clean_status(status):
|
||||||
clean = clean_dict(status, ['id', 'content', 'created_at', 'url', 'media_attachments', 'card'])
|
clean = clean_dict(status, ['id', 'content', 'created_at', 'url', 'media_attachments', 'card'])
|
||||||
clean['account'] = clean_author(status['account'])
|
clean['account'] = clean_author(status['account'])
|
||||||
|
for emoji in status['emojis']:
|
||||||
|
clean['content'] = clean['content'].replace(":" + emoji['shortcode'] + ":", '<img class="emoji" src="'+emoji['url']+'" />')
|
||||||
return clean
|
return clean
|
||||||
|
|
||||||
def clean_dict(dict, keys):
|
def clean_dict(dict, keys):
|
||||||
|
|
Loading…
Reference in a new issue