From 3471f848e6cbdbbd24e2e6552e3f3c6b9398811a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 9 May 2011 07:32:30 -0400 Subject: [PATCH] Integrate static rendering. --- web/.htaccess | 2 ++ web/index.html | 1 + web/js/010-control.js | 14 +++++++++----- web/redirect.php | 8 ++++---- web/staticrender.php | 4 ++++ web/utils/serverexecute | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 web/staticrender.php 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 @@ + JasonDonenfeld.com – Photos 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 += ""; + title += ""; title += components[i]; if (i < components.length - 1 || current_photo_cache != null) { title += ""; @@ -97,7 +97,7 @@ $(document).ready(function() { if (populate) { var photos = ""; for (var i = 0; i < current_album.photos.length; ++i) - photos += "\"""; + photos += "\"""; $("#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 += "
" + current_album.albums[i].path + "
"; + subalbums += "
" + current_album.albums[i].path + "
"; 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 = ""; @@ -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 @@ + 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 $@