mirror of
https://github.com/YunoHost/SSOwat.git
synced 2024-09-03 20:06:27 +02:00
Add YunoHost panel
This commit is contained in:
parent
098923c980
commit
418ae04571
4 changed files with 153 additions and 9 deletions
17
access.lua
17
access.lua
|
@ -130,12 +130,7 @@ end
|
|||
|
||||
function set_headers (user)
|
||||
user = user or ngx.var.cookie_SSOwAuthUser
|
||||
if not cache[user] then
|
||||
flash("info", "Please log in to access to this content")
|
||||
local back_url = ngx.var.scheme .. "://" .. ngx.var.http_host .. ngx.var.uri
|
||||
return redirect(portal_url.."?r="..ngx.encode_base64(back_url))
|
||||
end
|
||||
if not cache[user]["mail"] then
|
||||
if not cache[user] or not cache[user]["mail"] then
|
||||
ldap = lualdap.open_simple("localhost")
|
||||
for dn, attribs in ldap:search {
|
||||
base = "uid=".. user ..",ou=users,dc=yunohost,dc=org",
|
||||
|
@ -199,7 +194,7 @@ function serve(uri)
|
|||
-- Load login.html as index
|
||||
if rel_path == "/" then
|
||||
if is_logged_in() then
|
||||
rel_path = "/info.html"
|
||||
rel_path = "/panel.ms"
|
||||
else
|
||||
rel_path = "/login.html"
|
||||
end
|
||||
|
@ -222,6 +217,7 @@ function serve(uri)
|
|||
-- Associate to MIME type
|
||||
mime_types = {
|
||||
html = "text/html",
|
||||
ms = "text/html",
|
||||
js = "text/javascript",
|
||||
map = "text/javascript",
|
||||
css = "text/css",
|
||||
|
@ -245,6 +241,8 @@ function serve(uri)
|
|||
local rendered = hige.render(read_file(script_path.."portal/header.ms"), data)
|
||||
rendered = rendered..hige.render(content, data)
|
||||
content = rendered..hige.render(read_file(script_path.."portal/footer.ms"), data)
|
||||
elseif ext == "ms" then
|
||||
content = hige.render(content, {})
|
||||
end
|
||||
|
||||
-- Reset flash messages
|
||||
|
@ -344,7 +342,7 @@ function do_edit ()
|
|||
-- Edit user informations
|
||||
elseif string.ends(ngx.var.uri, "edit.html") then
|
||||
if args.givenName and args.sn and args.mail then
|
||||
|
||||
|
||||
local mailalias = {}
|
||||
if args["mailalias[]"] and type(args["mailalias[]"]) == "table" then
|
||||
mailalias = args["mailalias[]"]
|
||||
|
@ -389,7 +387,7 @@ function do_edit ()
|
|||
end
|
||||
end
|
||||
table.insert(maildrop, 1, user)
|
||||
|
||||
|
||||
local dn = "uid="..user..",ou=users,dc=yunohost,dc=org"
|
||||
local ldap = lualdap.open_simple("localhost", dn, cache[user]["password"])
|
||||
local cn = args.givenName.." "..args.sn
|
||||
|
@ -510,6 +508,7 @@ function logout_walkthrough (user)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
function redirect (url)
|
||||
ngx.header["Set-Cookie"] = cookies
|
||||
return ngx.redirect(url)
|
||||
|
|
41
portal/assets/css/panel.css
Normal file
41
portal/assets/css/panel.css
Normal file
|
@ -0,0 +1,41 @@
|
|||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
iframe {
|
||||
position: absolute;
|
||||
top: 0; bottom: 0; left: 0; width: 100%; height: 100%;
|
||||
border: none;
|
||||
box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box;
|
||||
}
|
||||
#ynhtopbar {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 110px;
|
||||
background-color: black;
|
||||
color: black;
|
||||
z-index: 1000;
|
||||
font-family: "helvetica";
|
||||
}
|
||||
#ynhtoggle {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
text-align: center;
|
||||
padding-top: 10px;
|
||||
top: 100px;
|
||||
left: 50px;
|
||||
width: 80px;
|
||||
height: 18px;
|
||||
z-index: 900;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
#ynhtoggle:hover {
|
||||
text-decoration: none;
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
|
||||
<head>
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height" />
|
||||
<title>YunoHost Portal</title>
|
||||
<link rel="stylesheet" href="assets/css/bootstrap.min.css" type="text/css"/>
|
||||
<script src="assets/js/jquery-1.10.2.min.js"></script>
|
||||
|
|
102
portal/panel.ms
Normal file
102
portal/panel.ms
Normal file
|
@ -0,0 +1,102 @@
|
|||
<!doctype html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height" />
|
||||
<title>Yunohost Apps</title>
|
||||
<link media="all" type="text/css" href="assets/css/panel.css" rel="stylesheet">
|
||||
<script src="assets/js/jquery-1.10.2.min.js"></script>
|
||||
</head>
|
||||
<body class="gradient" style="overflow: hidden">
|
||||
<!--<body class="gradient" style="">-->
|
||||
<iframe name="glu" id="glu" width="100%" src="/" style=""></iframe>
|
||||
<script>
|
||||
var ynh = {};
|
||||
ynh.jquery = jQuery.noConflict();
|
||||
(function( $ ) {
|
||||
|
||||
function datScroll(to) {
|
||||
preventRefire = true;
|
||||
$("body,html").animate({scrollTop:to}, '100', 'swing', function() {
|
||||
setTimeout(function() {
|
||||
if (to == 0) {
|
||||
$("#ynhtoggle").addClass("ynhopen");
|
||||
} else {
|
||||
$("#ynhtoggle").removeClass("ynhopen");
|
||||
}
|
||||
preventRefire = false;
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
||||
preventRefire = false;
|
||||
function checkScroll (direction) {
|
||||
if(preventRefire) return;
|
||||
|
||||
if((direction == "top") && ($("body").scrollTop() == 107 || $("html").scrollTop() == 107) && $("#ynhtoggle.ynhopen").length == 0) {
|
||||
datScroll(0);
|
||||
} else if((direction == "bottom") && $("#ynhtoggle.ynhopen").length > 0) {
|
||||
datScroll(h);
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function($) {
|
||||
scroll = $("body").scrollTop();
|
||||
h = 107;
|
||||
$('body').children().filter(function() {
|
||||
return $(this).css("position") === 'absolute' || $(this).css("position") === 'fixed';
|
||||
}).css({top: function(index, value) {
|
||||
return parseFloat(value) + h + 3;
|
||||
}});
|
||||
if ($(window).height() > $("html").height()) {
|
||||
alert('moualé');
|
||||
$("html").css('min-height', $(window).height() + h );
|
||||
}
|
||||
$("body").append('<div id="ynhtopbar"><div id="ynhtoggle" class="ynhopen">YunoHost</div></div>');
|
||||
$("body").css({marginTop: function(index, value) {
|
||||
return parseFloat(value) + h + 3;
|
||||
}});
|
||||
if (scroll == 0) {
|
||||
$("body,html").animate({scrollTop:h}, '100', 'swing', function() {
|
||||
setTimeout(function() {
|
||||
$("#ynhtoggle").removeClass("ynhopen");
|
||||
}, 300);
|
||||
//window.scrollTo(0, h);
|
||||
});
|
||||
}
|
||||
$("#ynhtoggle").on("click", function() {
|
||||
if ($("body").scrollTop() == 0 && $("html").scrollTop() == 0) {
|
||||
datScroll(h);
|
||||
} else {
|
||||
datScroll(0);
|
||||
}
|
||||
});
|
||||
|
||||
$("#glu").load(function() {
|
||||
$( $(this)[0].contentWindow ).bind("DOMMouseScroll mousewheel scroll", function(event) {
|
||||
if (event.currentTarget.scrollY > 0) {
|
||||
checkScroll("bottom");
|
||||
} else {
|
||||
checkScroll("top");
|
||||
}
|
||||
});
|
||||
$(document).bind("keyup keydown",function(event){
|
||||
if($('input:focus,textarea:focus').length > 0) return; //If an input field is focused
|
||||
if(event.which == 38 || event.which == 33) {
|
||||
checkScroll("top");
|
||||
} else if(event.which == 40 || event.which == 34) {
|
||||
checkScroll("bottom");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
})(ynh.jquery);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue