diff --git a/import.js b/import.js
index f7842c64..7bbf5b3a 100644
--- a/import.js
+++ b/import.js
@@ -199,9 +199,9 @@ function copyChannelTables(name, cb) {
rows = rows.map(function (r) {
if (r.rank === 10) {
- r.rank = 4;
+ r.rank = 5;
} else if (r.rank >= 3 && r.rank < 10) {
- r.rank = 3;
+ r.rank = 4;
}
return [r.name, r.rank];
});
diff --git a/index.js b/index.js
index 71f8f6ca..ad648e8c 100644
--- a/index.js
+++ b/index.js
@@ -25,3 +25,20 @@ if (!Config.get("debug")) {
sv.shutdown();
});
}
+
+var stdinbuf = "";
+process.stdin.on("data", function (data) {
+ stdinbuf += data;
+ if (stdinbuf.indexOf("\n") !== -1) {
+ var line = stdinbuf.substring(0, stdinbuf.indexOf("\n"));
+ stdinbuf = stdinbuf.substring(stdinbuf.indexOf("\n") + 1);
+ handleLine(line);
+ }
+});
+
+function handleLine(line) {
+ if (line === "/reload") {
+ Logger.syslog.log("Reloading config");
+ Config.load("config.yaml");
+ }
+}
diff --git a/lib/config.js b/lib/config.js
index f857cbc1..737a0aff 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -133,24 +133,50 @@ exports.load = function (file) {
mailconfig = cfg.mail.config;
delete cfg.mail.config;
}
-
merge(cfg, defaults, "config");
-
cfg.mail.config = mailconfig;
+
+ preprocessConfig(cfg);
+ Logger.syslog.log("Loaded configuration from " + file);
+};
+
+function preprocessConfig(cfg) {
+ // Root domain should start with a . for cookies
+ var root = cfg.http["root-domain"];
+ root = "." + root.replace(/^\.*/, "");
+ cfg.http["root-domain"] = root;
+
+ // Setup nodemailer
cfg.mail.nodemailer = nodemailer.createTransport(
cfg.mail.transport,
cfg.mail.config
);
+ // Debug
if (process.env.DEBUG === "1" || process.env.DEBUG === "true") {
cfg.debug = true;
} else {
cfg.debug = false;
}
+ // Strip trailing slashes from domains
cfg.http.domain = cfg.http.domain.replace(/\/*$/, "");
cfg.https.domain = cfg.https.domain.replace(/\/*$/, "");
+
+ // HTTP/HTTPS domains with port numbers
+ var httpfa = cfg.http.domain;
+ if (cfg.http.port !== 80) {
+ httpfa += ":" + cfg.http.port;
+ }
+ cfg.http["full-address"] = httpfa;
+
+ var httpsfa = cfg.https.domain;
+ if (cfg.https.port !== 443) {
+ httpsfa += ":" + cfg.https.port;
+ }
+ cfg.https["full-address"] = httpsfa;
+ // Generate RegExps for reserved names
var reserved = cfg["reserved-names"];
for (var key in reserved) {
if (reserved[key] && reserved[key].length > 0) {
@@ -159,9 +185,8 @@ exports.load = function (file) {
reserved[key] = false;
}
}
-
- Logger.syslog.log("Loaded configuration from " + file);
-};
+ return cfg;
+}
/**
* Retrieves a configuration value with the given key
diff --git a/lib/database/channels.js b/lib/database/channels.js
index f8498f0b..98868e7e 100644
--- a/lib/database/channels.js
+++ b/lib/database/channels.js
@@ -24,7 +24,7 @@ function initTables(name, owner, callback) {
return;
}
- rank = Math.max(rank, 4);
+ rank = Math.max(rank, 5);
module.exports.setRank(name, owner, rank, function (err) {
if (err) {
diff --git a/lib/web/jade.js b/lib/web/jade.js
index 8966f998..c5b4b220 100644
--- a/lib/web/jade.js
+++ b/lib/web/jade.js
@@ -14,8 +14,8 @@ function merge(locals) {
siteTitle: Config.get("html-template.title"),
siteDescription: Config.get("html-template.description"),
siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery",
- loginDomain: Config.get("https.enabled") ? Config.get("https.domain")+":"+Config.get("https.port")
- : Config.get("http.domain")+":"+Config.get("http.port")
+ loginDomain: Config.get("https.enabled") ? Config.get("https.full-address")
+ : Config.get("http.full-address")
};
if (typeof locals !== "object") {
return _locals;
@@ -30,7 +30,7 @@ function merge(locals) {
* Renders and serves a jade template
*/
function sendJade(res, view, locals) {
- if (!(view in cache) || process.env["DEBUG"]) {
+ if (!(view in cache) || Config.get("debug")) {
var file = path.join(templates, view + ".jade");
var fn = jade.compile(fs.readFileSync(file), {
filename: file,
diff --git a/lib/web/webserver.js b/lib/web/webserver.js
index 0abb3191..6e9f4635 100644
--- a/lib/web/webserver.js
+++ b/lib/web/webserver.js
@@ -64,12 +64,7 @@ function logRequest(req, status) {
function cookieall(res, name, val, opts) {
res.cookie(name, val, opts);
-
opts.domain = Config.get("http.root-domain");
- if (Config.get("http.domain").indexOf(opts.domain) === -1) {
- opts.domain = Config.get("http.domain");
- }
-
res.cookie(name, val, opts);
}
@@ -78,11 +73,7 @@ function cookieall(res, name, val, opts) {
*/
function redirectHttps(req, res) {
if (!req.secure && Config.get("https.enabled")) {
- var ssldomain = Config.get("https.domain");
- var port = Config.get("https.port");
- if (port !== 443) {
- ssldomain += ":" + port;
- }
+ var ssldomain = Config.get("https.full-address");
res.redirect(ssldomain + req.path);
return true;
}
@@ -94,11 +85,7 @@ function redirectHttps(req, res) {
*/
function redirectHttp(req, res) {
if (req.secure) {
- var domain = Config.get("http.domain");
- var port = Config.get("http.port");
- if (port !== 80) {
- domain += ":" + port;
- }
+ var domain = Config.get("http.full-address");
res.redirect(domain + req.path);
return true;
}
@@ -129,7 +116,7 @@ function handleChannel(req, res) {
var sio;
if (req.secure) {
- sio = Config.get("https.domain") + ":" + Config.get("https.port");
+ sio = Config.get("https.full-address");
} else {
sio = Config.get("io.domain") + ":" + Config.get("io.port");
}
diff --git a/www/js/util.js b/www/js/util.js
index 6e5ecae2..ada1d80a 100644
--- a/www/js/util.js
+++ b/www/js/util.js
@@ -1943,8 +1943,9 @@ function formatCSModList() {
var ranks = [
{ name: "Remove Moderator", rank: 1 },
{ name: "Moderator", rank: 2 },
- { name: "Channel Admin", rank: 3 },
- { name: "Channel Owner", rank: 4 }
+ { name: "Admin", rank: 3 },
+ { name: "Owner", rank: 4 },
+ { name: "Founder", rank: 5 }
];
ranks.forEach(function (r) {
@@ -1962,7 +1963,7 @@ function formatCSModList() {
});
});
} else {
- $("").addClass("glyphicon glyphicon-ok pull-right")
+ $("").addClass("glyphicon glyphicon-ok")
.appendTo(a);
li.addClass("disabled");
}