Go to file
scheinercc 9369675b6b adjust example queries
make usage of MDY date format (US) more obvious
https://en.wikipedia.org/wiki/Date_format_by_country
2013-04-15 11:46:13 +10:00
lib/DDG adjust example queries 2013-04-15 11:46:13 +10:00
share/goodie Added Fortune Goodie 2013-03-20 19:09:38 -04:00
t fixed hijri zci answer_type to match .pm 2013-04-07 20:56:31 -04:00
.gitignore fixes for new DDG (using strict) 2012-05-01 21:26:43 -06:00
README.md make readme header clearer 2013-03-25 14:44:59 -03:00
dist.ini specify origin/master for dzil release push 2013-04-06 19:21:27 -04:00

README.md

DuckDuckHack Goodies

This documentation walks you through the process of writing a DuckDuckHack Goodie plugin. Before reading this section, make sure you've read the DuckDuckHack Intro Site and the DuckDuckHack Developer's Overview. If you're here to brush up on Goodie info, scroll down. If you're here to learn how to write Goodie Plugins, check out the Goodies Overview.

Advanced Goodies

These advanced handle techniques are specific to Goodie plugins:

Returning HTML.  Goodies return text instant answers by default, but can return simple HTML as well. In that case, simply attach the html version to the end of the return statement.

return $text, html => $html

Other zci keywords.  The Chars example sets the is_cached zci keyword. You can find other settable attributes in the object documentation. For example, the GoldenRatio Goodie sets the answer_type variable, which gets returned in the API.

zci answer_type => "golden_ratio";

Location API

Sometimes, all a plugin needs is the user's location. This is where the Location API comes in. An example is the Is it snowing? plugin:

# Phoenixville, Pennsylvania, United States
my $location = join(", ", $loc->city, $loc->region_name, $loc->country_name);

When testing on duckpan, the plugin will always point you to "Phoenixville, Pennsylvania, United States," but don't worry, because it will show the real location once it's live. And it isn't limited to just the city, the state, and the country, either. Location.pm lists all the things that you can possibly use:

my @geo_ip_record_attrs = qw( country_code country_code3 country_name region
    region_name city postal_code latitude longitude time_zone area_code
	continent_code metro_code );

Sample contents of $loc:

longitude => -75.5385
country_name => United States
area_code => 610
region_name => Pennsylvania
country_code => US
region => PA
continent_code => NA
city => Phoenixville
postal_code => 19460
latitude => 40.1246
time_zone => America/New_York
metro_code => 504
country_code3 => USA