shithub: werc

ref: a213c90c1e28696dce4be33b0f6a71fda97c7eb6
dir: /apps/duckduckgo/app.rc/

View raw version
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>
<h3>using DuckDuckGo</h3>
<form action="/_search/" method="POST">
<input type="text" name="q" placeholder="Search text...">
<input type="submit" value="Search">
</form>'

}