liquid_feedback_frontend
view app/main/index/document.lua @ 401:08ba83dd47c0
Add support for files only available to logged in members
| author | bsw | 
|---|---|
| date | Wed Mar 07 19:07:20 2012 +0100 (2012-03-07) | 
| parents | |
| children | a42bc1f0ed45 | 
 line source
     1 if not config.document_dir then
     2   error("feature not enabled")
     3 end
     5 slot.put_into("title", _"Download documents")
     7 slot.select("actions", function()
     8   ui.link{
     9     content = function()
    10         ui.image{ static = "icons/16/cancel.png" }
    11         slot.put(_"Cancel")
    12     end,
    13     module = "index",
    14     view = "index"
    15   }
    16 end)
    18 util.help("index.document", _"Download documents")
    20 local file_list = os.listdir(config.document_dir)
    22 local tmp = {}
    23 for i, filename in ipairs(file_list) do
    24   if not filename:find("^%.") then
    25     tmp[#tmp+1] = filename
    26   end
    27 end
    29 local file_list = tmp
    31 table.sort(file_list, function(a, b) return a > b end)
    33 ui.list{
    34   records = file_list,
    35   columns = {
    36     {
    37       content = function(filename)
    38         slot.put(encode.html(filename))
    39       end
    40     },
    41     {
    42       content = function(filename)
    43         ui.link{
    44           content = _"Download",
    45           module = "index",
    46           view = "document_file",
    47           params = { filename = filename }
    48         }
    49       end
    50     }
    51   }
    52 }
