From 9dc056dc405ec2c23b3e802624c5596f518608d3 Mon Sep 17 00:00:00 2001 From: frosty Date: Wed, 18 Mar 2026 04:10:30 -0400 Subject: feature: moved domain for opensearch to config --- src/Main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Main.c') diff --git a/src/Main.c b/src/Main.c index 9cdd0ad..be5080b 100644 --- a/src/Main.c +++ b/src/Main.c @@ -15,10 +15,18 @@ #include "Routes/Search.h" #include "Scraping/Scraping.h" +Config global_config; + int handle_opensearch(UrlParams *params) { (void)params; - serve_static_file_with_mime("opensearch.xml", - "application/opensearchdescription+xml"); + extern Config global_config; + TemplateContext ctx = new_context(); + context_set(&ctx, "domain", global_config.domain); + char *rendered = render_template("opensearch.xml", &ctx); + serve_data(rendered, strlen(rendered), "application/opensearchdescription+xml"); + + free(rendered); + free_context(&ctx); return 0; } @@ -35,6 +43,7 @@ int main() { Config cfg = {.host = DEFAULT_HOST, .port = DEFAULT_PORT, + .domain = "", .proxy = "", .proxy_list_file = "", .max_proxy_retries = DEFAULT_MAX_PROXY_RETRIES, @@ -48,6 +57,8 @@ int main() { fprintf(stderr, "[WARN] Could not load config file, using defaults\n"); } + global_config = cfg; + if (cache_init(cfg.cache_dir) != 0) { fprintf(stderr, "[WARN] Failed to initialize cache, continuing without caching\n"); -- cgit v1.2.3