Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1559 from javathunderman/master
Browse files Browse the repository at this point in the history
ISS Location IA
  • Loading branch information
Jag Talon committed Mar 23, 2015
2 parents b000054 + de5890d commit ccf06b3
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/DDG/Spice/ISSLocation.pm
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;
44 changes: 44 additions & 0 deletions share/spice/isslocation/isslocation.css
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;
}
}
40 changes: 40 additions & 0 deletions share/spice/isslocation/isslocation.js
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));
24 changes: 24 additions & 0 deletions t/ISSLocation.t
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;

0 comments on commit ccf06b3

Please sign in to comment.