readme typo.
This commit is contained in:
parent
95478f85c3
commit
46012dc62d
58
README.md
58
README.md
|
@ -9,7 +9,8 @@ A Node.js library providing automatic site assets aggregation.
|
|||
|
||||
## 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
|
||||
|
||||
|
@ -50,7 +51,7 @@ A Node.js library providing automatic site assets aggregation.
|
|||
var express = require('express');
|
||||
var async = require('async');
|
||||
var path = require('path');
|
||||
var assets = require('../lib/node-ff-assets');
|
||||
var assets = require('node-ff-assets');
|
||||
|
||||
function buildAssets(server,callbackDone) {
|
||||
var singleResult = 'false' !== process.env.DEV_ASSETS_SINGLE_RESULT;
|
||||
|
@ -86,35 +87,17 @@ A Node.js library providing automatic site assets aggregation.
|
|||
},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) {
|
||||
return function (req, res) {
|
||||
res.render('index', {
|
||||
pageTitle: 'node-ff-assets example',
|
||||
pageKeywords: 'node,ff,assets,example,ui',
|
||||
pageCssFiles: server.get('ff_assets_css'),
|
||||
pageJsFiles: server.get('ff_assets_js'),
|
||||
});
|
||||
};
|
||||
return function (req, res) {
|
||||
res.render('index', {
|
||||
pageTitle: 'node-ff-assets example',
|
||||
pageKeywords: 'node,ff,assets,example,ui',
|
||||
pageCssFiles: server.get('ff_assets_css'),
|
||||
pageJsFiles: server.get('ff_assets_js'),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function sendRedirect() {
|
||||
return function (req, res) {
|
||||
res.redirect('/example-ui');
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var server = express();
|
||||
buildAssets(server,function(err) {
|
||||
if (err) {
|
||||
|
@ -122,26 +105,11 @@ A Node.js library providing automatic site assets aggregation.
|
|||
}
|
||||
console.info('Server assets done.');
|
||||
|
||||
server.set('view engine', 'ejs');
|
||||
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('/example-ui',renderPage(server));
|
||||
|
||||
server.get('/', sendRedirect());
|
||||
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');
|
||||
...snip.. config rest of server
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
version: 'example'
|
||||
};
|
||||
|
||||
### index.ejs
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
|
Loading…
Reference in a new issue