More work on the dynamic client side rendering + video display.

This commit is contained in:
Erik Forkalsrud 2011-03-19 23:58:42 -07:00
parent 2f5876a0e9
commit 9b584bd82e
14 changed files with 66 additions and 47 deletions

View file

@ -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;

View file

@ -146,7 +146,8 @@ public class DirectoryEntry extends EntryWithChildren<Entry> {
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"));

View file

@ -85,7 +85,7 @@ public class DirectoryMetadataGenerator {
if (name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".JPG")) {
Map<String, String> 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<String, String> p = generateVideoProperties(f);
addPropsForFile(props, f, p);
}

View file

@ -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;
}
/**

View file

@ -20,16 +20,9 @@ public class EntryWithChildren<T extends Entry> 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() {

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -11,11 +11,6 @@ public class SearchEntry extends Entry {
this.score = 1;
}
@Override
public boolean isFile() {
return true;
}
public void addScore() {
this.score += 1;
}

View file

@ -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()));

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -12,7 +12,7 @@
<script type="text/javascript" src="assets/fancybox/jquery.fancybox-1.3.1.js"></script>
<script type="text/javascript" src="assets/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript" src="assets/fancybox/jquery.mousewheel-3.0.2.pack.js"></script>
<!-- <script type="text/javascript" src="flowplayer/flowplayer-3.0.3.min.js"></script> -->
<script type="text/javascript" src="assets/flowplayer/flowplayer-3.0.3.min.js"></script>
<link rel="stylesheet" href="assets/fancybox/jquery.fancybox-1.3.1.css" type="text/css" media="screen" />
@ -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 = $("<div class=\"grid\">\n"
+ " <span class=\"name\">" + entry.name + "</span><br/>\n"
+ " <div class=\"imgborder\"><a class=\"ss\" href=\"album" + entry.path + "?size=800\" rel=\"album\" title=\"" + entry.name + "\">"
+ " <div class=\"imgborder\"><a class=\"ss\" id=\"ent" + idx + "\" href=\"album" + entry.path + "?size=800\" title=\"" + entry.name + "\">"
+ "<img class=\"picture\" src=\"album" + entry.path + "?size=250\" border=\"0\" width=\"" + dim.w + "\" height=\"" + dim.h + "\"/></a></div>\n"
+ "<p id=\"" + entry.name + "\" class=\"caption\"></p>\n"
+ "</div>\n");
gridDiv.appendTo('body');
var element = gridDiv.filter("a.ss");
//$("<p>" + entry.type + "</p>").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() {
<body>
<form method="get"><input name="q" value=""></form>
<h1 id="name">2001-12-santabarbara</h1>
<hr/>
<hr/>
</body>
</html>