Skip to content

Node.js based forum software built for the modern web

theme intergration into nodebb based on config hash value

Julian Lambaf379c6d7ed
diff --git a/public/templates/header.tpl b/public/templates/header.tpl
index 0f2885dc18..e0056401b0 100644
--- a/public/templates/header.tpl
+++ b/public/templates/header.tpl
@@ -28,7 +28,7 @@
}
</script>
- <link rel="stylesheet" type="text/css" href="{relative_path}/css/nodebb.css" />
+ <link rel="stylesheet" type="text/css" href="{relative_path}/css/theme.css" />
</head>
<body>
diff --git a/src/webserver.js b/src/webserver.js
index 758665cfef..b70c625323 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -102,7 +102,6 @@ var express = require('express'),
prefix: nconf.get('relative_path'),
yuicompress: true
}));
- app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public')));
app.use(express.bodyParser()); // Puts POST vars in request.body
app.use(express.cookieParser()); // If you want to parse cookies (res.cookies)
app.use(express.session({
@@ -131,20 +130,44 @@ var express = require('express'),
next();
},
function(next) {
- // Static Directories for NodeBB Plugins
- plugins.ready(function () {
- for (d in plugins.staticDirs) {
- app.use(nconf.get('relative_path') + '/plugins/' + d, express.static(plugins.staticDirs[d]));
- if (process.env.NODE_ENV === 'development') winston.info('Static directory routed for plugin: ' + d);
+ async.parallel([
+ function(next) {
+ // Static Directories for NodeBB Plugins
+ plugins.ready(function () {
+ for (d in plugins.staticDirs) {
+ app.use(nconf.get('relative_path') + '/plugins/' + d, express.static(plugins.staticDirs[d]));
+ if (process.env.NODE_ENV === 'development') winston.info('Static directory routed for plugin: ' + d);
+ }
+
+ next();
+ });
+ },
+ function(next) {
+ RDB.hmget('config', 'theme:type', 'theme:id', function(err, themeData) {
+ if (!themeData[0] || themeData[0] === 'local') {
+ var themeId = (themeData[1] || 'nodebb-theme-vanilla');
+ if (process.env.NODE_ENV === 'development') winston.info('[themes] Using theme ' + themeId);
+
+ app.use(require('less-middleware')({
+ src: path.join(__dirname, '../node_modules/' + themeId),
+ dest: path.join(__dirname, '../public/css'),
+ prefix: nconf.get('relative_path') + '/css',
+ yuicompress: true
+ }));
+
+ next();
+ }
+ });
}
-
- next();
- });
+ ], next);
},
function(next) {
// Router & post-router middlewares
app.use(app.router);
+ // Static directory /public
+ app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public')));
+
// 404 catch-all
app.use(function (req, res, next) {
res.status(404);