mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-05 21:45:47 +01:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
@@ -42,7 +42,8 @@
|
|||||||
"nodebb-widget-essentials": "~0.0",
|
"nodebb-widget-essentials": "~0.0",
|
||||||
"nodebb-theme-vanilla": "~0.0.14",
|
"nodebb-theme-vanilla": "~0.0.14",
|
||||||
"nodebb-theme-cerulean": "~0.0.13",
|
"nodebb-theme-cerulean": "~0.0.13",
|
||||||
"nodebb-theme-lavender": "~0.0.21"
|
"nodebb-theme-lavender": "~0.0.21",
|
||||||
|
"less": "^1.6.3"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"redis": "0.8.3",
|
"redis": "0.8.3",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<meta<!-- IF metaTags.name --> name="{metaTags.name}"<!-- ENDIF metaTags.name --><!-- IF metaTags.property --> property="{metaTags.property}"<!-- ENDIF metaTags.property --><!-- IF metaTags.content --> content="{metaTags.content}"<!-- ENDIF metaTags.content --> />
|
<meta<!-- IF metaTags.name --> name="{metaTags.name}"<!-- ENDIF metaTags.name --><!-- IF metaTags.property --> property="{metaTags.property}"<!-- ENDIF metaTags.property --><!-- IF metaTags.content --> content="{metaTags.content}"<!-- ENDIF metaTags.content --> />
|
||||||
<!-- END metaTags -->
|
<!-- END metaTags -->
|
||||||
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
|
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
|
||||||
<link rel="stylesheet" type="text/css" href="{relative_path}/css/theme.css?{cache-buster}" />
|
<link rel="stylesheet" type="text/css" href="{relative_path}/stylesheet.css?{cache-buster}" />
|
||||||
<!-- IF bootswatchCSS --><link href="{bootswatchCSS}" rel="stylesheet" media="screen"><!-- ENDIF bootswatchCSS -->
|
<!-- IF bootswatchCSS --><link href="{bootswatchCSS}" rel="stylesheet" media="screen"><!-- ENDIF bootswatchCSS -->
|
||||||
<!-- BEGIN linkTags -->
|
<!-- BEGIN linkTags -->
|
||||||
<link<!-- IF linkTags.link --> link="{linkTags.link}"<!-- ENDIF linkTags.link --><!-- IF linkTags.rel --> rel="{linkTags.rel}"<!-- ENDIF linkTags.rel --><!-- IF linkTags.type --> type="{linkTags.type}"<!-- ENDIF linkTags.type --><!-- IF linkTags.href --> href="{linkTags.href}"<!-- ENDIF linkTags.href --> />
|
<link<!-- IF linkTags.link --> link="{linkTags.link}"<!-- ENDIF linkTags.link --><!-- IF linkTags.rel --> rel="{linkTags.rel}"<!-- ENDIF linkTags.rel --><!-- IF linkTags.type --> type="{linkTags.type}"<!-- ENDIF linkTags.type --><!-- IF linkTags.href --> href="{linkTags.href}"<!-- ENDIF linkTags.href --> />
|
||||||
|
|||||||
@@ -337,6 +337,10 @@ var fs = require('fs'),
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Meta.css = {
|
||||||
|
cache: undefined
|
||||||
|
};
|
||||||
|
|
||||||
Meta.restart = function() {
|
Meta.restart = function() {
|
||||||
if (process.send) {
|
if (process.send) {
|
||||||
process.send('nodebb:restart');
|
process.send('nodebb:restart');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ var fs = require('fs'),
|
|||||||
Plugins.loadedHooks = {};
|
Plugins.loadedHooks = {};
|
||||||
Plugins.staticDirs = {};
|
Plugins.staticDirs = {};
|
||||||
Plugins.cssFiles = [];
|
Plugins.cssFiles = [];
|
||||||
|
Plugins.lessFiles = [];
|
||||||
|
|
||||||
Plugins.initialized = false;
|
Plugins.initialized = false;
|
||||||
|
|
||||||
@@ -221,6 +222,20 @@ var fs = require('fs'),
|
|||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
// LESS files for plugins
|
||||||
|
if (pluginData.less && pluginData.less instanceof Array) {
|
||||||
|
if (global.env === 'development') {
|
||||||
|
winston.info('[plugins] Found ' + pluginData.less.length + ' LESS file(s) for plugin ' + pluginData.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugins.lessFiles = Plugins.lessFiles.concat(pluginData.less.map(function(file) {
|
||||||
|
return path.join(pluginData.id, file);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
|||||||
52
src/routes/theme.js
Normal file
52
src/routes/theme.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
var path = require('path'),
|
||||||
|
nconf = require('nconf'),
|
||||||
|
less = require('less'),
|
||||||
|
|
||||||
|
meta = require('../meta'),
|
||||||
|
db = require('../database'),
|
||||||
|
plugins = require('../plugins');
|
||||||
|
|
||||||
|
(function (Meta) {
|
||||||
|
Meta.createRoutes = function(app) {
|
||||||
|
app.get('/stylesheet.css', function(req, res) {
|
||||||
|
if (meta.css.cache) {
|
||||||
|
res.type('text/css').send(200, meta.css.cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
|
||||||
|
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
|
||||||
|
baseThemePath = path.join(nconf.get('themes_path'), themeId),
|
||||||
|
paths = [baseThemePath, path.join(__dirname, '../../node_modules')],
|
||||||
|
source = '@import "./theme";',
|
||||||
|
x, numLESS;
|
||||||
|
|
||||||
|
// Add the imports for each LESS file
|
||||||
|
for(x=0,numLESS=plugins.lessFiles.length;x<numLESS;x++) {
|
||||||
|
source += '\n@import "./' + plugins.lessFiles[x] + '";';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect if a theme has been selected, and handle appropriately
|
||||||
|
if (!themeData['theme:type'] || themeData['theme:type'] === 'local') {
|
||||||
|
// Local theme
|
||||||
|
var parser = new (less.Parser)({
|
||||||
|
paths: paths
|
||||||
|
});
|
||||||
|
|
||||||
|
parser.parse(source, function(err, tree) {
|
||||||
|
if (err) {
|
||||||
|
res.send(500, err.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
meta.css.cache = tree.toCSS();
|
||||||
|
res.type('text/css').send(200, meta.css.cache);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Bootswatch theme not supported yet
|
||||||
|
res.send(500, 'Give me time!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(exports);
|
||||||
@@ -22,16 +22,18 @@ var path = require('path'),
|
|||||||
topics = require('./topics'),
|
topics = require('./topics'),
|
||||||
ThreadTools = require('./threadTools'),
|
ThreadTools = require('./threadTools'),
|
||||||
notifications = require('./notifications'),
|
notifications = require('./notifications'),
|
||||||
admin = require('./routes/admin'),
|
|
||||||
userRoute = require('./routes/user'),
|
|
||||||
apiRoute = require('./routes/api'),
|
|
||||||
feedsRoute = require('./routes/feeds'),
|
|
||||||
auth = require('./routes/authentication'),
|
auth = require('./routes/authentication'),
|
||||||
meta = require('./meta'),
|
meta = require('./meta'),
|
||||||
plugins = require('./plugins'),
|
plugins = require('./plugins'),
|
||||||
logger = require('./logger'),
|
logger = require('./logger'),
|
||||||
templates = require('./../public/src/templates'),
|
templates = require('./../public/src/templates'),
|
||||||
translator = require('./../public/src/translator');
|
translator = require('./../public/src/translator'),
|
||||||
|
|
||||||
|
admin = require('./routes/admin'),
|
||||||
|
userRoute = require('./routes/user'),
|
||||||
|
apiRoute = require('./routes/api'),
|
||||||
|
feedsRoute = require('./routes/feeds'),
|
||||||
|
themeRoute = require('./routes/theme');
|
||||||
|
|
||||||
if(nconf.get('ssl')) {
|
if(nconf.get('ssl')) {
|
||||||
server = require('https').createServer({
|
server = require('https').createServer({
|
||||||
@@ -322,13 +324,6 @@ process.on('uncaughtException', function(err) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(require('less-middleware')({
|
|
||||||
src: path.join(nconf.get('themes_path'), themeId),
|
|
||||||
dest: path.join(__dirname, '../public/css'),
|
|
||||||
prefix: nconf.get('relative_path') + '/css',
|
|
||||||
yuicompress: app.enabled('minification') ? true : false
|
|
||||||
}));
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
// If not using a local theme (bootswatch, etc), drop back to vanilla
|
// If not using a local theme (bootswatch, etc), drop back to vanilla
|
||||||
@@ -487,8 +482,8 @@ process.on('uncaughtException', function(err) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.namespace(nconf.get('relative_path'), function () {
|
app.namespace(nconf.get('relative_path'), function () {
|
||||||
|
|
||||||
auth.registerApp(app);
|
auth.registerApp(app);
|
||||||
|
themeRoute.createRoutes(app);
|
||||||
admin.createRoutes(app);
|
admin.createRoutes(app);
|
||||||
userRoute.createRoutes(app);
|
userRoute.createRoutes(app);
|
||||||
apiRoute.createRoutes(app);
|
apiRoute.createRoutes(app);
|
||||||
|
|||||||
Reference in New Issue
Block a user