forked from mirrors/treebird
Fix account page
FossilOrigin-Name: e0fd2365447f86aa57fc204a248178d6a1c4c52c9241d25339d545f010dc3d10
This commit is contained in:
parent
484ebb5433
commit
ff3cd19926
5 changed files with 106 additions and 4 deletions
36
dist/treebird20.css
vendored
36
dist/treebird20.css
vendored
|
@ -657,6 +657,19 @@ svg.in-reply-to-icon
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.acct-badge
|
||||
{
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
top: 8px;
|
||||
font-size: 12px;
|
||||
padding: 4px 8px;
|
||||
color: #dadada;
|
||||
text-transform: uppercase;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.account-note
|
||||
{
|
||||
word-break: break-all;
|
||||
|
@ -997,7 +1010,8 @@ ul.large-list li a
|
|||
|
||||
/* MENUS */
|
||||
|
||||
.menu-container:hover .menu
|
||||
.menu-container:hover .menu,
|
||||
.menu-container:hover + .menu
|
||||
{
|
||||
position: absolute;
|
||||
display: block;
|
||||
|
@ -1008,6 +1022,7 @@ ul.large-list li a
|
|||
z-index: 5;
|
||||
display: none;
|
||||
background: #fafafa;
|
||||
color: #000;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
@ -1021,6 +1036,7 @@ ul.large-list li a
|
|||
.menu ul li
|
||||
{
|
||||
list-style-type: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu .btn-menu
|
||||
|
@ -1033,6 +1049,19 @@ ul.large-list li a
|
|||
border: 0;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.user-options-btn
|
||||
{
|
||||
padding: 4px;
|
||||
border-radius: 64px;
|
||||
margin: 8px;
|
||||
float: right;
|
||||
font-size: 12px;
|
||||
color: #dadada;
|
||||
text-transform: uppercase;
|
||||
background-color: rgba(0, 0, 0, .7);
|
||||
}
|
||||
|
||||
.menu .btn-menu:hover
|
||||
|
@ -1040,3 +1069,8 @@ ul.large-list li a
|
|||
background-color: #eaeaea;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.nolink
|
||||
{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
|
@ -24,12 +24,15 @@
|
|||
#include "account.h"
|
||||
#include "easprintf.h"
|
||||
#include "status.h"
|
||||
#include "http.h"
|
||||
|
||||
// Files
|
||||
#include "../static/index.chtml"
|
||||
#include "../static/account.chtml"
|
||||
#include "../static/account_info.chtml"
|
||||
|
||||
#define FOLLOWS_YOU_HTML "<span class=\"acct-badge\">%s</span>"
|
||||
|
||||
char* construct_account_info(struct mstdnt_account* acct,
|
||||
size_t* size)
|
||||
{
|
||||
|
@ -53,6 +56,7 @@ char* construct_account_page(mastodont_t* api,
|
|||
int cleanup = 0;
|
||||
int result_size;
|
||||
char* statuses_html;
|
||||
char* follows_you = NULL;
|
||||
char* info_html = NULL;
|
||||
char* result;
|
||||
|
||||
|
@ -67,19 +71,37 @@ char* construct_account_page(mastodont_t* api,
|
|||
{
|
||||
info_html = construct_account_info(acct, NULL);
|
||||
}
|
||||
|
||||
if (relationship)
|
||||
if (MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_FOLLOWED_BY))
|
||||
easprintf(&follows_you, FOLLOWS_YOU_HTML, "Follows you");
|
||||
|
||||
result_size = easprintf(&result, data_account_html,
|
||||
"",
|
||||
acct->header,
|
||||
follows_you ? follows_you : "",
|
||||
acct->display_name,
|
||||
acct->acct,
|
||||
config_url_prefix,
|
||||
acct->acct,
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_NOTIFYING) ? "un" : "",
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_NOTIFYING) ? "Unsubscribe" : "Subscribe",
|
||||
config_url_prefix,
|
||||
acct->acct,
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_BLOCKING) ? "un" : "",
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_BLOCKING) ? "Unblock" : "Block",
|
||||
config_url_prefix,
|
||||
acct->acct,
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_MUTING) ? "un" : "",
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_MUTING) ? "Unmute" : "Mute",
|
||||
"Statuses",
|
||||
acct->statuses_count,
|
||||
"Following",
|
||||
acct->following_count,
|
||||
"Followers",
|
||||
acct->followers_count,
|
||||
MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_FOLLOWING) ? "active" : "",
|
||||
MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_FOLLOWING) ? "Following!" : "Follow",
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_FOLLOWING) ? "active" : "",
|
||||
!relationship ? "" : MSTDNT_FLAG_ISSET(relationship->flags, MSTDNT_RELATIONSHIP_FOLLOWING) ? "Following!" : "Follow",
|
||||
acct->avatar,
|
||||
info_html ? info_html : "",
|
||||
statuses_html);
|
||||
|
@ -90,6 +112,7 @@ char* construct_account_page(mastodont_t* api,
|
|||
if (res_size) *res_size = result_size;
|
||||
if (cleanup) free(statuses_html);
|
||||
if (info_html) free(info_html);
|
||||
if (follows_you) free(follows_you);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -145,3 +168,31 @@ void content_account(struct session* ssn, mastodont_t* api, char** data)
|
|||
mstdnt_cleanup_relationships(relationships);
|
||||
free(account_page);
|
||||
}
|
||||
|
||||
void content_account_action(struct session* ssn, mastodont_t* api, char** data)
|
||||
{
|
||||
char* referer = getenv("HTTP_REFERER");
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
struct mstdnt_account acct = { 0 };
|
||||
|
||||
if (strcmp(data[1], "follow") == 0)
|
||||
mastodont_follow_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "unfollow") == 0)
|
||||
mastodont_unfollow_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "mute") == 0)
|
||||
mastodont_mute_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "unmute") == 0)
|
||||
mastodont_unmute_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "block") == 0)
|
||||
mastodont_block_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "unblock") == 0)
|
||||
mastodont_unblock_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "subscribe") == 0)
|
||||
mastodont_subscribe_account(api, data[0], &storage, &acct);
|
||||
else if (strcmp(data[1], "unsubscribe") == 0)
|
||||
mastodont_unsubscribe_account(api, data[0], &storage, &acct);
|
||||
|
||||
mastodont_storage_cleanup(&storage);
|
||||
|
||||
redirect(REDIRECT_303, referer);
|
||||
}
|
||||
|
|
|
@ -32,4 +32,5 @@ char* construct_account_page(mastodont_t* api,
|
|||
size_t* res_size);
|
||||
void content_account(struct session* ssn, mastodont_t* api, char** data);
|
||||
|
||||
void content_account_action(struct session* ssn, mastodont_t* api, char** data);
|
||||
#endif // ACCOUNT_H
|
||||
|
|
|
@ -83,6 +83,7 @@ int main(void)
|
|||
/* { "/config/account", content_config_account }, */
|
||||
{ "/login", content_login },
|
||||
{ "/test", content_test },
|
||||
{ "/@:/action/:", content_account_action },
|
||||
{ "/@:", content_account },
|
||||
{ "/status/create", content_status_create },
|
||||
{ "/status/:/interact", status_interact },
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
<div class="account">
|
||||
%s
|
||||
<div class="acct-banner" style="background-image:url('%s');">
|
||||
%s
|
||||
<div class="acct-info-data">
|
||||
<span class="acct-displayname">%s</span>
|
||||
<span class="acct-username">%s</span>
|
||||
</div>
|
||||
|
||||
<span class="menu-container user-options-btn">
|
||||
Menu
|
||||
<div class="menu menu-options">
|
||||
<ul>
|
||||
<li><a class="nolink" href="%s/@%s/action/%ssubscribe"><input class="btn-menu" type="button" value="%s"></a></li>
|
||||
<li><a class="nolink" href="%s/@%s/action/%sblock"><input class="btn-menu" type="button" value="%s"></a></li>
|
||||
<li><a class="nolink" href="%s/@%s/action/%smute"><input class="btn-menu" type="button" value="%s"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="acct-header">
|
||||
|
@ -22,7 +35,9 @@
|
|||
<span class="btn-content">%d</span>
|
||||
</a>
|
||||
|
||||
<a href="#" class="follow-btn btn %s">%s</a>
|
||||
<a class="follow-btn btn %s">
|
||||
%s
|
||||
</a>
|
||||
</div>
|
||||
<img class="acct-pfp" src="%s">
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue