Status icons

FossilOrigin-Name: af3a2a07971fa9fbbf9d8c894e1bec8dbc2442b50894460e479077c7911ffe57
This commit is contained in:
nekobit 2022-07-29 05:41:28 +00:00
parent 97c81d08b7
commit a11470cfd7
7 changed files with 182 additions and 10 deletions

29
perl/icons.pm Normal file
View file

@ -0,0 +1,29 @@
package icons;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw( &get_icon &get_icon_svg &get_icon_png );
sub get_icon
{
my ($ico, $is_png) = @_;
$is_png ||= 0;
$is_png ? get_icon_png($ico) : get_icon_svg($ico);
}
sub get_icon_svg
{
my %res = (
repeat => '<svg class="repeat" 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>',
like => '<svg class="like" 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>',
expand => '<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>',
reply => '<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>',
emoji => '<svg class="emoji-btn" 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"><circle cx="12" cy="12" r="10"/><g><line x1="9" x2="9" y1="6.9367" y2="11.755" stroke-width="1.7916"/><line x1="15" x2="15" y1="6.9367" y2="11.755" stroke-width="1.7916"/><path d="m7.0891 15.099s4.7206 4.7543 9.7109 0" stroke-linecap="round" stroke-linejoin="miter" stroke-width="1.9764"/></g></svg>',
likeboost => '<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>',
);
$res{$_[0]};
}

View file

@ -1,6 +1,7 @@
package status;
use strict;
use warnings;
use icons 'get_icon';
use Exporter 'import';
our @EXPORT = qw( status );
@ -12,8 +13,10 @@ sub status
my ($ssn, $data, $status) = @_;
my %vars = (
prefix => $ssn,
status => $status
prefix => '',
ssn => $ssn,
status => $status,
icon => \&get_icon,
);
to_template(\%vars, \$data->{'status.tt'});
@ -24,6 +27,7 @@ sub content_status
my ($ssn, $data, $status, $statuses_before, $statuses_after) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
data => $data,
create_status => \&status,

View file

@ -22,6 +22,7 @@
#include "../templates/notif_compact.ctt"
#include "../templates/status.ctt"
#include "../templates/content_status.ctt"
#include "../templates/emoji_picker.ctt"
HV* template_files;
pthread_mutex_t perl_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -34,6 +35,7 @@ void init_template_files()
hv_stores(template_files, "notif_compact.tt", newSVpv(data_notif_compact_tt, data_notif_compact_tt_size));
hv_stores(template_files, "status.tt", newSVpv(data_status_tt, data_status_tt_size));
hv_stores(template_files, "content_status.tt", newSVpv(data_content_status_tt, data_content_status_tt_size));
hv_stores(template_files, "emoji_picker.tt", newSVpv(data_emoji_picker_tt, data_emoji_picker_tt_size));
}
void cleanup_template_files()

View file

@ -1122,7 +1122,7 @@ HV* perlify_status(const struct mstdnt_status* status)
HV* status_hv = newHV();
hvstores_str(status_hv, "id", status->id);
hvstores_str(status_hv, "uri", status->uri);
hvstores_str(status_hv, "created_at", status->id);
hvstores_int(status_hv, "created_at", status->created_at);
hvstores_ref(status_hv, "account", perlify_account(&(status->account)));
hvstores_str(status_hv, "content", status->content);
hvstores_str(status_hv, "spoiler_text", status->spoiler_text);

View file

@ -1,5 +0,0 @@
<label for="status-quickreply-{{%s:status_id}}" class="pointer statbtn reply-btn">
{{ %s : reply_btn }}
<span class="count">{{%s:reply_count}}</span>
</label>

81
templates/emoji_picker.tt Normal file
View file

