diff --git a/src/base_page.c b/src/base_page.c
new file mode 100644
index 0000000..372f793
--- /dev/null
+++ b/src/base_page.c
@@ -0,0 +1,56 @@
+/*
+ * 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 .
+ */
+
+#include
+#include
+#include "base_page.h"
+#include "easprintf.h"
+
+// Files
+#include "../static/index.chtml"
+
+void render_base_page(struct base_page* page)
+{
+ enum l10n_locale locale = page->locale;
+
+ char* data;
+ int len = easprintf(&data, data_index_html,
+ L10N[locale][L10N_APP_NAME],
+ 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);
+}
diff --git a/src/base_page.h b/src/base_page.h
new file mode 100644
index 0000000..7b1a2d8
--- /dev/null
+++ b/src/base_page.h
@@ -0,0 +1,32 @@
+/*
+ * 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 .
+ */
+
+#ifndef BASE_PAGE_H
+#define BASE_PAGE_H
+#include "l10n.h"
+
+struct base_page
+{
+ enum l10n_locale locale;
+ char* content;
+ char* sidebar_right;
+};
+
+void render_base_page(struct base_page* page);
+
+#endif // BASE_PAGE_H
diff --git a/src/index.c b/src/index.c
index b75b083..c4a449a 100644
--- a/src/index.c
+++ b/src/index.c
@@ -18,9 +18,9 @@
#include
#include
+#include "base_page.h"
#include "../config.h"
#include "index.h"
-#include "easprintf.h"
#include "status.h"
// Files
@@ -32,17 +32,21 @@ void content_index(mastodont_t* api)
struct mstdnt_status* statuses;
struct mstdnt_storage storage;
char* status_format;
- int res = mastodont_timeline_public(api, NULL, &storage, &statuses, &status_count);
+ mastodont_timeline_public(api, NULL, &storage, &statuses, &status_count);
/* Construct statuses into HTML */
status_format = construct_statuses(statuses, status_count, &statuses_html_count);
if (status_format == NULL)
status_format = "Error in malloc!";
+ struct base_page b = {
+ .locale = L10N_ES_ES,
+ .content = status_format,
+ .sidebar_right = NULL
+ };
+
/* Output */
- printf("Content-Length: %ld\r\n\r\n",
- data_index_html_size + statuses_html_count + 1);
- printf(data_index_html, config_canonical_name, status_format);
+ render_base_page(&b);
/* Cleanup */
mastodont_storage_cleanup(&storage);