From 421a7801b7f6e4d610e99466ac4fb5a89777c640 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Thu, 31 Mar 2022 14:56:05 +0000 Subject: [PATCH] Notification follows and actions FossilOrigin-Name: 18a89f78e128c8c3c6726fe9ba907924959f81712cfe0728f89a92fd15cd936a --- Makefile | 5 +++- dist/svg/user-plus.svg | 1 + dist/treebird20.css | 42 +++++++++++++++++++++++--------- src/notifications.c | 26 ++++++++++++++++++-- src/notifications.h | 1 + src/status.c | 3 +-- src/type_string.c | 19 ++++++++++++++- src/type_string.h | 1 + static/follow_svg.html | 1 + static/notification.html | 6 +++-- static/notification_action.html | 24 ++++++++++++++++++ static/notification_compact.html | 5 +++- 12 files changed, 114 insertions(+), 20 deletions(-) create mode 100644 dist/svg/user-plus.svg create mode 100644 static/follow_svg.html create mode 100644 static/notification_action.html diff --git a/Makefile b/Makefile index 482acc1..6e73bce 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,10 @@ $(PAGES_DIR)/like_svg.chtml: $(PAGES_DIR)/like_svg.html ./filec $< data_like_svg_html > $@ $(PAGES_DIR)/repeat_svg.chtml: $(PAGES_DIR)/repeat_svg.html ./filec $< data_repeat_svg_html > $@ - +$(PAGES_DIR)/follow_svg.chtml: $(PAGES_DIR)/follow_svg.html + ./filec $< data_follow_svg_html > $@ +$(PAGES_DIR)/notification_action.chtml: $(PAGES_DIR)/notification_action.html + ./filec $< data_notification_action_html > $@ $(MASTODONT_DIR): git clone $(MASTODONT_URL) || true diff --git a/dist/svg/user-plus.svg b/dist/svg/user-plus.svg new file mode 100644 index 0000000..91fa65a --- /dev/null +++ b/dist/svg/user-plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dist/treebird20.css b/dist/treebird20.css index a4ad934..d3f399e 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -275,6 +275,7 @@ ul li:first-child a.sidebarbtn .notification { border-bottom: 1px solid #dadada; + width: 100%; } .pfp-compact-td @@ -308,14 +309,28 @@ ul li:first-child a.sidebarbtn font-weight: bold; } -.notification-info svg +.notification-info svg, +.notification-info-format svg { width: 16px; height: 16px; stroke: #aa0000; } -.notification-info svg.like +.notification-table-bit +{ + width: auto; +} + +/* Only move up if SVG is next to it, the SVG moves the text */ +.notification .notification-text-group-with-icon +{ + position: relative; + top: -2px; +} + +.notification-info svg.like, +.notification-info-format svg.like { fill: #aa0000; } @@ -338,7 +353,8 @@ ul li:first-child a.sidebarbtn margin-top: 7px; } -.notification-info img +.notification-info img, +.notification-info-format img { margin-left: 36px; width: 24px; @@ -346,7 +362,8 @@ ul li:first-child a.sidebarbtn object-fit: cover; } -.notification-info .notification-user +.notification-info .notification-user, +.ntoification-info-format .notification-user { display: inline; position: relative; @@ -356,7 +373,8 @@ ul li:first-child a.sidebarbtn /*************************** * Statuses * **************************/ -.status +.status, +.notification-regular { padding: 6px 2px 0 6px; border-bottom: 1px solid #cacaca !important; @@ -370,7 +388,8 @@ ul li:first-child a.sidebarbtn border-left: 3px solid #aa0000; } -.notification-info + .status +.notification-info + .status, +.notification-info-format + .status { padding-top: 0; } @@ -409,13 +428,13 @@ ul li:first-child a.sidebarbtn } -.status .status-info +.status .status-info, +.notification-info-format, +.notification-content { - margin: 0 5px 0px; min-width: 0; width: auto; - padding: 0 5px 0 5px; - display: flex; + padding: 0 0 0 10px; } .status .status-info > table.ui-table @@ -448,7 +467,8 @@ ul li:first-child a.sidebarbtn max-width: 520px; } -.status .username +.status .username, +.notification-regular .username { font-weight: bold; text-overflow: ellipsis; diff --git a/src/notifications.c b/src/notifications.c index a6cde97..4c6a2bf 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include #include #include "notifications.h" @@ -24,10 +25,12 @@ #include "easprintf.h" #include "status.h" #include "error.h" +#include "../config.h" // Pages #include "../static/notifications_page.chtml" #include "../static/notifications.chtml" +#include "../static/notification_action.chtml" #include "../static/notification.chtml" #include "../static/notification_compact.chtml" #include "../static/like_svg.chtml" @@ -44,20 +47,37 @@ char* construct_notification(struct mstdnt_notification* notif, int* size) notif_html = construct_status(notif->status, &s, notif, 0); } else { - notif_html = NULL; + notif_html = construct_notification_action(notif, &s); } if (size) *size = s; return notif_html; } +char* construct_notification_action(struct mstdnt_notification* notif, int* size) +{ + char* notif_html; + int s; + + s = easprintf(¬if_html, data_notification_action_html, + notif->account->avatar, + notif->account->display_name, + notification_type_compact_str(notif->type), + notification_type_svg(notif->type), + config_url_prefix, + notif->account->acct, + notif->account->acct); + + if (size) *size = s; + return notif_html; +} char* construct_notification_compact(struct mstdnt_notification* notif, int* size) { char* notif_html; char* notif_stats = NULL; - const char* type_str = notification_type_str(notif->type); + const char* type_str = notification_type_compact_str(notif->type); const char* type_svg = notification_type_svg(notif->type); if (notif->status) @@ -69,6 +89,8 @@ char* construct_notification_compact(struct mstdnt_notification* notif, int* siz size_t s = easprintf(¬if_html, data_notification_compact_html, notif->account->avatar, + /* If there is an icon, the text doesn't shift up relative to the SVG, this is a hack on the CSS side */ + strlen(type_svg) == 0 ? "" : "-with-icon", notif->account->display_name, type_str, type_svg, diff --git a/src/notifications.h b/src/notifications.h index 8858681..38db6da 100644 --- a/src/notifications.h +++ b/src/notifications.h @@ -23,6 +23,7 @@ #include "type_string.h" char* construct_notification(struct mstdnt_notification* notif, int* size); +char* construct_notification_action(struct mstdnt_notification* notif, int* size); char* construct_notification_compact(struct mstdnt_notification* notif, int* size); char* construct_notifications(struct mstdnt_notification* notifs, size_t size, diff --git a/src/status.c b/src/status.c index 82068b1..343ff26 100644 --- a/src/status.c +++ b/src/status.c @@ -106,7 +106,6 @@ char* construct_status(struct mstdnt_status* status, uint8_t flags) { char* stat_html; - const char* type_svg = notification_type_svg(notif->type); // Counts char* reply_count = NULL; @@ -130,7 +129,7 @@ char* construct_status(struct mstdnt_status* status, notif->account->avatar, notif->account->display_name, notification_type_str(notif->type), - type_svg); + notification_type_svg(notif->type)); size_t s = easprintf(&stat_html, data_status_html, diff --git a/src/type_string.c b/src/type_string.c index e6ed90b..7354bdc 100644 --- a/src/type_string.c +++ b/src/type_string.c @@ -17,10 +17,27 @@ */ #include "type_string.h" + +// Icons #include "../static/like_svg.chtml" #include "../static/repeat_svg.chtml" +#include "../static/follow_svg.chtml" const char* notification_type_str(mstdnt_notification_t type) +{ + switch (type) + { + case MSTDNT_NOTIFICATION_FOLLOW: return L10N[L10N_EN_US][L10N_NOTIF_FOLLOW]; + case MSTDNT_NOTIFICATION_FOLLOW_REQUEST: return L10N[L10N_EN_US][L10N_NOTIF_FOLLOW_REQUEST]; + case MSTDNT_NOTIFICATION_REBLOG: return L10N[L10N_EN_US][L10N_NOTIF_REPEATED]; + case MSTDNT_NOTIFICATION_FAVOURITE: return L10N[L10N_EN_US][L10N_NOTIF_LIKED]; + case MSTDNT_NOTIFICATION_POLL: return L10N[L10N_EN_US][L10N_NOTIF_POLL]; + case MSTDNT_NOTIFICATION_EMOJI_REACT: return L10N[L10N_EN_US][L10N_NOTIF_REACTED_WITH]; + default: return ""; + } +} + +const char* notification_type_compact_str(mstdnt_notification_t type) { switch (type) { @@ -39,7 +56,7 @@ const char* notification_type_svg(mstdnt_notification_t type) { switch (type) { - case MSTDNT_NOTIFICATION_FOLLOW: return ""; + case MSTDNT_NOTIFICATION_FOLLOW: return data_follow_svg_html; case MSTDNT_NOTIFICATION_FOLLOW_REQUEST: return ""; case MSTDNT_NOTIFICATION_REBLOG: return data_repeat_svg_html; case MSTDNT_NOTIFICATION_FAVOURITE: return data_like_svg_html; diff --git a/src/type_string.h b/src/type_string.h index 0e01d79..a24f403 100644 --- a/src/type_string.h +++ b/src/type_string.h @@ -23,5 +23,6 @@ const char* notification_type_svg(mstdnt_notification_t type); const char* notification_type_str(mstdnt_notification_t type); +const char* notification_type_compact_str(mstdnt_notification_t type); #endif // TYPE_STRING_H diff --git a/static/follow_svg.html b/static/follow_svg.html new file mode 100644 index 0000000..1c4063b --- /dev/null +++ b/static/follow_svg.html @@ -0,0 +1 @@ + diff --git a/static/notification.html b/static/notification.html index 30f6ee1..6911ab9 100644 --- a/static/notification.html +++ b/static/notification.html @@ -1,8 +1,10 @@
- %s - %s + + %s + %s + %s
diff --git a/static/notification_action.html b/static/notification_action.html new file mode 100644 index 0000000..c367fd5 --- /dev/null +++ b/static/notification_action.html @@ -0,0 +1,24 @@ + + + + + +
+ + + + + + +
+
+ + %s + %s + %s +
+ + @%s + +
+
diff --git a/static/notification_compact.html b/static/notification_compact.html index f90a0a9..d898311 100644 --- a/static/notification_compact.html +++ b/static/notification_compact.html @@ -5,7 +5,10 @@
- %s %s %s + + %s + %s + %s
%s
%s