feat: begin adding settings menu, move theme to settings

This commit is contained in:
frosty
2026-03-30 10:37:46 +03:00
parent 9e6e763064
commit c3ed901738
18 changed files with 444 additions and 19 deletions

28
src/Routes/SettingsSave.c Normal file
View File

@@ -0,0 +1,28 @@
#include "SettingsSave.h"
#include <stdlib.h>
#include <string.h>
int settings_save_handler(UrlParams *params) {
const char *theme = "";
const char *query = "";
if (params) {
for (int i = 0; i < params->count; i++) {
if (strcmp(params->params[i].key, "theme") == 0) {
theme = params->params[i].value;
} else if (strcmp(params->params[i].key, "q") == 0) {
query = params->params[i].value;
}
}
}
if (strlen(theme) > 0) {
set_cookie("theme", theme, "Fri, 31 Dec 2038 23:59:59 GMT", "/", false, false);
}
char redirect_url[512];
snprintf(redirect_url, sizeof(redirect_url), "/settings?q=%s", query);
send_redirect(redirect_url);
return 0;
}