Merge branch '3.0' of github.com:calzoneman/sync into 3.0

This commit is contained in:
calzoneman 2014-02-27 17:27:40 -06:00
commit ceab7dabf9
7 changed files with 60 additions and 30 deletions

View File

@ -199,9 +199,9 @@ function copyChannelTables(name, cb) {
rows = rows.map(function (r) { rows = rows.map(function (r) {
if (r.rank === 10) { if (r.rank === 10) {
r.rank = 4; r.rank = 5;
} else if (r.rank >= 3 && r.rank < 10) { } else if (r.rank >= 3 && r.rank < 10) {
r.rank = 3; r.rank = 4;
} }
return [r.name, r.rank]; return [r.name, r.rank];
}); });

View File

@ -25,3 +25,20 @@ if (!Config.get("debug")) {
sv.shutdown(); 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");
}
}

View File

@ -133,24 +133,50 @@ exports.load = function (file) {
mailconfig = cfg.mail.config; mailconfig = cfg.mail.config;
delete cfg.mail.config; delete cfg.mail.config;
} }
merge(cfg, defaults, "config"); merge(cfg, defaults, "config");
cfg.mail.config = mailconfig; 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.nodemailer = nodemailer.createTransport(
cfg.mail.transport, cfg.mail.transport,
cfg.mail.config cfg.mail.config
); );
// Debug
if (process.env.DEBUG === "1" || process.env.DEBUG === "true") { if (process.env.DEBUG === "1" || process.env.DEBUG === "true") {
cfg.debug = true; cfg.debug = true;
} else { } else {
cfg.debug = false; cfg.debug = false;
} }
// Strip trailing slashes from domains
cfg.http.domain = cfg.http.domain.replace(/\/*$/, ""); cfg.http.domain = cfg.http.domain.replace(/\/*$/, "");
cfg.https.domain = cfg.https.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"]; var reserved = cfg["reserved-names"];
for (var key in reserved) { for (var key in reserved) {
if (reserved[key] && reserved[key].length > 0) { if (reserved[key] && reserved[key].length > 0) {
@ -159,9 +185,8 @@ exports.load = function (file) {
reserved[key] = false; reserved[key] = false;
} }
} }
return cfg;
Logger.syslog.log("Loaded configuration from " + file); }
};
/** /**
* Retrieves a configuration value with the given key * Retrieves a configuration value with the given key

View File

@ -24,7 +24,7 @@ function initTables(name, owner, callback) {
return; return;
} }
rank = Math.max(rank, 4); rank = Math.max(rank, 5);
module.exports.setRank(name, owner, rank, function (err) { module.exports.setRank(name, owner, rank, function (err) {
if (err) { if (err) {

View File

@ -14,8 +14,8 @@ function merge(locals) {
siteTitle: Config.get("html-template.title"), siteTitle: Config.get("html-template.title"),
siteDescription: Config.get("html-template.description"), siteDescription: Config.get("html-template.description"),
siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery", siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery",
loginDomain: Config.get("https.enabled") ? Config.get("https.domain")+":"+Config.get("https.port") loginDomain: Config.get("https.enabled") ? Config.get("https.full-address")
: Config.get("http.domain")+":"+Config.get("http.port") : Config.get("http.full-address")
}; };
if (typeof locals !== "object") { if (typeof locals !== "object") {
return _locals; return _locals;
@ -30,7 +30,7 @@ function merge(locals) {
* Renders and serves a jade template * Renders and serves a jade template
*/ */
function sendJade(res, view, locals) { 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 file = path.join(templates, view + ".jade");
var fn = jade.compile(fs.readFileSync(file), { var fn = jade.compile(fs.readFileSync(file), {
filename: file, filename: file,

View File

@ -64,12 +64,7 @@ function logRequest(req, status) {
function cookieall(res, name, val, opts) { function cookieall(res, name, val, opts) {
res.cookie(name, val, opts); res.cookie(name, val, opts);
opts.domain = Config.get("http.root-domain"); 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); res.cookie(name, val, opts);
} }
@ -78,11 +73,7 @@ function cookieall(res, name, val, opts) {
*/ */
function redirectHttps(req, res) { function redirectHttps(req, res) {
if (!req.secure && Config.get("https.enabled")) { if (!req.secure && Config.get("https.enabled")) {
var ssldomain = Config.get("https.domain"); var ssldomain = Config.get("https.full-address");
var port = Config.get("https.port");
if (port !== 443) {
ssldomain += ":" + port;
}
res.redirect(ssldomain + req.path); res.redirect(ssldomain + req.path);
return true; return true;
} }
@ -94,11 +85,7 @@ function redirectHttps(req, res) {
*/ */
function redirectHttp(req, res) { function redirectHttp(req, res) {
if (req.secure) { if (req.secure) {
var domain = Config.get("http.domain"); var domain = Config.get("http.full-address");
var port = Config.get("http.port");
if (port !== 80) {
domain += ":" + port;
}
res.redirect(domain + req.path); res.redirect(domain + req.path);
return true; return true;
} }
@ -129,7 +116,7 @@ function handleChannel(req, res) {
var sio; var sio;
if (req.secure) { if (req.secure) {
sio = Config.get("https.domain") + ":" + Config.get("https.port"); sio = Config.get("https.full-address");
} else { } else {
sio = Config.get("io.domain") + ":" + Config.get("io.port"); sio = Config.get("io.domain") + ":" + Config.get("io.port");
} }

View File

@ -1943,8 +1943,9 @@ function formatCSModList() {
var ranks = [ var ranks = [
{ name: "Remove Moderator", rank: 1 }, { name: "Remove Moderator", rank: 1 },
{ name: "Moderator", rank: 2 }, { name: "Moderator", rank: 2 },
{ name: "Channel Admin", rank: 3 }, { name: "Admin", rank: 3 },
{ name: "Channel Owner", rank: 4 } { name: "Owner", rank: 4 },
{ name: "Founder", rank: 5 }
]; ];
ranks.forEach(function (r) { ranks.forEach(function (r) {
@ -1962,7 +1963,7 @@ function formatCSModList() {
}); });
}); });
} else { } else {
$("<span/>").addClass("glyphicon glyphicon-ok pull-right") $("<span/>").addClass("glyphicon glyphicon-ok")
.appendTo(a); .appendTo(a);
li.addClass("disabled"); li.addClass("disabled");
} }