--[==========================================================================[
Configuration options:
* host: A host to listen on.
- * dir: Directory to use a the http interface's root.
+ * dir: Directory to use as the http interface's root.
* no_error_detail: If set, do not print the Lua error message when generating
a page fails.
* no_index: If set, don't build directory indexes
return assert(loadstring(code,filename))
end
function process(filename)
- vlc.msg.dbg("Loading `"..filename.."'")
- local mtime = 0 -- vlc.fd.stat(filename).modification_time
+ local mtime = 0 -- vlc.fd.stat(filename).modification_time
local func = false -- process_raw(filename)
return function(...)
local new_mtime = vlc.fd.stat(filename).modification_time
if new_mtime ~= mtime then
-- Re-read the file if it changed
- vlc.msg.dbg("Reloading `"..filename.."'")
+ if mtime == 0 then
+ vlc.msg.dbg("Loading `"..filename.."'")
+ else
+ vlc.msg.dbg("Reloading `"..filename.."'")
+ end
func = process_raw(filename)
mtime = new_mtime
end
</html>]]
end
-function dirlisting(url,listing)
+function dirlisting(url,listing,acl_)
local list = {}
for _,f in ipairs(listing) do
if not string.match(f,"^%.") then
</body>
</html>]]
end
- return h:file_new(url,"text/html",nil,nil,nil,callback,nil)
+ return h:file_new(url,"text/html",nil,nil,acl_,callback,nil)
end
function file(h,path,url,acl_,mime)
function rawfile(h,path,url,acl_)
local filename = path
- vlc.msg.dbg("Loading `"..filename.."'")
- local mtime = 0 -- vlc.fd.stat(filename).modification_time
+ local mtime = 0 -- vlc.fd.stat(filename).modification_time
local page = false -- io.open(filename):read("*a")
local callback = function(data,request)
local new_mtime = vlc.fd.stat(filename).modification_time
if mtime ~= new_mtime then
-- Re-read the file if it changed
- vlc.msg.dbg("Reloading `"..filename.."'")
+ if mtime == 0 then
+ vlc.msg.dbg("Loading `"..filename.."'")
+ else
+ vlc.msg.dbg("Reloading `"..filename.."'")
+ end
page = io.open(filename):read("*a")
mtime = new_mtime
end
html = "text/html",
xml = "text/xml",
js = "text/javascript",
+ css = "text/css",
png = "image/png",
ico = "image/x-icon",
}
local function load_dir(dir,root,parent_acl)
local root = root or "/"
local has_index = false
- if string.match(dir,"/old") then
- return
- end
local my_acl = parent_acl
do
local af = dir.."/.hosts"
table.insert(files,rawfile(h,dir.."/"..f,url,my_acl and my_acl.private))
end
elseif s.type == "dir" then
- if f == "dialogs" then -- FIXME
- else
- load_dir(dir.."/"..f,root..f.."/",my_acl)
- end
+ load_dir(dir.."/"..f,root..f.."/",my_acl)
end
end
end