From 930d4eb9f8c7cb735b01f5f30809b909bf38d667 Mon Sep 17 00:00:00 2001 From: Kurt H Maier Date: Mon, 25 May 2020 17:13:01 -0700 Subject: [PATCH] apps: add simple site-search app --- apps/search/HOWTO | 16 ++++++++++++++++ apps/search/app.rc | 29 +++++++++++++++++++++++++++++ apps/search/footer.inc.sample | 3 +++ 3 files changed, 48 insertions(+) create mode 100644 apps/search/HOWTO create mode 100755 apps/search/app.rc create mode 100644 apps/search/footer.inc.sample diff --git a/apps/search/HOWTO b/apps/search/HOWTO new file mode 100644 index 0000000..8b5a1a0 --- /dev/null +++ b/apps/search/HOWTO @@ -0,0 +1,16 @@ +The default path for site search is /_search/. Assuming you want to keep +that default, you could enable site search like so: + + +mkdir -p /www/werc/sites/MYSITE/_search/_werc/ +echo 'conf_enable_search' > /www/werc/sites/MYSITE/_search/_werc/config +mkdir -p /www/werc/sites/MYSITE/_werc/lib/ +cp /www/werc/apps/search/footer.inc.sample /www/werc/sites/MYSITE/_werc/lib/ + +Searches will POST to /_search/ and from there get redirected to Duck Duck +Go with a site:$SERVER_NAME prefix. To have the search path URL be some- +thing differen, you'll have to edit line 23 of app.rc to point to the new +path. + +TODO: make it automatically work no matter which directory the app is +enabled in. diff --git a/apps/search/app.rc b/apps/search/app.rc new file mode 100755 index 0000000..affe4a9 --- /dev/null +++ b/apps/search/app.rc @@ -0,0 +1,29 @@ +fn conf_enable_search { + enable_search=yes + conf_enable_app search + pageTitle='Site Search' +} + + +fn search_init { + get_post_args q + if (! ~ $#q 0) { + redirect_string = 'https://duckduckgo.com/?q=site:'$SERVER_NAME^'+'^$"q + http_redirect $redirect_string '302 Found' + } + if not { + handler_body_main='search_body' + } +} + +fn search_body { + echo ' +

Site search

+

using DuckDuckGo

+
+ + +
' + +} + diff --git a/apps/search/footer.inc.sample b/apps/search/footer.inc.sample new file mode 100644 index 0000000..9b9e617 --- /dev/null +++ b/apps/search/footer.inc.sample @@ -0,0 +1,3 @@ +
Powered by werc
+ +