Perlify relationship

FossilOrigin-Name: 08437db1c8a6eae47804c4687a67c5522b2b98b7464cc089229bf07fbbd8880a
This commit is contained in:
nekobit 2022-08-05 04:01:03 +00:00
parent 72f8932155
commit 6ea891ae8b
4 changed files with 96 additions and 4 deletions

View file

@ -16,6 +16,7 @@ sub generate_account
prefix => '',
ssn => $ssn,
content => $content,
acct => $acct,
);
to_template(\%vars, \$data->{'account.tt'});
@ -23,7 +24,7 @@ sub generate_account
sub content_statuses
{
my ($ssn, $data, $acct, $statuses) = @_;
my ($ssn, $data, $acct, $relationships, $statuses) = @_;
my %vars = (
prefix => '',
@ -31,5 +32,5 @@ sub content_statuses
acct => $acct,
);
generate_account($ssn, $data, $acct, to_template(\%vars, \$data->{'account_statuses.tt'}));
generate_account($ssn, $data, $acct, $relationships, to_template(\%vars, \$data->{'account_statuses.tt'}));
}

View file

@ -242,6 +242,10 @@ static char* account_statuses_cb(HV* session_hv,
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
XPUSHs(newRV_noinc((SV*)perlify_account(acct)));
if (rel)
XPUSHs(newRV_noinc((SV*)perlify_relationship(rel)));
else ARG_UNDEFINED();
if (statuses)
XPUSHs(newRV_noinc((SV*)perlify_statuses(statuses, statuses_len)));
else ARG_UNDEFINED();
@ -914,3 +918,24 @@ HV* perlify_account(const struct mstdnt_account* acct)
return acct_hv;
}
HV* perlify_relationship(const struct mstdnt_relationship* rel)
{
if (!rel) return NULL;
HV* rel_hv = newHV();
hvstores_str(rel_hv, "id", rel->id);
hvstores_int(rel_hv, "following", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_FOLLOWING));
hvstores_int(rel_hv, "requested", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_REQUESTED));
hvstores_int(rel_hv, "endoresed", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_ENDORSED));
hvstores_int(rel_hv, "followed_by", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_FOLLOWED_BY));
hvstores_int(rel_hv, "muting", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_MUTING));
hvstores_int(rel_hv, "muting_notifs", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_MUTING_NOTIFS));
hvstores_int(rel_hv, "showing_reblogs", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_SHOWING_REBLOGS));
hvstores_int(rel_hv, "notifying", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_NOTIFYING));
hvstores_int(rel_hv, "blocking", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_BLOCKING));
hvstores_int(rel_hv, "domain_blocking", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_DOMAIN_BLOCKING));
hvstores_str(rel_hv, "blocked_by", rel->id);
return rel_hv;
}

View file

@ -98,5 +98,6 @@ void content_account_favourites(PATH_ARGS);
void content_account_bookmarks(PATH_ARGS);
HV* perlify_account(const struct mstdnt_account* acct);
HV* perlify_relationship(const struct mstdnt_relationship* rel);
#endif // ACCOUNT_H

View file

@ -1,3 +1,68 @@
account
{{%s:is_blocked}}
{{%s:menubar}}
<div class="account">
<div class="acct-banner" style="background-image:url('{{%s:header}}');">
{{%s:follows_you}}
<div class="acct-info-data">
<span class="acct-displayname">{{%s:display_name}}</span>
<span class="acct-username">{{%s:acct}}</span>
</div>
<span class="menu-container user-options-btn">
Menu
<div class="menu menu-options">
<ul>
<li><a class="nolink" href="{{%s:prefix}}/user/{{%s:userid}}/action/{{%s:unsubscribe}}subscribe"><input class="btn-menu" type="button" value="{{%s:subscribe_text}}"></a></li>
<li><a class="nolink" href="{{%s:prefix}}/user/{{%s:userid}}/action/{{%s:unblock}}block"><input class="btn-menu" type="button" value="{{%s:block_text}}"></a></li>
<li><a class="nolink" href="{{%s:prefix}}/user/{{%s:userid}}/action/{{%s:unmute}}mute"><input class="btn-menu" type="button" value="{{%s:mute_text}}"></a></li>
</ul>
</div>
</span>
</div>
<div class="acct-header">
<a href="{{%s:prefix}}/@{{%s:acct}}" class="header-btn btn">
<span class="btn-header">{{%s:tab_statuses_text}}</span>
<span class="btn-content">{{%d:statuses_count}}</span>
</a>
<a href="{{%s:prefix}}/@{{%s:acct}}/following" class="header-btn btn">
<span class="btn-header">{{%s:tab_following_text}}</span>
<span class="btn-content">{{%d:following_count}}</span>
</a>
<a href="{{%s:prefix}}/@{{%s:acct}}/followers" class="header-btn btn">
<span class="btn-header">{{%s:tab_followers_text}}</span>
<span class="btn-content">{{%d:followers_count}}</span>
</a>
{{%s:follow_btn}}
</div>
<div class="acct-pfp-wrapper">
<img class="acct-pfp" src="{{%s:avatar}}">
</div>
</div>
{{%s:info}}
<table class="tabs ui-table">
<tr>
<td>
<a href="{{%s:prefix}}/@{{%s:acct}}/statuses"><input class="tab-btn btn {{%s:tab_statuses_focused}}" type="button" value="{{%s:tab_statuses_text}}"></a>
</td>
<td>
<a href="{{%s:prefix}}/@{{%s:acct}}/scrobbles"><input class="tab-btn btn {{%s:tab_scrobbles_focused}}" type="button" value="{{%s:tab_scrobbles_text}}"></a>
</td>
<td>
<a href="{{%s:prefix}}/@{{%s:acct}}/media"><input class="tab-btn btn {{%s:tab_media_focused}}" type="button" value="{{%s:tab_media_text}}"></a>
</td>
<td>
<a href="{{%s:prefix}}/@{{%s:acct}}/pinned"><input class="tab-btn btn {{%s:tab_pinned_focused}}" type="button" value="{{%s:tab_pinned_text}}"></a>
</td>
</tr>
</table>
<div class="account-content">
{{%s:acct_content}}
</div>
[% content %]