mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	added css files support for plugins, added ready output for NodeBB, put
some minification related outputs to debug-mode only
This commit is contained in:
		| @@ -5,6 +5,9 @@ | |||||||
| 	{meta_tags} | 	{meta_tags} | ||||||
| 	<link href="{cssSrc}" rel="stylesheet" media="screen"> | 	<link href="{cssSrc}" rel="stylesheet" media="screen"> | ||||||
| 	<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"> | ||||||
|  | 	<!-- BEGIN pluginCSS --> | ||||||
|  | 	<link rel="stylesheet" href="{pluginCSS.path}"> | ||||||
|  | 	<!-- END pluginCSS --> | ||||||
| 	<script> | 	<script> | ||||||
| 		var RELATIVE_PATH = "{relative_path}"; | 		var RELATIVE_PATH = "{relative_path}"; | ||||||
| 	</script> | 	</script> | ||||||
|   | |||||||
| @@ -186,7 +186,7 @@ var utils = require('./../public/src/utils.js'), | |||||||
| 					}, | 					}, | ||||||
| 					minFile: function (next) { | 					minFile: function (next) { | ||||||
| 						if (!fs.existsSync(Meta.js.minFile)) { | 						if (!fs.existsSync(Meta.js.minFile)) { | ||||||
| 							winston.warn('No minified client-side library found'); | 							if (process.env.NODE_ENV === 'development') winston.warn('No minified client-side library found'); | ||||||
| 							return next(null, 0); | 							return next(null, 0); | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
| @@ -196,7 +196,7 @@ var utils = require('./../public/src/utils.js'), | |||||||
| 					} | 					} | ||||||
| 				}, function (err, results) { | 				}, function (err, results) { | ||||||
| 					if (results.minFile > results.mtime) { | 					if (results.minFile > results.mtime) { | ||||||
| 						winston.info('No changes to client-side libraries -- skipping minification'); | 						if (process.env.NODE_ENV === 'development') winston.info('No changes to client-side libraries -- skipping minification'); | ||||||
| 						callback(null, [path.relative(path.join(__dirname, '../public'), Meta.js.minFile)]); | 						callback(null, [path.relative(path.join(__dirname, '../public'), Meta.js.minFile)]); | ||||||
| 					} else { | 					} else { | ||||||
| 						Meta.js.minify(function () { | 						Meta.js.minify(function () { | ||||||
|   | |||||||
| @@ -109,12 +109,10 @@ var fs = require('fs'), | |||||||
| 					function(next) { | 					function(next) { | ||||||
| 						// CSS Files for plugins | 						// CSS Files for plugins | ||||||
| 						if (pluginData.css && pluginData.css instanceof Array) { | 						if (pluginData.css && pluginData.css instanceof Array) { | ||||||
| 							for(var x=0,numCss=pluginData.css.length;x<numCss;x++) { | 							if (global.env === 'development') winston.info('[plugins] Found ' + pluginData.css.length + ' CSS file(s) for plugin ' + pluginData.id); | ||||||
| 								_self.cssFiles.push({ | 							_self.cssFiles = _self.cssFiles.concat(pluginData.css.map(function(file) { | ||||||
| 									plugin: pluginData.id, | 								return path.join('/plugins', pluginData.id, file); | ||||||
| 									path: path.join(pluginPath, pluginData.css[x]) | 							})); | ||||||
| 								}); |  | ||||||
| 							} |  | ||||||
|  |  | ||||||
| 							next(); | 							next(); | ||||||
| 						} else next(); | 						} else next(); | ||||||
|   | |||||||
| @@ -63,6 +63,7 @@ var express = require('express'), | |||||||
| 			metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])), | 			metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])), | ||||||
| 			templateValues = { | 			templateValues = { | ||||||
| 				cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css', | 				cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css', | ||||||
|  | 				pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }), | ||||||
| 				title: meta.config.title || 'NodeBB', | 				title: meta.config.title || 'NodeBB', | ||||||
| 				browserTitle: meta.config.title || 'NodeBB', | 				browserTitle: meta.config.title || 'NodeBB', | ||||||
| 				csrf: options.res.locals.csrf_token, | 				csrf: options.res.locals.csrf_token, | ||||||
| @@ -119,27 +120,10 @@ var express = require('express'), | |||||||
|  |  | ||||||
| 				next(); | 				next(); | ||||||
| 			}, | 			}, | ||||||
| 			function(next) { |  | ||||||
| 				// Static CSS files for NodeBB Plugins |  | ||||||
| 				plugins.ready(function() { |  | ||||||
| 					var file,x,numCss,route; |  | ||||||
| 					for(x=0,numCss=plugins.cssFiles.length;x<numCss;x++) { |  | ||||||
| 						file = plugins.cssFiles[x]; |  | ||||||
| 						route = path.join(nconf.get('relative_path'), '/css/', file.plugin); |  | ||||||
| 						app.use(route, express.static(file.path)); |  | ||||||
| 						if (process.env.NODE_ENV === 'development') winston.info('Plugin CSS file found: ' + route); |  | ||||||
| 						console.log('route', route); |  | ||||||
| 						console.log('path', file.path); |  | ||||||
| 					} |  | ||||||
|  |  | ||||||
| 					next(); |  | ||||||
| 				}); |  | ||||||
| 			}, |  | ||||||
| 			function(next) { | 			function(next) { | ||||||
| 				// Static Directories for NodeBB Plugins | 				// Static Directories for NodeBB Plugins | ||||||
| 				plugins.ready(function () { | 				plugins.ready(function () { | ||||||
| 					for (d in plugins.staticDirs) { | 					for (d in plugins.staticDirs) { | ||||||
| 						console.log(plugins.staticDirs[d]); |  | ||||||
| 						app.use(nconf.get('relative_path') + '/plugins/' + d, express.static(plugins.staticDirs[d])); | 						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); | 						if (process.env.NODE_ENV === 'development') winston.info('Static directory routed for plugin: ' + d); | ||||||
| 					} | 					} | ||||||
| @@ -148,7 +132,6 @@ var express = require('express'), | |||||||
| 				}); | 				}); | ||||||
| 			}, | 			}, | ||||||
| 			function(next) { | 			function(next) { | ||||||
| 				console.log('router'); |  | ||||||
| 				// Router & post-router middlewares | 				// Router & post-router middlewares | ||||||
| 				app.use(app.router); | 				app.use(app.router); | ||||||
|  |  | ||||||
| @@ -212,6 +195,7 @@ var express = require('express'), | |||||||
| 			templates['logout'] = parsedTemplate; | 			templates['logout'] = parsedTemplate; | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
|  | 		winston.info('NodeBB Ready'); | ||||||
| 		server.listen(nconf.get('PORT') || nconf.get('port'), nconf.get('bind_address')); | 		server.listen(nconf.get('PORT') || nconf.get('port'), nconf.get('bind_address')); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user