Update template further

master
Zaahir Moolla 2015-11-17 14:58:31 -05:00
parent fb33450f8d
commit f2ffe39f55
2 changed files with 50 additions and 23 deletions

View File

@ -8,34 +8,54 @@ use DDG::Goodie;
use strict;
zci answer_type => '<: $lia_name :>';
# Caching - https://duck.co/duckduckhack/spice_advanced_backend#caching-api-responses
zci is_cached => 1;
name '<: $lia_name :>';
# Triggers
# Triggers - https://duck.co/duckduckhack/goodie_triggers
triggers any => 'triggerWord', 'trigger phrase';
# Handle statement
handle remainder => sub {
my $remainder = $_;
# Optional - Guard against no remainder
# i.e. the query is only 'triggerWord' or 'trigger phrase'
# 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
# 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 unless qr/^\w+|\d{5}$/;
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
};
# ID - Must be unique and match Instant Answer page
# E.g. https://duck.co/ia/view/calculator has `id => 'calculator'``
id => '<: $lia_id :>',
# Name - Used for Answer Bar Tab
# Value should be chosen from existing Instant Answer topics
# see https://duck.co/duckduckhack/display_reference#codenamecode-emstringem-required
name => 'Answer',
data => {
title => "My Instant Answer Title",
subtitle => "My Subtitle",
# image => "http://website.com/image.png"
},
templates => {
group => "text",
# options => {
#
# }
}
};
};
};

View File

@ -1,16 +1,23 @@
DDH.'<: $lia_id :>' = DDH.'<: $lia_id :>' || {};
(function(DDH) {
"use strict";
(function(env) {
console.log("DDH.'<: $lia_id :>'.build");
console.log("DDH.'<: $lia_id :>'.build"); // remove this before submitting pull request
// define private variables and functions here
//
// fuction helper () { ... }
//
// var a = '',
// b = '',
// c = '';
DDH.'<: $lia_id :>'.build = function(ops) {
return {
id: "life",
id: '<: $lia_id :>',
meta: {
sourceName: "Source Domain",
@ -18,18 +25,18 @@ DDH.'<: $lia_id :>' = DDH.'<: $lia_id :>' || {};
},
// data: {
// already defined in Perl Package
// you can re-define it here
// or access/modify 'ops.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
// use this to map your 'data'
// to the properties required for your chosen template
//
// return {
// title: data.myTitle
// subtitle: data.foo.subtitle
// title: item.myTitle
// subtitle: item.foo.subtitle
// };
// },