Merge pull request #596 from Xaekai/acpnav

Move ACP nav entry to templating
This commit is contained in:
Calvin Montgomery 2016-07-11 22:11:59 -07:00 committed by GitHub
commit 5e399b96cf
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]);