app.rc (636B)
1 fn conf_enable_duckduckgo { 2 enable_duckduckgo=yes 3 conf_enable_app duckduckgo 4 pageTitle='Site Search' 5 } 6 7 8 fn duckduckgo_init { 9 get_post_args q 10 if (! ~ $#q 0) { 11 redirect_string = 'https://duckduckgo.com/?q=site:'$SERVER_NAME^'+'^$"q 12 http_redirect $redirect_string '302 Found' 13 } 14 if not { 15 handler_body_main='duckduckgo_body' 16 } 17 } 18 19 fn duckduckgo_body { 20 echo ' 21 <h1>Site search</h1> 22 <h2>using DuckDuckGo</h2> 23 <form action="/_search/" method="POST"> 24 <label for="searchtext">Site search:</label> 25 <input type="text" id="searchtext" name="q" placeholder="Search text..."> 26 <input type="submit" value="Search"> 27 </form>' 28 29 } 30