treebird/src/base_page.c
me@ow.nekobit.net 90e5ac7259 Parse cookies
FossilOrigin-Name: a70c1b3c96720d7db399598e81e2cb87d1baae3f676926c511fa5b4f714c3555
2022-02-12 02:20:29 +00:00

76 lines
2.3 KiB
C

/*
* RatFE - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include "base_page.h"
#include "easprintf.h"
#include "cookie.h"
// Files
#include "../static/index.chtml"
void render_base_page(struct base_page* page)
{
char* cookie = getenv("HTTP_COOKIE");
enum l10n_locale locale = page->locale;
char* cookie_read = cookie;
struct http_cookie_info info = { 0 };
/*while (1)
{
cookie_read = parse_cookies(cookie_read, &info);
if (!(info.key && info.val)) break;
if (strcmp(info.key, "theme") == 0)
{
g_config.theme = info.val;
}
if (!cookie_read) break;
}*/
char* data;
int len = easprintf(&data, data_index_html,
L10N[locale][L10N_APP_NAME],
g_config.theme,
g_config.theme,
L10N[locale][L10N_APP_NAME],
L10N[locale][L10N_SEARCH_PLACEHOLDER],
L10N[locale][L10N_SEARCH_BUTTON],
L10N[locale][L10N_HOME],
L10N[locale][L10N_LOCAL],
L10N[locale][L10N_FEDERATED],
L10N[locale][L10N_NOTIFICATIONS],
L10N[locale][L10N_LISTS],
L10N[locale][L10N_DIRECT],
L10N[locale][L10N_CONFIG],
page->content);
if (!data)
{
perror("malloc");
return;
}
printf("Content-Length: %d\r\n\r\n", len + 1);
puts(data);
free(data);
}