mirror of
https://github.com/lxsang/antd-web-apps
synced 2025-07-23 17:19:47 +02:00
display photo
This commit is contained in:
@ -53,7 +53,8 @@ end
|
||||
|
||||
function IndexController:pdf(...)
|
||||
local tmp_file = WWW_ROOT.."/cv_exported.pdf"
|
||||
local cmd = "wkhtmltopdf "..HTTP_ROOT.."/"..self.registry.user.."/notoc "..tmp_file
|
||||
local cmd = "wkhtmltopdf "..HTTP_ROOT.."/"..self.registry.user.."/index/notoc "..tmp_file
|
||||
print(cmd)
|
||||
local r = os.execute(cmd)
|
||||
if r then
|
||||
local mime = std.mimeOf(tmp_file)
|
||||
|
@ -15,3 +15,25 @@ function UserController:index(...)
|
||||
self.template:set("data", data[1])
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function UserController:photo(...)
|
||||
local data = self.user:findAll()
|
||||
if not data or not data[1] then
|
||||
self:error("Cannot fetch user info")
|
||||
end
|
||||
if(not data[1] or data[1].photo == "") then
|
||||
self:error("User photo is not available")
|
||||
end
|
||||
local prefix = data[1].photo:match("%a+://")
|
||||
local suffix = data[1].photo:gsub(prefix,"")
|
||||
local path = string.format("/home/%s/", self.registry.user)..suffix
|
||||
print(path)
|
||||
if ulib.exists(path) then
|
||||
local mime = std.mimeOf(path)
|
||||
std.sendFile(path)
|
||||
else
|
||||
self:error("Asset file not found or access forbidden: "..path)
|
||||
end
|
||||
return false
|
||||
end
|
Reference in New Issue
Block a user