Added context path support and fixed some bugs
This commit is contained in:
parent
b09a5f0906
commit
5d4ea33012
5 changed files with 89 additions and 21 deletions
|
|
@ -9,6 +9,7 @@ var cors = require('cors');
|
|||
var morgan = require('morgan');
|
||||
var UglifyJS = require("uglify-js");
|
||||
var Hashes = require('jshashes');
|
||||
var minify = require('minify');
|
||||
|
||||
var clientResourcesWeb = [];
|
||||
var clientResources = {
|
||||
|
|
@ -80,8 +81,11 @@ function renderTemplatePath(viewPath) {
|
|||
function renderIndex() {
|
||||
return function (req, res) {
|
||||
var inlineScript = UglifyJS.minify(__dirname+'/../../es5-ff-spa-loader.js');
|
||||
res.render('index', {
|
||||
inlineScript: inlineScript.code
|
||||
minify(__dirname+'/../../es5-ff-spa-loader.css', {}, function(err, data) {
|
||||
res.render('index', {
|
||||
inlineScript: inlineScript.code,
|
||||
inlineStyle: data
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
@ -99,22 +103,24 @@ addClientResource('/static/js/controller/page-bar.js','js'); // deps: example-ap
|
|||
addClientResource('/static/js/controller/page-foo.js','js');
|
||||
addClientResource('/static/js/controller/page-index.js','js');
|
||||
|
||||
var appPath = '/test';
|
||||
var server = express();
|
||||
server.use(morgan('dev'));
|
||||
server.use(cors({credentials: true, origin: '*'}));
|
||||
server.use(cors({credentials: true, origin: '*', exposedHeaders: ['X-My-Api']}));
|
||||
server.set('view engine', 'ejs');
|
||||
server.set('views', path.join(__dirname,'www_views'));
|
||||
server.use(function(req, res, next) { res.header('X-My-Api', 'noknok');next(); });
|
||||
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/jquery', express.static(path.join(__dirname,'../node_modules/jquery/dist')));
|
||||
server.use('/static/module/angular', express.static(path.join(__dirname,'../node_modules/angular')));
|
||||
server.use('/static/module/angular-route', express.static(path.join(__dirname,'../node_modules/angular-route')));
|
||||
server.get('/static/spa-client-resources', function (req,res) {res.json({data: {resources: clientResourcesWeb}});});
|
||||
server.get('/static/spa-loader.css', function (req,res) {res.sendFile('es5-ff-spa-loader.css', { root: path.join(__dirname, '/../../') });});
|
||||
server.get('/', function (req, res) {res.redirect('/example-ui');});
|
||||
server.get('/example-ui/thtml/*', renderTemplatePath('thtml/'));
|
||||
server.get('/example-ui', renderIndex());
|
||||
server.set('views', path.join(__dirname,'www_views'));
|
||||
server.use(function(req, res, next) { res.header('X-My-Api', 'noknok');next(); });
|
||||
server.use(appPath+'/static', express.static(path.join(__dirname,'www_static')));
|
||||
server.use(appPath+'/static/module/bootstrap', express.static(path.join(__dirname,'../node_modules/bootstrap/dist')));
|
||||
server.use(appPath+'/static/module/jquery', express.static(path.join(__dirname,'../node_modules/jquery/dist')));
|
||||
server.use(appPath+'/static/module/angular', express.static(path.join(__dirname,'../node_modules/angular')));
|
||||
server.use(appPath+'/static/module/angular-route', express.static(path.join(__dirname,'../node_modules/angular-route')));
|
||||
server.get(appPath+'/static/spa-client-resources', function (req,res) {res.json({data: {resources: clientResourcesWeb}});});
|
||||
server.get(appPath+'/static/spa-loader.css', function (req,res) {res.sendFile('es5-ff-spa-loader.css', { root: path.join(__dirname, '/../../') });});
|
||||
server.get(appPath+'/', function (req, res) {res.redirect(appPath+'/example-ui');});
|
||||
server.get(appPath+'/example-ui/thtml/*', renderTemplatePath('thtml/'));
|
||||
server.get(appPath+'/example-ui', renderIndex());
|
||||
server.get('/', function (req, res) {res.redirect(appPath);});
|
||||
|
||||
server.listen(httpPort);
|
||||
console.info('Server started on port '+httpPort);
|
||||
|
|
|
|||
|
|
@ -3,17 +3,19 @@
|
|||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Loading</title>
|
||||
<link id="ffCleanupCss" rel="stylesheet" type="text/css" href="/static/spa-loader.css" />
|
||||
<script id="ffCleanupScript"><%- inlineScript %></script>
|
||||
<style id="ffCleanupStyle"><%- inlineStyle %></style>
|
||||
</head>
|
||||
<body>
|
||||
<script id="ffCleanupScript"><%- inlineScript %></script>
|
||||
<script id="ffCleanupConfig">
|
||||
FFSpaLoader.options.debug.enable = true;
|
||||
FFSpaLoader.options.boot.angular.modules.push('exampleUI');
|
||||
FFSpaLoader.options.boot.cleanup.tags.push('ffCleanupCss');
|
||||
FFSpaLoader.options.boot.cleanup.tags.push('ffCleanupStyle');
|
||||
FFSpaLoader.options.boot.cleanup.tags.push('ffCleanupScript');
|
||||
FFSpaLoader.options.boot.cleanup.tags.push('ffCleanupConfig');
|
||||
FFSpaLoader.options.server.url = window.location.href;
|
||||
FFSpaLoader.options.server.assets = '/static/spa-client-resources';
|
||||
FFSpaLoader.options.server.depath = 'example-ui';
|
||||
FFSpaLoader.options.server.header.response['X-My-Api'] = 'noknok';
|
||||
FFSpaLoader.start();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"jquery": "^2.1.4",
|
||||
"jshashes": "^1.0.5",
|
||||
"morgan": "^1.6.1",
|
||||
"minify": "1.4.x",
|
||||
"uglify-js": "^2.6.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue