From 5eebd88e13a4b3deadd6fb7683c7831e59e667a7 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Sun, 10 Jul 2016 20:46:10 -0700 Subject: [PATCH] Move ACP nav entry to templating Closes #516 --- package.json | 2 +- src/web/pug.js | 1 + templates/channel.pug | 1 + templates/index.pug | 1 + templates/nav.pug | 7 +++++++ www/js/callbacks.js | 4 ---- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 73fff5df..5a07793c 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/web/pug.js b/src/web/pug.js index bd735344..60815539 100644 --- a/src/web/pug.js +++ b/src/web/pug.js @@ -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), { diff --git a/templates/channel.pug b/templates/channel.pug index 2b4354dc..e9b491dd 100644 --- a/templates/channel.pug +++ b/templates/channel.pug @@ -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 diff --git a/templates/index.pug b/templates/index.pug index 251ed2de..4ee05954 100644 --- a/templates/index.pug +++ b/templates/index.pug @@ -11,6 +11,7 @@ html(lang="en") #nav-collapsible.collapse.navbar-collapse ul.nav.navbar-nav +navdefaultlinks("/") + +navsuperadmin(false) +navloginlogout("/") section#mainpage .container diff --git a/templates/nav.pug b/templates/nav.pug index 8cc80260..939e1b3b 100644 --- a/templates/nav.pug +++ b/templates/nav.pug @@ -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) diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 8e64811d..ae309e85 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -369,10 +369,6 @@ Callbacks = { CLIENT.rank = r; handlePermissionChange(); if(SUPERADMIN && $("#setrank").length == 0) { - $("").attr("href", "/acp") - .attr("target", "_blank") - .text("ACP") - .appendTo($("
  • ").appendTo($(".nav")[0])); var li = $("
  • ").addClass("dropdown") .attr("id", "setrank") .appendTo($(".nav")[0]);