Added theme support. Close #2

This commit is contained in:
Mattias Erming 2014-04-24 22:34:40 +02:00
parent efeb4a537a
commit bea3136078
4 changed files with 25 additions and 4 deletions

View File

@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="<%= typeof theme !== 'undefined' ? theme : "" %>">
</head>
<body>

View File

View File

@ -1,4 +1,5 @@
module.exports = {
theme: "/themes/default.css",
defaults: {
nick: "shout_user",
realname: "http://github.com/erming/shout",

View File

@ -1,9 +1,10 @@
var config = require("../config");
var _ = require("lodash");
var config = require("../config") || {};
var fs = require("fs");
var http = require("connect");
var io = require("socket.io");
var irc = require("slate-irc");
var net = require("net");
var _ = require("lodash");
// Models
@ -37,6 +38,7 @@ module.exports = listen;
function listen() {
var app = http()
.use(index)
.use(http.static("client"))
.listen(9000);
@ -48,14 +50,31 @@ function listen() {
});
});
config.networks.forEach(function(n) {
(config.networks || []).forEach(function(n) {
connect(n);
});
}
function index(req, res, next) {
if (req.url == "/" || req.url == "/index.html") {
var data = _.extend(
require("../package.json"),
config
);
fs.readFile(
"client/index.html",
function(e, file) {
res.end(_.template(file, data));
}
);
} else {
next();
}
}
function connect(params) {
params = _.extend(
config.defaults,
config.defaults || {},
params
);