Work on separating interaction button functionality

FossilOrigin-Name: 81fed2012889096af2e48dfb8d3214cdc2c09a5e9d8051911869b5b9b5b6739c
This commit is contained in:
nekobit 2022-05-20 05:08:21 +00:00
parent 1c403a4714
commit e232ca36a8
6 changed files with 137 additions and 104 deletions

View file

@ -122,6 +122,12 @@ $(PAGES_DIR)/emoji_picker.chtml: $(PAGES_DIR)/emoji_picker.html
./filec $< data_emoji_picker_html > $@
$(PAGES_DIR)/emoji.chtml: $(PAGES_DIR)/emoji.html
./filec $< data_emoji_html > $@
$(PAGES_DIR)/likeboost.chtml: $(PAGES_DIR)/likeboost.html
./filec $< data_likeboost_html > $@
$(PAGES_DIR)/reactions_btn.chtml: $(PAGES_DIR)/reactions_btn.html
./filec $< data_reactions_btn_html > $@
$(PAGES_DIR)/interaction_buttons.chtml: $(PAGES_DIR)/interaction_buttons.html
./filec $< data_interaction_buttons_html > $@
# Login panel
$(PAGES_DIR)/quick_login.chtml: $(PAGES_DIR)/quick_login.html
./filec $< data_quick_login_html > $@

View file

@ -42,6 +42,9 @@
#include "../static/status_interactions_label.chtml"
#include "../static/status_interactions.chtml"
#include "../static/status_interaction_profile.chtml"
#include "../static/likeboost.chtml"
#include "../static/reactions_btn.chtml"
#include "../static/interaction_buttons.chtml"
#define ACCOUNT_INTERACTIONS_LIMIT 11
#define NUM_STR "%u"
@ -172,6 +175,65 @@ char* construct_status_interactions_label(char* header, int val, size_t* size)
return html;
}
char* construct_interaction_buttons(struct session* ssn,
struct mstdnt_status* status,
size_t* size,
uint8_t flags)
{
char* interaction_html;
char* reply_count = NULL;
char* repeat_count = NULL;
char* favourites_count = NULL;
char* emoji_picker_html = NULL;
size_t s;
// Emojo picker
if ((flags & STATUS_EMOJI_PICKER) == STATUS_EMOJI_PICKER)
{
emoji_picker_html = construct_emoji_picker(status->id, keyint(ssn->post.emojoindex), NULL);
}
if (status->replies_count)
easprintf(&reply_count, NUM_STR, status->replies_count);
if (status->reblogs_count)
easprintf(&repeat_count, NUM_STR, status->reblogs_count);
if (status->favourites_count)
easprintf(&favourites_count, NUM_STR, status->favourites_count);
s = easprintf(&interaction_html, data_interaction_buttons_html,
config_url_prefix,
status->id,
status->id,
reply_count ? reply_count : "",
config_url_prefix,
status->id,
status->reblogged ? "un" : "",
status->reblogged ? "active" : "",
repeat_count ? repeat_count : "",
config_url_prefix,
status->id,
status->favourited ? "un" : "",
status->favourited ? "active" : "",
favourites_count ? favourites_count : "",
config_url_prefix,
status->id,
config_url_prefix,
status->id,
status->id,
emoji_picker_html ? emoji_picker_html : "",
config_url_prefix,
status->id,
status->id);
if (size) *size = s;
// Cleanup
if (emoji_picker_html) free(emoji_picker_html);
if (reply_count) free(reply_count);
if (repeat_count) free(repeat_count);
if (favourites_count) free(favourites_count);
return interaction_html;
}
char* construct_status_interactions(int fav_count,
int reblog_count,
struct mstdnt_account* fav_accounts,
@ -385,16 +447,13 @@ char* construct_status(struct session* ssn,
char* stat_html;
// Counts
char* reply_count = NULL;
char* repeat_count = NULL;
char* favourites_count = NULL;
char* formatted_display_name = NULL;
char* attachments = NULL;
char* emoji_reactions = NULL;
char* interaction_btns = NULL;
char* notif_info = NULL;
char* in_reply_to_str = NULL;
char* interactions_html = NULL;
char* emoji_picker_html = NULL;
struct mstdnt_status* status = local_status;
// Create a "fake" notification header which contains information for
// the reblogged status
@ -409,12 +468,6 @@ char* construct_status(struct session* ssn,
if (!status) return NULL;
// Emojo picker
if ((flags & STATUS_EMOJI_PICKER) == STATUS_EMOJI_PICKER)
{
emoji_picker_html = construct_emoji_picker(status->id, keyint(ssn->post.emojoindex), NULL);
}
// If focused, show status interactions
if ((flags & STATUS_FOCUSED) == STATUS_FOCUSED &&
(status->reblogs_count || status->favourites_count))
@ -457,6 +510,8 @@ char* construct_status(struct session* ssn,
// Format status
char* parse_content = reformat_status(ssn, status->content, status->emojis, status->emojis_len);
interaction_btns = construct_interaction_buttons(ssn, status, NULL, flags);
// Find and replace
if (args && args->highlight_word)
@ -474,12 +529,6 @@ char* construct_status(struct session* ssn,
free(repl_str);
}
if (status->replies_count)
easprintf(&reply_count, NUM_STR, status->replies_count);
if (status->reblogs_count)
easprintf(&repeat_count, NUM_STR, status->reblogs_count);
if (status->favourites_count)
easprintf(&favourites_count, NUM_STR, status->favourites_count);
if (status->media_attachments_len)
attachments = construct_attachments(status->sensitive, status->media_attachments, status->media_attachments_len, NULL);
if (status->pleroma.emoji_reactions_len)
@ -524,42 +573,17 @@ char* construct_status(struct session* ssn,
attachments ? attachments : "",
interactions_html ? interactions_html : "",
emoji_reactions ? emoji_reactions : "",
config_url_prefix,
status->id,
status->id,
reply_count ? reply_count : "",
config_url_prefix,
status->id,
status->reblogged ? "un" : "",
status->reblogged ? "active" : "",
repeat_count ? repeat_count : "",
config_url_prefix,
status->id,
status->favourited ? "un" : "",
status->favourited ? "active" : "",
favourites_count ? favourites_count : "",
config_url_prefix,
status->id,
config_url_prefix,
status->id,
status->id,
emoji_picker_html ? emoji_picker_html : "",
config_url_prefix,
status->id,
status->id);
interaction_btns);
if (size) *size = s;
// Cleanup
if (reply_count) free(reply_count);
if (repeat_count) free(repeat_count);
if (favourites_count) free(favourites_count);
if (interaction_btns) free(interaction_btns);
if (in_reply_to_str) free(in_reply_to_str);
if (attachments) free(attachments);
if (emoji_reactions) free(emoji_reactions);
if (notif) free(notif_info);
if (interactions_html) free(interactions_html);
//if (formatted_display_name != status->account.display_name) free(formatted_display_name);
if (emoji_picker_html) free(emoji_picker_html);
if (parse_content != status->content) free(parse_content);
return stat_html;
}

View file

@ -0,0 +1,45 @@
<div class="status-interact">
<table class="ui-table">
<tr>
<td>
<form action="%s/status/%s/reply#id-%s" method="post">
<label class="pointer">
<svg class="reply" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9l6 6-6 6"/><path d="M4 4v7a4 4 0 0 0 4 4h11"/></svg>
<span class="count">%s</span>
<input class="hidden" type="submit" value="Reply">
</label>
</form>
</td>
<td>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="%srepeat">
<label class="pointer">
<svg class="repeat %s" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 2.1l4 4-4 4"/><path d="M3 12.2v-2a4 4 0 0 1 4-4h12.8M7 21.9l-4-4 4-4"/><path d="M21 11.8v2a4 4 0 0 1-4 4H4.2"/></svg>
<span class="count">%s</span>
<input class="hidden" type="submit" value="Repeat">
</label>
</form>
</td>
<td>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="%slike">
<label class="pointer">
<svg class="like %s" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>
<span class="count">%s</span>
<input class="hidden" type="submit" value="Like">
</label>
</form>
</td>
%s
%s
<td>
<form action="%s/status/%s#id-%s" method="post">
<label class="pointer">
<svg class="expand" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M14 10l6.1-6.1M9 21H3v-6M10 14l-6.1 6.1"/></svg>
<input class="hidden" type="submit" >
</label>
</form>
</td>
</tr>
</table>
</div>

9
static/likeboost.html Normal file
View file

@ -0,0 +1,9 @@
<td>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="likeboost">
<label class="pointer">
<svg class="one-click-software" width="20" height="20" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g><g stroke-width="1.98"><path d="m19.15 8.5061 2.7598 2.7598-2.7598 2.7598"/><path d="m14.756 11.325s2.5484-0.05032 6.3258 0.01026m-15.639 10.807-2.7598-2.7598 2.7598-2.7598"/><path d="m22.4 15.327v1.2259c0 1.156-1.2356 2.7598-2.7598 2.7598h-16.664"/></g><polygon transform="matrix(.60736 0 0 .60736 .60106 .63577)" points="18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2 15.09 8.26 22 9.27 17 14.14" stroke-width="2.9656"/></g></svg>
<input class="hidden" type="submit" value="L+R">
</label>
</form>
</td>

View file

@ -0,0 +1,9 @@
<td>
<form action="%s/status/%s/react#id-%s" method="post">
<label class="pointer">
<svg class="emoji-btn" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>
<input class="hidden" type="submit" value="Emoji">
</label>
</form>
%s
</td>

View file

@ -44,67 +44,7 @@
%s
%s
%s
<div class="status-interact">
<table class="ui-table">
<tr>
<td>
<form action="%s/status/%s/reply#id-%s" method="post">
<label class="pointer">
<svg class="reply" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9l6 6-6 6"/><path d="M4 4v7a4 4 0 0 0 4 4h11"/></svg>
<span class="count">%s</span>
<input class="hidden" type="submit" value="Reply">
</label>
</form>
</td>
<td>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="%srepeat">
<label class="pointer">
<svg class="repeat %s" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 2.1l4 4-4 4"/><path d="M3 12.2v-2a4 4 0 0 1 4-4h12.8M7 21.9l-4-4 4-4"/><path d="M21 11.8v2a4 4 0 0 1-4 4H4.2"/></svg>
<span class="count">%s</span>
<input class="hidden" type="submit" value="Repeat">
</label>
</form>
</td>
<td>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="%slike">
<label class="pointer">
<svg class="like %s" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>
<span class="count">%s</span>
<input class="hidden" type="submit" value="Like">
</label>
</form>
</td>
<td>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="likeboost">
<label class="pointer">
<svg class="one-click-software" width="20" height="20" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g><g stroke-width="1.98"><path d="m19.15 8.5061 2.7598 2.7598-2.7598 2.7598"/><path d="m14.756 11.325s2.5484-0.05032 6.3258 0.01026m-15.639 10.807-2.7598-2.7598 2.7598-2.7598"/><path d="m22.4 15.327v1.2259c0 1.156-1.2356 2.7598-2.7598 2.7598h-16.664"/></g><polygon transform="matrix(.60736 0 0 .60736 .60106 .63577)" points="18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2 15.09 8.26 22 9.27 17 14.14" stroke-width="2.9656"/></g></svg>
<input class="hidden" type="submit" value="L+R">
</label>
</form>
</td>
<td>
<form action="%s/status/%s/react#id-%s" method="post">
<label class="pointer">
<svg class="emoji-btn" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>
<input class="hidden" type="submit" value="Emoji">
</label>
</form>
%s
</td>
<td>
<form action="%s/status/%s#id-%s" method="post">
<label class="pointer">
<svg class="expand" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M14 10l6.1-6.1M9 21H3v-6M10 14l-6.1 6.1"/></svg>
<input class="hidden" type="submit" >
</label>
</form>
</td>
</tr>
</table>
</div>
%s
</td>
</tr>
</table>