From 418ae04571958162a3ac3527238a49cbe98f9834 Mon Sep 17 00:00:00 2001 From: Kload Date: Wed, 23 Oct 2013 09:21:05 +0000 Subject: [PATCH] Add YunoHost panel --- access.lua | 17 +++--- portal/assets/css/panel.css | 41 +++++++++++++++ portal/header.ms | 2 + portal/panel.ms | 102 ++++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 9 deletions(-) create mode 100644 portal/assets/css/panel.css create mode 100644 portal/panel.ms diff --git a/access.lua b/access.lua index c992e7c..4c24df7 100644 --- a/access.lua +++ b/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) diff --git a/portal/assets/css/panel.css b/portal/assets/css/panel.css new file mode 100644 index 0000000..bd934b9 --- /dev/null +++ b/portal/assets/css/panel.css @@ -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; +} diff --git a/portal/header.ms b/portal/header.ms index 763c49a..cc8169e 100644 --- a/portal/header.ms +++ b/portal/header.ms @@ -1,6 +1,8 @@ + + YunoHost Portal diff --git a/portal/panel.ms b/portal/panel.ms new file mode 100644 index 0000000..8608c39 --- /dev/null +++ b/portal/panel.ms @@ -0,0 +1,102 @@ + + + + + + + + + + +Yunohost Apps + + + + + + + + +