Grab goodie version number in perl and pass it to javascript

master
lwood1 2016-06-21 08:04:53 +00:00
parent 2928f4d384
commit d288c0f05e
3 changed files with 11 additions and 2 deletions

View File

@ -9,6 +9,9 @@ use YAML::XS 'LoadFile';
zci answer_type => 'military_rank';
zci is_cached => 1;
# Get Goodie version to insert into no-insignia.svg path. Default to 999 for testing.
my $goodie_version = $DDG::GoodieBundle::OpenSourceDuckDuckGo::VERSION // 999;
my $DATA = LoadFile(share('military_rank.yml'));
my $DISPLAY_NAME_FOR = {
@ -57,6 +60,8 @@ 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.
@ -74,6 +79,7 @@ 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;
};

View File

@ -1,7 +1,8 @@
DDH.military_rank = DDH.military_rank || {};
var no_insignia_svg = DDG.get_asset_path('military_rank', 'no_insignia.svg');
no_insignia_svg = no_insignia_svg.replace(/spice/, 'goodie')
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 {

View File

@ -12,6 +12,7 @@ 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'
@ -215,6 +216,7 @@ 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'