Account sidebar
FossilOrigin-Name: fdae7c14435d63dc3f2b80dafe7d37fb867211e01f4cbff31296aa9f05b43b78
This commit is contained in:
parent
b8d67b3bcb
commit
440ee60b8d
9 changed files with 102 additions and 14 deletions
|
@ -11,4 +11,4 @@ config.h
|
|||
treebird
|
||||
test/tests
|
||||
scripts/*.o
|
||||
perl/*.cpl
|
||||
perl/*.ctt
|
|
@ -14,7 +14,7 @@ my $template = Template->new(
|
|||
|
||||
sub base_page
|
||||
{
|
||||
my ($ssn, $data, $main) = @_;
|
||||
my ($ssn, $data, $main, $acct) = @_;
|
||||
my $result;
|
||||
|
||||
my %vars = (
|
||||
|
@ -24,7 +24,9 @@ sub base_page
|
|||
lang => sub { $L10N{'EN_US'}->{shift(@_)} },
|
||||
main => $main,
|
||||
sidebar_opacity => $ssn->{config}->{sidebar_opacity} / 255,
|
||||
);
|
||||
acct => $acct
|
||||
);
|
||||
|
||||
|
||||
$template->process(\$data, \%vars, \$result) ||
|
||||
return $template->error();
|
||||
|
|
|
@ -875,3 +875,32 @@ void content_account_favourites(PATH_ARGS)
|
|||
if (navigation_box) free(navigation_box);
|
||||
if (output) free(output);
|
||||
}
|
||||
|
||||
HV* perlify_account(const struct mstdnt_account* acct)
|
||||
{
|
||||
HV* acct_hv = newHV();
|
||||
|
||||
if (!acct) return NULL;
|
||||
|
||||
hvstores_str(acct_hv, "id", acct->id);
|
||||
hvstores_str(acct_hv, "username", acct->username);
|
||||
hvstores_str(acct_hv, "acct", acct->acct);
|
||||
hvstores_str(acct_hv, "display_name", acct->display_name);
|
||||
hvstores_str(acct_hv, "note", acct->note);
|
||||
hvstores_str(acct_hv, "avatar", acct->avatar);
|
||||
hvstores_str(acct_hv, "avatar_static", acct->avatar_static);
|
||||
hvstores_str(acct_hv, "header", acct->header);
|
||||
hvstores_str(acct_hv, "header_static", acct->header_static);
|
||||
hvstores_str(acct_hv, "created_at", acct->created_at);
|
||||
hvstores_str(acct_hv, "last_status_at", acct->last_status_at);
|
||||
hvstores_str(acct_hv, "mute_expires_at", acct->mute_expires_at);
|
||||
hvstores_int(acct_hv, "statuses_count", acct->statuses_count);
|
||||
hvstores_int(acct_hv, "followers_count", acct->followers_count);
|
||||
hvstores_int(acct_hv, "following_count", acct->following_count);
|
||||
hvstores_int(acct_hv, "bot", acct->bot);
|
||||
hvstores_int(acct_hv, "suspended", acct->suspended);
|
||||
hvstores_int(acct_hv, "locked", acct->locked);
|
||||
hvstores_int(acct_hv, "discoverable", acct->discoverable);
|
||||
|
||||
return acct_hv;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#ifndef ACCOUNT_H
|
||||
#define ACCOUNT_H
|
||||
#include "global_perl.h"
|
||||
#include <stddef.h>
|
||||
#include <mastodont.h>
|
||||
#include "session.h"
|
||||
|
@ -95,4 +96,6 @@ void content_account_action(PATH_ARGS);
|
|||
void content_account_favourites(PATH_ARGS);
|
||||
void content_account_bookmarks(PATH_ARGS);
|
||||
|
||||
HV* perlify_account(const struct mstdnt_account* acct);
|
||||
|
||||
#endif // ACCOUNT_H
|
||||
|
|
|
@ -45,9 +45,11 @@ void render_base_page(struct base_page* page, FCGX_Request* req, struct session*
|
|||
PUSHMARK(SP);
|
||||
|
||||
HV* session_hv = perlify_session(ssn);
|
||||
HV* acct_hv = perlify_account(&(ssn->acct));
|
||||
XPUSHs(sv_2mortal(newRV_inc((SV*)session_hv)));
|
||||
XPUSHs(sv_2mortal(newSVpv(data_main_tt, 0)));
|
||||
XPUSHs(sv_2mortal(newSVpv(page->content, 0)));
|
||||
XPUSHs(sv_2mortal(newRV_inc((SV*)acct_hv)));
|
||||
|
||||
struct mstdnt_args m_args;
|
||||
set_mstdnt_args(&m_args, ssn);
|
||||
|
@ -99,8 +101,6 @@ void render_base_page(struct base_page* page, FCGX_Request* req, struct session*
|
|||
|
||||
send_result(req, NULL, "text/html", data, 0);
|
||||
cleanup:
|
||||
|
||||
|
||||
PUTBACK;
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include <EXTERN.h>
|
||||
#include <perl.h>
|
||||
|
||||
// hv_stores(ssn_hv, "id", newSVpv(acct->id, 0));
|
||||
#define hvstores_str(hv, key, val) hv_stores((hv), key, newSVpv((val), 0))
|
||||
#define hvstores_int(hv, key, val) hv_stores((hv), key, newSViv((val)))
|
||||
|
||||
static PerlInterpreter* perl;
|
||||
|
||||
#endif /* GLOBAL_PERL_H */
|
||||
|
|
|
@ -33,7 +33,7 @@ const char* const get_token(struct session* ssn)
|
|||
HV* perlify_session(struct session* ssn)
|
||||
{
|
||||
HV* ssn_hv = newHV();
|
||||
hv_stores(ssn_hv, "logged_in", newSVuv(ssn->logged_in));
|
||||
hvstores_int(ssn_hv, "logged_in", ssn->logged_in);
|
||||
HV* ssn_post_values = perlify_post_values(&(ssn->post));
|
||||
HV* ssn_get_values = perlify_get_values(&(ssn->query));
|
||||
HV* ssn_cookie_values = perlify_cookies(&(ssn->cookies));
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -83,14 +83,69 @@
|
|||
|
||||
<!-- Notifications and such -->
|
||||
<td id="rightbar" class="sidebar">
|
||||
{{ %s : sidebar_rightbar }}
|
||||
[% IF ssn.cookies.logged_in %]
|
||||
<div class="account-sidebar"
|
||||
[%- IF acct.header -%]
|
||||
style="background: linear-gradient(var(--account-overlay-gradient-top), var(--account-overlay-gradient-bottom)), url([% acct.header %]);"
|
||||
[%- END %]>
|
||||
<table class="acct-info">
|
||||
<tr>
|
||||
<td>
|
||||
<img src="[% acct.avatar %]" class="acct-pfp" loading="lazy">
|
||||
</td>
|
||||
<td class="acct-info-right">
|
||||
<span class="username">[% acct.username %]</span>
|
||||
<span class="acct">@<span class="acct-js-grep">[% acct.acct %]</span></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="acct-stats">
|
||||
<tr>
|
||||
<td class="header-btn btn">
|
||||
<a href="$prefix/@[% acct.acct %]">
|
||||
<span class="btn-header">[% lang('TAB_STATUSES') %]</span>
|
||||
<span class="btn-content">[% acct.statuses_count %]</span>
|
||||
</a>
|
||||
</td>
|
||||
<td class="header-btn btn">
|
||||
<a href="$prefix/@[% acct.acct %]/following">
|
||||
<span class="btn-header">[% lang('TAB_FOLLOWING') %]</span>
|
||||
<span class="btn-content">[% acct.following_count %]</span>
|
||||
</a>
|
||||
</td>
|
||||
<td class="header-btn btn">
|
||||
<a href="$prefix/@[% acct.acct %]/followers">
|
||||
<span class="btn-header">[% lang('TAB_FOLLOWERS') %]</span>
|
||||
<span class="btn-content">[% acct.followers_count %]</span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<div class="sidebar-login">
|
||||
<form action="$prefix/login" method="post">
|
||||
<div class="form-group">
|
||||
<label for="login-username">[% lang('USERNAME') %]: </label>
|
||||
<input type="text" id="login-username" name="username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="login-password">[% lang('PASSWORD') %]: </label>
|
||||
<input type="password" id="login-password" name="password"><br>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn" type="submit" value="[% lang('LOGIN_BTN') %]">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
[% END %]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Source -->
|
||||
<script src="/js/main.js"></script>
|
||||
<script src="/js/emoji.js"></script>
|
||||
<script src="$prefix/js/main.js"></script>
|
||||
<script src="$prefix/js/emoji.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue