diff --git a/src/main.c b/src/main.c index 218ef56..62dd029 100644 --- a/src/main.c +++ b/src/main.c @@ -61,7 +61,8 @@ int main(void) { "/login", content_login }, { "/@:", content_account }, { "/status/:/interact", status_interact }, - { "/status/:", content_status }, + { "/status/:/reply", status_reply }, + { "/status/:", status_view }, { "/lists", content_lists } }; diff --git a/src/status.c b/src/status.c index d5362a7..aa5ba30 100644 --- a/src/status.c +++ b/src/status.c @@ -25,7 +25,10 @@ #include "cookie.h" #include "string_helpers.h" #include "../config.h" + +// Pages #include "../static/status.chtml" +#include "../static/post.chtml" int try_post_status(mastodont_t* api) { @@ -124,14 +127,24 @@ void status_interact(mastodont_t* api, char** data, size_t data_size) referer ? referer : "/"); } -void content_status(mastodont_t* api, char** data, size_t data_size) +void status_view(mastodont_t* api, char** data, size_t data_size) +{ + content_status(api, data, data_size, 0); +} + +void status_reply(mastodont_t* api, char** data, size_t data_size) +{ + content_status(api, data, data_size, 1); +} + +void content_status(mastodont_t* api, char** data, size_t data_size, int is_reply) { 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, *stat_html = NULL, *after_html = NULL; + char* before_html = NULL, *stat_html = NULL, *after_html = NULL, *stat_reply; #ifdef _TEST_ #include "test/status_test.h" @@ -141,13 +154,15 @@ void content_status(mastodont_t* api, char** data, size_t data_size) mastodont_view_status(api, data[0], &status_storage, &status); before_html = construct_statuses(statuses_before, stat_before_len, NULL); stat_html = construct_status(&status, NULL); + stat_reply = data_post_html; after_html = construct_statuses(statuses_after, stat_after_len, NULL); #endif - easprintf(&output, "%s%s%s", - before_html != NULL ? before_html : "", - stat_html != NULL ? stat_html : "", - after_html != NULL ? after_html : ""); + easprintf(&output, "%s%s%s%s", + before_html ? before_html : "", + stat_html ? stat_html : "", + stat_reply ? stat_reply : "", + after_html ? after_html : ""); struct base_page b = { .locale = L10N_EN_US, diff --git a/src/status.h b/src/status.h index c9c26e2..70c48a9 100644 --- a/src/status.h +++ b/src/status.h @@ -22,9 +22,16 @@ int try_post_status(mastodont_t* api); int try_interact_status(mastodont_t* api, char* id); + +// HTML Builders char* construct_status(struct mstdnt_status* status, int* size); char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* ret_size); -void content_status(mastodont_t* api, char** data, size_t data_size); + +// Status frontends +void status_view(mastodont_t* api, char** data, size_t data_size); +void status_reply(mastodont_t* api, char** data, size_t data_size); void status_interact(mastodont_t* api, char** data, size_t data_size); +// Above wraps to the below function +void content_status(mastodont_t* api, char** data, size_t data_size, int is_reply); #endif // STATUS_H diff --git a/static/post.html b/static/post.html index 55b96be..3704c81 100644 --- a/static/post.html +++ b/static/post.html @@ -3,12 +3,11 @@
- Quality content +
-