Permalink
Browse files

Now using a Flickr App API Key for all YQL calls.

  • Loading branch information...
1 parent b08323c commit a1fddfaaea223edfa2af3cbb450fd4e571b6444b @ericf ericf committed Sep 6, 2011
Showing with 113 additions and 87 deletions.
  1. +4 −3 index.html
  2. +11 −2 public/js/models/photo.js
  3. +11 −6 public/js/models/photos.js
  4. +7 −2 public/js/models/place.js
  5. +80 −74 public/js/yui-config.js
View
@@ -97,10 +97,11 @@
</script>
- <script src="/js/yui-config.js"></script>
- <script src="/js/handlebars.js"></script>
- <script src="http://use.typekit.com/wkh7ffm.js"></script>
+
<script src="http://yui.yahooapis.com/3.4.0/build/yui/yui-min.js"></script>
+ <script src="http://use.typekit.com/wkh7ffm.js"></script>
+ <script src="/js/handlebars.js"></script>
+ <script src="/js/yui-config.js"></script>
<script>
// Load Typekit.
try { Typekit.load(); } catch (e) {}
View
@@ -2,15 +2,24 @@ YUI.add('photo', function (Y) {
var Lang = Y.Lang,
sub = Lang.sub,
- isString = Lang.isString;
+ isString = Lang.isString,
+
+ FLICKR_API_KEY = YUI.namespace('Env.Flickr').API_KEY || '';
Y.Photo = Y.Base.create('photo', Y.Model, [Y.ModelSync.YQL], {
cache : new Y.CacheOffline(),
- query : 'SELECT * FROM flickr.photos.info WHERE photo_id={id}',
+ query : 'SELECT * FROM flickr.photos.info WHERE api_key={api_key} AND photo_id={id}',
imgUrl : 'http://farm{farm}.static.flickr.com/{server}/{id}_{secret}_{size}.jpg',
pageUrl: 'http://www.flickr.com/photos/{user}/{id}/',
+ buildQuery: function () {
+ return sub(this.query, {
+ api_key: FLICKR_API_KEY,
+ id : this.get('id')
+ });
+ },
+
parse: function (results) {
if ( ! results) { return; }
View
@@ -1,22 +1,27 @@
YUI.add('photos', function (Y) {
-var sub = Y.Lang.sub;
+var sub = Y.Lang.sub,
+
+ FLICKR_API_KEY = YUI.namespace('Env.Flickr').API_KEY || '';
Y.Photos = Y.Base.create('photos', Y.ModelList, [Y.ModelSync.YQL], {
model: Y.Photo,
cache: new Y.CacheOffline(),
query: 'SELECT * FROM flickr.photos.search({start},{num}) ' +
- 'WHERE woe_id={woeid} AND sort="interestingness-desc" ' +
- 'AND extras="path_alias"',
+ 'WHERE api_key={api_key} ' +
+ 'AND woe_id={woeid} ' +
+ 'AND sort="interestingness-desc" ' +
+ 'AND extras="path_alias"',
buildQuery: function (options) {
options || (options = {});
return sub(this.query, {
- start: options.start || 0,
- num : options.num || 100,
- woeid: options.place.get('id')
+ api_key: FLICKR_API_KEY,
+ start : options.start || 0,
+ num : options.num || 100,
+ woeid : options.place.get('id')
});
},
@@ -1,6 +1,8 @@
YUI.add('place', function (Y) {
-var sub = Y.Lang.sub;
+var sub = Y.Lang.sub,
+
+ FLICKR_API_KEY = YUI.namespace('Env.Flickr').API_KEY || '';
Y.Place = Y.Base.create('place', Y.Model, [Y.ModelSync.YQL], {
@@ -10,13 +12,16 @@ Y.Place = Y.Base.create('place', Y.Model, [Y.ModelSync.YQL], {
placeFromId : 'SELECT * FROM geo.places WHERE woeid={id}',
placeFromLatLon: 'SELECT * FROM geo.places WHERE woeid ' +
'IN (SELECT place.woeid FROM flickr.places ' +
- 'WHERE lat={latitude} AND lon={longitude})'
+ 'WHERE api_key={api_key} ' +
+ 'AND lat={latitude} ' +
+ 'AND lon={longitude})'
},
buildQuery: function () {
if (this.isNew()) {
// assumes we at least have a lat/lon
return sub(this.queries.placeFromLatLon, {
+ api_key : FLICKR_API_KEY,
latitude : this.get('latitude'),
longitude: this.get('longitude')
});
View
@@ -1,85 +1,91 @@
-YUI_config = (function () {
- var loc = window.location,
- filter = (loc.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min';
+(function () {
- return {
- filter : filter,
- combine : filter === 'min',
- allowRollup: false,
- gallery : 'gallery-2011.08.31-20-57',
- groups : {
- app: {
- base : '/js/',
- comboBase: '/js/?',
- combine : filter === 'min',
- root : '',
- modules : {
- 'place': {
- path : 'models/place.js',
- requires: [ 'model'
- , 'yql'
- , 'gallery-model-sync-yql'
- , 'cache-offline'
- ]
- },
+var filter = (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min';
- 'photo': {
- path : 'models/photo.js',
- requires: [ 'model'
- , 'yql'
- , 'gallery-model-sync-yql'
- , 'cache-offline'
- , 'place'
- ]
- },
+// YUI Config.
+YUI_config = {
+ filter : filter,
+ combine : filter === 'min',
+ allowRollup: false,
+ gallery : 'gallery-2011.08.31-20-57',
+ groups : {
+ app: {
+ base : '/js/',
+ comboBase: '/js/?',
+ combine : filter === 'min',
+ root : '',
+ modules : {
+ 'place': {
+ path : 'models/place.js',
+ requires: [ 'model'
+ , 'yql'
+ , 'gallery-model-sync-yql'
+ , 'cache-offline'
+ ]
+ },
- 'photos': {
- path : 'models/photos.js',
- requires: [ 'model-list'
- , 'yql'
- , 'gallery-model-sync-yql'
- , 'cache-offline'
- , 'photo'
- ]
- },
+ 'photo': {
+ path : 'models/photo.js',
+ requires: [ 'model'
+ , 'yql'
+ , 'gallery-model-sync-yql'
+ , 'cache-offline'
+ , 'place'
+ ]
+ },
- 'grid-view': {
- path : 'views/grid.js',
- requires: [ 'view'
- , 'node-style'
- , 'node-screen'
- , 'photos'
- ]
- },
+ 'photos': {
+ path : 'models/photos.js',
+ requires: [ 'model-list'
+ , 'yql'
+ , 'gallery-model-sync-yql'
+ , 'cache-offline'
+ , 'photo'
+ ]
+ },
- 'lightbox-view': {
- path : 'views/lightbox.js',
- requires: [ 'view'
- , 'place'
- , 'photos'
- ]
- },
+ 'grid-view': {
+ path : 'views/grid.js',
+ requires: [ 'view'
+ , 'node-style'
+ , 'node-screen'
+ , 'photos'
+ ]
+ },
- 'app-view': {
- path : 'views/app.js',
- requires: [ 'view'
- , 'place'
- ]
- },
+ 'lightbox-view': {
+ path : 'views/lightbox.js',
+ requires: [ 'view'
+ , 'place'
+ , 'photos'
+ ]
+ },
- 'photosnearme': {
- path : 'photosnearme.js',
- requires: [ 'controller'
- , 'gallery-geo'
- , 'place'
- , 'photos'
- , 'app-view'
- , 'grid-view'
- , 'lightbox-view'
- ]
- }
+ 'app-view': {
+ path : 'views/app.js',
+ requires: [ 'view'
+ , 'transition'
+ , 'place'
+ ]
+ },
+
+ 'photosnearme': {
+ path : 'photosnearme.js',
+ requires: [ 'controller'
+ , 'gallery-geo'
+ , 'place'
+ , 'photos'
+ , 'app-view'
+ , 'grid-view'
+ , 'lightbox-view'
+ ]
}
}
}
- };
+ }
+};
+
+// Flickr API Key.
+YUI && (YUI.namespace('Env.Flickr').API_KEY = '0984607e2222db7a1be6a5692741ca08');
+
}());

0 comments on commit a1fddfa

Please sign in to comment.