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", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.18.4", "version": "3.18.5",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

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

View File

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

View File

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

View File

@ -36,6 +36,13 @@ mixin navdefaultlinks(page)
li: a(href=loginDomain+"/login?dest=" + encodeURIComponent(baseUrl + page)) Login li: a(href=loginDomain+"/login?dest=" + encodeURIComponent(baseUrl + page)) Login
li: a(href=loginDomain+"/register") Register 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) mixin navloginlogout(redirect)
if loggedIn if loggedIn
+navlogoutform(redirect) +navlogoutform(redirect)

View File

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