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

121 lines
5.4 KiB
Plaintext
Raw Normal View History

2018-02-21 22:42:19 +01:00
<?lua
std.html()
local user = "mrsang"
local die = function(m)
echo(m)
debug.traceback=nil
error("Permission denied")
end
2018-02-25 13:54:37 +01:00
local mobilecls = ""
if HEADER.mobile then mobilecls = "mobile" end
2018-02-21 22:42:19 +01:00
local db = require("db.model").get(user,"user",nil)
if db == nil then die("cannot get db data") end
local data, a = db:getAll()
db:close()
if data == nil or data[0] == nil then die("Cannot fetch user info") end
data = data[0]
?>
2018-02-21 19:04:26 +01:00
<!DOCTYPE html>
<html lang="en">
<head>
2018-02-22 20:46:56 +01:00
<title>Hi, I'm Xuan Sang LE</title>
2018-02-21 19:04:26 +01:00
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="grs/ubuntu-regular.css" />
<link rel="stylesheet" type="text/css" href="grs/font-awesome.css" />
<link rel="stylesheet" type="text/css" href="grs/mainsite.css" />
2018-02-22 15:47:09 +01:00
<script src="grs/gscripts/jquery-3.2.1.min.js"> </script>
<script src="grs/resources/antos_tags.js" type="riot/tag"></script>
<script src="grs/gscripts/riot.compiler.min.js"> </script>
<script>
var scheme = undefined;
function mailtoMe()
{
if(scheme) return;
// get scheme
$.get( "grs/sendto.html")
.done(function(d) {
scheme = $.parseHTML(d)
2018-02-22 21:12:40 +01:00
var obs = riot.observable()
$(scheme).css("visibility","hidden")
2018-02-22 15:47:09 +01:00
$("#desktop").append(scheme)
2018-02-22 19:15:03 +01:00
obs.on("exit", function(){
2018-02-22 15:47:09 +01:00
$(scheme).remove()
scheme = undefined
})
2018-02-22 19:15:03 +01:00
obs.on("rendered", function(d){
$("[data-id='send']", scheme).click(function(){
var status = $("[data-id='status']", scheme)
status.html("");
var els = $("[data-class='data']", scheme)
2018-02-22 15:47:09 +01:00
var data = {}
for(var i = 0; i < els.length; i++)
data[els[i].name] = $(els[i]).val()
if(data.email == "" || data.subject == "" || data.content == "" || data.name == "")
2018-02-22 19:15:03 +01:00
return status.html("Please enter all the fields");
2018-02-22 15:47:09 +01:00
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if(!re.test(String(data.email).toLowerCase()))
2018-02-22 19:15:03 +01:00
return status.html("Email is not correct");
2018-02-22 15:47:09 +01:00
$.ajax({
type: 'POST',
url: "info/sendmail.lua",
contentType: 'application/json',
data: JSON.stringify(data),
dataType: 'json',
success: null
}).done(function(r){
if(r.error)
alert(r.error)
else
2018-02-22 15:48:14 +01:00
{
2018-02-22 19:15:03 +01:00
obs.trigger("exit")
alert("Email sent. Thank")
2018-02-22 15:48:14 +01:00
}
2018-02-22 15:47:09 +01:00
}).fail(function(){
alert("Service unavailable at the moment")
})
})
2018-02-22 21:12:40 +01:00
$(scheme).css("visibility","visible")
2018-02-22 15:47:09 +01:00
})
2018-02-22 19:15:03 +01:00
riot.mount(scheme, {observable:obs})
2018-02-22 15:47:09 +01:00
})
.fail(function() {
alert( "Cannot get the form" );
})
}
</script>
2018-02-21 19:04:26 +01:00
</head>
<body>
2018-02-22 15:47:09 +01:00
<div id = "desktop">
2018-02-21 19:04:26 +01:00
<div id = "top">
<ul>
2018-02-26 13:17:46 +01:00
<li ><i class = "fa fa-address-card"></i><a href="https://info.lxsang.me" >Porfolio</a></li>
<li><i class = "fa fa-newspaper-o"></i><a href="https://blog.lxsang.me" >Blog</a></li>
2018-02-22 15:47:09 +01:00
<li><i class = "fa fa-paper-plane"></i><a href="#" onclick="mailtoMe()" >Contact</a></li>
2018-02-21 19:04:26 +01:00
<li > <i class = "fa fa-globe"></i><a href = "https://os.lxsang.me" target="_blank">Web OS</a></li>
</ul>
</div>
<div id = "center">
2018-02-25 13:54:37 +01:00
<div id = "container" class="<?=mobilecls?>" >
2018-02-21 19:04:26 +01:00
<img src = "grs/images/mrsang.png" ></img>
<div id = "vcard">
<p class = "greeting">Hi, I'm <b>Xuan Sang LE</b></p>
<p class = "dedicate">
<span class="fa fa-quote-left"></span>
<span>
2018-02-21 22:42:19 +01:00
<?=data.shortbiblio?>
2018-02-21 19:04:26 +01:00
</span>
<span class="fa fa-quote-right"></span>
</p>
2018-02-26 13:17:46 +01:00
<a href="https://info.lxsang.me" class ="about">Find out more about me</a>
2018-02-21 19:04:26 +01:00
</div>
</div>
</div>
<div id = "bottom">
2018-02-22 15:47:09 +01:00
Powered by antd server, (c) 2017 - 2018 Xuan Sang LE
2018-02-21 19:04:26 +01:00
</div>
</div>
</body>
</html>