Last active
August 29, 2015 14:14
-
-
Save AshleyGrant/55b3763c5a9bf7fe2577 to your computer and use it in GitHub Desktop.
flickr.js
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
import {HttpClient} from 'aurelia-http-client'; | |
var url = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=rainier&tagmode=any&format=json'; | |
export class FlickrApi{ | |
static inject() { return [HttpClient]; } | |
constructor(http){ | |
this.http = http; | |
} | |
getImages(){ | |
return this.http.jsonp(url).then(response => { | |
return response.content.items; | |
}); | |
} | |
} |
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
import {FlickrApi} from './flickr-api'; | |
//import {FlickrApi} from './mock_apis/flickr-api'; | |
export class Flickr{ | |
static inject() { return [FlickrApi]; } | |
constructor(flickrApi){ | |
this.heading = 'Flickr'; | |
this.images = []; | |
this.flickrApi = flickrApi; | |
} | |
activate(){ | |
return this.flickrApi.getImages().then(images => { | |
this.images = images; | |
}); | |
} | |
canDeactivate(){ | |
return confirm('Are you sure you want to leave?'); | |
} | |
} |
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
export class FlickrApi{ | |
constructor(){} | |
getImages(){ | |
return Promise.resolve(images); | |
} | |
} | |
var images = [ | |
{ | |
"title": "Mount Rainier and Reflection Lake", | |
"link": "http://www.flickr.com/photos/mayurkotlikar/16393489545/", | |
"media": {"m":"http://farm8.staticflickr.com/7359/16393489545_51399db002_m.jpg"}, | |
"date_taken": "2014-09-08T00:17:30-08:00", | |
"description": " <p><a href=\"http://www.flickr.com/people/mayurkotlikar/\">Mayur Kotlikar<\/a> posted a photo:<\/p> <p><a href=\"http://www.flickr.com/photos/mayurkotlikar/16393489545/\" title=\"Mount Rainier and Reflection Lake\"><img src=\"http://farm8.staticflickr.com/7359/16393489545_51399db002_m.jpg\" width=\"240\" height=\"159\" alt=\"Mount Rainier and Reflection Lake\" /><\/a><\/p> <p>Reflection of mount Rainier at Reflection lake.<\/p>", | |
"published": "2015-01-29T06:26:38Z", | |
"author": "[email protected] (Mayur Kotlikar)", | |
"author_id": "27675462@N00", | |
"tags": "seattle summer lake mountains reflection horizontal landscape us washington spring mount rainier" | |
}, | |
{ | |
"title": "Sound Sprinkler --- keeping the bay wet.", | |
"link": "http://www.flickr.com/photos/effjohn/16207549387/", | |
"media": {"m":"http://farm9.staticflickr.com/8645/16207549387_b71ebe7714_m.jpg"}, | |
"date_taken": "2014-07-30T14:14:36-08:00", | |
"description": " <p><a href=\"http://www.flickr.com/people/effjohn/\">Hammerin Man<\/a> posted a photo:<\/p> <p><a href=\"http://www.flickr.com/photos/effjohn/16207549387/\" title=\"Sound Sprinkler --- keeping the bay wet.\"><img src=\"http://farm9.staticflickr.com/8645/16207549387_b71ebe7714_m.jpg\" width=\"240\" height=\"160\" alt=\"Sound Sprinkler --- keeping the bay wet.\" /><\/a><\/p> ", | |
"published": "2015-01-29T06:20:07Z", | |
"author": "[email protected] (Hammerin Man)", | |
"author_id": "53022549@N04", | |
"tags": "seattle washington sprinkler rainier sound pugetsound harborisland mtrainier fireboat" | |
}, | |
{ | |
"title": "Western Washington Farm - EXPLORED", | |
"link": "http://www.flickr.com/photos/kylewaz/16359458096/", | |
"media": {"m":"http://farm9.staticflickr.com/8595/16359458096_a1fdc96583_m.jpg"}, | |
"date_taken": "2015-01-26T17:08:03-08:00", | |
"description": " <p><a href=\"http://www.flickr.com/people/kylewaz/\">kwphotos.com<\/a> posted a photo:<\/p> <p><a href=\"http://www.flickr.com/photos/kylewaz/16359458096/\" title=\"Western Washington Farm - EXPLORED\"><img src=\"http://farm9.staticflickr.com/8595/16359458096_a1fdc96583_m.jpg\" width=\"240\" height=\"135\" alt=\"Western Washington Farm - EXPLORED\" /><\/a><\/p> <p>A farm in Graham, Washington with stunning Mt. Rainier in the background.<br /> <br /> <a href=\"http://www.kwphotos.com\" rel=\"nofollow\">www.kwphotos.com<\/a><\/p>", | |
"published": "2015-01-28T03:41:18Z", | |
"author": "[email protected] (kwphotos.com)", | |
"author_id": "94424247@N04", | |
"tags": "park county horses panorama mountain snow mountains color kyle landscape photography volcano photo washington afternoon mt state pacific northwest farm olympus farmland snowcapped mount national rainier western glaciers pierce cascade graham stitched 45mm wasielewski kwphotos kwphotoscom" | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment