Merge pull request #3078 from duckduckgo/mintsoft/makemeasandwich
MakeMeASandwich: Switching to templatemaster
commit
b7ac37c0fb
|
@ -9,9 +9,6 @@ triggers end => 'make me a sandwich';
|
|||
zci answer_type => 'xkcd_sandwich';
|
||||
zci is_cached => 1;
|
||||
|
||||
my $xkcd_query = 'https://duckduckgo.com/?q=' . uri_esc('xkcd 149');
|
||||
my $operation = '<a href="' . $xkcd_query . '">xkcd 149</a>';
|
||||
|
||||
handle remainder => sub {
|
||||
|
||||
my $rem = lc $_;
|
||||
|
@ -26,12 +23,18 @@ handle remainder => sub {
|
|||
|
||||
return unless defined $result;
|
||||
|
||||
return $result,
|
||||
structured_answer => {
|
||||
input => [$input],
|
||||
operation => $operation,
|
||||
result => $result
|
||||
};
|
||||
return $result, structured_answer => {
|
||||
data => {
|
||||
title => $result,
|
||||
subtitle => [
|
||||
$input,
|
||||
{ text => "XKCD 149", href => "https://duckduckgo.com/?q=xkcd%20149" }
|
||||
]
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -10,27 +10,32 @@ use DDG::Test::Goodie;
|
|||
zci answer_type => 'xkcd_sandwich';
|
||||
zci is_cached => 1;
|
||||
|
||||
my @yes = (
|
||||
'Okay.',
|
||||
structured_answer => {
|
||||
input => ['sudo make me a sandwich'],
|
||||
operation => '<a href="https://duckduckgo.com/?q=xkcd%20149">xkcd 149</a>',
|
||||
result => 'Okay.'
|
||||
});
|
||||
my @no = (
|
||||
'What? Make it yourself.',
|
||||
structured_answer => {
|
||||
input => ['make me a sandwich'],
|
||||
operation => '<a href="https://duckduckgo.com/?q=xkcd%20149">xkcd 149</a>',
|
||||
result => 'What? Make it yourself.'
|
||||
my $yes = 'Okay.';
|
||||
my $no = 'What? Make it yourself.';
|
||||
|
||||
sub build_test
|
||||
{
|
||||
my ($text, $input) = @_;
|
||||
return test_zci($text, structured_answer => {
|
||||
data => {
|
||||
title => $text,
|
||||
subtitle => [
|
||||
$input,
|
||||
{ text => "XKCD 149", href => "https://duckduckgo.com/?q=xkcd%20149"}
|
||||
]
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
['DDG::Goodie::MakeMeASandwich'],
|
||||
'make me a sandwich' => test_zci(@no),
|
||||
'MAKE ME A SANDWICH' => test_zci(@no),
|
||||
'sudo make me a sandwich' => test_zci(@yes),
|
||||
'SUDO MAKE ME A SANDWICH' => test_zci(@yes),
|
||||
'make me a sandwich' => build_test($no, "make me a sandwich"),
|
||||
'MAKE ME A SANDWICH' => build_test($no, "make me a sandwich"),
|
||||
'sudo make me a sandwich' => build_test($yes, "sudo make me a sandwich"),
|
||||
'SUDO MAKE ME A SANDWICH' => build_test($yes, 'sudo make me a sandwich'),
|
||||
'blahblah make me a sandwich' => undef,
|
||||
'0 make me a sandwich' => undef,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue