v1.18.x
Julian Lam 11 years ago
parent 3e296a42f7
commit 970b259e06

@ -135,7 +135,6 @@ function start() {
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path'));
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates'));
nconf.set('theme_templates_path', meta.config['theme:templates'] ? path.join(nconf.get('themes_path'), meta.config['theme:id'], meta.config['theme:templates']) : nconf.get('base_templates_path'));
plugins.ready(function() {
webserver.init();

@ -150,7 +150,7 @@ var fs = require('fs'),
function(config, next) {
themeData['theme:staticDir'] = config.staticDir ? config.staticDir : '';
themeData['theme:templates'] = config.templates ? config.templates : '';
themeData['theme:src'] = config.frameworkCSS ? config.frameworkCSS : '';
themeData['theme:src'] = '';
db.setObject('config', themeData, next);
}
@ -234,6 +234,7 @@ var fs = require('fs'),
'vendor/jquery/js/jquery-ui-1.10.4.custom.js',
'vendor/jquery/timeago/jquery.timeago.min.js',
'vendor/jquery/js/jquery.form.min.js',
'vendor/jquery/serializeObject/jquery.ba-serializeobject.min.js',
'vendor/bootstrap/js/bootstrap.min.js',
'vendor/requirejs/require.js',
'vendor/bootbox/bootbox.min.js',

@ -45,21 +45,31 @@ function routeThemeScreenshots(app, themes) {
});
}
function routeCurrentTheme(app, themeData) {
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla');
function routeCurrentTheme(app, themeId, themesData) {
var themeId = (themeId || 'nodebb-theme-vanilla'),
themeObj = (function(id) {
return themesData.filter(function(themeObj) {
return themeObj.id === id;
})[0];
})(themeId);
// Detect if a theme has been selected, and handle appropriately
if (process.env.NODE_ENV === 'development') {
winston.info('[themes] Using theme ' + themeId);
}
// Theme's static directory
if (themeData['theme:staticDir']) {
app.use(relativePath + '/css/assets', express.static(path.join(themesPath, themeData['theme:id'], themeData['theme:staticDir']), {
// Theme's templates path
nconf.set('theme_templates_path', themeObj.templates ? path.join(themesPath, themeObj.id, themeObj.templates) : nconf.get('base_templates_path'));
themeTemplatesPath = nconf.get('theme_templates_path');
// Theme's static directory (to be deprecated for 0.5.0)
if (themeObj.staticDir) {
app.use(relativePath + '/css/assets', express.static(path.join(themesPath, themeObj.id, themeObj.staticDir), {
maxAge: app.enabled('cache') ? 5184000000 : 0
}));
if (process.env.NODE_ENV === 'development') {
winston.info('Static directory routed for theme: ' + themeData['theme:id']);
winston.info('Static directory routed for theme: ' + themeObj.id);
}
}
}
@ -173,7 +183,6 @@ module.exports = function(app, data) {
viewsPath = nconf.get('views_dir');
themesPath = nconf.get('themes_path');
baseTemplatesPath = nconf.get('base_templates_path');
themeTemplatesPath = nconf.get('theme_templates_path');
app.configure(function() {
app.engine('tpl', templates.__express);
@ -210,7 +219,7 @@ module.exports = function(app, data) {
auth.initialize(app);
routeCurrentTheme(app, data.currentThemeData);
routeCurrentTheme(app, data.currentThemeId, data.themesData);
routeThemeScreenshots(app, data.themesData);
plugins.getTemplates(function(err, pluginTemplates) {

@ -49,10 +49,10 @@ if(nconf.get('ssl')) {
meta.sounds.init();
});
async.series({
async.parallel({
themesData: meta.themes.get,
currentThemeData: function(next) {
db.getObjectFields('config', ['theme:type', 'theme:id', 'theme:staticDir', 'theme:templates'], next);
currentThemeId: function(next) {
db.getObjectField('config', 'theme:id', next);
}
}, function(err, data) {
middleware = middleware(app, data);

Loading…
Cancel
Save