Display emoji reacts
FossilOrigin-Name: 2a98c43dd72822b00edc5590f3032ef9f6ab535e70acd996df4f365d2e7f9e71
This commit is contained in:
parent
2ef8740731
commit
266426ca10
11 changed files with 122 additions and 0 deletions
4
Makefile
4
Makefile
|
@ -48,6 +48,10 @@ $(PAGES_DIR)/attachments.chtml: $(PAGES_DIR)/attachments.html
|
|||
./filec $< data_attachments_html > $@
|
||||
$(PAGES_DIR)/attachment_image.chtml: $(PAGES_DIR)/attachment_image.html
|
||||
./filec $< data_attachment_image_html > $@
|
||||
$(PAGES_DIR)/emoji_reactions.chtml: $(PAGES_DIR)/emoji_reactions.html
|
||||
./filec $< data_emoji_reactions_html > $@
|
||||
$(PAGES_DIR)/emoji_reaction.chtml: $(PAGES_DIR)/emoji_reaction.html
|
||||
./filec $< data_emoji_reaction_html > $@
|
||||
|
||||
$(MASTODONT_DIR):
|
||||
git clone $(MASTODONT_URL) || true
|
||||
|
|
7
dist/ratfe20.css
vendored
7
dist/ratfe20.css
vendored
|
@ -463,3 +463,10 @@ ul li:first-child a.sidebarbtn
|
|||
color: #fff !important;
|
||||
text-shadow: 0px 0px 5px #cc4444cc !important;
|
||||
}
|
||||
|
||||
/* Emoji reacts */
|
||||
.emoji-react-box
|
||||
{
|
||||
border-radius: 4px;
|
||||
border: 1px solid #cacaca;
|
||||
}
|
||||
|
|
14
dist/skel.css
vendored
14
dist/skel.css
vendored
|
@ -484,3 +484,17 @@ ul li:not(:last-child) .split,
|
|||
{
|
||||
border: 1px solid #cacaca;
|
||||
}
|
||||
|
||||
/* Emoji reacts */
|
||||
.emoji-reactions
|
||||
{
|
||||
display: flex;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.emoji-react-box
|
||||
{
|
||||
padding: 3px 7px;
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
|
|
1
src/.#attachments.c
Symbolic link
1
src/.#attachments.c
Symbolic link
|
@ -0,0 +1 @@
|
|||
nekobit@toomuchram.2139:1646100446
|
55
src/emoji_reaction.c
Normal file
55
src/emoji_reaction.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* RatFE - Lightweight frontend for Pleroma
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "string_helpers.h"
|
||||
#include "emoji_reaction.h"
|
||||
#include <stdlib.h>
|
||||
#include "easprintf.h"
|
||||
|
||||
// Templates
|
||||
#include "../static/emoji_reaction.chtml"
|
||||
#include "../static/emoji_reactions.chtml"
|
||||
|
||||
char* construct_emoji_reaction(struct mstdnt_emoji_reaction* emo, int* str_size)
|
||||
{
|
||||
char* emo_html;
|
||||
|
||||
size_t s = easprintf(&emo_html, data_emoji_reaction_html,
|
||||
emo->name, emo->count);
|
||||
if (str_size) *str_size = s;
|
||||
return emo_html;
|
||||
}
|
||||
|
||||
static char* construct_emoji_reactions_voidwrap(void* passed, size_t index, int* res)
|
||||
{
|
||||
return construct_emoji_reaction((struct mstdnt_emoji_reaction*)passed + index, res);
|
||||
}
|
||||
|
||||
char* construct_emoji_reactions(struct mstdnt_emoji_reaction* emos, size_t emos_len, size_t* str_size)
|
||||
{
|
||||
size_t elements_size;
|
||||
char* elements = construct_func_strings(construct_emoji_reactions_voidwrap, emos, emos_len, &elements_size);
|
||||
char* emos_view;
|
||||
|
||||
size_t s = easprintf(&emos_view, data_emoji_reactions_html, elements);
|
||||
if (str_size) *str_size = s;
|
||||
// Cleanup
|
||||
free(elements);
|
||||
return emos_view;
|
||||
}
|
||||
|
26
src/emoji_reaction.h
Normal file
26
src/emoji_reaction.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* RatFE - Lightweight frontend for Pleroma
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EMOJI_REACTION_H
|
||||
#define EMOJI_REACTION_H
|
||||
#include <mastodont.h>
|
||||
|
||||
char* construct_emoji_reaction(struct mstdnt_emoji_reaction* emo, int* str_len);
|
||||
char* construct_emoji_reactions(struct mstdnt_emoji_reaction* emos, size_t emos_len, size_t* str_len);
|
||||
|
||||
#endif // EMOJI_REACTION_H
|
|
@ -26,6 +26,7 @@
|
|||
#include "string_helpers.h"
|
||||
#include "reply.h"
|
||||
#include "attachments.h"
|
||||
#include "emoji_reaction.h"
|
||||
#include "../config.h"
|
||||
|
||||
// Pages
|
||||
|
@ -91,6 +92,7 @@ char* construct_status(struct mstdnt_status* status, int* size)
|
|||
char* repeat_count = NULL;
|
||||
char* favourites_count = NULL;
|
||||
char* attachments = NULL;
|
||||
char* emoji_reactions = NULL;
|
||||
if (status->replies_count)
|
||||
easprintf(&reply_count, NUM_STR, status->replies_count);
|
||||
if (status->reblogs_count)
|
||||
|
@ -99,6 +101,9 @@ char* construct_status(struct mstdnt_status* status, int* size)
|
|||
easprintf(&favourites_count, NUM_STR, status->favourites_count);
|
||||
if (status->media_attachments_len)
|
||||
attachments = construct_attachments(status->media_attachments, status->media_attachments_len, NULL);
|
||||
if (status->pleroma.emoji_reactions_len)
|
||||
emoji_reactions = construct_emoji_reactions(status->pleroma.emoji_reactions, status->pleroma.emoji_reactions_len, NULL);
|
||||
|
||||
|
||||
size_t s = easprintf(&stat_html, data_status_html,
|
||||
status->account.avatar,
|
||||
|
@ -109,6 +114,7 @@ char* construct_status(struct mstdnt_status* status, int* size)
|
|||
"Public", /* visibility */
|
||||
status->content,
|
||||
attachments ? attachments : "",
|
||||
emoji_reactions ? emoji_reactions : "",
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
reply_count ? reply_count : "",
|
||||
|
@ -130,6 +136,7 @@ char* construct_status(struct mstdnt_status* status, int* size)
|
|||
if (repeat_count) free(repeat_count);
|
||||
if (favourites_count) free(favourites_count);
|
||||
if (attachments) free(attachments);
|
||||
if (emoji_reactions) free(emoji_reactions);
|
||||
return stat_html;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#ifndef STRING_HELPERS_H
|
||||
#define STRING_HELPERS_H
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Constructs a string based on a function
|
||||
|
|
3
static/emoji_reaction.html
Normal file
3
static/emoji_reaction.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="emoji-react-box btn">
|
||||
<span class="emoji">%s</span> %u
|
||||
</div>
|
3
static/emoji_reactions.html
Normal file
3
static/emoji_reactions.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="emoji-reactions">
|
||||
%s
|
||||
</div>
|
|
@ -13,6 +13,7 @@
|
|||
%s
|
||||
</span>
|
||||
%s
|
||||
%s
|
||||
<div class="status-interact">
|
||||
<ul>
|
||||
<li>
|
||||
|
|
Loading…
Reference in a new issue