diff --git a/dist/treebird20.css b/dist/treebird20.css index a683827..05d8c5f 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -336,7 +336,7 @@ ul li:first-child a.sidebarbtn display: flex; /* To maintain compatibility while keeping it a flexbox, we have to * hardcode the width, sorry! Tables are just weird and I hate CSS */ - max-width: 550px; + max-width: 520px; } .status .username diff --git a/src/login.c b/src/login.c index 3304c42..2b3b81a 100644 --- a/src/login.c +++ b/src/login.c @@ -68,7 +68,7 @@ void content_login(mastodont_t* api, char** data, size_t data_size) } else { // TODO checking, also ^ returns non-zero - fputs("Status: 302 Found\r\n", stdout); + fputs("Status: 303 See Other\r\n", stdout); printf("Set-Cookie: access_token=%s; Path=/; Max-Age=31536000\r\n", token.access_token); printf("Set-Cookie: logged_in=t; Path=/; Max-Age=31536000\r\n"); // if config_url_prefix is empty, make it root diff --git a/src/main.c b/src/main.c index c9d8dec..4ebc4b6 100644 --- a/src/main.c +++ b/src/main.c @@ -65,6 +65,7 @@ int main(void) { "/login", content_login }, { "/test", content_test }, { "/@:", content_account }, + { "/status/create", content_status_create }, { "/status/:/interact", status_interact }, { "/status/:/reply", status_reply }, { "/status/:", status_view }, diff --git a/src/reply.c b/src/reply.c index 622dd4c..dd3a1d9 100644 --- a/src/reply.c +++ b/src/reply.c @@ -21,6 +21,7 @@ #include #include "reply.h" #include "easprintf.h" +#include "../config.h" // Pages #include "../static/post.chtml" @@ -39,7 +40,9 @@ char* construct_post_box(char* reply_id, snprintf(id_reply, ID_REPLY_SIZE, ID_RESPONSE, reply_id); // Construct box - size_t s = easprintf(&reply_html, data_post_html, reply_id ? id_reply : "", + size_t s = easprintf(&reply_html, data_post_html, + config_url_prefix, + reply_id ? id_reply : "", default_content); if (size) *size = s; return reply_html; diff --git a/src/status.c b/src/status.c index 5b4086c..e81f893 100644 --- a/src/status.c +++ b/src/status.c @@ -65,6 +65,19 @@ int try_post_status(mastodont_t* api) return 0; } +void content_status_create(mastodont_t* api, char** data, size_t data_size) +{ + char* referer = getenv("HTTP_REFERER"); + + try_post_status(api); + + printf("Status: 303 See Other\r\n" + "Location: %s\r\n" + "Content-Length: 14\r\n\r\n" + "Redirecting...", + referer ? referer : "/"); +} + int try_interact_status(mastodont_t* api, char* id) { struct mstdnt_storage storage = { 0 }; @@ -157,7 +170,7 @@ void status_interact(mastodont_t* api, char** data, size_t data_size) try_interact_status(api, data[0]); - printf("Status: 302 Found\r\n" + printf("Status: 303 See Other\r\n" "Location: %s\r\n" "Content-Length: 14\r\n\r\n" "Redirecting...", diff --git a/src/status.h b/src/status.h index 1c2fc6d..fd90029 100644 --- a/src/status.h +++ b/src/status.h @@ -22,6 +22,7 @@ int try_post_status(mastodont_t* api); int try_interact_status(mastodont_t* api, char* id); +void content_status_create(mastodont_t* api, char** data, size_t data_size); // HTML Builders char* construct_post_box(char* reply_id, diff --git a/static/post.html b/static/post.html index 79b637c..ce6ab07 100644 --- a/static/post.html +++ b/static/post.html @@ -1,4 +1,4 @@ -
+ %s
diff --git a/static/status.html b/static/status.html index 2cdb6ce..fcb5d64 100644 --- a/static/status.html +++ b/static/status.html @@ -52,7 +52,7 @@ -
+