From 125653a75b770d93e9159840f32aaf5773f60185 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Tue, 22 Feb 2022 15:56:54 +0000 Subject: [PATCH] View original status ID FossilOrigin-Name: bd6604d92603e91dbaeba0f68778a667ac6654fca08d6ac45a3c1453a4b71a6f --- dist/ratfe20.css | 1 + src/index.c | 7 ++++--- src/status.c | 26 ++++++++++++++++++++------ static/status.html | 1 + 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/dist/ratfe20.css b/dist/ratfe20.css index a4359b3..1a0394d 100644 --- a/dist/ratfe20.css +++ b/dist/ratfe20.css @@ -435,6 +435,7 @@ ul li:first-child a.sidebarbtn color: #aa0000 !important; padding: 0 7px !important; margin: 0 5px; + text-decoration: none; cursor: pointer !important; outline: inherit !important; font-size: 14px; diff --git a/src/index.c b/src/index.c index 53caf75..30aa03b 100644 --- a/src/index.c +++ b/src/index.c @@ -36,6 +36,10 @@ void content_index(mastodont_t* api) struct mstdnt_storage storage; char* status_format; char* output = NULL; + + try_post_status(api); + try_interact_status(api); + if (mastodont_timeline_public(api, NULL, &storage, &statuses, &status_count)) { status_format = "An error occured loading the timeline"; @@ -49,9 +53,6 @@ void content_index(mastodont_t* api) cleanup = 1; } - try_post_status(api); - try_interact_status(api); - easprintf(&output, "%s %s", data_post_html, status_format); struct base_page b = { diff --git a/src/status.c b/src/status.c index 8147fd4..aefa5de 100644 --- a/src/status.c +++ b/src/status.c @@ -85,7 +85,8 @@ char* construct_status(struct mstdnt_status* status, int* size) status->content, status->reblogged ? "nobutton-active" : "", status->id, - status->favourited ? "nobutton-active" : ""); + status->favourited ? "nobutton-active" : "", + status->id); if (size) *size = s; return stat_html; } @@ -95,6 +96,8 @@ char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* re char* stat_html, *result = NULL; int curr_parse_size = 0, last_parse_size, parse_size; + if (size <= 0) return NULL; + for (size_t i = 0; i < size; ++i) { stat_html = construct_status(statuses + i, &parse_size); @@ -130,19 +133,28 @@ char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* re void content_status(mastodont_t* api, char** data, size_t data_size) { - struct mstdnt_storage storage; - struct mstdnt_status* statuses_before, *statuses_after; + char* output; + // Status context + struct mstdnt_storage storage, status_storage; + struct mstdnt_status* statuses_before, *statuses_after, status; size_t stat_before_len, stat_after_len; - char* before_html = NULL, *after_html = NULL; + char* before_html = NULL, *stat_html = NULL, *after_html = NULL; mastodont_status_context(api, data[0], &storage, &statuses_before, &statuses_after, &stat_before_len, &stat_after_len); + mastodont_view_status(api, data[0], &status_storage, &status); before_html = construct_statuses(statuses_before, stat_before_len, NULL); -// after_html = construct_statuses(statuses_after, stat_after_len, NULL); + stat_html = construct_status(&status, NULL); + after_html = construct_statuses(statuses_after, stat_after_len, NULL); + + easprintf(&output, "%s%s%s", + before_html != NULL ? before_html : "", + stat_html != NULL ? stat_html : "", + after_html != NULL ? after_html : ""); struct base_page b = { .locale = L10N_EN_US, - .content = before_html, + .content = output, .sidebar_right = NULL }; @@ -151,6 +163,8 @@ void content_status(mastodont_t* api, char** data, size_t data_size) // Cleanup if (before_html) free(before_html); + if (stat_html) free(stat_html); if (after_html) free(after_html); + if (output) free(output); mastodont_storage_cleanup(&storage); } diff --git a/static/status.html b/static/status.html index 9e23605..d4fd35e 100644 --- a/static/status.html +++ b/static/status.html @@ -27,6 +27,7 @@
+ View