diff --git a/src/main/java/org/forkalsrud/album/exif/ComparatorFactory.java b/src/main/java/org/forkalsrud/album/exif/ComparatorFactory.java index a9c4db3..c4d0ed9 100644 --- a/src/main/java/org/forkalsrud/album/exif/ComparatorFactory.java +++ b/src/main/java/org/forkalsrud/album/exif/ComparatorFactory.java @@ -30,9 +30,11 @@ public class ComparatorFactory { public int compare(Entry e1, Entry e2) { - if (!e1.isFile() && e2.isFile()) { + boolean d1 = "dir".equals(e1.getType()); + boolean d2 = "dir".equals(e2.getType()); + if (d1 && !d2) { return -1; - } else if (e1.isFile() && !e2.isFile()) { + } else if (!d1 && d2) { return +1; } return 0; diff --git a/src/main/java/org/forkalsrud/album/exif/DirectoryEntry.java b/src/main/java/org/forkalsrud/album/exif/DirectoryEntry.java index ad35b99..3128e76 100644 --- a/src/main/java/org/forkalsrud/album/exif/DirectoryEntry.java +++ b/src/main/java/org/forkalsrud/album/exif/DirectoryEntry.java @@ -146,7 +146,8 @@ public class DirectoryEntry extends EntryWithChildren { String name = key.substring("file.".length(), key.length() - ".dimensions".length()); if (!entryMap.containsKey(name)) { File f = new File(file, name); - FileEntry entry = new FileEntry(this, f); + String type = props.getProperty("file." + name + ".type", "image"); + FileEntry entry = new FileEntry(this, f, type); Thumbnail thumbnail = new Thumbnail(f); entry.setCaption(props.getProperty("file." + name + ".caption")); Date fileDate = sdf.parse(props.getProperty("file." + name + ".captureDate")); diff --git a/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java b/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java index 8ccb5c2..0dc5858 100644 --- a/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java +++ b/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java @@ -85,7 +85,7 @@ public class DirectoryMetadataGenerator { if (name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".JPG")) { Map p = generateThumbnailProperties(f); addPropsForFile(props, f, p); - } else if (name.endsWith(".MOV") || name.endsWith(".mp4") || name.endsWith(".avi")) { + } else if (name.endsWith(".mov") || name.endsWith(".MOV") || name.endsWith(".mp4") || name.endsWith(".avi")) { Map p = generateVideoProperties(f); addPropsForFile(props, f, p); } diff --git a/src/main/java/org/forkalsrud/album/exif/Entry.java b/src/main/java/org/forkalsrud/album/exif/Entry.java index c7353d5..52bd6ef 100644 --- a/src/main/java/org/forkalsrud/album/exif/Entry.java +++ b/src/main/java/org/forkalsrud/album/exif/Entry.java @@ -26,13 +26,15 @@ public abstract class Entry { Entry next; Entry prev; Entry parent; + String type; - protected Entry(File file) { + protected Entry(File file, String type) { this.file = file; + this.type = type; } protected Entry(Entry other) { - this(other.file); + this(other.file, other.type); this.thumbnail = other.thumbnail; this.caption = other.caption; this.date = other.date; @@ -43,7 +45,9 @@ public abstract class Entry { */ } - public abstract boolean isFile(); + public String getType() { + return this.type; + } /** diff --git a/src/main/java/org/forkalsrud/album/exif/EntryWithChildren.java b/src/main/java/org/forkalsrud/album/exif/EntryWithChildren.java index bee3996..23dd512 100644 --- a/src/main/java/org/forkalsrud/album/exif/EntryWithChildren.java +++ b/src/main/java/org/forkalsrud/album/exif/EntryWithChildren.java @@ -20,16 +20,9 @@ public class EntryWithChildren extends Entry { } protected EntryWithChildren(File path) { - super(path); + super(path, "dir"); } - /* (non-Javadoc) - * @see org.forkalsrud.album.exif.Entry#isFile() - */ - @Override - public boolean isFile() { - return false; - } void fillLinkedList() { diff --git a/src/main/java/org/forkalsrud/album/exif/FileEntry.java b/src/main/java/org/forkalsrud/album/exif/FileEntry.java index c73fbd7..828f7bf 100644 --- a/src/main/java/org/forkalsrud/album/exif/FileEntry.java +++ b/src/main/java/org/forkalsrud/album/exif/FileEntry.java @@ -12,18 +12,14 @@ import java.io.File; public class FileEntry extends Entry { - public FileEntry(Entry parent, File file) { + public FileEntry(Entry parent, File file, String type) { - super(file); + super(file, type); if (!file.isFile()) { throw new RuntimeException("Use FileEntry only for files: " + file); } this.parent = parent; } - @Override - public boolean isFile() { - return true; - } } diff --git a/src/main/java/org/forkalsrud/album/exif/SearchEngine.java b/src/main/java/org/forkalsrud/album/exif/SearchEngine.java index 8c01f52..84113d5 100644 --- a/src/main/java/org/forkalsrud/album/exif/SearchEngine.java +++ b/src/main/java/org/forkalsrud/album/exif/SearchEngine.java @@ -35,7 +35,7 @@ public class SearchEngine { tryAttribute(dir, dir.getPath().getAbsolutePath(), query); for (Entry e : dir.getContents()) { - if (!e.isFile()) { + if ("dir".equals(e.getType())) { queue.add((DirectoryEntry)e); continue; } diff --git a/src/main/java/org/forkalsrud/album/exif/SearchEntry.java b/src/main/java/org/forkalsrud/album/exif/SearchEntry.java index 7fab023..a91c9d5 100644 --- a/src/main/java/org/forkalsrud/album/exif/SearchEntry.java +++ b/src/main/java/org/forkalsrud/album/exif/SearchEntry.java @@ -11,11 +11,6 @@ public class SearchEntry extends Entry { this.score = 1; } - @Override - public boolean isFile() { - return true; - } - public void addScore() { this.score += 1; } diff --git a/src/main/java/org/forkalsrud/album/web/AlbumServlet.java b/src/main/java/org/forkalsrud/album/web/AlbumServlet.java index e0b3c58..a65ca90 100644 --- a/src/main/java/org/forkalsrud/album/web/AlbumServlet.java +++ b/src/main/java/org/forkalsrud/album/web/AlbumServlet.java @@ -6,6 +6,9 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.util.Calendar; import java.util.Date; import java.util.Properties; @@ -279,7 +282,7 @@ public class AlbumServlet out.println(" {"); out.println(" \"name\": " + jsStr(e.getName()) + ","); out.println(" \"path\": " + jsStr(mapper.map(e.getThumbnail().getPath())) + ","); - out.println(" \"type\": \"" + (e.isFile() ? "file" : "dir") + "\","); + out.println(" \"type\": " + jsStr(e.getType()) + ","); out.println(" \"width\": " + e.getThumbnail().getSize().getWidth() + ","); out.println(" \"height\": " + e.getThumbnail().getSize().getHeight() + ","); out.println(" \"caption\": " + jsStr(e.getCaption())); diff --git a/src/main/webapp/assets/flowplayer/flowplayer-3.0.3.min.js b/src/main/webapp/assets/flowplayer/flowplayer-3.0.3.min.js new file mode 100644 index 0000000..7f851db --- /dev/null +++ b/src/main/webapp/assets/flowplayer/flowplayer-3.0.3.min.js @@ -0,0 +1,24 @@ +/** + * flowplayer.js 3.0.3. The Flowplayer API + * + * Copyright 2008 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see . + * + * Version: 3.0.3 - Wed Jan 07 2009 13:22:30 GMT-0000 (GMT+00:00) + */ +(function(){function log(args){console.log("$f.fireEvent",[].slice.call(args));}function clone(obj){if(!obj||typeof obj!='object'){return obj;}var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}}return temp;}function each(obj,fn){if(!obj){return;}var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i=0&&arg01){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}}return null;};extend(window.$f,{fireEvent:function(id,evt,a0,a1,a2){var p=$f(id);return p?p._fireEvent(evt,a0,a1,a2):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(document.all){window.onbeforeunload=function(){$f("*").each(function(){if(this.isLoaded()){this.close();}});};}if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);}return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';function isDomReady(){if(domReady.done){return false;}var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i';return html;}function getObjectCode(p,c,embeddable){var html='';var e=extend({},p);e.id=e.width=e.height=e.src=null;for(var k in e){if(e[k]!==null){html+='\n\t';}}if(c){html+='\n\t';}if(embeddable){html+=getEmbedCode(p,c);}html+="";return html;}function getFullHTML(p,c){return getObjectCode(p,c,true);}function getHTML(p,c){var isNav=navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length;return(isNav)?getEmbedCode(p,c):getObjectCode(p,c);}window.flashembed=function(root,userParams,flashvars){var params={src:'#',width:'100%',height:'100%',version:null,onFail:null,expressInstall:null,debug:false,allowfullscreen:true,allowscriptaccess:'always',quality:'high',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};if(typeof userParams=='string'){userParams={src:userParams};}extend(params,userParams);var version=flashembed.getVersion();var required=params.version;var express=params.expressInstall;var debug=params.debug;if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,userParams,flashvars);});return;}}if(!root){return;}if(!required||flashembed.isSupported(required)){params.onFail=params.version=params.expressInstall=params.debug=null;root.innerHTML=getHTML(params,flashvars);return root.firstChild;}else if(params.onFail){var ret=params.onFail.call(params,flashembed.getVersion(),flashvars);if(ret===true){root.innerHTML=ret;}}else if(required&&express&&flashembed.isSupported([6,65])){extend(params,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(params,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="

Flash version "+required+" or greater is required

"+"

"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"

"+"

Download latest version from here

";}}return root;};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML,getFullHTML:getFullHTML});if(jQ){jQuery.prototype.flashembed=function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});};}})(); \ No newline at end of file diff --git a/src/main/webapp/assets/flowplayer/flowplayer-3.0.3.swf b/src/main/webapp/assets/flowplayer/flowplayer-3.0.3.swf new file mode 100644 index 0000000..303efd6 Binary files /dev/null and b/src/main/webapp/assets/flowplayer/flowplayer-3.0.3.swf differ diff --git a/src/main/webapp/assets/flowplayer/flowplayer.controls-3.0.3.swf b/src/main/webapp/assets/flowplayer/flowplayer.controls-3.0.3.swf new file mode 100644 index 0000000..08e1b70 Binary files /dev/null and b/src/main/webapp/assets/flowplayer/flowplayer.controls-3.0.3.swf differ diff --git a/src/main/webapp/assets/flowplayer/flowplayer.h264streaming-3.0.5.swf b/src/main/webapp/assets/flowplayer/flowplayer.h264streaming-3.0.5.swf new file mode 100644 index 0000000..13c17a9 Binary files /dev/null and b/src/main/webapp/assets/flowplayer/flowplayer.h264streaming-3.0.5.swf differ diff --git a/src/main/webapp/dynamic.html b/src/main/webapp/dynamic.html index 502a6bb..2720d67 100644 --- a/src/main/webapp/dynamic.html +++ b/src/main/webapp/dynamic.html @@ -12,7 +12,7 @@ - + @@ -87,9 +87,9 @@ $(function() { function scale(w, h, max) { if (w > h) { - return { w : Math.round(max), h: Math.round((max * h + max / 2) / w) }; + return { w : Math.floor(max), h: Math.floor((max * h + max / 2) / w) }; } else { - return { w: Math.round((max * w + max / 2) / h), h: Math.round(max) }; + return { w: Math.floor((max * w + max / 2) / h), h: Math.floor(max) }; } } @@ -104,18 +104,19 @@ $(function() { var gridDiv = $("
\n" + " " + entry.name + "
\n" - + "
" + + " \n" + "

\n" + "
\n"); gridDiv.appendTo('body'); var element = gridDiv.filter("a.ss"); - + + //$("

" + entry.type + "

").appendTo("#dbg"); + switch (entry.type) { - case "video": - element.fancybox({ - 'index' : idx, + case "movie": + $("#ent" + idx).attr("rel", "album").attr("href", "raw/" + entry.name).fancybox({ 'titlePosition' : 'inside', 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', @@ -123,7 +124,7 @@ $(function() { 'easingOut' : 'easeOutQuad', 'titleFormat' : formatTitle, 'padding' : 0, - 'href' : "flowplayer/flowplayer-3.0.3.swf", + 'href' : "assets/flowplayer/flowplayer-3.0.3.swf", 'width' : entry.width, 'height' : entry.height, 'type' : 'swf', @@ -131,13 +132,13 @@ $(function() { 'allowfullscreen' : 'true', 'wmode' : 'transparent', 'flashvars': - "config={ 'clip': { 'url': '" + escape(element.href) + "', 'provider': 'h264streaming' },\ + "config={ 'clip': { 'url': 'raw/" + escape(entry.name) + "', 'provider': 'h264streaming' },\ 'plugins': {\ 'h264streaming': {\ - 'url': 'flowplayer/flowplayer.h264streaming-3.0.5.swf'\ + 'url': 'assets/flowplayer/flowplayer.h264streaming-3.0.5.swf'\ },\ 'controls': {\ - 'url': 'flowplayer/flowplayer.controls-3.0.3.swf',\ + 'url': 'assets/flowplayer/flowplayer.controls-3.0.3.swf',\ 'backgroundColor': 'transparent', 'progressColor': 'transparent', 'bufferColor': 'transparent',\ 'play':true,\ 'fullscreen':true,\ @@ -148,19 +149,19 @@ $(function() { } }); break; - case "file": - element.fancybox({ - 'index' : idx, + case "image": + var largeDim = scale(entry.width, entry.height, 800); + $("#ent" + idx).attr("rel", "album").fancybox({ 'titlePosition' : 'inside', 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'easingIn' : 'easeInQuad', 'easingOut' : 'easeOutQuad', 'titleFormat' : formatTitle, - 'width' : entry.width, - 'height' : entry.height, + 'width' : largeDim.w, + 'height' : largeDim.h, 'type' : "image", - 'href' : element.href + 'href' : $("#ent" + idx).href }); break; } @@ -191,6 +192,6 @@ $(function() {

2001-12-santabarbara

-
+