Move ACP nav entry to templating

Closes #516
This commit is contained in:
Xaekai 2016-07-10 20:46:10 -07:00
parent 44cc6336b9
commit 5eebd88e13
6 changed files with 11 additions and 5 deletions

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.18.4",
"version": "3.18.5",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View file

@ -38,6 +38,7 @@ function getBaseUrl(res) {
function sendPug(res, view, locals) {
locals.loggedIn = locals.loggedIn || !!res.user;
locals.loginName = locals.loginName || res.user ? res.user.name : false;
locals.superadmin = locals.superadmin || res.user ? res.user.global_rank >= 255 : false;
if (!(view in cache) || Config.get("debug")) {
var file = path.join(templates, view + ".pug");
var fn = pug.compile(fs.readFileSync(file), {

View file

@ -22,6 +22,7 @@ html(lang="en")
ul.dropdown-menu
li: a(href="#" onclick="javascript:chatOnly()") Chat Only
li: a(href="#" onclick="javascript:removeVideo(event)") Remove Video
+navsuperadmin(true)
+navloginlogout(cname)
section#mainpage
.container

View file

@ -11,6 +11,7 @@ html(lang="en")
#nav-collapsible.collapse.navbar-collapse
ul.nav.navbar-nav
+navdefaultlinks("/")
+navsuperadmin(false)
+navloginlogout("/")
section#mainpage
.container

View file

@ -36,6 +36,13 @@ mixin navdefaultlinks(page)
li: a(href=loginDomain+"/login?dest=" + encodeURIComponent(baseUrl + page)) Login
li: a(href=loginDomain+"/register") Register
mixin navsuperadmin(newTab)
if superadmin
if newTab
li: a(href="/acp", target="_blank") ACP
else
li: a(href="/acp") ACP
mixin navloginlogout(redirect)
if loggedIn
+navlogoutform(redirect)

View file

@ -369,10 +369,6 @@ Callbacks = {
CLIENT.rank = r;
handlePermissionChange();
if(SUPERADMIN && $("#setrank").length == 0) {
$("<a/>").attr("href", "/acp")
.attr("target", "_blank")
.text("ACP")
.appendTo($("<li/>").appendTo($(".nav")[0]));
var li = $("<li/>").addClass("dropdown")
.attr("id", "setrank")
.appendTo($(".nav")[0]);