Calculator: Switch to canonical structured answer (#3916)
* Switch Calculator to canoncial structured answer * Add Goodie Templatemaster
parent
a22710e65e
commit
5f7329fc67
|
@ -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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<h3 class="c-base__title">{{{title_html}}}</h3>
|
957
t/Calculator.t
957
t/Calculator.t
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue