From 30c9b1b53b28969eed9415d68a1244e5df4f7410 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 3 Jul 2021 20:59:01 -0500 Subject: [PATCH 1/6] add flickr exif data --- src/jquery.nanogallery2.core.js | 8 ++-- src/jquery.nanogallery2.data_flickr.js | 58 ++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/jquery.nanogallery2.core.js b/src/jquery.nanogallery2.core.js index 3aaf4ac9..e1365523 100644 --- a/src/jquery.nanogallery2.core.js +++ b/src/jquery.nanogallery2.core.js @@ -1335,6 +1335,7 @@ RTL : false, flickrSkipOriginal : true, flickrAPIKey: '', + flickrExif: false, breadcrumbAutoHideTopLevel : true, displayBreadcrumb : true, breadcrumbOnlyCurrentLevel : true, @@ -2097,7 +2098,7 @@ // author: underscore.js - http://underscorejs.org/docs/underscore.html // Returns a function, that, when invoked, will only be triggered at most once during a given window of time. // Normally, the throttled function will run as much as it can, without ever going more than once per wait duration; - // but if you’d like to disable the execution on the leading edge, pass {leading: false}. + // but if you�d like to disable the execution on the leading edge, pass {leading: false}. // To disable execution on the trailing edge, ditto. var throttle = function(func, wait, options) { var context, args, result; @@ -7888,7 +7889,7 @@ }; } - // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel + // requestAnimationFrame polyfill by Erik M�ller. fixes from Paul Irish and Tino Zijdel // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // MIT license @@ -8396,7 +8397,7 @@ var vimg = new VImg(ngy2ItemIdx); G.VOM.items.push(vimg); items.push(G.I[ngy2ItemIdx]); - //TODO -> danger? -> pourquoi reconstruire la liste si déjà ouvert (back/forward) + //TODO -> danger? -> pourquoi reconstruire la liste si d�j� ouvert (back/forward) var l = G.I.length; for( let idx = ngy2ItemIdx+1; idx < l ; idx++) { let item = G.I[idx]; @@ -15961,4 +15962,3 @@ if (typeof define === 'function' && define.amdDISABLED) { // }); }).call(null); - diff --git a/src/jquery.nanogallery2.data_flickr.js b/src/jquery.nanogallery2.data_flickr.js index 13772672..0565b8f7 100644 --- a/src/jquery.nanogallery2.data_flickr.js +++ b/src/jquery.nanogallery2.data_flickr.js @@ -161,6 +161,56 @@ } + // ----------- + // Retrieve flickr EXIF data + function FlickrGetExif ( itemID, newItem ) { + jQuery.ajaxSetup({ cache: false }); + jQuery.support.cors = true; + + var sourceData=[]; + + var tId = setTimeout( function() { + // workaround to handle JSONP (cross-domain) errors + NanoAlert('Could not retrieve AJAX data...'); + }, 60000 ); + + url = Flickr.url() + "?&method=flickr.photos.getExif&api_key=" + G.O.flickrAPIKey + "&photo_id="+itemID+"&format=json"; + + jQuery.getJSON( url + '&jsoncallback=?' , function(data, status, xhr) { + // Exif - model + if( data.photo.camera !== undefined ) { newItem.exif.model = data.photo.camera; } + // Exif - flash + var flash = data.photo.exif.filter(function(exif) {return exif.tag == "Flash"}) + if( flash.length == 1 ) { newItem.exif.flash = flash[0].raw._content; } + // Exif - focallength + var fl = data.photo.exif.filter(function(exif) {return exif.tag == "FocalLength"}); + if( fl.length == 1 ) { newItem.exif.focallength = fl[0].raw._content; } + // Exif - fstop + var fstop = data.photo.exif.filter(function(exif) {return exif.tag == "FNumber"}); + if( fstop.length == 1 ) { newItem.exif.fstop = fstop[0].raw._content; } + // Exif - exposure + var exposure = data.photo.exif.filter(function(exif) {return exif.tag == "ExposureTime"}); + if( exposure.length == 1 ) { newItem.exif.exposure = exposure[0].raw._content; } + // Exif - iso + var iso = data.photo.exif.filter(function(exif) {return exif.tag == "ISO"}); + if( iso.length == 1 ) { newItem.exif.iso = iso[0].raw._content; } + // Exif - time + var time = data.photo.exif.filter(function(exif) {return exif.tag == "DateTimeOriginal"}); + if( time.length == 1 ) { newItem.exif.time = time[0].raw._content; } + // Exif - location + var location = data.photo.exif.filter(function(exif) {return exif.tag == "LOLcation"}); + if( location.length == 1 ) { newItem.exif.location = location[0].raw._content; } + + // author + var author = data.photo.exif.filter(function(exif) {return exif.tag == "OwnerName"}); + if( author.length >= 1 ) { newItem.author = author[0].raw._content; } + + clearTimeout(tId); + }).fail(function(jqXHR, textStatus, errorThrown) { + console.log("Unable to get EXIF data from Flickr"); + }) + } + // ----------- // Retrieve items for one Flickr photoset @@ -212,6 +262,11 @@ // create item var newItem = NGY2Item.New( G, itemTitle, itemDescription, itemID, albumID, 'image', tags ); + // grab EXIF data + if ( G.O.flickrExif ) { + FlickrGetExif(itemID, newItem); + } + // add image newItem.setMediaURL( imgUrl, 'img'); newItem.imageWidth = imgW; @@ -419,6 +474,3 @@ // END FLICKR DATA SOURCE FOR NANOGALLERY2 // }( jQuery )); })); - - - From f3a9bb81f7bfa2f9d330ffa835d56721f7ded7e1 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 3 Jul 2021 21:08:55 -0500 Subject: [PATCH 2/6] cleanup --- src/jquery.nanogallery2.core.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jquery.nanogallery2.core.js b/src/jquery.nanogallery2.core.js index e1365523..60b595d3 100644 --- a/src/jquery.nanogallery2.core.js +++ b/src/jquery.nanogallery2.core.js @@ -2098,7 +2098,7 @@ // author: underscore.js - http://underscorejs.org/docs/underscore.html // Returns a function, that, when invoked, will only be triggered at most once during a given window of time. // Normally, the throttled function will run as much as it can, without ever going more than once per wait duration; - // but if you�d like to disable the execution on the leading edge, pass {leading: false}. + // but if you’d like to disable the execution on the leading edge, pass {leading: false}. // To disable execution on the trailing edge, ditto. var throttle = function(func, wait, options) { var context, args, result; @@ -7889,7 +7889,7 @@ }; } - // requestAnimationFrame polyfill by Erik M�ller. fixes from Paul Irish and Tino Zijdel + // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // MIT license @@ -15962,3 +15962,4 @@ if (typeof define === 'function' && define.amdDISABLED) { // }); }).call(null); + From e68bffff0a96baa2aa41bb89ff7bc0e15120ab1d Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 3 Jul 2021 21:10:18 -0500 Subject: [PATCH 3/6] one more --- src/jquery.nanogallery2.core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.nanogallery2.core.js b/src/jquery.nanogallery2.core.js index 60b595d3..553fe626 100644 --- a/src/jquery.nanogallery2.core.js +++ b/src/jquery.nanogallery2.core.js @@ -8397,7 +8397,7 @@ var vimg = new VImg(ngy2ItemIdx); G.VOM.items.push(vimg); items.push(G.I[ngy2ItemIdx]); - //TODO -> danger? -> pourquoi reconstruire la liste si d�j� ouvert (back/forward) + //TODO -> danger? -> pourquoi reconstruire la liste si déjà ouvert (back/forward) var l = G.I.length; for( let idx = ngy2ItemIdx+1; idx < l ; idx++) { let item = G.I[idx]; From d07f4f1d47c8636293b3cc8cd126bd65f2ad4100 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 3 Jul 2021 21:12:16 -0500 Subject: [PATCH 4/6] one more --- src/jquery.nanogallery2.core.js | 2 +- src/jquery.nanogallery2.data_flickr.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jquery.nanogallery2.core.js b/src/jquery.nanogallery2.core.js index 553fe626..46b10fd4 100644 --- a/src/jquery.nanogallery2.core.js +++ b/src/jquery.nanogallery2.core.js @@ -8397,7 +8397,7 @@ var vimg = new VImg(ngy2ItemIdx); G.VOM.items.push(vimg); items.push(G.I[ngy2ItemIdx]); - //TODO -> danger? -> pourquoi reconstruire la liste si déjà ouvert (back/forward) + //TODO -> danger? -> pourquoi reconstruire la liste si déjà ouvert (back/forward) var l = G.I.length; for( let idx = ngy2ItemIdx+1; idx < l ; idx++) { let item = G.I[idx]; diff --git a/src/jquery.nanogallery2.data_flickr.js b/src/jquery.nanogallery2.data_flickr.js index 0565b8f7..eaa15587 100644 --- a/src/jquery.nanogallery2.data_flickr.js +++ b/src/jquery.nanogallery2.data_flickr.js @@ -474,3 +474,5 @@ // END FLICKR DATA SOURCE FOR NANOGALLERY2 // }( jQuery )); })); + + From c3fa1e30fb4447cff0eb2654c579c99311955ba3 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sat, 3 Jul 2021 21:13:10 -0500 Subject: [PATCH 5/6] one last one? --- src/jquery.nanogallery2.data_flickr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jquery.nanogallery2.data_flickr.js b/src/jquery.nanogallery2.data_flickr.js index eaa15587..a66bc166 100644 --- a/src/jquery.nanogallery2.data_flickr.js +++ b/src/jquery.nanogallery2.data_flickr.js @@ -475,4 +475,5 @@ // }( jQuery )); })); - + + From e9491c09825c45f6cbb700cad4f9a09d6934cb28 Mon Sep 17 00:00:00 2001 From: Jonathan Keane Date: Sun, 4 Jul 2021 22:06:12 -0500 Subject: [PATCH 6/6] allow any non-zero number of EXIF hits --- src/jquery.nanogallery2.data_flickr.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jquery.nanogallery2.data_flickr.js b/src/jquery.nanogallery2.data_flickr.js index a66bc166..9d0a0e27 100644 --- a/src/jquery.nanogallery2.data_flickr.js +++ b/src/jquery.nanogallery2.data_flickr.js @@ -181,25 +181,25 @@ if( data.photo.camera !== undefined ) { newItem.exif.model = data.photo.camera; } // Exif - flash var flash = data.photo.exif.filter(function(exif) {return exif.tag == "Flash"}) - if( flash.length == 1 ) { newItem.exif.flash = flash[0].raw._content; } + if( flash.length >= 1 ) { newItem.exif.flash = flash[0].raw._content; } // Exif - focallength var fl = data.photo.exif.filter(function(exif) {return exif.tag == "FocalLength"}); - if( fl.length == 1 ) { newItem.exif.focallength = fl[0].raw._content; } + if( fl.length >= 1 ) { newItem.exif.focallength = fl[0].raw._content; } // Exif - fstop var fstop = data.photo.exif.filter(function(exif) {return exif.tag == "FNumber"}); - if( fstop.length == 1 ) { newItem.exif.fstop = fstop[0].raw._content; } + if( fstop.length >= 1 ) { newItem.exif.fstop = fstop[0].raw._content; } // Exif - exposure var exposure = data.photo.exif.filter(function(exif) {return exif.tag == "ExposureTime"}); - if( exposure.length == 1 ) { newItem.exif.exposure = exposure[0].raw._content; } + if( exposure.length >= 1 ) { newItem.exif.exposure = exposure[0].raw._content; } // Exif - iso var iso = data.photo.exif.filter(function(exif) {return exif.tag == "ISO"}); - if( iso.length == 1 ) { newItem.exif.iso = iso[0].raw._content; } + if( iso.length >= 1 ) { newItem.exif.iso = iso[0].raw._content; } // Exif - time var time = data.photo.exif.filter(function(exif) {return exif.tag == "DateTimeOriginal"}); - if( time.length == 1 ) { newItem.exif.time = time[0].raw._content; } + if( time.length >= 1 ) { newItem.exif.time = time[0].raw._content; } // Exif - location var location = data.photo.exif.filter(function(exif) {return exif.tag == "LOLcation"}); - if( location.length == 1 ) { newItem.exif.location = location[0].raw._content; } + if( location.length >= 1 ) { newItem.exif.location = location[0].raw._content; } // author var author = data.photo.exif.filter(function(exif) {return exif.tag == "OwnerName"});