|
@@ -15,10 +15,18 @@
|
|
|
#include "Routes/Search.h"
|
|
#include "Routes/Search.h"
|
|
|
#include "Scraping/Scraping.h"
|
|
#include "Scraping/Scraping.h"
|
|
|
|
|
|
|
|
|
|
+Config global_config;
|
|
|
|
|
+
|
|
|
int handle_opensearch(UrlParams *params) {
|
|
int handle_opensearch(UrlParams *params) {
|
|
|
(void)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;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -35,6 +43,7 @@ int main() {
|
|
|
|
|
|
|
|
Config cfg = {.host = DEFAULT_HOST,
|
|
Config cfg = {.host = DEFAULT_HOST,
|
|
|
.port = DEFAULT_PORT,
|
|
.port = DEFAULT_PORT,
|
|
|
|
|
+ .domain = "",
|
|
|
.proxy = "",
|
|
.proxy = "",
|
|
|
.proxy_list_file = "",
|
|
.proxy_list_file = "",
|
|
|
.max_proxy_retries = DEFAULT_MAX_PROXY_RETRIES,
|
|
.max_proxy_retries = DEFAULT_MAX_PROXY_RETRIES,
|
|
@@ -48,6 +57,8 @@ int main() {
|
|
|
fprintf(stderr, "[WARN] Could not load config file, using defaults\n");
|
|
fprintf(stderr, "[WARN] Could not load config file, using defaults\n");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ global_config = cfg;
|
|
|
|
|
+
|
|
|
if (cache_init(cfg.cache_dir) != 0) {
|
|
if (cache_init(cfg.cache_dir) != 0) {
|
|
|
fprintf(stderr,
|
|
fprintf(stderr,
|
|
|
"[WARN] Failed to initialize cache, continuing without caching\n");
|
|
"[WARN] Failed to initialize cache, continuing without caching\n");
|