Seperate notifications logic, fix perl modules
FossilOrigin-Name: 8dedd9a9e0ca9f982140de1e980be166d07e9d549eae5cb50115fc3a7a414ae6
This commit is contained in:
parent
9923154112
commit
2609b8d54f
|
@ -97,3 +97,5 @@ sub content_accounts
|
|||
return $acct_list_page;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -23,3 +23,4 @@ sub generate_attachment
|
|||
to_template(\%vars, \$data->{'attachment.tt'});
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -33,3 +33,4 @@ sub content_chats
|
|||
to_template(\%vars, \$data->{'content_chats.tt'});
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -22,3 +22,4 @@ sub generate_emoji
|
|||
to_template(\%vars, \$data->{'emoji.tt'});
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -69,3 +69,5 @@ sub visibility_to_icon
|
|||
# Assume local for anything else, because well... I'm not sure
|
||||
get_icon('local');
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -3,7 +3,7 @@ use warnings;
|
|||
# Modules
|
||||
use Template;
|
||||
use l10n qw( &lang %L10N );
|
||||
use notifications qw( generate_notification_compact content_notifications );
|
||||
use notifications qw( generate_notification content_notifications );
|
||||
use template_helpers qw( &to_template );
|
||||
use timeline;
|
||||
use icons 'get_icon';
|
||||
|
@ -39,7 +39,7 @@ sub base_page
|
|||
acct => $ssn->{account},
|
||||
data => $data,
|
||||
notifs => $notifs,
|
||||
notification_compact => \&generate_notification_compact,
|
||||
notification => \&generate_notification,
|
||||
);
|
||||
|
||||
to_template(\%vars, \$data->{'main.tt'});
|
||||
|
|
|
@ -3,24 +3,29 @@ use strict;
|
|||
use warnings;
|
||||
use Exporter 'import';
|
||||
|
||||
our @EXPORT = qw( generate_notification_compact content_notifications );
|
||||
our @EXPORT = qw( generate_notification content_notifications );
|
||||
|
||||
use template_helpers 'to_template';
|
||||
use status 'generate_status';
|
||||
use string_helpers qw( random_error_kaomoji );
|
||||
use icons 'get_icon';
|
||||
|
||||
sub generate_notification_compact
|
||||
sub generate_notification
|
||||
{
|
||||
my ($ssn, $data, $notif) = @_;
|
||||
my ($ssn, $data, $notif, $is_compact) = @_;
|
||||
|
||||
$is_compact ||= 0;
|
||||
|
||||
my %vars = (
|
||||
prefix => '',
|
||||
ssn => $ssn,
|
||||
notif => $notif
|
||||
notif => $notif,
|
||||
compact => $is_compact,
|
||||
create_status => sub { generate_status($ssn, $data, shift, shift, $is_compact); },
|
||||
icon => \&get_icon,
|
||||
);
|
||||
|
||||
to_template(\%vars, \$data->{'notif_compact.tt'});
|
||||
to_template(\%vars, \$data->{'notification.tt'});
|
||||
}
|
||||
|
||||
sub content_notifications
|
||||
|
@ -31,10 +36,11 @@ sub content_notifications
|
|||
prefix => '',
|
||||
ssn => $ssn,
|
||||
notifs => $notifs,
|
||||
create_status => sub { generate_status($ssn, $data, shift, shift); },
|
||||
icon => \&get_icon,
|
||||
notification => sub { generate_notification($ssn, $data, shift); },
|
||||
random_error_kaomoji => \&random_error_kaomoji,
|
||||
);
|
||||
|
||||
to_template(\%vars, \$data->{'content_notifs.tt'});
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -13,9 +13,12 @@ our @EXPORT = qw( content_status generate_status );
|
|||
|
||||
use template_helpers 'to_template';
|
||||
|
||||
# Useful variable to prevent collisions
|
||||
my $rel_context = 0;
|
||||
|
||||
sub generate_status
|
||||
{
|
||||
my ($ssn, $data, $status, $notif) = @_;
|
||||
my ($ssn, $data, $status, $notif, $is_compact) = @_;
|
||||
my $boost_acct;
|
||||
|
||||
# Move status reference for boosts and keep account
|
||||
|
@ -33,7 +36,9 @@ sub generate_status
|
|||
boost => $boost_acct, # May be undef
|
||||
data => $data,
|
||||
notif => $notif, # May be undef
|
||||
compact => $is_compact, # May be undef
|
||||
is_statusey_notif => ($notif && ($notif->{type} eq 'mention' || $notif->{type} eq 'status')),
|
||||
unique_toggle_id => $rel_context++,
|
||||
# Functions
|
||||
icon => \&get_icon,
|
||||
lang => \&lang,
|
||||
|
@ -56,6 +61,8 @@ sub content_status
|
|||
{
|
||||
my ($ssn, $data, $status, $statuses_before, $statuses_after) = @_;
|
||||
|
||||
$rel_context = 0;
|
||||
|
||||
my %vars = (
|
||||
prefix => '',
|
||||
ssn => $ssn,
|
||||
|
@ -70,3 +77,5 @@ sub content_status
|
|||
|
||||
to_template(\%vars, \$data->{'content_status.tt'});
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
/* TODO let's generate this file dynamically with a Perl script? */
|
||||
#include "../templates/main.ctt"
|
||||
#include "../templates/notif_compact.ctt"
|
||||
#include "../templates/notification.ctt"
|
||||
#include "../templates/status.ctt"
|
||||
#include "../templates/content_status.ctt"
|
||||
#include "../templates/emoji_picker.ctt"
|
||||
|
@ -50,7 +50,7 @@ void init_template_files(pTHX)
|
|||
template_files = newHV();
|
||||
|
||||
hv_stores(template_files, "main.tt", newSVpv(data_main_tt, data_main_tt_size));
|
||||
hv_stores(template_files, "notif_compact.tt", newSVpv(data_notif_compact_tt, data_notif_compact_tt_size));
|
||||
hv_stores(template_files, "notification.tt", newSVpv(data_notification_tt, data_notification_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));
|
||||
|
|
|
@ -14,39 +14,7 @@
|
|||
</div>
|
||||
[% IF notifs %]
|
||||
[% FOREACH notif IN notifs %]
|
||||
[%# There are 3 types of "different" notifications to render
|
||||
- Mention, statuses (just regular statuses)
|
||||
- Favorites, moves, reblogs, polls (no interaction buttons)
|
||||
- Follows, follow requests
|
||||
%]
|
||||
[% IF notif.type == 'mention' ||
|
||||
notif.type == 'status' ||
|
||||
notif.type == 'favourite' ||
|
||||
notif.type == 'reblog' ||
|
||||
notif.type == 'emoji reaction' ||
|
||||
notif.type == 'poll' %]
|
||||
[% create_status(notif.status, notif) %]
|
||||
[% ELSIF notif.type == 'follow' || notif.type == 'follow request' %]
|
||||
<table class="notification notification-regular ui-table">
|
||||
<tr>
|
||||
<td class="pfp-td">
|
||||
<img src="[% notif.account.avatar %]" loading="lazy">
|
||||
</td>
|
||||
<td class="notification-info">
|
||||
<div class="notification-info-format">
|
||||
<span class="notification-text-group-with-icon">
|
||||
<span title="[% notif.account.acct %]" class="username">[% notif.account.display_name %]</span>
|
||||
<span class="action">followed</span>
|
||||
</span>
|
||||
[% icon('follow') %]
|
||||
</div>
|
||||
<div class="notification-content">
|
||||
<a href="/@[% notif.account.acct %]">@[% notif.account.acct %]</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
[% END %]
|
||||
[% notification(notif) %]
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<div class="fancy-error">
|
||||
|
|
|
@ -106,16 +106,16 @@
|
|||
</ul>
|
||||
|
||||
<ul class="sidebar-config">
|
||||
<li><a class="sidebarbtn-sub" href="{{%s:prefix}}/config/general">[% lang('GENERAL') %]</a></li>
|
||||
<li><a class="sidebarbtn-sub" href="{{%s:prefix}}/config/appearance">[% lang('APPEARANCE') %]</a></li>
|
||||
<li><a class="sidebarbtn-sub" href="$prefix/config/general">[% lang('GENERAL') %]</a></li>
|
||||
<li><a class="sidebarbtn-sub" href="$prefix/config/appearance">[% lang('APPEARANCE') %]</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<!-- <div class="static-html" id="instance-panel"></div> -->
|
||||
<div class="mini-links">
|
||||
<a href="{{%s:prefix}}/about">About</a>
|
||||
<a href="$prefix/about">About</a>
|
||||
<span class="bullet-separate">•</span>
|
||||
<a href="{{%s:prefix}}/about/license">License</a>
|
||||
<a href="$prefix/about/license">License</a>
|
||||
<span class="bullet-separate">•</span>
|
||||
<a href="https://fossil.nekobit.net/treebird">Source code</a>
|
||||
</div>
|
||||
|
@ -169,9 +169,11 @@
|
|||
</div>
|
||||
|
||||
<!-- Notifications -->
|
||||
[% FOREACH notif IN notifs %]
|
||||
[% notification_compact(ssn, data, notif) %]
|
||||
[% END %]
|
||||
<div class="notifications-compact">
|
||||
[% FOREACH notif IN notifs %]
|
||||
[% notification(ssn, data, notif) %]
|
||||
[% END %]
|
||||
</div>
|
||||
|
||||
[% ELSE %]
|
||||
<div class="sidebar-login">
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
[%# There are 3 types of "different" notifications to render
|
||||
- Mention, statuses (just regular statuses)
|
||||
- Favorites, moves, reblogs, polls (no interaction buttons)
|
||||
- Follows, follow requests
|
||||
%]
|
||||
[% IF notif.type == 'mention' ||
|
||||
notif.type == 'status' ||
|
||||
notif.type == 'favourite' ||
|
||||
notif.type == 'reblog' ||
|
||||
notif.type == 'emoji reaction' ||
|
||||
notif.type == 'poll' %]
|
||||
[% create_status(notif.status, notif) %]
|
||||
[% ELSIF notif.type == 'follow' || notif.type == 'follow request' %]
|
||||
<table class="notification notification-regular ui-table">
|
||||
<tr>
|
||||
<td class="pfp-td">
|
||||
<img src="[% notif.account.avatar %]" loading="lazy">
|
||||
</td>
|
||||
<td class="notification-info">
|
||||
<div class="notification-info-format">
|
||||
<span class="notification-text-group-with-icon">
|
||||
<span title="[% notif.account.acct %]" class="username">[% notif.account.display_name %]</span>
|
||||
<span class="action">followed</span>
|
||||
</span>
|
||||
[% icon('follow') %]
|
||||
</div>
|
||||
<div class="notification-content">
|
||||
<a href="/@[% notif.account.acct %]">@[% notif.account.acct %]</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
[% END %]
|
|
@ -1,4 +1,4 @@
|
|||
<input type="checkbox" class="status-hide" id="status-toggle-[% status.id %]"[% IF status.muted %] checked[% END %]>
|
||||
<input type="checkbox" class="status-hide" id="status-toggle-[% status.id %]-[% unique_toggle_id %]"[% IF status.muted %] checked[% END %]>
|
||||
<div class="status
|
||||
[%- IF notif %] status-notification[% IF notif.pleroma && !notif.pleroma.is_seen %] notification-unread[% END %][% END %]
|
||||
[%- IF is_statusey_notif -%] status-notification-mention[% END %]
|
||||
|
@ -84,7 +84,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<label for="status-toggle-[% status.id %]" class="status-view"></label>
|
||||
<label for="status-toggle-[% status.id %]-[% unique_toggle_id %]" class="status-view"></label>
|
||||
</span>
|
||||
</div>
|
||||
<div class="status-data">
|
||||
|
|
Loading…
Reference in New Issue