From c3e8af299f445355fcba9988a89209d4b468d150 Mon Sep 17 00:00:00 2001 From: nekobit Date: Tue, 28 Jun 2022 06:12:08 +0000 Subject: [PATCH] IMG react buttons FossilOrigin-Name: b68a8c576c99dfbf981642f6551d02de7a74a6f3e49136d5d7005a910dfd0d3c --- src/cookie.c | 1 + src/cookie.h | 1 + src/local_config.h | 1 + src/local_config_set.c | 1 + src/main.c | 1 + src/query.c | 1 + src/query.h | 1 + src/status.c | 36 +++++++++++++++++++++++++++++++-- static/config_general.tmpl | 4 ++++ static/expand_btn.tmpl | 1 + static/expand_btn_img.tmpl | 1 + static/interaction_buttons.tmpl | 10 +++++---- static/like_btn.tmpl | 1 + static/like_btn_img.tmpl | 1 + static/repeat_btn.tmpl | 1 + static/repeat_btn_img.tmpl | 1 + static/reply_btn.tmpl | 1 + static/reply_btn_img.tmpl | 1 + 18 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 static/expand_btn.tmpl create mode 100644 static/expand_btn_img.tmpl create mode 100644 static/like_btn.tmpl create mode 100644 static/like_btn_img.tmpl create mode 100644 static/repeat_btn.tmpl create mode 100644 static/repeat_btn_img.tmpl create mode 100644 static/reply_btn.tmpl create mode 100644 static/reply_btn_img.tmpl diff --git a/src/cookie.c b/src/cookie.c index 7ef1128..7aa8509 100644 --- a/src/cookie.c +++ b/src/cookie.c @@ -55,6 +55,7 @@ char* read_cookies_env(struct cookie_values* cookies) { "lang", &(cookies->lang), key_int }, { "instance_url", &(cookies->instance_url), key_string }, { "background_url", &(cookies->background_url), key_string }, + { "interact_img", &(cookies->interact_img), key_int }, { "client_id", &(cookies->client_id), key_string }, { "client_secret", &(cookies->client_secret), key_string }, { "themeclr", &(cookies->themeclr), key_int }, diff --git a/src/cookie.h b/src/cookie.h index cd912d7..5e4dfc3 100644 --- a/src/cookie.h +++ b/src/cookie.h @@ -36,6 +36,7 @@ struct cookie_values struct key jsreply; struct key jslive; struct key js; + struct key interact_img; struct key stat_attachments; struct key stat_greentexts; struct key stat_dope; diff --git a/src/local_config.h b/src/local_config.h index a6a4080..9efb231 100644 --- a/src/local_config.h +++ b/src/local_config.h @@ -31,6 +31,7 @@ struct local_config int jsreply; int jslive; int js; + int interact_img; int stat_attachments; int stat_greentexts; int stat_dope; diff --git a/src/local_config_set.c b/src/local_config_set.c index aba8448..bfe8462 100644 --- a/src/local_config_set.c +++ b/src/local_config_set.c @@ -95,5 +95,6 @@ void load_config(struct session* ssn, mastodont_t* api) set_config_int(LOAD_CFG_SIM("instanceshowshoutbox", instance_show_shoutbox)); set_config_int(LOAD_CFG_SIM("instancepanel", instance_panel)); set_config_int(LOAD_CFG_SIM("notifembed", notif_embed)); + set_config_int(LOAD_CFG_SIM("interact_img", interact_img)); set_config_int(LOAD_CFG_SIM("lang", lang)); } diff --git a/src/main.c b/src/main.c index c7560de..fc5cc79 100644 --- a/src/main.c +++ b/src/main.c @@ -121,6 +121,7 @@ int main(void) .jsreply = 1, .jslive = 0, .js = 1, + .interact_img = 0, .stat_attachments = 1, .stat_greentexts = 1, .stat_dope = 1, diff --git a/src/query.c b/src/query.c index a8d32fb..501344c 100644 --- a/src/query.c +++ b/src/query.c @@ -108,6 +108,7 @@ char* read_post_data(struct post_values* post) { "emojoindex", &(post->emojoindex), key_int }, { "only_media", &(post->only_media), key_int }, { "replies_only", &(post->replies_only), key_int }, + { "interact_img", &(post->interact_img), key_int }, { "js", &(post->js), key_int }, { "statattachments", &(post->stat_attachments), key_int }, { "statgreentexts", &(post->stat_greentexts), key_int }, diff --git a/src/query.h b/src/query.h index bb706de..f0b67e3 100644 --- a/src/query.h +++ b/src/query.h @@ -39,6 +39,7 @@ struct post_values struct key jsreply; // Int struct key jslive; // Int struct key js; // Int + struct key interact_img; // Int struct key stat_attachments; // Int struct key stat_greentexts; // Int struct key stat_dope; // Int diff --git a/src/status.c b/src/status.c index f37080c..06b4eaa 100644 --- a/src/status.c +++ b/src/status.c @@ -50,6 +50,14 @@ #include "../static/reactions_btn.ctmpl" #include "../static/interaction_buttons.ctmpl" #include "../static/menu_item.ctmpl" +#include "../static/like_btn.ctmpl" +#include "../static/repeat_btn.ctmpl" +#include "../static/reply_btn.ctmpl" +#include "../static/expand_btn.ctmpl" +#include "../static/like_btn_img.ctmpl" +#include "../static/repeat_btn_img.ctmpl" +#include "../static/reply_btn_img.ctmpl" +#include "../static/expand_btn_img.ctmpl" #define ACCOUNT_INTERACTIONS_LIMIT 11 #define NUM_STR "%u" @@ -226,7 +234,10 @@ char* construct_interaction_buttons(struct session* ssn, size_t* size, uint8_t flags) { + int use_img = ssn->config.interact_img; char* interaction_html; + char* repeat_btn; + char* like_btn; char* likeboost_html = NULL; char* reply_count = NULL; char* repeat_count = NULL; @@ -269,16 +280,35 @@ char* construct_interaction_buttons(struct session* ssn, time_str = reltime_to_str(status->created_at); + // TODO cleanup? + if (use_img) + { + struct repeat_btn_img_template rpbdata = { .prefix = config_url_prefix, .repeat_active = status->reblogged ? "active" : "" }; + repeat_btn = tmpl_gen_repeat_btn_img(&rpbdata, NULL); + struct like_btn_img_template ldata = { .prefix = config_url_prefix, .favourite_active = status->favourited ? "active" : "" }; + like_btn = tmpl_gen_like_btn_img(&ldata, NULL); + } + else { + struct repeat_btn_template rpbdata = { .repeat_active = status->reblogged ? "active" : "" }; + repeat_btn = tmpl_gen_repeat_btn(&rpbdata, NULL); + struct like_btn_template ldata = { .favourite_active = status->favourited ? "active" : "" }; + like_btn = tmpl_gen_like_btn(&ldata, NULL); + } + struct interaction_buttons_template data = { + // Icons + .reply_btn = use_img ? data_reply_btn_img : data_reply_btn, + .expand_btn = use_img ? data_expand_btn_img : data_expand_btn, + .repeat_btn = repeat_btn, + .like_btn = like_btn, + // Interactions data .prefix = config_url_prefix, .status_id = status->id, .reply_count = reply_count, .unrepeat = status->reblogged ? "un" : "", - .repeat_active = status->reblogged ? "active" : "", .repeats_count = repeat_count, .repeat_text = "Repeat", .unfavourite = status->favourited ? "un" : "", - .favourite_active = status->favourited ? "active" : "", .favourites_count = favourites_count, .favourites_text = "Favorite", .likeboost_btn = (likeboost_html && @@ -298,6 +328,8 @@ char* construct_interaction_buttons(struct session* ssn, free(reactions_btn_html); free(likeboost_html); free(time_str); + free(like_btn); + free(repeat_btn); return interaction_html; } diff --git a/static/config_general.tmpl b/static/config_general.tmpl index b544b1b..50c8ffb 100644 --- a/static/config_general.tmpl +++ b/static/config_general.tmpl @@ -55,6 +55,10 @@ +
  • + + +
  • diff --git a/static/expand_btn.tmpl b/static/expand_btn.tmpl new file mode 100644 index 0000000..19e5569 --- /dev/null +++ b/static/expand_btn.tmpl @@ -0,0 +1 @@ + diff --git a/static/expand_btn_img.tmpl b/static/expand_btn_img.tmpl new file mode 100644 index 0000000..6a57ac1 --- /dev/null +++ b/static/expand_btn_img.tmpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/interaction_buttons.tmpl b/static/interaction_buttons.tmpl index 8524276..097a861 100644 --- a/static/interaction_buttons.tmpl +++ b/static/interaction_buttons.tmpl @@ -3,7 +3,8 @@ - + {{ %s : reply_btn }} + {{%s:reply_count}} @@ -12,7 +13,8 @@
    @@ -22,7 +24,7 @@ @@ -32,7 +34,7 @@ {{%s:reactions_btn}} - + {{ %s : expand_btn }} diff --git a/static/like_btn.tmpl b/static/like_btn.tmpl new file mode 100644 index 0000000..3707a83 --- /dev/null +++ b/static/like_btn.tmpl @@ -0,0 +1 @@ + diff --git a/static/like_btn_img.tmpl b/static/like_btn_img.tmpl new file mode 100644 index 0000000..f9049a7 --- /dev/null +++ b/static/like_btn_img.tmpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/repeat_btn.tmpl b/static/repeat_btn.tmpl new file mode 100644 index 0000000..3148f92 --- /dev/null +++ b/static/repeat_btn.tmpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/repeat_btn_img.tmpl b/static/repeat_btn_img.tmpl new file mode 100644 index 0000000..b3b6398 --- /dev/null +++ b/static/repeat_btn_img.tmpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/reply_btn.tmpl b/static/reply_btn.tmpl new file mode 100644 index 0000000..d191f95 --- /dev/null +++ b/static/reply_btn.tmpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/reply_btn_img.tmpl b/static/reply_btn_img.tmpl new file mode 100644 index 0000000..3edcc5e --- /dev/null +++ b/static/reply_btn_img.tmpl @@ -0,0 +1 @@ + \ No newline at end of file