Update template Perl, add template JS file
parent
033df06569
commit
6fd9f1114f
|
@ -1,4 +1,5 @@
|
|||
package DDG::Goodie::<: $ia_package_name :>;
|
||||
|
||||
# ABSTRACT: Write an abstract here
|
||||
# Start at https://duck.co/duckduckhack/goodie_overview if you are new
|
||||
# to instant answer development
|
||||
|
@ -9,14 +10,33 @@ use strict;
|
|||
zci answer_type => '<: $lia_name :>';
|
||||
zci is_cached => 1;
|
||||
|
||||
name '<: $lia_name :>';
|
||||
|
||||
# Triggers
|
||||
triggers any => 'triggerWord', 'trigger phrase';
|
||||
|
||||
# Handle statement
|
||||
handle remainder => sub {
|
||||
# Query can be accessed in $_
|
||||
|
||||
return $_;
|
||||
# Optional - Guard against no remainder
|
||||
# i.e. the query is only 'triggerWord' or 'trigger phrase'
|
||||
#
|
||||
# return unless $remainder;
|
||||
|
||||
# Optional - Regular expression guard
|
||||
# use this approach to ensure the remainder matches a pattern
|
||||
# i.e. it only contains letters, or numbers, or contains certain words
|
||||
#
|
||||
# return unless qr/^\w+/;
|
||||
|
||||
return "plain text response",
|
||||
structured_answer => {
|
||||
id => '<: $lia_id :>', # Should be an existing Instant Answer topic
|
||||
name => 'Answerbar Tab Name', # Should be an existing Instant Answer topic
|
||||
data => { q => $_ },
|
||||
templates => 1
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
DDH.'<: $lia_id :>' = DDH.'<: $lia_id :>' || {};
|
||||
|
||||
|
||||
(function(env) {
|
||||
|
||||
console.log("DDH.'<: $lia_id :>'.build");
|
||||
|
||||
// define private variables and functions here
|
||||
|
||||
DDH.'<: $lia_id :>'.build = function(ops) {
|
||||
|
||||
return {
|
||||
id: "life",
|
||||
|
||||
meta: {
|
||||
sourceName: "Source Domain",
|
||||
sourceUrl: "https://source.website.com"
|
||||
},
|
||||
|
||||
// data: {
|
||||
// already defined in Perl Package
|
||||
// you can re-define it here
|
||||
// or access/modify 'ops.data'
|
||||
// },
|
||||
|
||||
// normalize: function(item){
|
||||
// use this to map your 'data'
|
||||
// to the properties required for your chosen template
|
||||
//
|
||||
// return {
|
||||
// title: data.myTitle
|
||||
// subtitle: data.foo.subtitle
|
||||
// };
|
||||
// },
|
||||
|
||||
templates: {
|
||||
group: 'text',
|
||||
|
||||
// options: {
|
||||
//
|
||||
// },
|
||||
|
||||
// variants: {
|
||||
//
|
||||
// }
|
||||
},
|
||||
|
||||
// Function that executes after template content is displayed
|
||||
onShow: function() {
|
||||
|
||||
// define any callbacks or event handlers here
|
||||
//
|
||||
// var $dom = $(".zci--'<: $lia_id :>'");
|
||||
// $dom.find(".my-special-class").click(funtcion(){
|
||||
//
|
||||
// });
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
})(DDH);
|
Loading…
Reference in New Issue