FossilOrigin-Name: 3a045ba54e0a29f2710a5e09bcd9a1e1d7dcdfeeee80b800f104d02c5b0bc799
This commit is contained in:
nekobit 2022-05-15 04:46:33 +00:00
parent 297a2a4f8a
commit 5aeda8107e
7 changed files with 55 additions and 15 deletions

View File

@ -114,6 +114,9 @@ $(PAGES_DIR)/emoji_picker.chtml: $(PAGES_DIR)/emoji_picker.html
./filec $< data_emoji_picker_html > $@
$(PAGES_DIR)/emoji.chtml: $(PAGES_DIR)/emoji.html
./filec $< data_emoji_html > $@
# Login panel
$(PAGES_DIR)/quick_login.chtml: $(PAGES_DIR)/quick_login.html
./filec $< data_quick_login_html > $@
$(MASTODONT_DIR):
fossil clone $(MASTODONT_URL) || true

14
dist/treebird20.css vendored
View File

@ -1,9 +1,4 @@
/* Look, I tried my best to make this theme compatible with browsers like Netsurf and stuff, I HATE
the modern web and flexboxes and stuff, so as a result, you WILL see some fugly things in here
that you will probably want to cleanup or throw out completely, this CSS is a big hack.
Other themes do not need to be compatible with Netsurf and older browsers or use tables,
I just wanted this to be as compatible as possible, go wild with your own themes */
*
{
@ -1071,7 +1066,8 @@ svg.in-reply-to-icon
/* Emoji */
.status-content .emoji,
.notification-content .emoji
.notification-content .emoji,
.username .emoji
{
font-family: monospace;
display: inline;
@ -1082,6 +1078,12 @@ svg.in-reply-to-icon
transition: transform .2s;
}
.username .emoji
{
width: 20px;
height: 20px;
}
.status-content .emoji:hover,
.notification-content .emoji:hover
{

View File

@ -187,9 +187,10 @@ static void fetch_account_page(struct session* ssn,
render_base_page(&b, ssn, api);
/* Output */
mstdnt_cleanup_account(&acct);
mstdnt_cleanup_relationships(relationships);
mastodont_storage_cleanup(&storage);
mastodont_storage_cleanup(&relations_storage);
mstdnt_cleanup_relationships(relationships);
free(account_page);
}

View File

@ -29,6 +29,7 @@
// Files
#include "../static/index.chtml"
#include "../static/quick_login.chtml"
#define BODY_STYLE "style=\"background:url('%s');\""
@ -53,10 +54,11 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
{
easprintf(&background_url_css, BODY_STYLE, ssn->config.background_url);
}
// Get / Show notifications on sidebar
// If user is logged in
if (ssn->cookies.logged_in && ssn->cookies.access_token)
{
// Get / Show notifications on sidebar
struct mstdnt_get_notifications_args args = {
.exclude_types = 0,
.account_id = NULL,
@ -71,12 +73,22 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
};
if (mastodont_get_notifications(api, &args, &storage, &notifs, &notifs_len) == 0)
{
sidebar_str = construct_notifications_compact(ssn, api, notifs, notifs_len, NULL);
}
mstdnt_cleanup_notifications(notifs, notifs_len);
mastodont_storage_cleanup(&storage);
}
else {
// Construct small login page
easprintf(&sidebar_str, data_quick_login_html,
config_url_prefix,
L10N[L10N_EN_US][L10N_USERNAME],
L10N[L10N_EN_US][L10N_PASSWORD],
L10N[L10N_EN_US][L10N_LOGIN_BTN]);
}
char* data;
int len = easprintf(&data, data_index_html,
L10N[locale][L10N_APP_NAME],
@ -119,7 +131,7 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
page->sidebar_left ?
page->sidebar_left : "",
page->content,
sidebar_str ? sidebar_str : "<p>Not logged in</p>");
sidebar_str ? sidebar_str : "");
if (!data)
{

View File

@ -30,7 +30,7 @@
char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len)
{
size_t sc_len;
char* oldres;
char* oldres = NULL;
char* res = content;
char* emoji_url_str;
char* coloned;
@ -50,7 +50,7 @@ char* emojify(char* content, struct mstdnt_emoji* emos, size_t emos_len)
easprintf(&emoji_url_str, "<img class=\"emoji\" src=\"%s\">", emos[i].url);
res = strrepl(res, coloned, emoji_url_str, STRREPL_ALL);
if (oldres != content) free(oldres);
if (oldres != content && res != oldres) free(oldres);
// Cleanup
free(emoji_url_str);
free(coloned);

View File

@ -274,7 +274,7 @@ char* get_in_reply_to(mastodont_t* api, struct mstdnt_status* status, size_t* si
&acct,
&storage);
char* html = construct_in_reply_to(status, res ? &acct : NULL, size);
char* html = construct_in_reply_to(status, res == 0 ? &acct : NULL, size);
mastodont_storage_cleanup(&storage);
return html;
@ -381,6 +381,7 @@ char* construct_status(struct session* ssn,
char* reply_count = NULL;
char* repeat_count = NULL;
char* favourites_count = NULL;
char* formatted_display_name = NULL;
char* attachments = NULL;
char* emoji_reactions = NULL;
char* notif_info = NULL;
@ -442,6 +443,11 @@ char* construct_status(struct session* ssn,
notif = &notif_reblog;
}
// Format username with emojis
formatted_display_name = emojify(status->account.display_name,
status->account.emojis,
status->account.emojis_len);
// Format status
char* parse_content = reformat_status(status->content, status->emojis, status->emojis_len);
// Find and replace
@ -488,7 +494,7 @@ char* construct_status(struct session* ssn,
"focused" : "",
notif_info ? notif_info : "",
status->account.avatar,
status->account.display_name, /* Username */
formatted_display_name, /* Username */
config_url_prefix,
status->account.acct,
status->account.acct, /* Account */
@ -544,6 +550,7 @@ char* construct_status(struct session* ssn,
if (emoji_reactions) free(emoji_reactions);
if (notif) free(notif_info);
if (interactions_html) free(interactions_html);
//if (formatted_display_name != status->account.display_name) free(formatted_display_name);
if (emoji_picker_html) free(emoji_picker_html);
if (parse_content != status->content) free(parse_content);
return stat_html;

15
static/quick_login.html Normal file
View File

@ -0,0 +1,15 @@
<div class="sidebar-login">
<form action="%s/login" method="post">
<div class="form-group">
<label for="login-username">%s: </label>
<input type="text" id="login-username" name="username">
</div>
<div class="form-group">
<label for="login-password">%s: </label>
<input type="password" id="login-password" name="password"><br>
</div>
<div class="form-group">
<input class="btn" type="submit" value="%s">
</div>
</form>
</div>