diff options
author | glenda <glenda@9front.local> | 2020-11-15 15:13:27 +0000 |
---|---|---|
committer | glenda <glenda@9front.local> | 2020-11-15 15:13:27 +0000 |
commit | 39318169e0b50551db511851829f9337c5fa6313 (patch) | |
tree | 65a0ef5c1da9677532fa8105293d017919473057 /apps/duckduckgo |
Import site to git
Diffstat (limited to 'apps/duckduckgo')
-rw-r--r-- | apps/duckduckgo/HOWTO | 20 | ||||
-rwxr-xr-x | apps/duckduckgo/app.rc | 30 | ||||
-rw-r--r-- | apps/duckduckgo/footer.inc.sample | 3 |
3 files changed, 53 insertions, 0 deletions
diff --git a/apps/duckduckgo/HOWTO b/apps/duckduckgo/HOWTO new file mode 100644 index 0000000..8bb952c --- /dev/null +++ b/apps/duckduckgo/HOWTO @@ -0,0 +1,20 @@ +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_duckduckgo' > /www/werc/sites/MYSITE/_search/_werc/config +mkdir -p /www/werc/sites/MYSITE/_werc/lib/ +cp /www/werc/apps/duckduckgo/footer.inc.sample /www/werc/sites/MYSITE/_werc/lib/footer.inc + +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 different, 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. +* OR make the search path a configuration option. +* Provide a template for non-footer deployment +* Enable the search path itself to serve a search form to GET requests + diff --git a/apps/duckduckgo/app.rc b/apps/duckduckgo/app.rc new file mode 100755 index 0000000..72dd0ec --- /dev/null +++ b/apps/duckduckgo/app.rc @@ -0,0 +1,30 @@ +fn conf_enable_duckduckgo { + enable_duckduckgo=yes + conf_enable_app duckduckgo + pageTitle='Site Search' +} + + +fn duckduckgo_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='duckduckgo_body' + } +} + +fn duckduckgo_body { + echo ' +<h1>Site search</h1> +<h2>using DuckDuckGo</h2> +<form action="/_search/" method="POST"> +<label for="searchtext">Site search:</label> +<input type="text" id="searchtext" name="q" placeholder="Search text..."> +<input type="submit" value="Search"> +</form>' + +} + diff --git a/apps/duckduckgo/footer.inc.sample b/apps/duckduckgo/footer.inc.sample new file mode 100644 index 0000000..4dd671d --- /dev/null +++ b/apps/duckduckgo/footer.inc.sample @@ -0,0 +1,3 @@ +<div><a href="http://werc.cat-v.org">Powered by werc</a></div> + +<div><form action="/_search/" method="POST"><label for="searchtext">Site search:</label> <input type="text" id="searchtext" name="q" placeholder="Enter search text..."><input type="submit" display="Search"></form></div> |