Allow channel path to be customizable

We now allow server operators to customize the /r/ part of the channel links
The new config option in the template is commented and the config module validates and will terminate with status 78 if an improper value is used.
We've also dropped some old cruft and uses a more elegant method to assign CHANNEL.name

Resolves #668
This commit is contained in:
Xaekai 2017-06-16 00:16:59 -07:00
parent 00a65a1584
commit 6d4558c978
18 changed files with 71 additions and 75 deletions

View file

@ -453,8 +453,8 @@ console.log(channels[0]);
channels.forEach(function (c) {
var tr = $("<tr/>").appendTo(tbl);
var name = $("<td/>").appendTo(tr);
$("<a/>").attr("href", "/r/" + c.name)
.text(c.pagetitle + " (/r/" + c.name + ")")
$("<a/>").attr("href", `/${CHANNELPATH}/${c.name}`)
.text(c.pagetitle + ` (/${CHANNELPATH}/${c.name})`)
.appendTo(name);
var usercount = $("<td/>").text(c.usercount).appendTo(tr);
count += c.usercount;
@ -475,7 +475,7 @@ console.log(channels[0]);
.attr("title", "Unload")
.appendTo(controlInner)
.click(function () {
if (confirm("Are you sure you want to unload /r/" + c.name + "?")) {
if (confirm(`Are you sure you want to unload /${CHANNELPATH}/${c.name}?`)) {
socket.emit("acp-force-unload", {
name: c.name
});

View file

@ -425,23 +425,6 @@ Callbacks = {
if (!CLIENT.guest) {
socket.emit("initUserPLCallbacks");
if ($("#loginform").length === 0) {
return;
}
var logoutform = $("<p/>").attr("id", "logoutform")
.addClass("navbar-text pull-right")
.insertAfter($("#loginform"));
$("<span/>").attr("id", "welcome").text("Welcome, " + CLIENT.name)
.appendTo(logoutform);
$("<span/>").html("&nbsp;&middot;&nbsp;").appendTo(logoutform);
var domain = $("#loginform").attr("action").replace("/login", "");
$("<a/>").attr("id", "logout")
.attr("href", domain + "/logout?redirect=/r/" + CHANNEL.name)
.text("Logout")
.appendTo(logoutform);
$("#loginform").remove();
}
}
},

View file

@ -19,7 +19,7 @@ var CHANNEL = {
css: "",
js: "",
motd: "",
name: false,
name: CHANNELNAME,
usercount: 0,
emotes: []
};

View file

@ -615,17 +615,6 @@ $("#shuffleplaylist").click(function() {
}
});
/* load channel */
var loc = document.location+"";
var m = loc.match(/\/r\/([a-zA-Z0-9-_]+)/);
if(m) {
CHANNEL.name = m[1];
if (CHANNEL.name.indexOf("#") !== -1) {
CHANNEL.name = CHANNEL.name.substring(0, CHANNEL.name.indexOf("#"));
}
}
/* channel ranks stuff */
function chanrankSubmit(rank) {
var name = $("#cs-chanranks-name").val();