summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2011-05-09 07:32:30 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2011-05-09 07:32:30 -0400
commit3471f848e6cbdbbd24e2e6552e3f3c6b9398811a (patch)
tree765c78c277ca2e1baa26e9254cbdf12a502e337d
parentAdd server executer based on htmlunit. (diff)
downloadPhotoFloat-3471f848e6cbdbbd24e2e6552e3f3c6b9398811a.tar.xz
PhotoFloat-3471f848e6cbdbbd24e2e6552e3f3c6b9398811a.zip
Integrate static rendering.
-rw-r--r--web/.htaccess2
-rw-r--r--web/index.html1
-rw-r--r--web/js/010-control.js14
-rw-r--r--web/redirect.php8
-rw-r--r--web/staticrender.php4
-rwxr-xr-xweb/utils/serverexecute2
6 files changed, 21 insertions, 10 deletions
diff --git a/web/.htaccess b/web/.htaccess
index f86bccb..8deaafe 100644
--- a/web/.htaccess
+++ b/web/.htaccess
@@ -20,6 +20,8 @@ AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css a
RewriteEngine On
RewriteBase /
RewriteRule ^redirect\.php$ - [L]
+RewriteCond %{QUERY_STRING} _escaped_fragment_=
+RewriteRule . staticrender.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /redirect.php [L]
diff --git a/web/index.html b/web/index.html
index 38267a0..e9b0b9a 100644
--- a/web/index.html
+++ b/web/index.html
@@ -3,6 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
+ <meta name="fragment" content="!" />
<title>JasonDonenfeld.com &#8211; Photos</title>
<link href="css/styles.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/scripts.min.js"></script>
diff --git a/web/js/010-control.js b/web/js/010-control.js
index d064313..4e481d7 100644
--- a/web/js/010-control.js
+++ b/web/js/010-control.js
@@ -79,7 +79,7 @@ $(document).ready(function() {
if (i)
last += "/" + components[i];
if (i < components.length - 1 || current_photo_cache != null)
- title += "<a href=\"#" + (i == 0 ? "" : cachePath(last.substring(1))) + "\">";
+ title += "<a href=\"#!/" + (i == 0 ? "" : cachePath(last.substring(1))) + "\">";
title += components[i];
if (i < components.length - 1 || current_photo_cache != null) {
title += "</a>";
@@ -97,7 +97,7 @@ $(document).ready(function() {
if (populate) {
var photos = "";
for (var i = 0; i < current_album.photos.length; ++i)
- photos += "<a href=\"#" + current_album_cache + "/" + cachePath(current_album.photos[i].name) + "\"><img title=\"" + trimExtension(current_album.photos[i].name) + "\" alt=\"" + trimExtension(current_album.photos[i].name) + "\" id=\"thumb-" + cachePath(current_album.photos[i].name) + "\" src=\"" + imagePath(current_album.photos[i].name, current_album.path, 150, true) + "\" height=\"150\" width=\"150\"></a>";
+ photos += "<a href=\"#!/" + current_album_cache + "/" + cachePath(current_album.photos[i].name) + "\"><img title=\"" + trimExtension(current_album.photos[i].name) + "\" alt=\"" + trimExtension(current_album.photos[i].name) + "\" id=\"thumb-" + cachePath(current_album.photos[i].name) + "\" src=\"" + imagePath(current_album.photos[i].name, current_album.path, 150, true) + "\" height=\"150\" width=\"150\"></a>";
$("#thumbs").html(photos);
var subalbums = "";
@@ -105,7 +105,7 @@ $(document).ready(function() {
for (var i = current_album.albums.length - 1; i >= 0; --i) {
var path = cachePath(current_album.path + "/" + current_album.albums[i].path);
var id = "album-" + path;
- subalbums += "<a href=\"#" + path + "\"><div title=\"" + current_album.albums[i].date + "\" id=\"" + id + "\" class=\"album-button\">" + current_album.albums[i].path + "</div></a>";
+ subalbums += "<a href=\"#!/" + path + "\"><div title=\"" + current_album.albums[i].date + "\" id=\"" + id + "\" class=\"album-button\">" + current_album.albums[i].path + "</div></a>";
thumbFinderList.push({ path: path, id: escapeId(id) });
}
$("#subalbums").html(subalbums);
@@ -172,10 +172,10 @@ $(document).ready(function() {
];
$.preloadImages(imagePath(nextPhoto.name, current_album.path, maxSize, false), imagePath(previousPhoto.name, current_album.path, maxSize, false));
- var nextLink = "#" + current_album_cache + "/" + cachePath(nextPhoto.name);
+ var nextLink = "#!/" + current_album_cache + "/" + cachePath(nextPhoto.name);
$("#next-photo").attr("href", nextLink);
$("#next").attr("href", nextLink);
- $("#back").attr("href", "#" + current_album_cache + "/" + cachePath(previousPhoto.name));
+ $("#back").attr("href", "#!/" + current_album_cache + "/" + cachePath(previousPhoto.name));
$("#original-link").attr("target", "_blank").attr("href", "albums/" + current_album.path + "/" + current_photo.name);
var text = "<table>";
@@ -273,6 +273,10 @@ $(document).ready(function() {
var album_cache = new Array();
$(window).hashchange(function() {
var new_album_cache = location.hash.substring(1);
+ if (new_album_cache.length && new_album_cache[0] == "!")
+ new_album_cache = new_album_cache.substring(1);
+ if (new_album_cache.length && new_album_cache[0] == "/")
+ new_album_cache = new_album_cache.substring(1);
var index = new_album_cache.lastIndexOf("/");
if (index != -1 && index != new_album_cache.length - 1) {
previous_photo_cache = current_photo_cache;
diff --git a/web/redirect.php b/web/redirect.php
index 83b6fcc..ddcd2c9 100644
--- a/web/redirect.php
+++ b/web/redirect.php
@@ -22,17 +22,17 @@ if ($url[strlen($url) - 1] == '/')
if (strpos(strtolower($url), ".php") == strlen($url) - 4) {
$url = substr($url, 0, strlen($url) - 4);
$index = strrpos($url, "/");
- $redirect = "/#".cachePath(substr($url, 0, $index))."/".cachePath(substr($url, $index));
+ $redirect = "/#!/".cachePath(substr($url, 0, $index))."/".cachePath(substr($url, $index));
} else if (strpos(strtolower($url), ".jpg") == strlen($url) - 4) {
$index = strrpos($url, "/");
- $redirect = "/#".cachePath(substr($url, 0, $index))."/".cachePath(substr($url, $index));
+ $redirect = "/#!/".cachePath(substr($url, 0, $index))."/".cachePath(substr($url, $index));
} else if (strpos($url, "/cache/") === 0 || strpos($url, "/albums/") === 0 || strpos($url, "/img/") === 0 || strpos($url, "/img/") === 0 || strpos($url, "/js/") === 0 || strpos($url, "/css/") === 0) {
header("HTTP/1.1 404 Not Found");
exit();
} else
- $redirect = "/#".cachePath($url);
+ $redirect = "/#!/".cachePath($url);
header("HTTP/1.1 301 Moved Permanently");
header("Location: $redirect");
-?> \ No newline at end of file
+?>
diff --git a/web/staticrender.php b/web/staticrender.php
new file mode 100644
index 0000000..8994662
--- /dev/null
+++ b/web/staticrender.php
@@ -0,0 +1,4 @@
+<?php
+putenv('LANG=en_US.UTF-8');
+passthru("utils/serverexecute ".escapeshellarg($_ENV["SCRIPT_URI"]."#!".$_GET["_escaped_fragment_"]));
+?>
diff --git a/web/utils/serverexecute b/web/utils/serverexecute
index af4fa68..97a7e65 100755
--- a/web/utils/serverexecute
+++ b/web/utils/serverexecute
@@ -1,3 +1,3 @@
#!/bin/sh
cd $(dirname $0)
-java -classpath $(for i in htmlunit-2.8/*; do echo $i; done|tr '\n' ':') ServerExecute $@
+java -Xmx128m -classpath $(for i in htmlunit-2.8/*; do echo $i; done|tr '\n' ':') ServerExecute $@