Moved logic to insert no insignia image into perl module. Removed javascript file.
parent
d288c0f05e
commit
883e16d6e4
|
@ -60,8 +60,6 @@ handle words => sub {
|
|||
my ($country, $branch) = $_ =~ $complete_regex;
|
||||
|
||||
return unless $branch;
|
||||
|
||||
return unless $goodie_version;
|
||||
|
||||
# TODO: Localize this default to the country of the searcher.
|
||||
$country = 'us' unless $country; # Default $country to us.
|
||||
|
@ -71,6 +69,10 @@ handle words => sub {
|
|||
my $text_response = join ' ', ($DISPLAY_NAME_FOR->{$country}, $DISPLAY_NAME_FOR->{$branch}, 'Rank');
|
||||
|
||||
my $structured_answer = $DATA->{$country}->{$branch};
|
||||
foreach my $rank (@{$structured_answer->{data}}) {
|
||||
$rank->{image} = '/share/goodie/military_rank/' . $goodie_version . '/no_insignia.svg'
|
||||
unless $rank->{image};
|
||||
}
|
||||
$structured_answer->{templates} = {
|
||||
group => 'media',
|
||||
detail => 0,
|
||||
|
@ -79,7 +81,6 @@ handle words => sub {
|
|||
# Scales oversize images to fit instead of clipping them.
|
||||
elClass => { tileMedia => 'tile__media--pr' },
|
||||
};
|
||||
$structured_answer->{goodie_version} = $goodie_version;
|
||||
|
||||
return $text_response, structured_answer => $structured_answer;
|
||||
};
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
DDH.military_rank = DDH.military_rank || {};
|
||||
|
||||
DDH.military_rank.build = function(ops) {
|
||||
var no_insignia_svg = '/share/goodie/military_rank/' + ops.goodie_version + '/no_insignia.svg';
|
||||
|
||||
return {
|
||||
normalize: function(item) {
|
||||
return {
|
||||
image: item.image.length == 0 ? no_insignia_svg : item.image
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
|
@ -12,14 +12,13 @@ zci is_cached => 1;
|
|||
my @us_army = (
|
||||
'United States Army Rank',
|
||||
structured_answer => {
|
||||
goodie_version => 999,
|
||||
meta => {
|
||||
sourceName => 'Wikipedia',
|
||||
sourceUrl => 'http://wikipedia.org/wiki/United_States_Army_enlisted_rank_insignia'
|
||||
},
|
||||
data => [
|
||||
{
|
||||
image => '',
|
||||
image => '/share/goodie/military_rank/999/no_insignia.svg',
|
||||
title => 'Private',
|
||||
altSubtitle => 'PV1',
|
||||
description => 'E-1 | OR-1',
|
||||
|
@ -216,7 +215,6 @@ my @us_army = (
|
|||
my @pl_af = (
|
||||
'Poland Air Force Rank',
|
||||
structured_answer => {
|
||||
goodie_version => 999,
|
||||
meta => {
|
||||
sourceName => 'Wikipedia',
|
||||
sourceUrl => 'http://en.wikipedia.org/wiki/Polish_Armed_Forces_rank_insignia'
|
||||
|
|
Loading…
Reference in New Issue