diff --git a/README.md b/README.md index ca6e69a..d025ed0 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,7 @@ Add unit tests for any new or changed functionality. Lint and test your code. * Added options.boot.error.[enable|title]. * start(cb) function callback now includes error. * Moved options.debug.* to options.boot.debug.*. +* Fixed example offline use. (safe page as(html only)) ### 0.2.1 * Fixed clearCache method to added json header. diff --git a/example/app_server/example.js b/example/app_server/example.js index e20eec3..5955f25 100644 --- a/example/app_server/example.js +++ b/example/app_server/example.js @@ -70,23 +70,12 @@ var createClientResourceFetchList = function() { return fetchList; }; -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 renderIndex() { return function (req, res) { var inlineScript = UglifyJS.minify(__dirname+'/../../es5-ff-spa-loader.js'); minify(__dirname+'/../../es5-ff-spa-loader.css', {}, function(err, data) { res.render('index', { - inlineScript: 'console.log(\'test\');'+inlineScript.code, + inlineScript: inlineScript.code, inlineStyle: data }); }); @@ -122,7 +111,6 @@ server.use(appPath+'/static/module/angular-route', express.static(path.join(__di 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);}); diff --git a/example/app_server/www_static/js/controller/page-bar.js b/example/app_server/www_static/js/controller/page-bar.js index bee4ac8..781be3f 100644 --- a/example/app_server/www_static/js/controller/page-bar.js +++ b/example/app_server/www_static/js/controller/page-bar.js @@ -1,7 +1,14 @@ pageRouteInit.push(function ($routeProvider, $locationProvider) { + var tpl = '

Bar

Welcome to the bar.

'; + tpl += ''; + tpl += ''; + tpl += ''; + tpl += ''; + tpl += ''; + tpl += '
ChairPersonDrinking
seat 1emptynone
seat 2youcoffee
seat 3catwater
'; $routeProvider.when('/example-ui/bar', { - templateUrl: window.serverUrl+'/example-ui/thtml/bar', + template: tpl, controller: PageFoo }); }); diff --git a/example/app_server/www_static/js/controller/page-foo.js b/example/app_server/www_static/js/controller/page-foo.js index a30d182..ab0f96d 100644 --- a/example/app_server/www_static/js/controller/page-foo.js +++ b/example/app_server/www_static/js/controller/page-foo.js @@ -1,11 +1,10 @@ -var tpl = '

Foo

Welcome to the foo.

'; -tpl += ''; -tpl += ''; -tpl += ''; -tpl += '

{{message}}

'; - pageRouteInit.push(function ($routeProvider, $locationProvider) { + var tpl = '

Foo

Welcome to the foo.

'; + tpl += ''; + tpl += ''; + tpl += ''; + tpl += '

{{message}}

'; $routeProvider.when('/example-ui/foo', { template: tpl, controller: PageFoo diff --git a/example/app_server/www_static/js/example-app.js b/example/app_server/www_static/js/example-app.js index 3934085..9c89acd 100644 --- a/example/app_server/www_static/js/example-app.js +++ b/example/app_server/www_static/js/example-app.js @@ -12,14 +12,35 @@ console.log('FFExample provided serverUrl \"'+serverUrl+'\"'); // }); //}); + +var moduleTpl = angular.module('app-tpl', []); +moduleTpl.run(["$templateCache", function($templateCache) { + var tpl = ''; + tpl += '\n'; + $templateCache.put('/example-ui/thtml/header', tpl); + $templateCache.put('/example-ui/thtml/footer', '\n'); +}]); + $(document.createElement('div')).attr('id', 'wrapper').appendTo($('body')); -$(document.createElement('div')).attr('ng-controller', 'ApplicationController').attr('ng-include', '\''+serverUrl+'/example-ui/thtml/header\'').appendTo($('#wrapper')); +$(document.createElement('div')).attr('ng-controller', 'ApplicationController').attr('ng-include', '\'/example-ui/thtml/header\'').appendTo($('#wrapper')); $(document.createElement('div')).attr('id', 'page-wrapper').appendTo($('#wrapper')); $(document.createElement('div')).attr('id', 'container-fluid').attr('ng-view', '').appendTo($('#page-wrapper')); -$(document.createElement('div')).attr('ng-include', '\''+serverUrl+'/example-ui/thtml/footer\'').appendTo($('body')); +$(document.createElement('div')).attr('ng-include', '\'/example-ui/thtml/footer\'').appendTo($('body')); var pageRouteInit = []; -var exampleUI = angular.module('exampleUI', ['ngRoute']).config( +var exampleUI = angular.module('exampleUI', ['app-tpl','ngRoute']).config( ['$routeProvider','$locationProvider','$sceDelegateProvider', function ($routeProvider , $locationProvider , $sceDelegateProvider) { pageRouteInit.forEach(function(init) { init($routeProvider, $locationProvider); }); diff --git a/example/app_server/www_views/thtml/bar.ejs b/example/app_server/www_views/thtml/bar.ejs deleted file mode 100644 index 8609501..0000000 --- a/example/app_server/www_views/thtml/bar.ejs +++ /dev/null @@ -1,7 +0,0 @@ -

Bar

Welcome to the bar.

- - - - - -
ChairPersonDrinking
seat 1emptynone
seat 2youcoffee
seat 3catwater
\ No newline at end of file diff --git a/example/app_server/www_views/thtml/footer.ejs b/example/app_server/www_views/thtml/footer.ejs deleted file mode 100644 index 3ff644a..0000000 --- a/example/app_server/www_views/thtml/footer.ejs +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/example/app_server/www_views/thtml/header.ejs b/example/app_server/www_views/thtml/header.ejs deleted file mode 100644 index dfccf11..0000000 --- a/example/app_server/www_views/thtml/header.ejs +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/package.json b/package.json index 41ad7a2..21de307 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "es5-ff-spa-loader", - "version": "0.2.1", + "version": "0.3.0", "description": "Javascript Single Page Application Loader", "main": "es5-ff-spa-loader.js", "scripts": {