This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 944
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 #1559 from javathunderman/master
ISS Location IA
- Loading branch information
Showing
4 changed files
with
133 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,25 @@ | ||
package DDG::Spice::ISSLocation; | ||
# ABSTRACT: Returns International Space Station's current location from Open Notify API. | ||
|
||
use DDG::Spice; | ||
|
||
primary_example_queries "iss location"; | ||
secondary_example_queries "iss position"; | ||
description "International Space Station Location"; | ||
name "ISSLocation"; | ||
source "open-notify"; | ||
code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/ISSLocation.pm"; | ||
topics "science"; | ||
category "random"; | ||
attribution github => ['https://github.com/rishiag','Rishi Agarwal'], | ||
twitter => ['http://twitter.com/rishiagar','Rishi Agarwal']; | ||
|
||
triggers any => "iss location", "iss position", "iss tracker", "iss tracking"; | ||
spice to => 'http://api.open-notify.org/iss-now.json?callback={{callback}}'; | ||
spice proxy_cache_valid => "418 1d"; | ||
|
||
handle remainder => sub { | ||
return $_ if $_; | ||
}; | ||
|
||
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,44 @@ | ||
.zci--isslocation h5 { | ||
font-size: 1.5em; | ||
margin-bottom: 0; | ||
padding-bottom: 0; | ||
padding-top: 0; | ||
color: #333; | ||
} | ||
|
||
.zci--isslocation p { | ||
margin-top: 0; | ||
padding-top: 0; | ||
color: #999; | ||
} | ||
|
||
.zci--isslocation .zci__more-at { | ||
padding-top: 0em; | ||
} | ||
|
||
.mapview-marker.mapview-marker-star, | ||
.mapview-marker.mapview-marker-star.has-focus { | ||
background-image: url("1x.png") !important; | ||
background-size: 30px 44px !important; | ||
|
||
width: 30px !important; | ||
height: 44px !important; | ||
margin-left: -15px !important; | ||
} | ||
|
||
@media only screen | ||
and (max-device-width : 480px) { | ||
.zci--isslocation h5 { | ||
font-size: 1.15em; | ||
padding-top: 0.05em; | ||
} | ||
|
||
.zci--isslocation p { | ||
font-size: 0.85em; | ||
} | ||
|
||
.zci--isslocation .zci__more-at { | ||
margin-bottom: 0; | ||
padding-top: 0em; | ||
} | ||
} |
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,40 @@ | ||
(function(env) { | ||
"use strict"; | ||
env.ddg_spice_isslocation = function(api_result) { | ||
|
||
if (!api_result || !api_result.message || api_result.message !== "success"){ | ||
return Spice.failed('isslocation'); | ||
} | ||
var issLatitude = (Math.round(api_result.iss_position.latitude * 100) / 100).toFixed(2); | ||
var issLongitude = (Math.round(api_result.iss_position.longitude * 100) / 100).toFixed(2); | ||
|
||
DDG.require('maps', function() { | ||
Spice.add({ | ||
id: "isslocation", | ||
name: "Map", | ||
model: 'Place', | ||
|
||
view: 'Map', | ||
data: [{ | ||
url: "http://www.nasa.gov/mission_pages/station/main/index.html", | ||
display_name: "International Space Station", | ||
name: "International Space Station", | ||
lat: issLatitude, | ||
lon: issLongitude | ||
}], | ||
meta: { | ||
zoomLevel: 1, | ||
sourceName: "open-notify.org", | ||
sourceUrl: 'http://open-notify.org' | ||
}, | ||
normalize: function(item) { | ||
|
||
return { | ||
lat: issLatitude, | ||
lon: issLongitude | ||
}; | ||
} | ||
}); | ||
}); | ||
} | ||
}(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,24 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use DDG::Test::Spice; | ||
|
||
ddg_spice_test( | ||
[qw( DDG::Spice::ISSLocation )], | ||
'iss location' => test_spice( | ||
'/js/spice/isslocation/', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::ISSLocation', | ||
is_unsafe => 0 | ||
), | ||
'iss position' => test_spice( | ||
'/js/spice/isslocation/', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::ISSLocation', | ||
is_unsafe => 0 | ||
), | ||
); | ||
|
||
done_testing; |