liquid_feedback_frontend
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/index/document.lua Wed Mar 07 19:07:20 2012 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +if not config.document_dir then 1.5 + error("feature not enabled") 1.6 +end 1.7 + 1.8 +slot.put_into("title", _"Download documents") 1.9 + 1.10 +slot.select("actions", function() 1.11 + ui.link{ 1.12 + content = function() 1.13 + ui.image{ static = "icons/16/cancel.png" } 1.14 + slot.put(_"Cancel") 1.15 + end, 1.16 + module = "index", 1.17 + view = "index" 1.18 + } 1.19 +end) 1.20 + 1.21 +util.help("index.document", _"Download documents") 1.22 + 1.23 +local file_list = os.listdir(config.document_dir) 1.24 + 1.25 +local tmp = {} 1.26 +for i, filename in ipairs(file_list) do 1.27 + if not filename:find("^%.") then 1.28 + tmp[#tmp+1] = filename 1.29 + end 1.30 +end 1.31 + 1.32 +local file_list = tmp 1.33 + 1.34 +table.sort(file_list, function(a, b) return a > b end) 1.35 + 1.36 +ui.list{ 1.37 + records = file_list, 1.38 + columns = { 1.39 + { 1.40 + content = function(filename) 1.41 + slot.put(encode.html(filename)) 1.42 + end 1.43 + }, 1.44 + { 1.45 + content = function(filename) 1.46 + ui.link{ 1.47 + content = _"Download", 1.48 + module = "index", 1.49 + view = "document_file", 1.50 + params = { filename = filename } 1.51 + } 1.52 + end 1.53 + } 1.54 + } 1.55 +} 1.56 \ No newline at end of file