Status creation PRG
FossilOrigin-Name: eed5aebd5cd17c72dd184459759c81513905659aa7bb1d9c6c1401a44d738359
This commit is contained in:
parent
ea5388d281
commit
78ce1e4fe3
8 changed files with 24 additions and 6 deletions
2
dist/treebird20.css
vendored
2
dist/treebird20.css
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <string.h>
|
||||
#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;
|
||||
|
|
15
src/status.c
15
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...",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<form action="." method="post">
|
||||
<form action="%s/status/create" method="post">
|
||||
%s
|
||||
<div class="statusbox">
|
||||
<textarea name="content" placeholder="Just landed in N.Y." rows="5">%s</textarea>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="%s/status/%s" method="get">
|
||||
<form action="%s/status/%s" method="post">
|
||||
<label class="pointer">
|
||||
<svg class="%s" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M14 10l6.1-6.1M9 21H3v-6M10 14l-6.1 6.1"/></svg>
|
||||
<input class="hidden" type="submit">
|
||||
|
|
Loading…
Reference in a new issue