@ -0,0 +1,81 @@
<div class="emoji-picker">
<table class="tabs ui-table">
<tr>
<td>
<label for="cat-smileys">
<span class="tab-btn btn btn-alt">😃</span>
</label>
</td>
<td>
<label for="cat-animals">
<span class="tab-btn btn btn-alt">🐻</span>
</label>
</td>
<td>
<label for="cat-food">
<span class="tab-btn btn btn-alt">🍔</span>
</label>
</td>
<td>
<label for="cat-travel">
<span class="tab-btn btn btn-alt">🚀</span>
</label>
</td>
<td>
<label for="cat-activities">
<span class="tab-btn btn btn-alt">⚽</span>
</label>
</td>
<td>
<label for="cat-objects">
<span class="tab-btn btn btn-alt">🔧</span>
</label>
</td>
<td>
<label for="cat-symbols">
<span class="tab-btn btn btn-alt">🔢</span>
</label>
</td>
<td>
<label for="cat-flags">
<span class="tab-btn btn btn-alt">🎌</span>
</label>
</td>
</tr>
</table>
<div class="emoji-picker-emojos-wrapper">
<input type="radio" class="hidden" id="cat-smileys" name="emoji-cat" checked>
<div class="emoji-picker-emojos">
{{%s:emojis_smileys}}
</div>
<input type="radio" class="hidden" id="cat-animals" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_animals}}
</div>
<input type="radio" class="hidden" id="cat-food" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_food}}
</div>
<input type="radio" class="hidden" id="cat-travel" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_travel}}
</div>
<input type="radio" class="hidden" id="cat-activities" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_activities}}
</div>
<input type="radio" class="hidden" id="cat-objects" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_objects}}
</div>
<input type="radio" class="hidden" id="cat-symbols" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_symbols}}
</div>
<input type="radio" class="hidden" id="cat-flags" name="emoji-cat">
<div class="emoji-picker-emojos">
{{%s:emojis_flags}}
</div>
</div>
</div>

View file

@ -9,7 +9,7 @@
<td class="status-info">
<div class="poster-stats">
<span class="username">[% status.account.display_name %]</span>
<a class="instance-info" href="$prefix/@{{%s:acct}}">[% status.account.acct %]</a>
<a class="instance-info" href="$prefix/@[% status.account.acct %]">[% status.account.acct %]</a>
<span class="alignend">
<div class="menu-container status-visibility">
{{%s:visibility}}
@ -61,7 +61,68 @@
{{%s:attachments}}
{{%s:interactions}}
{{%s:emoji_reactions}}
{{%s:interaction_btns}}
<div class="status-interact">
<table class="ui-table">
<tr>
<td>
<label for="status-quickreply-{{%s:status_id}}" class="pointer statbtn reply-btn">
[% icon('reply') %]
<span class="count">[% status.replies_count %]</span>
</label>
</td>
<td>
<form action="$prefix/status/[% status.id %]/interact" method="post">
<input class="itype" type="hidden" name="itype" value="{{%s:unrepeat}}repeat">
<label class="repeat-btn pointer statbtn">
[% icon('repeat') %]
<span class="count">[% status.reblogs_count %]</span>
<input class="hidden" type="submit" value="Repeat">
</label>
</form>
</td>
<td>
<form action="$prefix/status/[% status.id %]/interact" method="post">
<input class="itype" type="hidden" name="itype" value="{{%s:unfavourite}}like">
<label class="pointer statbtn like-btn">
[% icon('like') %]
<span class="count">[% status.favourites_count %]</span>
<input class="hidden" type="submit" value="Like">
</label>
</form>
</td>
[% IF ssn.config.stat_oneclicksoftware %]
<td>
<form action="$prefix/status/[% status.id %]/interact" method="post">
<input class="itype" type="hidden" name="itype" value="likeboost">
<label class="pointer statbtn likeboost-btn">
[% icon('likeboost') %]
<input class="hidden" type="submit" value="L+R">
</label>
</form>
</td>
[% END %]
<td>
<a target="_parent" href="$prefix/status/[% status.id %]/react#[% status.id %]" class="pointer statbtn react-btn">
[% icon('emoji') %]
</a>
[% IF emoji_picker -%]
[% emoji_picker %]
[%- END %]
</td>
<td>
<a target="_parent" href="$prefix/status/[% status.id %]#[% status.id %]" class="pointer statbtn view-btn">
[% icon('expand') %]
</a>
</td>
<td>
<a href="#[% status.id %]" class="time">[% status.created_at %]</a>
</td>
</tr>
</table>
</div>
</div>
</td>
</tr>