Zeroclickinfo-goodies: Convert HTML Goodies to use templates

Created on 30 May 2015  路  24Comments  路  Source: duckduckgo/zeroclickinfo-goodies

Many legacy Goodies return HTML strings for rendering. This was previously acceptable as we did not have access to the Handlebars templates used in every Spice IA.

Now that we have templates, we should convert all Goodies returning HTML into templated Goodie that ideally won't need to actually declare any HTML! We have many built-in templates and most IA's can leverage these by specifying only the data and letting our template system do the rest of the work.

In some cases the use of a Handlebars sub-template is necessary and acceptable. In rare cases a custom template is required and we now support that (but please check with us first to make sure its absolutely necessary!)

Let's cleanup our Goodies and hopefully simplify them by moving to our new templates!

Details on template usage can be seen here: https://duck.co/duckduckhack/goodie_displaying

Note: Goodies also support JS and CSS now, which means we should remove any inline scripts and styles and if necessary, move them to separate CSS and JS files.

Here's a list of the existing IA's which return HTML:

  • [x] Average.pm
  • [x] BashPrimaryExpressions.pm
  • [x] BinaryLogic.pm
  • [x] BloodDonor.pm
  • [x] CalendarToday.pm
  • [x] Chess960.pm
  • [x] ChineseZodiac.pm
  • [x] ColorCodes.pm
  • [x] ConvertLatLon.pm
  • [x] CrontabCheatSheet.pm
  • [x] CryptHashCheck.pm
  • [x] CurrencyIn.pm
  • [x] Cusip.pm
  • [x] Dessert.pm
  • [ ] Dewey.pm
  • [x] Dice.pm
  • [ ] FenViewer.pm
  • [x] FIGlet.pm
  • [ ] Frequency.pm
  • [ ] FrequencySpectrum.pm (this one sorely needs conversion! It should move the styles and scripts into a CSS file and a [x] JavaScript file)
  • [x] GoldenRatio.pm
  • [x] GuitarChords.pm
  • [x] HTMLEntitiesDecode.pm
  • [x] HTMLEntitiesEncode.pm
  • [ ] IDN.pm
  • [x] IndependenceDay.pm
  • [ ] IPS.pm
  • [ ] JsKeycodes.pm ( there is a Spice PR which will convert this to use JS -- technically it could remain a Goodie and do [x] this...)
  • [ ] KernelTaint.pm
  • [ ] Latex.pm
  • [ ] Loan.pm
  • [ ] NameDays.pm
  • [ ] NLetterWords.pm
  • [ ] Palindrome.pm
  • [x] PercentError.pm
  • [x] Phonetic.pm
  • [ ] Poker.pm
  • [x] PrimeFactors.pm
  • [x] PrivateNetwork.pm
  • [x] PublicDNS.pm
  • [ ] Randagram.pm
  • [x] RandomName.pm
  • [x] ResistorColors.pm
  • [x] ReverseResistorColours.pm
  • [ ] RouterPasswords.pm (currently offline -- should be converted to Fathead!)
  • [x] RubiksCubePatterns.pm
  • [ ] Shortcut.pm
  • [x] SubnetCalc.pm
  • [x] Sudoku.pm
  • [x] SumOfNaturalNumbers.pm
  • [x] SunInfo.pm
  • [x] Teredo.pm
  • [x] TimezoneConverter.pm
  • [x] Tips.pm
  • [x] UN.pm
  • [x] Unicode.pm
  • [ ] UnicodeFuzzySearch.pm
  • [x] Unicornify.pm
  • [ ] Unidecode.pm
  • [x] UnixPermissions.pm
  • [x] UnixTime.pm
  • [x] Uptime.pm
  • [x] VIN.pm
  • [ ] Week.pm

If you'd like to work on converting any of these, please post below to let us know!

Thanks guys :smile:

Convert To Structured Answer Low-Hanging Fruit Maintenance

Most helpful comment

I'll tackle Dewey if no one else is working on it.

All 24 comments

BTW, the Shipping Goodie are already being converted in #1150

I'll take the ones I've messed with, i.e:

  • [x] BashPrimaryExpressions.pm
  • [x] BloodDonor.pm
  • [x] ColorCodes.pm
  • [x] HTMLEntitiesDecode.pm
  • [x] HTMLEntitiesEncode.pm
  • [x] PrivateNetwork.pm
  • [x] ResistorColors.pm
  • [x] RubiksCubePatterns.pm
  • [x] SubnetCalc.pm
  • [x] Sudoku.pm

I think that's the lot

@mintsoft that's awesome! Thanks :+1:

I would like to take up

  • [ ] Average.pm

Once I complete this I will take up more.

@phoenixwizard thanks a lot! We really appreciate it :+1:

@moollaza Mind posting the stuff that hasn't been tackled yet?

@javathunderman We're just ticking them off as they're done :)

@mintsoft Ah, alright.

