Custom emoji reactions

FossilOrigin-Name: 0aae537cb034f505724ba9bf1c90c2f0b946d665bc306e1de944cf564d3dfb63
This commit is contained in:
nekobit 2022-06-08 22:01:31 +00:00
parent 04ae07d796
commit d4d81258ba
4 changed files with 36 additions and 7 deletions

21
dist/treebird20.css vendored
View file

@ -1251,7 +1251,8 @@ p}
/* Emoji */
.status-content .emoji,
.notification-content .emoji,
.username .emoji
.username .emoji,
.custom-emoji-react
{
font-family: monospace;
display: inline;
@ -1263,10 +1264,16 @@ p}
transition: transform .2s;
}
.custom-emoji-react
{
width: 27px;
height: 27px;
}
.username .emoji
{
width: 20px;
height: 20px;
width: 26px;
height: 26px;
}
.status-content .emoji:hover,
@ -1441,10 +1448,14 @@ p}
{
display: inline-block;
list-style-type: none;
padding: 3px 7px;
padding: 5px 7px;
margin: 1px 2px;
vertical-align: middle;
}
.emoji-react-box.custom-emoji-container
{
padding: 1px 5px;
}
.emoji

View file

@ -23,6 +23,7 @@
#include "easprintf.h"
// Templates
#include "../static/custom_emoji_reaction.ctmpl"
#include "../static/emoji_reaction.ctmpl"
#include "../static/emoji_reactions.ctmpl"
@ -34,14 +35,30 @@ struct construct_emoji_reactions_args
char* construct_emoji_reaction(char* id, struct mstdnt_emoji_reaction* emo, size_t* str_size)
{
char* ret;
char* emoji = emo->name;
if (emo->url)
{
struct custom_emoji_reaction_template c_data = {
.url = emo->url,
};
emoji = tmpl_gen_custom_emoji_reaction(&c_data, NULL);
}
struct emoji_reaction_template data = {
.prefix = config_url_prefix,
.status_id = id,
.custom_emoji = emo->url ? "custom-emoji-container" : NULL,
.emoji = emo->name,
.emoji_display = emoji,
.emoji_active = emo->me ? "active" : NULL,
.emoji_count = emo->count
};
return tmpl_gen_emoji_reaction(&data, str_size);
ret = tmpl_gen_emoji_reaction(&data, str_size);
if (emoji != emo->name)
free(emoji);
return ret;
}
static char* construct_emoji_reactions_voidwrap(void* passed, size_t index, size_t* res)

View file

@ -0,0 +1 @@
<img src="{{ %s : url }}" class="custom-emoji-react">

View file

@ -1 +1 @@
<a href="{{%s:prefix}}/status/{{%s:status_id}}/react/{{%s:emoji}}" class="emoji-react-box btn btn-alt {{%s:emoji_active}}"><span class="emoji">{{%s:emoji}}</span> <span class="emoji-num">{{%u:emoji_count}}<span></a>
<a href="{{%s:prefix}}/status/{{%s:status_id}}/react/{{%s:emoji}}" class="emoji-react-box {{%s:custom_emoji}} btn btn-alt {{%s:emoji_active}}"><span class="emoji">{{%s:emoji_display}}</span> <span class="emoji-num">{{%u:emoji_count}}<span></a>