Added photo detail page

This commit is contained in:
knut 2008-11-24 19:54:24 +00:00
parent fed49dccc3
commit 00130d9823
57 changed files with 173 additions and 51 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View file

@ -67,17 +67,19 @@ var Loader = {
_assets: $H({}),
_checkInterval: null,
_options: {},
_update: function() {
var allLoaded = true;
Loader._assets.each(function(a) {
if(!a[1].complete && a[1].image.complete) {
if (!a[1].complete && a[1].image.complete) {
a[1].complete = true;
a[1].completed_at = new Date().getTime();
if(a[1].options.onComplete) {
a[1].options.onComplete(a[0]);
}
}
if(!a[1].complete && !a[1].image.complete) {
if (!a[1].complete && !a[1].image.complete) {
allLoaded = false;
}
});
@ -139,7 +141,7 @@ var Loader = {
},
isQueued: function(url) {
return !!(Loader._assets.get(url));
return Loader._assets.get(url);
},
isLoaded: function(url) {
@ -230,7 +232,7 @@ Effect.HScrollToElement = function(element, direction) {
var delta = -(offset - elementMiddle) - clickOffset;
new Effect.HScroll(delta);
}
/*
Effect.MoveRight = Class.create();
Object.extend(Object.extend(Effect.MoveRight.prototype, Effect.Base.prototype), {
@ -254,3 +256,4 @@ Object.extend(Object.extend(Effect.MoveRight.prototype, Effect.Base.prototype),
});
}
});
*/

View file

@ -1,7 +1,7 @@
var Album = {
pictures: [],
queue: { position: 'end', scope: 'shop' },
queue: { position: 'end', scope: 'album' },
cubic: function(pos) {
pos /= 0.5;
@ -59,7 +59,7 @@ var Album = {
imgtags.each(function(img, index) {
var container = img.parentNode;
var picturebox = container.parentNode;
var darkener = img.next();
// var darkener = img.next();
var picture = _pictures[container.id.substr(3)];
$(img).setStyle({ width: picture.width + 'px', height: picture.height + 'px' });
@ -67,29 +67,6 @@ var Album = {
$(picturebox).setStyle({ width: picture.width + 'px' });
totalWidth += picture.width;
pictureCount += 1;
/*
if (!container.hasClassName('highlight') && highlight.include(picture)) {
new Effect.Opacity(container, { from: 1, to: 0, afterFinish:function() {
container.setOpacity(1);
container.addClassName('highlight');
darkener.setOpacity(0.001);
}});
} else if (container.hasClassName('highlight') && !highlight.include(picture)) {
container.setOpacity(0);
container.removeClassName('highlight');
new Effect.Opacity(container,{ from: 0, to: 1.0 });
new Effect.Opacity(darkener, { from: 0, to: 0.3 });
}
if (picture != null) {
Album.thumbs.push({
id: picture.style,
stylegroup: picture.id,
thumburl: picture.thumburl
});
}
*/
});
totalWidth += (pictureCount - 1) * 65;
@ -125,8 +102,8 @@ var Album = {
if ((x0 >= 0 && x0 < w) || (x1 >=0 && x1 < w)) {
visibles.push(img);
} else {
img.src = 'assets/empty.gif';
Loader.remove(picture.url);
img.src = 'assets/empty.gif';
}
});
@ -135,7 +112,6 @@ var Album = {
var id = img.parentNode.id;
var picture = _pictures[id.substr(3)];
// alert(picture.url);
if (img.src == picture.url) return;
@ -143,14 +119,15 @@ var Album = {
if (Loader.isQueued(imageObj)) return;
// alert('src: ' + img.src + '\nurl: ' + picture.url + '\nmatch: ' + img.src.match('assets/empty\.gif$') + '\nloader: ' + Loader.isQueued(imageObj));
// alert('Loading: ' + imageObj + '\nsrc: ' + img.src + '\nurl: ' + picture.url + '\nmatch: ' + img.src.match('assets/empty\.gif$') + '\nloader: ' + Loader.isQueued(imageObj));
// $(img).setStyle({ position: 'relative', left: ('-' + picture.width + 'px') });
Loader.cacheOrLoad(imageObj, {
onComplete: function(obj) {
// $(img).setStyle({ position: 'relative', left: '0px'}).setOpacity(0);
$(img).setOpacity(0);
img.setOpacity(0);
// alert(obj);
img.src = obj;
new Effect.Opacity(img, { from: 0, to: 1, delay: 0.2, transition: Album.cubic, duration: 0.8 });
}});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

86
src/ShardulFilter.java Normal file
View file

@ -0,0 +1,86 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.util.Date;
import java.util.Enumeration;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ShardulFilter implements Filter {
public void doFilter(ServletRequest req0, ServletResponse res0, FilterChain chain) throws IOException,
ServletException {
HttpServletRequest req = (HttpServletRequest)req0;
HttpServletResponse res = (HttpServletResponse)res0;
String ref = req.getHeader("Referer");
if (ref != null) {
try {
URI refUri = new URI(ref);
String host = refUri.getHost();
if (host != null && host.toLowerCase().endsWith(".wordpress.com")) {
logRequest("redirect", req, null);
res.sendRedirect("http://www.forkalsrud.org/stalker.jpg");
return;
}
} catch (Exception e) {
logRequest("error", req, e);
}
}
chain.doFilter(req, res);
}
private void logRequest(String string, HttpServletRequest req, Exception e) {
try {
File logfile = new File(System.getProperty("user.home"), "stalker.log");
FileWriter fw = new FileWriter(logfile, true);
fw.write("--------------------\n");
fw.write("" + new Date() + "\n");
fw.write("IP: " + req.getRemoteAddr() + " " + req.getRemoteHost() + " " + req.getRequestURL().toString() + "\n");
Enumeration enm = req.getParameterNames();
while (enm.hasMoreElements()) {
String param = (String)enm.nextElement();
String[] val = req.getParameterValues(param);
for (String s : val) {
fw.write("param " + param + ": " + s + "\n");
}
}
fw.write("\n");
enm = req.getHeaderNames();
while (enm.hasMoreElements()) {
String header = (String)enm.nextElement();
String val = req.getHeader(header);
fw.write(header + ": " + val + "\n");
}
fw.write("\n");
if (e != null) {
e.printStackTrace(new PrintWriter(fw, true));
}
fw.write("\n");
fw.flush();
fw.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
public void init(FilterConfig arg0) throws ServletException {
// noop
}
public void destroy() {
// noop
}
}

View file

@ -107,6 +107,18 @@ public class EntryDao {
}
public Entry readFile(File file) throws FileNotFoundException, IOException, JpegProcessingException, MetadataException, ParseException {
List<Entry> dir = read(file.getParentFile());
String name = file.getName();
for (Entry e : dir) {
if (name.equals(e.name)) {
return e;
}
}
return null;
}
void generateEntries(File directory, Properties cachedProps) throws JpegProcessingException, MetadataException, FileNotFoundException, IOException {
File[] files = directory.listFiles(new FileFilter() {

View file

@ -45,24 +45,13 @@ public class AlbumServlet
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
/*
System.out.println("pathInfo: " + req.getPathInfo());
System.out.println("pathXlat: " + req.getPathTranslated());
System.out.println("queryString: " + req.getQueryString());
System.out.println("requestUri: " + req.getRequestURI());
System.out.println("servletPath: " + req.getServletPath());
*/
/* useless
Set paths = getServletContext().getResourcePaths(req.getPathTranslated());
for (Object path2 : paths) {
System.out.println(" " + String.valueOf(path2));
}
System.out.println();
*/
String path = req.getPathTranslated();
// System.out.println("file: " + path);
String page = null;
if (path.endsWith(".photo")) {
path = path.substring(0, path.length() - ".photo".length());
page = "photo";
}
File file = new File(path);
if (file == null) {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
@ -100,6 +89,16 @@ public class AlbumServlet
} catch (Exception e) {
throw new RuntimeException("sadness", e);
}
} else if ("photo".equals(page)) {
try {
Entry e = dao.readFile(file);
req.setAttribute("entry", e);
RequestDispatcher rd = req.getRequestDispatcher("/WEB-INF/velocity/photo.vm");
rd.forward(req, res);
} catch (Exception e) {
throw new RuntimeException("sadness", e);
}
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}

View file

@ -11,7 +11,6 @@
font-family: "Lucida Grande", Arial, sans-serif;
color: #6d6d6d;
background: #acc95f;
width: 600px;
margin: 10px auto;
text-align: center;
}
@ -42,7 +41,7 @@
#set($dim = $entry.size.scaled($thmb))
<div class="home_entry_table">
<span class="name">$entry.name</span><br/>
<a href="$entry.name"><img src="$entry.name?size=$thmb" border="0" width="$dim.width" height="$dim.height"/></a><br/>
<a href="${entry.name}.photo"><img src="$entry.name?size=$thmb" border="0" width="$dim.width" height="$dim.height"/></a><br/>
<span class="caption">$!entry.caption</span>
</div>
#end

View file

@ -0,0 +1,46 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width = 600" />
<title>$entry.name</title>
<style type="text/css">
body {
font-size: 11px;
font-family: "Lucida Grande", Arial, sans-serif;
color: #6d6d6d;
background: #acc95f;
margin: 10px auto;
text-align: center;
}
a:link, a:visited {
text-decoration: none;
color: #4c4c4c;
font-weight: 700;
}
a:hover, a:focus {
text-decoration: underline;
color: #6a6a6a;
}
div.photo {
align: center;
height: 200px;
}
img {
padding: 5px;
}
</style>
</head>
<body>
#set($thmb = 480)
#set($dim = $entry.size.scaled($thmb))
<div class="photo">
<span class="name">$entry.name</span><br/>
<a href="$entry.name"><img src="$entry.name?size=$thmb" border="0" width="$dim.width" height="$dim.height"/></a><br/>
<span class="caption">$!entry.caption</span>
</div>
</body>
</html>