fixes #1148: Use icon template for independence day IA.

master
cskksc 2015-07-01 19:10:14 +00:00
parent bb775daaf5
commit 274bda4043
4 changed files with 77 additions and 142 deletions

View File

@ -5,6 +5,7 @@ use strict;
use DDG::Goodie;
use JSON;
use utf8;
use Locale::Country;
zci answer_type => "independence_day";
zci is_cached => 1;
@ -78,11 +79,22 @@ handle query_clean => sub {
return $text,
structured_answer => {
input => [],
operation => $prolog,
result => $date_str
id => 'independence_day',
templates => {
group => "icon",
item => 0,
elClass => {
iconTitle => "t-xxl",
iconSubtitle => "tx--15"
}
},
data => {
country_code => country2code($country_key),
date => $date_str,
info => $prolog
}
};
};
1;
1;

View File

@ -0,0 +1,3 @@
.zci__body{
display: inline-block;
}

View File

@ -0,0 +1,19 @@
DDH.independence_day = DDH.independence_day || {};
DDH.independence_day.build = function(ops) {
return {
normalize: function(item) {
var isMobile = ($('.is-mobile').length > 0) ? true : false;
var info = {
title: ops.data.date,
subtitle: ops.data.info
};
if (isMobile) {
info.image = DDG.settings.region.getSmallIconURL(ops.data.country_code);
} else {
info.image = DDG.settings.region.getLargeIconURL(ops.data.country_code);
}
return info;
}
};
};

View File

@ -4,149 +4,50 @@ use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
use Locale::Country;
zci answer_type => "independence_day";
zci is_cached => 1;
sub answer {
my $prolog;
$prolog = "Independence Day of " . $_[0] . " " . $_[1];
test_zci($prolog, structured_answer => {
id => "independence_day",
data => {
country_code => country2code($_[0]),
date => $_[1],
info => "Independence Day of " . $_[0]
},
templates => {
group => "icon",
item => "0",
elClass => {
iconTitle => "t-xxl",
iconSubtitle => "tx--15"
}
}
});
}
ddg_goodie_test(
[qw(
DDG::Goodie::IndependenceDay
)],
# primary example queries
'what is the independence day of norway' => test_zci(
'Independence Day of Norway May 17th, 1814',
structured_answer => {
input => [],
operation => 'Independence Day of Norway',
result => 'May 17th, 1814',
}
),
'independence day, papua new guinea' => test_zci(
'Independence Day of Papua New Guinea September 16th, 1975',
structured_answer => {
input => [],
operation => 'Independence Day of Papua New Guinea',
result => 'September 16th, 1975',
}
),
# question marks
'what is the independence day of norway?' => test_zci(
'Independence Day of Norway May 17th, 1814',
structured_answer =>{
input => [],
operation => 'Independence Day of Norway',
result => 'May 17th, 1814',
}
),
# some aliases
'when is the independence day of republic of congo' => test_zci(
'Independence Day of Republic of the Congo August 15th, 1960',
structured_answer => {
input => [],
operation => 'Independence Day of Republic of the Congo',
result => 'August 15th, 1960',
}
),
'when is the independence day of republic of the congo' => test_zci(
'Independence Day of Republic of the Congo August 15th, 1960',
structured_answer => {
input => [],
operation => 'Independence Day of Republic of the Congo',
result => 'August 15th, 1960',
}
),
'gambia independence day' => test_zci(
'Independence Day of The Gambia February 18th, 1965',
structured_answer => {
input => [],
operation => 'Independence Day of The Gambia',
result => 'February 18th, 1965',
}
),
'the gambia independence day' => test_zci(
'Independence Day of The Gambia February 18th, 1965',
structured_answer => {
input => [],
operation => 'Independence Day of The Gambia',
result => 'February 18th, 1965',
}
),
'usa independence day' => test_zci(
'Independence Day of United States of America July 4th, 1776',
structured_answer => {
input => [],
operation => 'Independence Day of United States of America',
result => 'July 4th, 1776',
}
),
# data points with two dates
'independence day of panama' => test_zci(
'Independence Day of Panama November 28th, 1821 and November 3rd, 1903',
structured_answer => {
input => [],
operation => 'Independence Day of Panama',
result => 'November 28th, 1821 and November 3rd, 1903',
}
),
'independence day of armenia' => test_zci(
'Independence Day of Armenia May 28th, 1918 and September 21th, 1991',
structured_answer => {
input => [],
operation => 'Independence Day of Armenia',
result => 'May 28th, 1918 and September 21th, 1991',
}
),
# miscellaneous
'independence day of papua new guinea' => test_zci(
'Independence Day of Papua New Guinea September 16th, 1975',
structured_answer => {
input => [],
operation => 'Independence Day of Papua New Guinea',
result => 'September 16th, 1975',
}
),
'day of independence of sri lanka' => test_zci(
'Independence Day of Sri Lanka February 4th, 1948',
structured_answer => {
input => [],
operation => 'Independence Day of Sri Lanka',
result => 'February 4th, 1948',
}
),
'when is the day of independence for norway' => test_zci(
'Independence Day of Norway May 17th, 1814',
structured_answer => {
input => [],
operation => 'Independence Day of Norway',
result => 'May 17th, 1814',
}
),
'day of independence, norway' => test_zci(
'Independence Day of Norway May 17th, 1814',
structured_answer => {
input => [],
operation => 'Independence Day of Norway',
result => 'May 17th, 1814',
}
),
'norway independence day' => test_zci(
'Independence Day of Norway May 17th, 1814',
structured_answer => {
input => [],
operation => 'Independence Day of Norway',
result => 'May 17th, 1814',
}
),
'what day is the independence day of norway' => test_zci(
'Independence Day of Norway May 17th, 1814',
structured_answer => {
input => [],
operation => 'Independence Day of Norway',
result => 'May 17th, 1814',
}
),
[qw(DDG::Goodie::IndependenceDay)],
"what is the independence day of norway" => answer("Norway", "May 17th, 1814"),
"independence day, papua new guinea" => answer("Papua New Guinea", "September 16th, 1975"),
"what is the independence day of norway?" => answer("Norway", "May 17th, 1814"),
"when is the independence day of republic of congo" => answer("Republic of the Congo", "August 15th, 1960"),
"when is the independence day of republic of the congo" => answer("Republic of the Congo", "August 15th, 1960"),
"gambia independence day" => answer("The Gambia", "February 18th, 1965"),
"the gambia independence day" => answer("The Gambia", "February 18th, 1965"),
"usa independence day" => answer("United States of America", "July 4th, 1776"),
"independence day of panama" => answer("Panama", "November 28th, 1821 and November 3rd, 1903"),
"Independence Day of Armenia" => answer("Armenia", "May 28th, 1918 and September 21th, 1991"),
"independence day of papua new guinea" => answer("Papua New Guinea", "September 16th, 1975"),
"day of independence of sri lanka" => answer("Sri Lanka", "February 4th, 1948"),
"when is the independence day of norway" => answer("Norway", "May 17th, 1814"),
"day of independence, norway" => answer("Norway", "May 17th, 1814"),
"norway independence day" => answer("Norway", "May 17th, 1814"),
"what day is the independence day of norway" => answer("Norway", "May 17th, 1814")
);
done_testing;