Calculator: Switch to canonical structured answer (#3916)

* Switch Calculator to canoncial structured answer

* Add Goodie Template
master
Zaahir Moolla 2017-02-06 16:06:33 -05:00 committed by GitHub
parent a22710e65e
commit 5f7329fc67
3 changed files with 314 additions and 665 deletions

View File

@ -149,10 +149,10 @@ handle query_nowhitespace => sub {
my $results = prepare_for_display($query, $tmp_result, $style); my $results = prepare_for_display($query, $tmp_result, $style);
return unless $results && $results->{text};
return if $results->{text} =~ /^\s/; return if $results->{text} =~ /^\s/;
return $results->{text}, return $results->{text},
structured_answer => $results->{structured}, structured_answer => $results->{structured};
heading => "Calculator";
}; };
sub prepare_for_display { sub prepare_for_display {
@ -174,12 +174,19 @@ sub prepare_for_display {
$spaced_query =~ s/^ - /-/; $spaced_query =~ s/^ - /-/;
return +{ return +{
text => $spaced_query . ' = ' . $result, text => "$spaced_query = $result",
structured => { structured => {
input => [$spaced_query], data => {
operation => 'Calculate', title_html => $style->with_html($result),
result => "<a href='javascript:;' onclick='document.x.q.value=\"$result\";document.x.q.focus();'>" . $style->with_html($result) . "</a>" subtitle => "Calculate: $spaced_query"
}, },
templates => {
group => 'text',
options => {
title_content => 'DDH.calculator.title_content'
}
}
}
}; };
} }

View File

@ -0,0 +1 @@
<h3 class="c-base__title">{{{title_html}}}</h3>

File diff suppressed because it is too large Load Diff