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 = '
Welcome to the bar.
Chair | Person | Drinking |
---|---|---|
seat 1 | empty | none |
seat 2 | you | coffee |
seat 3 | cat | water |
Welcome to the foo.
{{message}}
'; - pageRouteInit.push(function ($routeProvider, $locationProvider) { + var tpl = 'Welcome to the foo.
{{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 @@ -Welcome to the bar.
Chair | Person | Drinking |
---|---|---|
seat 1 | empty | none |
seat 2 | you | coffee |
seat 3 | cat | water |