Changeset 7f6b37b1018478196ac4f7ae35c49848ada4883e

Show
Ignore:
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
  • share/lua/intf/http.lua

    r43055c9 r7f6b37b  
    2525Configuration options: 
    2626 * 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. 
    2828 * no_error_detail: If set, do not print the Lua error message when generating 
    2929                    a page fails. 
     
    7070end 
    7171function 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 
    7473    local func = false -- process_raw(filename) 
    7574    return function(...) 
     
    7776        if new_mtime ~= mtime then 
    7877            -- 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 
    8083            func = process_raw(filename) 
    8184            mtime = new_mtime 
     
    102105end 
    103106 
    104 function dirlisting(url,listing
     107function dirlisting(url,listing,acl_
    105108    local list = {} 
    106109    for _,f in ipairs(listing) do 
     
    120123</html>]] 
    121124    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) 
    123126end 
    124127 
     
    154157function rawfile(h,path,url,acl_) 
    155158    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 
    158160    local page = false -- io.open(filename):read("*a") 
    159161    local callback = function(data,request) 
     
    161163        if mtime ~= new_mtime then 
    162164            -- 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 
    164170            page = io.open(filename):read("*a") 
    165171            mtime = new_mtime 
     
    222228    xml = "text/xml", 
    223229    js = "text/javascript", 
     230    css = "text/css", 
    224231    png = "image/png", 
    225232    ico = "image/x-icon", 
     
    228235    local root = root or "/" 
    229236    local has_index = false 
    230     if string.match(dir,"/old") then 
    231         return 
    232     end 
    233237    local my_acl = parent_acl 
    234238    do 
     
    262266                end 
    263267            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) 
    268269            end 
    269270        end