diff --git a/.gitignore b/.gitignore index 49f144eb0a..b5bda3e26f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ npm-debug.log node_modules/ sftp-config.json config.json +public/src/nodebb.min.js public/config.json public/css/*.css public/themes/* @@ -15,4 +16,4 @@ public/themes/* *.sublime-project *.sublime-workspace plugins/* -.project \ No newline at end of file +.project diff --git a/app.js b/app.js index 33c765a012..8225491a5c 100644 --- a/app.js +++ b/app.js @@ -26,6 +26,8 @@ var fs = require('fs'), winston = require('winston'), pkg = require('./package.json'), + path = require('path'), + uglifyjs = require('uglify-js'), meta; // Runtime environment @@ -69,6 +71,33 @@ winston.info('Base Configuration OK.'); } + // Minify JS + var toMinify = [ + '/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js', + '/vendor/jquery/js/jquery.timeago.js', + '/vendor/bootstrap/js/bootstrap.min.js', + '/src/app.js', + '/vendor/requirejs/require.js', + '/vendor/bootbox/bootbox.min.js', + '/src/templates.js', + '/src/ajaxify.js', + '/src/jquery.form.js', + '/src/utils.js' + ], + minified; + toMinify = toMinify.map(function (jsPath) { + return path.join(__dirname + '/public', jsPath); + }); + minified = uglifyjs.minify(toMinify); + fs.writeFile(path.join(__dirname, '/public/src', 'nodebb.min.js'), minified.code, function (err) { + if (!err) { + winston.info('Minified client-side libraries'); + } else { + winston.error('Problem minifying client-side libraries, exiting.'); + process.exit(); + } + }); + meta.configs.init(function () { // Initial setup for Redis & Reds var reds = require('reds'), diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 0efb66394d..5a1339ed54 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -9,23 +9,14 @@ var RELATIVE_PATH = "{relative_path}"; - - - - - - + - - - - diff --git a/src/webserver.js b/src/webserver.js index 3e46fa3147..ff6d1421fe 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -48,20 +48,14 @@ var express = require('express'), metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])), templateValues = { cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css', - title: meta.config['title'] || 'NodeBB', - browserTitle: meta.config['title'] || 'NodeBB', + title: meta.config.title || 'NodeBB', + browserTitle: meta.config.title || 'NodeBB', csrf: options.res.locals.csrf_token, relative_path: nconf.get('relative_path'), meta_tags: metaString }; - // meta.build_title(options.title, (options.req.user ? options.req.user.uid : 0), function(err, title) { - // if (!err) templateValues.browserTitle = title; - - // callback(null, templates['header'].parse(templateValues)); - // }); - - callback(null, templates['header'].parse(templateValues)); + callback(null, templates.header.parse(templateValues)); }; // Middlewares