forked from duckduckgo/zeroclickinfo-spice
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update to fix alternativeto and add nginx override for randword
- Loading branch information
1 parent
70dca45
commit 5e195be
Showing
2 changed files
with
19 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
package DDG::Spice::RandWord; | ||
use DDG::Spice; | ||
|
||
sub nginx_conf { | ||
my $api_key = $ENV{WORDNIK_API_KEY}; | ||
$nginx_conf = <<"__END_OF_CONF__"; | ||
location ^~ /js/spice/rand_word/ { | ||
rewrite ^$/js/spice/rand_word/(?:([0-9]+)\-([0-9]+)|) /v4/words.json/randomWord?minLength=$1&maxLength=$2&api_key=$api_key&callback=ddg_spice_rand_word break; | ||
proxy_pass http://api.wordnik.com/; | ||
} | ||
__END_OF_CONF__ | ||
} | ||
|
||
triggers any => "random", "word"; | ||
#spice is_memcached => 0; | ||
handle query_lc => sub { | ||
if ($_ =~ /^random word(?: ([0-9]+\-[0-9]+)|)$/) { | ||
if ($1) { | ||
return qq(/iwrd/$1); | ||
return $1; | ||
} else { | ||
return qq(/iwrd/); | ||
return; | ||
} | ||
# $is_kill_pre_results = 1; | ||
} | ||
return; | ||
}; | ||
1; |