forked from mirrors/treebird
Show emojis in certain locations
FossilOrigin-Name: 653d3bf1653802edf8000318354f3f3aeae05a5eacecbd7c6cbf9496b3fa9535
This commit is contained in:
parent
0a34c78ff8
commit
c070b6a031
4 changed files with 41 additions and 10 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "scrobble.h"
|
||||
#include "string_helpers.h"
|
||||
#include "navigation.h"
|
||||
#include "emoji.h"
|
||||
|
||||
// Files
|
||||
#include "../static/account.ctmpl"
|
||||
|
@ -51,10 +52,17 @@ struct account_args
|
|||
char* load_account_info(struct mstdnt_account* acct,
|
||||
size_t* size)
|
||||
{
|
||||
char* info_html;
|
||||
char* note = emojify(acct->note,
|
||||
acct->emojis,
|
||||
acct->emojis_len);
|
||||
struct account_info_template data = {
|
||||
.acct_note = acct->note
|
||||
.acct_note = note
|
||||
};
|
||||
return tmpl_gen_account_info(&data, size);
|
||||
info_html = tmpl_gen_account_info(&data, size);
|
||||
if (note != acct->note)
|
||||
free(note);
|
||||
return info_html;
|
||||
}
|
||||
|
||||
char* construct_account_sidebar(struct mstdnt_account* acct, size_t* size)
|
||||
|
@ -215,12 +223,20 @@ static void fetch_account_page(struct session* ssn,
|
|||
|
||||
size_t construct_account_page(char** result, struct account_page* page, char* content)
|
||||
{
|
||||
if (!page->account)
|
||||
{
|
||||
*result = NULL;
|
||||
return 0;
|
||||
}
|
||||
size_t size;
|
||||
struct mstdnt_relationship* rel = page->relationship;
|
||||
char* follow_btn = NULL, *follow_btn_text = NULL;
|
||||
char* follows_you = NULL;
|
||||
char* info_html = NULL;
|
||||
char* is_blocked = NULL;
|
||||
char* display_name = emojify(page->display_name,
|
||||
page->account->emojis,
|
||||
page->account->emojis_len);
|
||||
|
||||
// Check if note is not empty
|
||||
if (page->note && strcmp(page->note, "") != 0)
|
||||
|
@ -260,10 +276,11 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
|
|||
struct account_template acct_data = {
|
||||
.block_text = STR_NULL_EMPTY(is_blocked),
|
||||
.header = page->header_image,
|
||||
.display_name = page->display_name,
|
||||
.display_name = display_name,
|
||||
.acct = page->acct,
|
||||
.prefix = config_url_prefix,
|
||||
.userid = page->id,
|
||||
.follows_you = follows_you,
|
||||
.unsubscribe = (rel && MSTDNT_FLAG_ISSET(rel->flags,
|
||||
MSTDNT_RELATIONSHIP_NOTIFYING)
|
||||
? "un" : ""),
|
||||
|
@ -304,10 +321,12 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
|
|||
|
||||
*result = tmpl_gen_account(&acct_data, &size);
|
||||
|
||||
if (info_html) free(info_html);
|
||||
if (follows_you) free(follows_you);
|
||||
if (follow_btn) free(follow_btn);
|
||||
if (is_blocked) free(is_blocked);
|
||||
free(info_html);
|
||||
free(follows_you);
|
||||
free(follow_btn);
|
||||
free(is_blocked);
|
||||
if (display_name != page->display_name)
|
||||
free(display_name);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ int main(void)
|
|||
{ "/login", content_login },
|
||||
{ "/test", content_test },
|
||||
{ "/user/:/action/:", content_account_action },
|
||||
{ "/user/:", content_account_statuses },
|
||||
{ "/@:/scrobbles", content_account_scrobbles },
|
||||
{ "/@:/pinned", content_account_pinned },
|
||||
{ "/@:/media", content_account_media },
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "navigation.h"
|
||||
#include "status.h"
|
||||
#include "error.h"
|
||||
#include "emoji.h"
|
||||
#include "../config.h"
|
||||
|
||||
// Pages
|
||||
|
@ -66,14 +67,19 @@ char* construct_notification(struct session* ssn,
|
|||
|
||||
char* construct_notification_action(struct mstdnt_notification* notif, size_t* size)
|
||||
{
|
||||
char* display_name = emojify(notif->account->display_name,
|
||||
notif->account->emojis,
|
||||
notif->account->emojis_len);
|
||||
struct notification_action_template tdata = {
|
||||
.avatar = notif->account->avatar,
|
||||
.acct = notif->account->acct,
|
||||
.display_name = notif->account->display_name,
|
||||
.display_name = display_name,
|
||||
.prefix = config_url_prefix,
|
||||
.action = notification_type_compact_str(notif->type),
|
||||
.notif_svg = notification_type_svg(notif->type)
|
||||
};
|
||||
if (display_name != notif->account->display_name)
|
||||
free(display_name);
|
||||
return tmpl_gen_notification_action(&tdata, size);
|
||||
}
|
||||
|
||||
|
@ -100,11 +106,14 @@ char* construct_notification_compact(struct session* ssn,
|
|||
notif->status->emojis_len);
|
||||
}
|
||||
|
||||
char* display_name = emojify(notif->account->display_name,
|
||||
notif->account->emojis,
|
||||
notif->account->emojis_len);
|
||||
struct notification_compact_template tdata = {
|
||||
.avatar = notif->account->avatar,
|
||||
.has_icon = strlen(type_svg) == 0 ? "" : "-with-icon",
|
||||
.acct = notif->account->acct,
|
||||
.display_name = notif->account->display_name,
|
||||
.display_name = display_name,
|
||||
.action = type_str,
|
||||
.notif_svg = type_svg,
|
||||
/* Might show follower address */
|
||||
|
@ -118,6 +127,8 @@ char* construct_notification_compact(struct session* ssn,
|
|||
if (status_format &&
|
||||
status_format != notif->status->content) free(status_format);
|
||||
if (notif_stats) free(notif_stats);
|
||||
if (display_name != notif->account->display_name)
|
||||
free(display_name);
|
||||
return notif_html;
|
||||
}
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ char* get_in_reply_to(mastodont_t* api, struct mstdnt_status* status, size_t* si
|
|||
struct mstdnt_account acct = { 0 };
|
||||
|
||||
int res = mastodont_get_account(api,
|
||||
config_experimental_lookup,
|
||||
0,
|
||||
status->in_reply_to_account_id,
|
||||
&acct,
|
||||
&storage);
|
||||
|
|
Loading…
Reference in a new issue