# HG changeset patch # User bsw # Date 1331145052 -3600 # Node ID a42bc1f0ed453c1f5c916bf7c4deea7f5da8d336 # Parent 08ba83dd47c0e44d7e010814d4037b67af678487 Support to show documents inline instead of downloading diff -r 08ba83dd47c0 -r a42bc1f0ed45 app/main/index/document.lua --- a/app/main/index/document.lua Wed Mar 07 19:07:20 2012 +0100 +++ b/app/main/index/document.lua Wed Mar 07 19:30:52 2012 +0100 @@ -46,6 +46,13 @@ view = "document_file", params = { filename = filename } } + slot.put(" ") + ui.link{ + content = _"Show", + module = "index", + view = "document_file", + params = { filename = filename, inline = true } + } end } } diff -r 08ba83dd47c0 -r a42bc1f0ed45 app/main/index/document_file.lua --- a/app/main/index/document_file.lua Wed Mar 07 19:07:20 2012 +0100 +++ b/app/main/index/document_file.lua Wed Mar 07 19:30:52 2012 +0100 @@ -6,8 +6,11 @@ local file = assert(io.open(encode.file_path(config.document_dir, filename)), "file not found") -print('Content-type: application/octet-stream') -print('Content-disposition: attachment; filename=' .. filename) +if param.get("inline") then + print('Content-disposition: inline; filename=' .. filename) +else + print('Content-disposition: attachment; filename=' .. filename) +end print('') io.stdout:write(file:read("*a"))