@moollaza I've just added https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/PublicDNS.pm to this list; as it's not immediately obvious from the code, but it's definitely returning HTML

I'll tackle Dewey if no one else is working on it.

Hi @AlterationBrick. That would be great - thank you.

@mintsoft Would you mind just checking to see if any of the conversions (specifically yours) in #2767 fix these?

Update

We've converted many Goodies that were using our "auto-templates" to use our Full Templates. Excellent job everyone! 馃挴 馃帀

_However_, we still have a few Goodies remaining that return plaintext and HTML (even worse!) that need to be addressed. Some of these may have ongoing PRs that have gone stale, so ping me and I'll try to get it moving along 馃憤 . Some of these are also not online and in some cases should be removed. RouterPasswords is one example that should probably be moved to a FatHead as we previously ran into issues with it as a Goodie.

The various package tracking Goodies are still live, but several are slated to be replaced by an ongoing Spice PR that may need to be revived (/cc @Mailkov )

Here's a list of Goodies that don't contain structured_answer in their Perl:

  • CanadaPost.pm
  • CrontabCheatSheet.pm
  • DHL.pm
  • Dewey.pm
  • FedEx.pm
  • FenViewer.pm
  • Frequency.pm
  • GoldenRatio.pm
  • HKDK.pm
  • IDN.pm
  • IPS.pm
  • KernelTaint.pm
  • LaserShip.pm
  • Latex.pm
  • Loan.pm
  • NLetterWords.pm
  • NameDays.pm
  • Palindrome.pm
  • Parcelforce.pm
  • Phonetic.pm
  • Poker.pm
  • PrivateNetwork.pm
  • RandomName.pm
  • Randagram.pm
  • RouterPasswords.pm
  • Sudoku.pm
  • SumOfNaturalNumbers.pm
  • Tips.pm
  • Unicode.pm
  • Unidecode.pm
  • UnicodeFuzzySearch.pm
  • UPS.pm
  • USPS.pm

/cc @duckduckgo/duckduckhack-contributors

-_- Hold the party everyone, looks like there's more to do :sob:

I've updated the checklist above accordingly

What's the status of this issue?

Still in-progress; this list https://github.com/duckduckgo/zeroclickinfo-goodies/issues/1163#issuecomment-224946724 are goodies that are still using the old output format and need to be converted to use structured_answer and a template

I'm attempting to improve the Sudoku app so I will first convert it to use templates.

As there hasn't been much activity on this issue for a while I will claim it.

Notes:

  • Converted but not marked: Dewey, Frequency, FrequencySpectrum, HTMLEntitiesDecode, HTMLEntitiesEncode, Tips, Week
  • to be moved to spice https://github.com/duckduckgo/zeroclickinfo-goodies/issues/3973: DHL, IPS, HKDK, Parcelforce
  • Open pull requests: Sudoku, RandomName, Unicode, SumOfNaturalNumbers
  • To be remove: RouterPasswords

Left to do

  • [x] CrontabCheatSheet.pm
  • [x] Dewey.pm
  • [x] DHL.pm
  • [ ] FenViewer.pm
  • [x] Frequency.pm
  • [x] FrequencySpectrum.pm (this one sorely needs conversion! It should move the styles and scripts into a CSS file and a [x] JavaScript file)
  • [x] HKDK.pm
  • [x] HTMLEntitiesDecode.pm
  • [x] HTMLEntitiesEncode.pm
  • [ ] IDN.pm
  • [x] IPS.pm
  • [ ] JsKeycodes.pm ( there is a Spice PR which will convert this to use JS -- technically it could remain a Goodie and do [x] this...)
  • [ ] KernelTaint.pm
  • [ ] Latex.pm
  • [ ] Loan.pm
  • [ ] NameDays.pm
  • [ ] NLetterWords.pm
  • [x] Palindrome.pm
  • [x] Parcelforce.pm
  • [ ] Phonetic.pm
  • [x] Poker.pm
  • [ ] PrivateNetwork.pm
  • [ ] Randagram.pm
  • [x] RandomName.pm
  • [x] RouterPasswords.pm
  • [ ] Shortcut.pm
  • [ ] Sudoku.pm
  • [ ] SumOfNaturalNumbers.pm
  • [x] Tips.pm
  • [ ] Unicode.pm
  • [x] Week

@kirkins CrontabCheatSheet.pm was converted to a cheat sheet.

We might want to skip the _PrivateNetwork Goodie_ and remove it completely #4257

We might want to skip the PrivateNetwork Goodie and remove it completely #4257

Well not remove it, just reduce the scope of the triggering somewhat :)

Unidecode was not part of the list, but it wasn't using templates, so I converted it on #4396

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sam09 picture sam09  路  17Comments

nickrsan picture nickrsan  路  29Comments

atomic1fire picture atomic1fire  路  15Comments

GuiltyDolphin picture GuiltyDolphin  路  12Comments

moollaza picture moollaza  路  14Comments