Desserts! [again] #109

Merged
merged 12 commits into from Oct 29, 2013

Projects

None yet

4 participants

@kennydude
Contributor

This one should have what DuckDuckGo want :)

kennydude added some commits Jul 3, 2012
@kennydude kennydude Desserts!
My first DuckDuckHack plugin: "desserts beginning with [letter-name]"
4d123b4
@kennydude kennydude Merge remote-tracking branch 'upstream/master' 77dde91
@kennydude kennydude Merge remote-tracking branch 'upstream/master' d5327b0
@kennydude kennydude Update to the dessert zero-click thing that does that team DDG want :) c1fd948
@kennydude kennydude Notepad Goodie
- Creates a small notepad which auto-expands and has a save as plain text button all in JS
- Tiny line removed in dessert goodie
77613d9
@majuscule majuscule was assigned Aug 17, 2012
@crazedpsyc
Contributor

Just from a speed/readability perspective, I would recommend making these changes: https://gist.github.com/3383335
I moved the letter=>dessert part to a hash, in which the dessert lists are array references. Then I de-reference the arrays in the handler function to pass to itemify.
I also changed itemify a bit, simply because weird things were going on in there -- assigning a floating point integer as an array, and that sort of thing ;-)
Thanks, and I'll let Dylan handle the functionality feedback and merging. :)

Oops; I somehow missed copying the y section, so make sure you don't use my regex change.

@kennydude
Contributor

Thanks, I'm not very good with Perl, so I tried to get it to just work at all :)

Hopefully working on more DDG stuff can help train me up :)

@kennydude
Contributor

Right, so that has been updated. I had worked on another goodie, which I didn't want to have to remove which makes a notepad in html. I probably could have done some mad branching stuff, but I don't like to venture that far into git. I can easily remove it if you guys don't want it though :)

@majuscule
Member

Excellent! I agree with @crazedpsyc suggestions and it's looking good. Before I can merge it in however, it needs a test file. You can take a look at the existing test files in the t/ directory. For this goodie I suggest using a regex test, a simple example of which is at t/ABC.t. Also, you should be returning both a text-only and an html result (with the <a> link) as you did in Notepad.pm. Which brings me to the next point :-) which I'm afraid is that Notepad must be in it's own pull request - please remove it from this one. It's an interesting idea and one we have discussed here before. I'd like to see what we can do with it, but it needs its own workspace.

Thanks again! And don't hesitate to ask any questions you may have.

@kennydude
Contributor

I don't know how I can do that except from moving it out of the repo
On Aug 20, 2012 5:36 PM, "Dylan Lloyd" notifications@github.com wrote:

Excellent! I agree with @crazedpsyc https://github.com/crazedpsycsuggestions and it's looking good. Before I can merge it in however, it
needs a test file. You can take a look at the existing test files in the t/
directory. For this goodie I suggest using a regex test, a simple example
of which is at t/ABC.t. Also, you should be returning both a text-only and
an html result (with the link) as you did in Notepad.pm. Which brings me
to the next point :-) which I'm afraid is that Notepad must be in it's own
pull request - please remove it from this one. It's an interesting idea and
one we have discussed here before. I'd like to see what we can do with it,
but it needs its own workspace.

Thanks again! And don't hesitate to ask any questions you may have.


Reply to this email directly or view it on GitHubhttps://github.com/duckduckgo/zeroclickinfo-goodies/pull/109#issuecomment-7875129.

@majuscule
Member
mv lib/DDG/Goodie/Notepad.pm ~ &&
git rm lib/DDG/Goodie/Notepad.pm &&
git commit -m "rm'd notepad" &&
git checkout -b Dessert &&
git branch -D master &&
git fetch &&
git checkout -b master &&
git checkout -b notepad &&
mv ~/Notepad.pm lib/DDG/Goodie &&
git add lib/DDG/Goodie/Notepad.pm &&
git commit -m "started work on notepad" &&
git branch

So what we're doing here is, moving the notepad source file, removing it from the repo, committing the deletion, making a new branch for your work on Desserts (this keeps all your commits), deleting your master branch, fetching the code from our (duckduckgo) repo, checking out the master branch (now without any of your commits from Dessert), creating a new branch to work on called Notepad, and then adding and committing your file. You now have two separate branches of your work. The last git branch lists your three existing branches, master, dessert and notepad. Switch between them with git checkout.

I know this is a bit complicated but does it seem to make sense? Feel free to ask about what doesn't.

@kennydude
Contributor

