forked from duckduckgo/zeroclickinfo-spice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request duckduckgo#2224 from soleo/cocoapods
New Cocoapods Spice
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package DDG::Spice::Cocoapods; | ||
|
||
use DDG::Spice; | ||
|
||
spice is_cached => 1; | ||
|
||
name "Cocoapods"; | ||
source "https://cocoapods.org"; | ||
icon_url "https://cocoapods.org/favicons/favicon.ico"; | ||
description "Search Pod Info from Cocoapods"; | ||
primary_example_queries "cocoapods AFNetworking", "cocoapods SVProgressHUD"; | ||
secondary_example_queries "cocoapods AFNetworking for ios"; | ||
|
||
category "programming"; | ||
|
||
topics "computing", "programming"; | ||
code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Cocoapods.pm"; | ||
attribution github => ["https://github.com/soleo", "Xinjiang Shao"], | ||
twitter => ['https://twitter.com/soleoshao', 'Xinjiang Shao']; | ||
|
||
triggers startend => 'cocoapods'; | ||
|
||
spice to => 'http:https://search.cocoapods.org/api/v1/pods.flat.hash.json?query=$1'; | ||
spice wrap_jsonp_callback => 1; | ||
|
||
handle remainder => sub { | ||
return lc $_ if $_; | ||
return; | ||
}; | ||
|
||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(function (env) { | ||
"use strict"; | ||
env.ddg_spice_cocoapods = function(api_result){ | ||
|
||
|
||
if (!api_result || api_result.error) { | ||
return Spice.failed('cocoapods'); | ||
} | ||
|
||
// Get the original query. | ||
var query = DDG.get_query().replace("cocoapods", ""); | ||
|
||
// Render the response | ||
Spice.add({ | ||
id: "cocoapods", | ||
name: "Software", | ||
data: api_result, | ||
meta: { | ||
sourceName: "CocoaPods", | ||
sourceUrl: 'https://cocoapods.org/?q=' + encodeURIComponent(query), | ||
sourceIconUrl: 'http:https://cocoapods.org/favicons/favicon.ico', | ||
total: api_result.length | ||
}, | ||
|
||
normalize: function(item) { | ||
return { | ||
title: item.id, | ||
subtitle: item.version, | ||
url: item.link, | ||
description: item.summary, | ||
platforms: item.platforms.join(', ').toUpperCase() | ||
} | ||
}, | ||
|
||
templates: { | ||
group: 'list', | ||
detail: false, | ||
item_detail: false, | ||
variants: { | ||
tile: 'basic4', | ||
tileSnippet: 'small' | ||
}, | ||
options: { | ||
footer: Spice.cocoapods.footer | ||
} | ||
} | ||
}); | ||
}; | ||
}(this)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="one-line opt--right"> | ||
{{platforms}} | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use DDG::Test::Spice; | ||
|
||
spice is_cached => 1; | ||
|
||
ddg_spice_test( | ||
[qw( DDG::Spice::Cocoapods)], | ||
|
||
'cocoapods test' => test_spice( | ||
'/js/spice/cocoapods/test', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::Cocoapods' | ||
), | ||
'cocoapods afnetworking' => test_spice( | ||
'/js/spice/cocoapods/afnetworking', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::Cocoapods' | ||
), | ||
'cocoapods SVProgressHUD' => test_spice( | ||
'/js/spice/cocoapods/svprogresshud', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::Cocoapods' | ||
), | ||
'cocoapods AFNetworking for ios' => test_spice( | ||
'/js/spice/cocoapods/afnetworking%20for%20ios', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::Cocoapods' | ||
), | ||
|
||
# Try to include some examples of queries on which it might | ||
# appear that your answer will trigger, but does not. | ||
'cocoapod test afnetworking' => undef, | ||
'pod afnetworking' => undef, | ||
); | ||
|
||
done_testing; | ||
|