1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

display photo

This commit is contained in:
lxsang 2021-01-05 19:12:35 +00:00
parent 9eb6d62d7d
commit 87169dd41f
6 changed files with 74 additions and 32 deletions

View File

@ -53,7 +53,8 @@ end
function IndexController:pdf(...) function IndexController:pdf(...)
local tmp_file = WWW_ROOT.."/cv_exported.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) local r = os.execute(cmd)
if r then if r then
local mime = std.mimeOf(tmp_file) local mime = std.mimeOf(tmp_file)

View File

@ -15,3 +15,25 @@ function UserController:index(...)
self.template:set("data", data[1]) self.template:set("data", data[1])
return true return true
end 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

View File

@ -67,7 +67,7 @@ function NotfoundController:index(...)
self:error("404: Controller "..args[1].." not found : "..args[2]) self:error("404: Controller "..args[1].." not found : "..args[2])
return return
end end
REQUEST.r = "index/"..std.trim(REQUEST.r:gsub(user, ""), "/") REQUEST.r = std.trim(REQUEST.r:gsub(user, ""), "/")
if REGISTRY.db then REGISTRY.db:close() end if REGISTRY.db then REGISTRY.db:close() end
REGISTRY.user = user REGISTRY.user = user
REGISTRY.db = DBHelper:new{db=REGISTRY.user} REGISTRY.db = DBHelper:new{db=REGISTRY.user}

View File

@ -31,7 +31,7 @@
} }
.layout div.container{ .layout div.container{
display: none; display: block;
} }
.layout div.container_active{ .layout div.container_active{
display: block; display: block;
@ -170,3 +170,15 @@ hr{
padding: 0; padding: 0;
} }
img {max-width:100%} img {max-width:100%}
.header_container {
display: block;
width: 100%;
}
.header_container img {
float: left;
max-width: 150px;
margin-right: 10px;
margin-bottom: 20px;
display: block;
}

View File

@ -8,7 +8,8 @@
local active = "toc_active" local active = "toc_active"
for k, v in pairs(data) do for k, v in pairs(data) do
?> ?>
<li class="<?=active?>"><a href=<?='"#toc'..v[2]..'"'?> onclick='switchTab("toc<?=v[2]?>", this)' ><?=v[1]?></a></li> <!--onclick='switchTab("toc<?=v[2]?>", this)'-->
<li class="<?=active?>"><a href=<?='"#toc'..v[2]..'"'?> ><?=v[1]?></a></li>
<?lua <?lua
active = '' active = ''
end end

View File

@ -1,27 +1,33 @@
<h1> <div class="header_container">
<span class="name"><?=data.fullname?></span> <?lua if data.photo and data.photo ~= "" then ?>
<span class="cv">Curriculum Vitae</span> <img src="/<?=data.user?>/user/photo"></img>
</h1> <?lua end ?>
<p class="coordination"> <h1>
<span class="fa fa-home"></span><?=data.address?></p> <span class="name"><?=data.fullname?></span>
<p class="coordination"> <span class="cv">Curriculum Vitae</span>
<span class="fa fa-phone"></span> </h1>
<span class="text"><?=data.Phone?></span> <p class="coordination">
<span class="fa fa-envelope-o"></span> <span class="fa fa-home"></span><?=data.address?></p>
<span class="text"><?=data.email?></span> <p class="coordination">
<span class="fa fa-globe"></span> <span class="fa fa-phone"></span>
<span class="text"><a href ="<?=data.url?>"><?=data.url?></a></span> <span class="text"><?=data.Phone?></span>
<?lua <span class="fa fa-envelope-o"></span>
if not preview then <span class="text"><?=data.email?></span>
?> <br/>
<span class="fa fa-file-pdf-o"></span> <span class="fa fa-globe"></span>
<span class="text"><a href ="<?=HTTP_ROOT?>/<?=data.user?>/pdf" target="_blank">Download</a></span> <span class="text"><a href ="<?=data.url?>"><?=data.url?></a></span>
<?lua <?lua
end if not preview then
?> ?>
</p> <span class="fa fa-file-pdf-o"></span>
<p class="shortbio"> <span class="text"><a href ="<?=HTTP_ROOT?>/<?=data.user?>/index/pdf" target="_blank">Download</a></span>
<span class="fa fa-quote-left"></span> <?lua
<span><?=data.shortbiblio?></span> end
<span class="fa fa-quote-right"></span> ?>
</p> </p>
<p class="shortbio">
<span class="fa fa-quote-left"></span>
<span><?=data.shortbiblio?></span>
<span class="fa fa-quote-right"></span>
</p>
</div>