Thanks, that makes much more sense than the official documentation :)
On Aug 20, 2012 5:56 PM, "Dylan Lloyd" notifications@github.com wrote:

mv lib/DDG/Goodie/Notepad.pm ~ &&
git rm lib/DDG/Goodie/Notepad.pm &&
git commit -m "rm'd notepad" &&
git checkout -b Dessert &&
git branch -D master &&
git fetch &&
git checkout -b master &&
git checkout -b notepad &&
mv ~/Notepad.pm lib/DDG/Goodie &&
git add lib/DDG/Goodie/Notepad.pm &&
git commit -m "started work on notepad" &&
git branch

So what we're doing here is, moving the notepad source file, removing it
from the repo, committing the deletion, making a new branch for your work
on Desserts (this keeps all your commits), deleting your master branch,
fetching the code from our (duckduckgo) repo, checking out the master
branch (now without any of your commits from Dessert), creating a new
branch to work on called Notepad, and then adding and committing your file.
You now have two separate branches of your work. The last git branchlists your three existing branches, master, dessert and notepad. Switch
between them with git checkout.

I know this is a bit complicated but does it seem to make sense? Feel free
to ask about what doesn't.


Reply to this email directly or view it on GitHubhttps://github.com/duckduckgo/zeroclickinfo-goodies/pull/109#issuecomment-7875777.

@kennydude
Contributor

Righto, this pull request should be correct now! :D

@majuscule
Member

The test file and changes work well. I've noticed that many of the desserts lead to disambiguation pages, such as cupcake, chocolate, cherry pie and biscuit. It would be nice to instead point these to their canonical pages, such as https://duckduckgo.com/Cupcake. Another option is to use the existing results from our dessert fathead listed here https://duckduckgo.com/2/c/Desserts, or add "recipe" to the query for desserts that would hit our Punchfork spice such as https://duckduckgo.com/?q=cherry+pie+recipe.

@kennydude
Contributor

Sorry for the massive delay, but I think I've got those covered now (college work comes before ducks!)

@majuscule
Member

Hi again Kenny!

This time I am sorry for the delay! I was trying to think of a nicer way to do this than grunt work, but I don't really see another option. I also apologize because it seems I was unclear in my last reply. If you test the links your goodie is returning (such as the first, http://duckduckgo.com/2/apple+turnover) you'll notice that it does not return a zeroclickinfo result for the dessert. Unfortunately, as different dessert zeroclickinfo are triggered by various means (such as the recipe (punchfork) spice, and the dessert fathead), there is no single cannonical way to format these links. This is why I suggested using the existing dessert results from the desserts fathead (https://duckduckgo.com/2/c/Desserts). If you only use these desserts, you are guaranteed to have a cannonical URI at https://duckduckgo.com/2/dessert_name. To use desserts not listed there, you'll need to manually look up https://duckduckgo.com/?q=cupcake and follow the disambiguation to https://duckduckgo.com/cupcake, which would be the correct url to include in the goodie.

Does this make sense?

Also, please feel free to email me at dylan@duckduckgo.com :-)

Thanks again!

@majuscule
Member

Also, why don't you add attribution to the code for yourself? It will look something like this:

primary_example_queries 'example query';
name 'Desserts';
description 'Find a dessert';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Dessert.pm';
category 'Food and Drink';
topics 'Food';
attribution github => ['https://github.com/kennydude', 'kennydude'],
                web => ['http://kennydude.com', 'Kenny Dude'];

This code will be used to generate the description and attribution on https://duckduckgo.com/goodies.html

@kennydude
Contributor

Is there an example using a current fathead as I don't see a way other than
copying the data from the fathead?

On 16 November 2012 18:19, Dylan Lloyd notifications@github.com wrote:

Also, why don't you add attribution to the code for yourself? It will look
something like this:

primary_example_queries 'example query';
name 'Desserts';
description 'Find a dessert';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Dessert.pm';
category 'Food and Drink';
topics 'Food';
attribution github => ['https://github.com/kennydude', 'kennydude'],
web => ['http://kennydude.com', 'Kenny Dude'];

This code will be used to generate the description and attribution on
https://duckduckgo.com/goodies.html


Reply to this email directly or view it on GitHubhttps://github.com/duckduckgo/zeroclickinfo-goodies/pull/109#issuecomment-10456477.

@jagtalon
Member

Hey, @kennydude! This actually looks good! It's short and sweet. I'll check it out. :)

@jagtalon jagtalon merged commit e0eaf69 into duckduckgo:master Oct 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment