From 22ce8eef02cc9e0952a23a0b1fe9918b196a0df9 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Wed, 20 Apr 2022 16:20:41 +0000 Subject: [PATCH] Fix Emoji CSS FossilOrigin-Name: 14f012492f3cd0706d7610cc814fceeaa81458e5f7a454ff890bc57c6ca5e8dc --- dist/treebird20-dark.css | 35 ++++++++++++++++++++++++++++++++++- dist/treebird20.css | 37 +++++++++++++++++++++++++++++++++++-- dist/treebird40.css | 34 +++++++++++++++++++++++++++++++++- src/emoji.c | 5 +++-- src/notifications.c | 12 +++++++++++- src/status.c | 2 +- 6 files changed, 117 insertions(+), 8 deletions(-) diff --git a/dist/treebird20-dark.css b/dist/treebird20-dark.css index d72c1b8..31b65ca 100644 --- a/dist/treebird20-dark.css +++ b/dist/treebird20-dark.css @@ -413,6 +413,18 @@ ul li:first-child a.sidebarbtn min-width: 100%; } +.notification-compact .notification-content +{ + max-height: 100px; + overflow: hidden; +} + +.notification-compact:hover .notification-content +{ + max-height: unset; + overflow: hidden; +} + .notification-compact p { margin: 0; @@ -965,7 +977,28 @@ svg.in-reply-to-icon color: #f4ffff; } -/* Emoji reacts */ +/* Emoji */ +.emoji +{ + font-family: monospace; + display: inline; + width: 32px; + height: 32px; + vertical-align: middle; + object-fit: contain; + transition: transform .2s; +} + +.emoji:hover +{ + transform: scale(1.5); +} + +.emoji:active +{ + transform: scale(2.7); +} + .emoji-react-box { border-radius: 4px; diff --git a/dist/treebird20.css b/dist/treebird20.css index 8cb9f5a..d553236 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -89,7 +89,7 @@ a, a:visited, a:hover, a:active .greentext { - color: #008000; + color: #00aa00; } /* Cleans up most of the tables */ @@ -389,6 +389,19 @@ ul li:first-child a.sidebarbtn { margin: 0; } + +.notification-compact .notification-content +{ + max-height: 100px; + overflow: hidden; +} + +.notification-compact:hover .notification-content +{ + max-height: unset; + overflow: hidden; +} + .notification-compact .notification-info { font-size: 12px; @@ -932,7 +945,27 @@ svg.in-reply-to-icon padding-bottom: 3px; } -/* Emoji reacts */ +/* Emoji */ +.emoji +{ + font-family: monospace; + display: inline; + width: 32px; + height: 32px; + vertical-align: middle; + object-fit: contain; +} + +.emoji:hover +{ + transform: scale(1.5); +} + +.emoji:active +{ + transform: scale(2.7); +} + .emoji-react-box { border-radius: 4px; diff --git a/dist/treebird40.css b/dist/treebird40.css index f2f1ce6..8b85a1e 100644 --- a/dist/treebird40.css +++ b/dist/treebird40.css @@ -90,7 +90,7 @@ a, a:visited, a:hover, a:active .greentext { - color: #008000; + color: #00aa00; } /* Cleans up most of the tables */ @@ -411,6 +411,18 @@ input[type=button], input[type=submit] min-width: 100%; } +.notification-compact .notification-content +{ + max-height: 100px; + overflow: hidden; +} + +.notification-compact:hover .notification-content +{ + max-height: unset; + overflow: hidden; +} + .notification-compact p { margin: 0; @@ -961,6 +973,26 @@ svg.in-reply-to-icon } /* Emoji reacts */ +.emoji +{ + font-family: monospace; + display: inline; + width: 32px; + height: 32px; + vertical-align: middle; + object-fit: contain; +} + +.emoji:hover +{ + transform: scale(1.5); +} + +.emoji:active +{ + transform: scale(2.7); +} + .emoji-react-box { border-radius: 4px; diff --git a/src/emoji.c b/src/emoji.c index 67c79f0..444b086 100644 --- a/src/emoji.c +++ b/src/emoji.c @@ -35,11 +35,12 @@ char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len) // Add colons around string sc_len = strlen(emos[i].shortcode); + // 3 = \0 and two : coloned = malloc(sc_len+3); coloned[0] = ':'; strncpy(coloned + 1, emos[i].shortcode, sc_len); - coloned[sc_len-1] = ':'; - coloned[sc_len] = '\0'; + coloned[sc_len+1] = ':'; + coloned[sc_len+2] = '\0'; easprintf(&emoji_url_str, "", emos[i].url); diff --git a/src/notifications.c b/src/notifications.c index 978369f..308587d 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -86,16 +86,25 @@ char* construct_notification_compact(mastodont_t* api, int* size) { char* notif_html; + char* status_format; char* notif_stats = NULL; const char* type_str = notification_type_compact_str(notif->type); const char* type_svg = notification_type_svg(notif->type); if (notif->status) + { easprintf(¬if_stats, "%d - %d - %d", notif->status->replies_count, notif->status->reblogs_count, notif->status->favourites_count); + status_format = reformat_status(notif->status->content, + notif->status->emojis, + notif->status->emojis_len); + } + else { + status_format = NULL; + } size_t s = easprintf(¬if_html, data_notification_compact_html, notif->account->avatar, @@ -108,12 +117,13 @@ char* construct_notification_compact(mastodont_t* api, /* Might show follower address */ notif->type == MSTDNT_NOTIFICATION_FOLLOW ? notif->account->acct : - notif->status ? notif->status->content : "", + status_format ? status_format : "", /* end */ notif_stats ? notif_stats : ""); if (size) *size = s; + if (status_format) free(status_format); if (notif_stats) free(notif_stats); return notif_html; } diff --git a/src/status.c b/src/status.c index 06e3e32..ea60bb8 100644 --- a/src/status.c +++ b/src/status.c @@ -173,7 +173,7 @@ char* reformat_status(char* content, struct mstdnt_emoji* emos, size_t emos_len) if (emos) { emo_res = emojify(gt_res, emos, emos_len); - free(gt_res); + if (gt_res != content) free(gt_res); return emo_res; } return gt_res;