Menubar on current account

FossilOrigin-Name: 1a9669dd23cb49106ec919cbaac5cab4511e009fa46fbf311e216983a87a0be4
This commit is contained in:
nekobit 2022-06-11 05:02:23 +00:00
parent eb6c8285f7
commit 698bba32c6
6 changed files with 58 additions and 18 deletions

12
dist/treebird20.css vendored
View file

@ -1697,19 +1697,23 @@ ul.large-list li a
.mini-links
{
margin: 10px 8px;
margin: 16px 8px;
text-align: center;
color: #909090;
color: #aaa;
font-size: 10px;
}
.mini-links .bullet-separate
{
color: #909090;
font-size: 10px;
color: #ccc;
font-size: 8px;
margin: unset;
}
#instance-panel + .mini-links
{
margin: 10px 8px;
}
/******************************
* Scrobbles *

View file

@ -39,6 +39,7 @@
#include "../static/bookmarks_page.ctmpl"
#include "../static/account_stub.ctmpl"
#include "../static/account_sidebar.ctmpl"
#include "../static/account_current_menubar.ctmpl"
#define FOLLOWS_YOU_HTML "<span class=\"acct-badge\">%s</span>"
@ -221,7 +222,10 @@ static void fetch_account_page(struct session* ssn,
free(account_page);
}
size_t construct_account_page(char** result, struct account_page* page, char* content)
size_t construct_account_page(struct session* ssn,
char** result,
struct account_page* page,
char* content)
{
if (!page->account)
{
@ -230,13 +234,18 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
}
size_t size;
struct mstdnt_relationship* rel = page->relationship;
char* follow_btn = NULL, *follow_btn_text = NULL;
char* follows_you = NULL;
char* info_html = NULL;
char* is_blocked = NULL;
char* display_name = emojify(page->display_name,
page->account->emojis,
page->account->emojis_len);
int is_same_user = ssn->logged_in && strcmp(ssn->acct.acct, page->acct) == 0;
char* follow_btn = NULL,
* follow_btn_text = NULL,
* follows_you = NULL,
* info_html = NULL,
* is_blocked = NULL,
* menubar = NULL,
* display_name = NULL;
emojify(page->display_name,
page->account->emojis,
page->account->emojis_len);
// Check if note is not empty
if (page->note && strcmp(page->note, "") != 0)
@ -244,7 +253,8 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
info_html = load_account_info(page->account, NULL);
}
if (rel)
// Display follow button only if not the same user
if (rel && !is_same_user)
{
if (MSTDNT_FLAG_ISSET(rel->flags, MSTDNT_RELATIONSHIP_FOLLOWED_BY))
easprintf(&follows_you, FOLLOWS_YOU_HTML, L10N[page->locale][L10N_FOLLOWS_YOU]);
@ -273,9 +283,22 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
follow_btn = tmpl_gen_account_follow_btn(&data, NULL);
}
// Display menubar with extra options for access if same user
if (is_same_user)
{
struct account_current_menubar_template acmdata = {
.blocked_str = "Blocks",
.muted_str = "Mutes",
.favourited_str = "Favorites",
};
menubar = tmpl_gen_account_current_menubar(&acmdata, NULL);
}
struct account_template acct_data = {
.block_text = STR_NULL_EMPTY(is_blocked),
.header = page->header_image,
.menubar = menubar,
.display_name = display_name,
.acct = page->acct,
.prefix = config_url_prefix,
@ -325,6 +348,7 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
free(follows_you);
free(follow_btn);
free(is_blocked);
free(menubar);
if (display_name != page->display_name)
free(display_name);
return size;
@ -392,7 +416,7 @@ char* load_account_page(struct session* ssn,
.relationship = relationship,
};
size = construct_account_page(&result, &page, content);
size = construct_account_page(ssn, &result, &page, content);
if (res_size) *res_size = size;
return result;

View file

@ -66,7 +66,10 @@ char* construct_accounts(mastodont_t* api,
uint8_t flags,
size_t* ret_size);
size_t construct_account_page(char** result, struct account_page* page, char* content);
size_t construct_account_page(struct session *ssn,
char** result,
struct account_page* page,
char* content);
char* load_account_page(struct session* ssn,
mastodont_t* api,

View file

@ -110,9 +110,10 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
main_sidebar_str ? main_sidebar_str : "");
// Create instance panel
easprintf(&instance_str, "<div class=\"static-html\" id=\"instance-panel\">%s</div>",
(g_cache.panel_html.response ?
g_cache.panel_html.response : ""));
if (g_cache.panel_html.response)
easprintf(&instance_str, "<div class=\"static-html\" id=\"instance-panel\">%s</div>",
(g_cache.panel_html.response ?
g_cache.panel_html.response : ""));
struct index_template index = {
.title = L10N[locale][L10N_APP_NAME],

View file

@ -1,4 +1,5 @@
{{%s:is_blocked}}
{{%s:menubar}}
<div class="account">
<div class="acct-banner" style="background-image:url('{{%s:header}}');">
{{%s:follows_you}}

View file

@ -0,0 +1,7 @@
<div class="menubar">
<a href="{{%s:prefix}}/blocked">{{ %s : blocked_str }}</a>
<span class="bullet-separate">&bull;</span>
<a href="{{%s:prefix}}/muted">{{ %s : muted_str }}</a>
<span class="bullet-separate">&bull;</span>
<a href="{{%s:prefix}}/favourites">{{ %s : favourited_str }}</a>
</div>