aboutsummaryrefslogtreecommitdiff
path: root/src/Routes/Settings.c
diff options
context:
space:
mode:
authorfrosty <gabriel@bwaaa.monster>2026-05-10 00:00:08 -0400
committerfrosty <gabriel@bwaaa.monster>2026-05-10 00:00:08 -0400
commit3c856f93ed3d1362a8b6190d9ce44b2939fca717 (patch)
treef98a84d341b7b1739b573441e29cd366e04ea7b4 /src/Routes/Settings.c
parentba6dae676a5c268d6b4265d26b9556ba1cfa6923 (diff)
downloadomnisearch-3c856f93ed3d1362a8b6190d9ce44b2939fca717.tar.gz
feat(wip): load themes dynamically from static/themes/*.css
Diffstat (limited to 'src/Routes/Settings.c')
-rw-r--r--src/Routes/Settings.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/Routes/Settings.c b/src/Routes/Settings.c
index b21dd6f..eb3072b 100644
--- a/src/Routes/Settings.c
+++ b/src/Routes/Settings.c
@@ -32,7 +32,8 @@ int settings_handler(UrlParams *params) {
char **user_engines = NULL;
int user_engine_count = 0;
- int has_user_pref = (get_user_engines(&user_engines, &user_engine_count) == 0);
+ int has_user_pref =
+ (get_user_engines(&user_engines, &user_engine_count) == 0);
int enabled_count = 0;
for (int i = 0; i < ENGINE_COUNT; i++) {
@@ -77,7 +78,34 @@ int settings_handler(UrlParams *params) {
context_set(&ctx, "query", query);
context_set(&ctx, "theme", theme);
context_set(&ctx, "locale", locale);
- context_set_array_of_arrays(&ctx, "locales", locale_data, locale_count, inner_counts);
+ context_set_array_of_arrays(&ctx, "locales", locale_data, locale_count,
+ inner_counts);
+
+ char **themes = NULL;
+ int themes_count = 0;
+ get_available_themes(&themes, &themes_count);
+
+ if (themes_count > 0) {
+ char ***theme_ptrs = malloc(sizeof(char **) * themes_count);
+ int *theme_inner = malloc(sizeof(int) * themes_count);
+ for (int i = 0; i < themes_count; i++) {
+ theme_ptrs[i] = malloc(sizeof(char *) * 2);
+ theme_ptrs[i][0] = themes[i];
+ theme_ptrs[i][1] = strdup(themes[i]);
+ if (theme_ptrs[i][1][0] >= 'a' && theme_ptrs[i][1][0] <= 'z') {
+ theme_ptrs[i][1][0] = theme_ptrs[i][1][0] - 'a' + 'A';
+ }
+ theme_inner[i] = 2;
+ }
+ context_set_array_of_arrays(&ctx, "themes", theme_ptrs, themes_count,
+ theme_inner);
+ for (int i = 0; i < themes_count; i++) {
+ free(theme_ptrs[i][1]);
+ free(theme_ptrs[i]);
+ }
+ free(theme_ptrs);
+ free(theme_inner);
+ }
if (enabled_count > 0) {
context_set_array_of_arrays(&ctx, "enabled_engines", engine_data,