readme typo.
This commit is contained in:
parent
95478f85c3
commit
46012dc62d
42
README.md
42
README.md
|
@ -9,7 +9,8 @@ A Node.js library providing automatic site assets aggregation.
|
||||||
|
|
||||||
## Example Application
|
## Example Application
|
||||||
|
|
||||||
There is a fully working bootstrap with angularjs example in the example folder.
|
There is a fully working express example application in the example folder.
|
||||||
|
This contains bootstrap and angularjs and ejs templates and results in single js and css file.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ A Node.js library providing automatic site assets aggregation.
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var assets = require('../lib/node-ff-assets');
|
var assets = require('node-ff-assets');
|
||||||
|
|
||||||
function buildAssets(server,callbackDone) {
|
function buildAssets(server,callbackDone) {
|
||||||
var singleResult = 'false' !== process.env.DEV_ASSETS_SINGLE_RESULT;
|
var singleResult = 'false' !== process.env.DEV_ASSETS_SINGLE_RESULT;
|
||||||
|
@ -86,17 +87,6 @@ A Node.js library providing automatic site assets aggregation.
|
||||||
},callbackDone);
|
},callbackDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTemplatePath(viewPath) {
|
|
||||||
return function (req, res) {
|
|
||||||
res.locals.query = req.query;
|
|
||||||
var qi = req.url.indexOf('?');
|
|
||||||
if (qi === -1) {
|
|
||||||
qi = req.url.length;
|
|
||||||
}
|
|
||||||
res.render(viewPath + req.url.substring(req.route.path.length-1, qi));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPage(server) {
|
function renderPage(server) {
|
||||||
return function (req, res) {
|
return function (req, res) {
|
||||||
res.render('index', {
|
res.render('index', {
|
||||||
|
@ -108,13 +98,6 @@ A Node.js library providing automatic site assets aggregation.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendRedirect() {
|
|
||||||
return function (req, res) {
|
|
||||||
res.redirect('/example-ui');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var server = express();
|
var server = express();
|
||||||
buildAssets(server,function(err) {
|
buildAssets(server,function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -122,26 +105,11 @@ A Node.js library providing automatic site assets aggregation.
|
||||||
}
|
}
|
||||||
console.info('Server assets done.');
|
console.info('Server assets done.');
|
||||||
|
|
||||||
server.set('view engine', 'ejs');
|
server.get('/example-ui',renderPage(server));
|
||||||
server.set('views', path.join(__dirname,'www_views'));
|
|
||||||
server.use('/static', express.static(path.join(__dirname,'www_static')));
|
|
||||||
server.use('/static/module/bootstrap', express.static(path.join(__dirname,'node_modules/bootstrap/dist')));
|
|
||||||
server.use('/static/module/flot', express.static(path.join(__dirname,'node_modules/flot')));
|
|
||||||
|
|
||||||
server.get('/', sendRedirect());
|
...snip.. config rest of server
|
||||||
server.get('/example-ui/thtml/*', renderTemplatePath('thtml/'));
|
|
||||||
server.get('/example-ui', renderPage(server));
|
|
||||||
server.get('/example-ui/*', renderPage(server)); // must be last; for HTML5 history
|
|
||||||
console.info('Server config done.');
|
|
||||||
|
|
||||||
server.listen(8080);
|
|
||||||
console.info('Server started on port 8080');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
version: 'example'
|
|
||||||
};
|
|
||||||
|
|
||||||
### index.ejs
|
### index.ejs
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
Loading…
Reference in a new issue