FossilOrigin-Name: f119b99dd52742e32c76f98f6dfc67056cca552e16cd124b7ac2e8cc9868ad8a
This commit is contained in:
me@ow.nekobit.net 2022-03-23 15:10:23 +00:00
parent 16ba91984a
commit 0f181fc9bb
4 changed files with 44 additions and 14 deletions

View file

@ -74,6 +74,11 @@ enum l10n_string
L10N_VIS_LOCAL,
/* LOGIN */
L10N_LOGIN,
L10N_REGISTER,
L10N_USERNAME,
L10N_PASSWORD,
L10N_LOGIN_BTN,
L10N_LOGIN_HEADER,
L10N_LOGIN_FAIL,
@ -143,6 +148,11 @@ static const char* const L10N[][_L10N_LEN] = {
"Local",
/* LOGIN */
"Login",
"Register"
"Username",
"Password",
"Login",
"Login / Register",
"Couldn't login",
@ -209,6 +219,11 @@ static const char* const L10N[][_L10N_LEN] = {
"Local",
/* LOGIN */
"Login",
"Register"
"Username",
"Password",
"Login",
"Login / Register",
"Couldn't login",

View file

@ -70,11 +70,23 @@ void content_login(mastodont_t* api, char** data, size_t data_size)
fputs("Status: 302 Found\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");
printf("Location: %s/\r\n", config_url_prefix);
// if config_url_prefix is empty, make it root
printf("Location: %s/\r\n",
config_url_prefix[0] == '\0' ?
"/" : config_url_prefix);
return;
}
}
easprintf(&page, "%s%s", error ? error : "", data_login_html);
// Concat
easprintf(&page, data_login_html,
L10N[L10N_EN_US][L10N_LOGIN],
error ? error : "",
config_url_prefix,
L10N[L10N_EN_US][L10N_USERNAME],
L10N[L10N_EN_US][L10N_PASSWORD],
L10N[L10N_EN_US][L10N_LOGIN_BTN]);
struct base_page b = {
.locale = L10N_EN_US,
.content = page,

View file

@ -37,20 +37,21 @@ char* construct_notification(struct mstdnt_notification* notif, int* size)
char* construct_notification_compact(struct mstdnt_notification* notif, int* size)
{
char* notif_html;
char* notif_stats;
char* notif_stats = NULL;
easprintf(&notif_stats, "%d - %d - %d",
notif->status->replies_count,
notif->status->reblogs_count,
notif->status->favourites_count);
if (notif->status)
easprintf(&notif_stats, "%d - %d - %d",
notif->status->replies_count,
notif->status->reblogs_count,
notif->status->favourites_count);
size_t s = easprintf(&notif_html, data_notification_compact_html,
notif->account->avatar,
notif->account->display_name,
"interacted",
notif->status->content,
notif_stats);
notif->status ? notif->status->content : "",
notif_stats ? notif_stats : "");
if (size) *size = s;

View file

@ -1,17 +1,19 @@
<div class="simple-page">
<h1>Login</h1>
<h1>%s</h1>
<form action="/treebird.cgi/login" method="post">
%s
<form action="%s/login" method="post">
<div class="form-group">
<label for="login-username">Username: </label>
<label for="login-username">%s: </label>
<input type="text" id="login-username" name="username">
</div>
<div class="form-group">
<label for="login-password">Password: </label>
<label for="login-password">%s: </label>
<input type="password" id="login-password" name="password"><br>
</div>
<div class="form-group">
<input type="submit" value="Login">
<input type="submit" value="%s">
</div>
</form>
</div>