diff --git a/dist/treebird20.css b/dist/treebird20.css index 4e7b58e..f4b7bc0 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -51,7 +51,7 @@ ul } #main-page { - margin: 8px; +v margin: 8px; margin-top: 0; width: 1000px; border-top: 0 !important; @@ -1064,7 +1064,8 @@ svg.in-reply-to-icon } /* Emoji */ -.emoji +.status-content .emoji, +.notification-content .emoji { font-family: monospace; display: inline; @@ -1075,12 +1076,14 @@ svg.in-reply-to-icon transition: transform .2s; } -.emoji:hover +.status-content .emoji:hover, +.notification-content .emoji:hover { transform: scale(1.5); } -.emoji:active +.status-content .emoji:active, +.notification-content .emoji:active { transform: scale(2.7); } @@ -1091,6 +1094,35 @@ svg.in-reply-to-icon border: 1px solid #cacaca; } +/* Emojo picker */ +.emoji-picker +{ + position: absolute; + margin-left: -15px; + width: 260px; + border: 1px solid #cacaca; + background-color: #fff; + background: linear-gradient(#fff, #f3f3f3); + border-radius: 8px; + box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.2); +} + +.emoji-picker .emoji +{ + font-size: 18px; + text-align: center; + vertical-align: center; + padding: 8px 0; +} + +.emoji-picker-emojos +{ + display: grid; + grid-template-columns: repeat(8, 1fr); + padding: 0px 8px; + z-index: 999; +} + .form-group { padding: 5px; diff --git a/src/account.c b/src/account.c index fee69a3..3068fb0 100644 --- a/src/account.c +++ b/src/account.c @@ -80,7 +80,7 @@ static char* account_statuses_cb(struct session* ssn, statuses_html = construct_error(storage.error, E_ERROR, 1, NULL); } else { - statuses_html = construct_statuses(api, statuses, statuses_len, NULL, NULL); + statuses_html = construct_statuses(ssn, api, statuses, statuses_len, NULL, NULL); if (!statuses_html) statuses_html = construct_error("No statuses", E_NOTICE, 1, NULL); } @@ -487,7 +487,7 @@ void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** dat } else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL); } @@ -547,7 +547,7 @@ void content_account_favourites(struct session* ssn, mastodont_t* api, char** da } else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL); } diff --git a/src/base_page.c b/src/base_page.c index c033fe7..f7df633 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -71,7 +71,7 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t* }; if (mastodont_get_notifications(api, &args, &storage, ¬ifs, ¬ifs_len) == 0) - sidebar_str = construct_notifications_compact(api, notifs, notifs_len, NULL); + sidebar_str = construct_notifications_compact(ssn, api, notifs, notifs_len, NULL); mstdnt_cleanup_notifications(notifs, notifs_len); } diff --git a/src/emoji.c b/src/emoji.c index 9f09634..c1016a3 100644 --- a/src/emoji.c +++ b/src/emoji.c @@ -58,11 +58,18 @@ char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len) return res; } -char* construct_emoji(struct emoji_info* emoji, size_t* size) +struct construct_emoji_picker_args +{ + char* status_id; + unsigned index; +}; + +char* construct_emoji(struct emoji_info* emoji, char* status_id, int* size) { char* emoji_html; - size_t s = easprintf(&emoji_html, data_emoji_html, emoji->codes); + size_t s = easprintf(&emoji_html, data_emoji_html, + status_id, emoji->codes, emoji->codes); if (size) *size = s; return emoji_html; @@ -70,18 +77,31 @@ char* construct_emoji(struct emoji_info* emoji, size_t* size) static char* construct_emoji_voidwrap(void* passed, size_t index, int* res) { - return construct_emoji((struct emoji_info*)passed + index, 0); + struct construct_emoji_picker_args* args = passed; + size_t calc_index = index + args->index; + return calc_index < 0 || calc_index > emojos_size ? NULL : + construct_emoji(emojos + calc_index, args->status_id, res); } -char* construct_emoji_picker(enum emoji_picker_cat cat, unsigned index, size_t* size) +char* construct_emoji_picker(char* status_id, unsigned index, size_t* size) { + struct construct_emoji_picker_args args = { + .status_id = status_id, + .index = index + }; char* emoji_picker_html; char* emojis; - emojis = construct_func_strings(construct_emoji_voidwrap, emojos, 8, NULL); + emojis = construct_func_strings(construct_emoji_voidwrap, &args, EMOJI_FACTOR_NUM, NULL); size_t s = easprintf(&emoji_picker_html, data_emoji_picker_html, - emojis); + emojis ? emojis : "", + status_id, + // Index movements + index > 0 ? index - EMOJI_FACTOR_NUM : 0, + 0 > index - EMOJI_FACTOR_NUM ? "disabled" : "", + status_id, + index + EMOJI_FACTOR_NUM); free(emojis); if (size) *size = s; diff --git a/src/emoji.h b/src/emoji.h index 061409e..4868a77 100644 --- a/src/emoji.h +++ b/src/emoji.h @@ -21,7 +21,9 @@ #include #include "emoji_codes.h" +#define EMOJI_FACTOR_NUM 32 +// No use? enum emoji_picker_cat { EMOJI_CAT_CUSTOM, @@ -29,7 +31,7 @@ enum emoji_picker_cat }; char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len); -char* construct_emoji(struct emoji_info* emoji, size_t* size); -char* construct_emoji_picker(enum emoji_picker_cat cat, unsigned index, size_t* size); +char* construct_emoji(struct emoji_info* emoji, char* status_id, int* size); +char* construct_emoji_picker(char* status_id, unsigned index, size_t* size); #endif // EMOJI_H diff --git a/src/emoji_codes.h b/src/emoji_codes.h index db6d08f..861a53d 100644 --- a/src/emoji_codes.h +++ b/src/emoji_codes.h @@ -3,140 +3,139 @@ #define EMOJOS_H #include "emoji_info.h" -struct emoji_info emojos[] = { - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { "☺️", "smile", "Smiles" }, - { NULL, NULL, NULL }, +#define emojos_size 130 +static struct emoji_info emojos[] = { + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, + { "☺️", "smile", "Smiles" }, }; #endif diff --git a/src/emoji_info.h b/src/emoji_info.h index 1c2dac7..29362d2 100644 --- a/src/emoji_info.h +++ b/src/emoji_info.h @@ -21,9 +21,9 @@ struct emoji_info { - char* codes; - char* name; - char* group; + const char* codes; + const char* name; + const char* group; }; #endif /* EMOJI_INFO_H */ diff --git a/src/notifications.c b/src/notifications.c index 9ecdd4b..0147ba6 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -39,11 +39,13 @@ struct notification_args { + struct session* ssn; mastodont_t* api; struct mstdnt_notification* notifs; }; -char* construct_notification(mastodont_t* api, +char* construct_notification(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notif, int* size) { @@ -53,7 +55,7 @@ char* construct_notification(mastodont_t* api, if (notif->status) { // Construct status with notification_info - notif_html = construct_status(api, notif->status, &s, notif, NULL, 0); + notif_html = construct_status(ssn, api, notif->status, &s, notif, NULL, 0); } else { notif_html = construct_notification_action(notif, &s); @@ -82,7 +84,8 @@ char* construct_notification_action(struct mstdnt_notification* notif, int* size return notif_html; } -char* construct_notification_compact(mastodont_t* api, +char* construct_notification_compact(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notif, int* size) { @@ -132,33 +135,37 @@ char* construct_notification_compact(mastodont_t* api, static char* construct_notification_voidwrap(void* passed, size_t index, int* res) { struct notification_args* args = passed; - return construct_notification(args->api, args->notifs + index, res); + return construct_notification(args->ssn, args->api, args->notifs + index, res); } static char* construct_notification_compact_voidwrap(void* passed, size_t index, int* res) { struct notification_args* args = passed; - return construct_notification_compact(args->api, args->notifs + index, res); + return construct_notification_compact(args->ssn, args->api, args->notifs + index, res); } -char* construct_notifications(mastodont_t* api, +char* construct_notifications(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notifs, size_t size, size_t* ret_size) { struct notification_args args = { + .ssn = ssn, .api = api, .notifs = notifs }; return construct_func_strings(construct_notification_voidwrap, &args, size, ret_size); } -char* construct_notifications_compact(mastodont_t* api, +char* construct_notifications_compact(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notifs, size_t size, size_t* ret_size) { struct notification_args args = { + .ssn = ssn, .api = api, .notifs = notifs }; @@ -194,7 +201,7 @@ void content_notifications(struct session* ssn, mastodont_t* api, char** data) if (mastodont_get_notifications(api, &args, &storage, ¬ifs, ¬ifs_len) == 0) { - notif_html = construct_notifications(api, notifs, notifs_len, NULL); + notif_html = construct_notifications(ssn, api, notifs, notifs_len, NULL); start_id = ssn->post.start_id ? ssn->post.start_id : notifs[0].id; navigation_box = construct_navigation_box(start_id, notifs[0].id, diff --git a/src/notifications.h b/src/notifications.h index 83b0f4c..73d6a86 100644 --- a/src/notifications.h +++ b/src/notifications.h @@ -22,18 +22,22 @@ #include "session.h" #include "type_string.h" -char* construct_notification(mastodont_t* api, +char* construct_notification(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notif, int* size); char* construct_notification_action(struct mstdnt_notification* notif, int* size); -char* construct_notification_compact(mastodont_t* api, +char* construct_notification_compact(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notif, int* size); -char* construct_notifications(mastodont_t* api, +char* construct_notifications(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notifs, size_t size, size_t* ret_size); -char* construct_notifications_compact(mastodont_t* api, +char* construct_notifications_compact(struct session* ssn, + mastodont_t* api, struct mstdnt_notification* notifs, size_t size, size_t* ret_size); diff --git a/src/query.c b/src/query.c index d563f0d..6642322 100644 --- a/src/query.c +++ b/src/query.c @@ -116,6 +116,7 @@ char* read_post_data(struct query_values* post) { "start_id", &(post->start_id), key_string }, { "instance", &(post->instance), key_string }, { "visibility", &(post->visibility), key_string }, + { "emojoindex", &(post->emojoindex), key_int }, { "file", &(post->files), key_files } }; // END Query references diff --git a/src/query.h b/src/query.h index 09d2865..f408a94 100644 --- a/src/query.h +++ b/src/query.h @@ -59,6 +59,7 @@ struct query_values char* replyid; char* visibility; char* instance; + int emojoindex; // Navigation char* min_id; diff --git a/src/search.c b/src/search.c index 66bfa56..cc4d418 100644 --- a/src/search.c +++ b/src/search.c @@ -89,7 +89,7 @@ void content_search_statuses(struct session* ssn, mastodont_t* api, char** data) struct construct_statuses_args statuses_args = { .highlight_word = ssn->query.query, }; - statuses_html = construct_statuses(api, results.statuses, results.statuses_len, &statuses_args, NULL); + statuses_html = construct_statuses(ssn, api, results.statuses, results.statuses_len, &statuses_args, NULL); if (!statuses_html) statuses_html = construct_error("No statuses", E_ERROR, 1, NULL); } diff --git a/src/status.c b/src/status.c index 8a55883..8bb492f 100644 --- a/src/status.c +++ b/src/status.c @@ -51,6 +51,7 @@ struct status_args mastodont_t* api; struct mstdnt_status* status; struct construct_statuses_args* args; + struct session* ssn; }; int try_post_status(struct session* ssn, mastodont_t* api) @@ -105,7 +106,7 @@ int try_react_status(struct session* ssn, mastodont_t* api, char* id, char* emoj mstdnt_cleanup_status(&status); mastodont_storage_cleanup(&storage); - return 1; + return 0; } void content_status_create(struct session* ssn, mastodont_t* api, char** data) @@ -366,7 +367,8 @@ char* greentextify(char* content) return res; } -char* construct_status(mastodont_t* api, +char* construct_status(struct session* ssn, + mastodont_t* api, struct mstdnt_status* local_status, int* size, struct mstdnt_notification* local_notif, @@ -402,7 +404,7 @@ char* construct_status(mastodont_t* api, // Emojo picker if ((flags & STATUS_EMOJI_PICKER) == STATUS_EMOJI_PICKER) { - emoji_picker_html = construct_emoji_picker(EMOJI_CAT_FACES, 0, NULL); + emoji_picker_html = construct_emoji_picker(status->id, ssn->post.emojoindex, NULL); } // If focused, show status interactions @@ -526,10 +528,11 @@ char* construct_status(mastodont_t* api, status->id, config_url_prefix, status->id, + status->id, + emoji_picker_html ? emoji_picker_html : "", config_url_prefix, status->id, - status->id, - emoji_picker_html); + status->id); if (size) *size = s; // Cleanup @@ -549,10 +552,11 @@ char* construct_status(mastodont_t* api, static char* construct_status_voidwrap(void* passed, size_t index, int* res) { struct status_args* args = passed; - return construct_status(args->api, args->status + index, res, NULL, args->args, 0); + return construct_status(args->ssn, args->api, args->status + index, res, NULL, args->args, 0); } -char* construct_statuses(mastodont_t* api, +char* construct_statuses(struct session* ssn, + mastodont_t* api, struct mstdnt_status* statuses, size_t size, struct construct_statuses_args* args, @@ -563,6 +567,7 @@ char* construct_statuses(mastodont_t* api, .api = api, .status = statuses, .args = args, + .ssn = ssn, }; return construct_func_strings(construct_status_voidwrap, &stat_args, size, ret_size); } @@ -617,10 +622,10 @@ void content_status(struct session* ssn, mastodont_t* api, char** data, uint8_t stat_html = construct_error("Status not found", E_ERROR, 1, NULL); } else { - before_html = construct_statuses(api, statuses_before, stat_before_len, NULL, 0); + before_html = construct_statuses(ssn, api, statuses_before, stat_before_len, NULL, 0); // Current status - stat_html = construct_status(api, &status, NULL, NULL, NULL, flags); + stat_html = construct_status(ssn, api, &status, NULL, NULL, NULL, flags); if ((flags & STATUS_REPLY) == STATUS_REPLY) { stat_reply = reply_status(data[0], @@ -629,7 +634,7 @@ void content_status(struct session* ssn, mastodont_t* api, char** data, uint8_t } // After... - after_html = construct_statuses(api, statuses_after, stat_after_len, NULL, 0); + after_html = construct_statuses(ssn, api, statuses_after, stat_after_len, NULL, 0); easprintf(&output, "%s%s%s%s", before_html ? before_html : "", diff --git a/src/status.h b/src/status.h index 72b8630..bd281c2 100644 --- a/src/status.h +++ b/src/status.h @@ -50,13 +50,15 @@ void content_status_react(struct session* ssn, mastodont_t* api, char** data); char* construct_post_box(char* reply_id, char* default_content, int* size); -char* construct_status(mastodont_t* api, +char* construct_status(struct session* ssn, + mastodont_t* api, struct mstdnt_status* status, int* size, struct mstdnt_notification* notif, struct construct_statuses_args* args, uint8_t flags); -char* construct_statuses(mastodont_t* api, +char* construct_statuses(struct session* ssn, + mastodont_t* api, struct mstdnt_status* statuses, size_t size, struct construct_statuses_args* args, diff --git a/src/timeline.c b/src/timeline.c index e9acb11..8f949c1 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -62,7 +62,7 @@ void tl_home(struct session* ssn, mastodont_t* api, int local) } else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL); } @@ -127,7 +127,7 @@ void tl_direct(struct session* ssn, mastodont_t* api) } else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL); } @@ -197,7 +197,7 @@ void tl_public(struct session* ssn, mastodont_t* api, int local, enum base_categ } else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("Couldn't load posts", E_ERROR, 1, NULL); } @@ -260,7 +260,7 @@ void tl_list(struct session* ssn, mastodont_t* api, char* list_id) } else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("No statuses", E_ERROR, 1, NULL); } @@ -320,7 +320,7 @@ void tl_tag(struct session* ssn, mastodont_t* api, char* tag_id) status_format = construct_error(storage.error, E_ERROR, 1, NULL); else { // Construct statuses into HTML - status_format = construct_statuses(api, statuses, status_count, NULL, &statuses_html_count); + status_format = construct_statuses(ssn, api, statuses, status_count, NULL, &statuses_html_count); if (!status_format) status_format = construct_error("No statuses", E_ERROR, 1, NULL); } diff --git a/static/emoji.html b/static/emoji.html index 9e3395c..f0c2eda 100644 --- a/static/emoji.html +++ b/static/emoji.html @@ -1 +1 @@ -%s +%s diff --git a/static/emoji_picker.html b/static/emoji_picker.html index f1e096e..0222ed0 100644 --- a/static/emoji_picker.html +++ b/static/emoji_picker.html @@ -1,3 +1,28 @@
- %s +
+ %s +
+ + + + + + +
diff --git a/static/status.html b/static/status.html index e6e81e8..6b604f5 100644 --- a/static/status.html +++ b/static/status.html @@ -86,12 +86,13 @@ -
+
+ %s
@@ -110,4 +111,3 @@ -%s