[Logilogi-svn] SF.net SVN: logilogi:[1582] projects/loglog/trunk/public/cache.lua
Status: Beta
Brought to you by:
wybow
|
From: <wy...@us...> - 2009-09-08 15:10:27
|
Revision: 1582
http://logilogi.svn.sourceforge.net/logilogi/?rev=1582&view=rev
Author: wybow
Date: 2009-09-08 15:10:19 +0000 (Tue, 08 Sep 2009)
Log Message:
-----------
Added lua script
Added Paths:
-----------
projects/loglog/trunk/public/cache.lua
Added: projects/loglog/trunk/public/cache.lua
===================================================================
--- projects/loglog/trunk/public/cache.lua (rev 0)
+++ projects/loglog/trunk/public/cache.lua 2009-09-08 15:10:19 UTC (rev 1582)
@@ -0,0 +1,25 @@
+-- Common function, used for setting headers and sending content
+function set_for_send (postfix, header_table)
+ file = lighty.env["physical.doc-root"] .. lighty.env["request.uri"] .. postfix
+ if lighty.stat(file) then
+ for k,v in pairs(header_table) do lighty.header[k] = v end
+ lighty.content = { { filename = file } }
+ return 200
+ else
+ return lighty.RESTART_REQUEST
+ end
+end
+
+-- Look for cached index.html
+if ( lighty.env["request.uri"] == nil or lighty.env["request.uri"] == "/") then
+ return set_for_send("/index.html", {["Content-Type"] = "text/html"})
+-- Llcorners pngs, use inline disposition
+elseif ( string.find(lighty.env["request.uri"], ".*\.png$") ) then
+ return set_for_send("", {["Content-Type"] = "image/png", ["Content-Disposition"] = "inline"})
+-- Atom feeds
+elseif ( string.find(lighty.env["request.uri"], ".*\.atom$") ) then
+ return set_for_send("", {["Content-Type"] = "application/atom+xml"})
+-- Misc html pages
+else
+ return set_for_send(".html", {["Content-Type"] = "text/html"})
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|