Integrate static rendering.

This commit is contained in:
Jason A. Donenfeld 2011-05-09 07:32:30 -04:00
parent a57aa30957
commit 3471f848e6
6 changed files with 21 additions and 10 deletions

View File

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

View File

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

View File

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

View File

@ -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");
?>
?>

4
web/staticrender.php Normal file
View File

@ -0,0 +1,4 @@
<?php
putenv('LANG=en_US.UTF-8');
passthru("utils/serverexecute ".escapeshellarg($_ENV["SCRIPT_URI"]."#!".$_GET["_escaped_fragment_"]));
?>

View File

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