Changeset 7f6b37b1018478196ac4f7ae35c49848ada4883e
- Timestamp:
- 04/07/08 22:15:16
(3 months ago)
- Author:
- Antoine Cellerier <dionoea@videolan.org>
- git-committer:
- Antoine Cellerier <dionoea@videolan.org> 1207599316 +0200
- git-parent:
[f809a7d04e7bdbdcedd2b9576410c3282116ed2e]
- git-author:
- Antoine Cellerier <dionoea@videolan.org> 1207599180 +0200
- Message:
Misc changes to Lua HTTP interface: spelling, Load/Reload debug message now reflects real behavior, enforce .hosts files for directory listings, accept Lua code in CSS files too, remove useless "/old" exclusion.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r43055c9 |
r7f6b37b |
|
| 25 | 25 | Configuration options: |
|---|
| 26 | 26 | * host: A host to listen on. |
|---|
| 27 | | * dir: Directory to use a the http interface's root. |
|---|
| | 27 | * dir: Directory to use as the http interface's root. |
|---|
| 28 | 28 | * no_error_detail: If set, do not print the Lua error message when generating |
|---|
| 29 | 29 | a page fails. |
|---|
| … | … | |
| 70 | 70 | end |
|---|
| 71 | 71 | function process(filename) |
|---|
| 72 | | vlc.msg.dbg("Loading `"..filename.."'") |
|---|
| 73 | | local mtime = 0 -- vlc.fd.stat(filename).modification_time |
|---|
| | 72 | local mtime = 0 -- vlc.fd.stat(filename).modification_time |
|---|
| 74 | 73 | local func = false -- process_raw(filename) |
|---|
| 75 | 74 | return function(...) |
|---|
| … | … | |
| 77 | 76 | if new_mtime ~= mtime then |
|---|
| 78 | 77 | -- Re-read the file if it changed |
|---|
| 79 | | vlc.msg.dbg("Reloading `"..filename.."'") |
|---|
| | 78 | if mtime == 0 then |
|---|
| | 79 | vlc.msg.dbg("Loading `"..filename.."'") |
|---|
| | 80 | else |
|---|
| | 81 | vlc.msg.dbg("Reloading `"..filename.."'") |
|---|
| | 82 | end |
|---|
| 80 | 83 | func = process_raw(filename) |
|---|
| 81 | 84 | mtime = new_mtime |
|---|
| … | … | |
| 102 | 105 | end |
|---|
| 103 | 106 | |
|---|
| 104 | | function dirlisting(url,listing) |
|---|
| | 107 | function dirlisting(url,listing,acl_) |
|---|
| 105 | 108 | local list = {} |
|---|
| 106 | 109 | for _,f in ipairs(listing) do |
|---|
| … | … | |
| 120 | 123 | </html>]] |
|---|
| 121 | 124 | end |
|---|
| 122 | | return h:file_new(url,"text/html",nil,nil,nil,callback,nil) |
|---|
| | 125 | return h:file_new(url,"text/html",nil,nil,acl_,callback,nil) |
|---|
| 123 | 126 | end |
|---|
| 124 | 127 | |
|---|
| … | … | |
| 154 | 157 | function rawfile(h,path,url,acl_) |
|---|
| 155 | 158 | local filename = path |
|---|
| 156 | | vlc.msg.dbg("Loading `"..filename.."'") |
|---|
| 157 | | local mtime = 0 -- vlc.fd.stat(filename).modification_time |
|---|
| | 159 | local mtime = 0 -- vlc.fd.stat(filename).modification_time |
|---|
| 158 | 160 | local page = false -- io.open(filename):read("*a") |
|---|
| 159 | 161 | local callback = function(data,request) |
|---|
| … | … | |
| 161 | 163 | if mtime ~= new_mtime then |
|---|
| 162 | 164 | -- Re-read the file if it changed |
|---|
| 163 | | vlc.msg.dbg("Reloading `"..filename.."'") |
|---|
| | 165 | if mtime == 0 then |
|---|
| | 166 | vlc.msg.dbg("Loading `"..filename.."'") |
|---|
| | 167 | else |
|---|
| | 168 | vlc.msg.dbg("Reloading `"..filename.."'") |
|---|
| | 169 | end |
|---|
| 164 | 170 | page = io.open(filename):read("*a") |
|---|
| 165 | 171 | mtime = new_mtime |
|---|
| … | … | |
| 222 | 228 | xml = "text/xml", |
|---|
| 223 | 229 | js = "text/javascript", |
|---|
| | 230 | css = "text/css", |
|---|
| 224 | 231 | png = "image/png", |
|---|
| 225 | 232 | ico = "image/x-icon", |
|---|
| … | … | |
| 228 | 235 | local root = root or "/" |
|---|
| 229 | 236 | local has_index = false |
|---|
| 230 | | if string.match(dir,"/old") then |
|---|
| 231 | | return |
|---|
| 232 | | end |
|---|
| 233 | 237 | local my_acl = parent_acl |
|---|
| 234 | 238 | do |
|---|
| … | … | |
| 262 | 266 | end |
|---|
| 263 | 267 | elseif s.type == "dir" then |
|---|
| 264 | | if f == "dialogs" then -- FIXME |
|---|
| 265 | | else |
|---|
| 266 | | load_dir(dir.."/"..f,root..f.."/",my_acl) |
|---|
| 267 | | end |
|---|
| | 268 | load_dir(dir.."/"..f,root..f.."/",my_acl) |
|---|
| 268 | 269 | end |
|---|
| 269 | 270 | end |
|---|