Skip to content

Commit

Permalink
update packages version, update angular to 1.3 and fix related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yamalight committed Oct 15, 2014
1 parent fc415d3 commit 776a581
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For powder.js to function properly, you'll need to have following things install

Alternatively you can use [vagrant](http://www.vagrantup.com/) environment provided by `powder:vagrant` generator, it includes all the required packages.
Or [docker](https://www.docker.com/) environment provided by `powder:docker` generator.
Please note, both docker and vagrant assume you have server-side in generated project.
Please note, both docker and vagrant assume you have server-side in generated project.
If not, you will have to modify the environments yourself.

### Installation
Expand All @@ -56,7 +56,7 @@ Creates a new powder.js application.
Generates a new server-side mongodb database named *myName* and installs all the needed dependencies in main app.

`$ yo powder:module myName`
Generates a new angular client-side module named *myName* and injects it into main app.
Generates a new angular client-side module named *myName* and injects it into main app.
Module can consists of controller, directive, service and filter. Or just any one of those.

`$ yo powder:model myName`
Expand Down Expand Up @@ -103,7 +103,7 @@ listening on port 8080
### Project Structure
Client:
Client:
- **/client/css/** - CSS files
- **/client/js/app.js** - Client-side javascript app entry point bootstrapper
- **/client/js/bootstrap.js** - Client-side javascript app bootstrapper
Expand All @@ -120,7 +120,7 @@ Client module (can be generated with `powder:module`):
- **/client/MODULE/filter.js** - Client-side app angular filter
- **/client/MODULE/service.js** - Client-side app angular service
Server (optional):
Server (optional):
- **/server/index.js** - Server application entry point
- **/server/app/** - Server application and middleware configuration
- **/server/controllers/** - Server application routes
Expand Down Expand Up @@ -169,7 +169,7 @@ Client-side templates are loaded from the `/client/js/MODULE/templates/` directo
### POST requests
Since Powder.js utilizes CSRF tokens for increased security, to send POST request that will be accepted you need to inclide this token.
To do that you have to pass token from server into your template (or javascript request). The token can be retrieved from `csrf` variable.
To do that you have to pass token from server into your template (or javascript request). The token can be retrieved from `csrf` variable and is by default exposed as `window.csrf`.
Request must contain the token in `_csrf` field.
For example, you can include it in template like this: `<input type="hidden" name="_csrf" value="{csrf}" />`
Expand Down Expand Up @@ -237,7 +237,7 @@ To do so, follow the steps below:
2. Run `docker build -t appname .` to generate new docker container
3. Run `docker run -i -t -p 8080:8080 appname` to launch generated container
Please, note that adding Dockerfile (running `powder:docker`) changes your package.json file and removes post-install directive from it.
Please, note that adding Dockerfile (running `powder:docker`) changes your package.json file and removes post-install directive from it.
It is done to allow docker to cache `npm install` and `bower install` steps so that if you change only your app files, you don't need to wait for these steps again.
### TODO
Expand Down
6 changes: 3 additions & 3 deletions app/templates/client/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "<%= camelizedAppName %>",
"version": "0.0.0",
"dependencies": {
"angular": "~1.2.22",
"angular-route": "~1.2.22",
"angular": "~1.3.0",
"angular-route": "~1.3.0",
"bootstrap": "~3.2.0",
"angular-bootstrap": "~0.11.0"
"angular-bootstrap": "~0.11.2"
}
}
2 changes: 1 addition & 1 deletion app/templates/client/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function configureApp(app) {
]);

// on app run
app.run(function () {
app.run(function() {
// inject all the modules
modules.forEach(function(module) {
module(app);
Expand Down
2 changes: 1 addition & 1 deletion app/templates/client/js/index/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function(app) {
// register route for controller
app.register.route('/', {
templateUrl: 'index/template.html',
templateUrl: '/index/template.html',
controller: require('./controller'),
});
};
2 changes: 1 addition & 1 deletion app/templates/client/js/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function(app) {
app.register.directive('navigation', function navigationDirective() {
return {
restrict: 'E',
templateUrl: 'navigation/template.html',
templateUrl: '/navigation/template.html',
controller: require('./controller'),
};
});
Expand Down
4 changes: 3 additions & 1 deletion app/templates/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ exports.cookieSecret = 'andMeToo';
exports.passwordSalt = 'ThisIsPasswordSalt';

// default app port
exports.defaultHost = 'localhost';
exports.defaultPort = 8080;
<% } %>
exports.baseUrl = 'http://' + exports.defaultHost + ':' + exports.defaultPort + '/';
<% } %>
8 changes: 4 additions & 4 deletions app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"body-parser": "^1.0.2",
"browserify-middleware": "^4.1.0",
"bunyan": "^1.0.0",
"compression": "^1.1.0",
"compression": "^1.1.1",
"consolidate": "^0.10.0",
"cookie-parser": "^1.0.1",
"csurf": "^1.1.0",
"dustjs-helpers": "^1.2.0",
"dustjs-linkedin": "^2.2.8",
"express": "^4.1.1",
"express": "^4.9.7",
"express-session": "^1.0.4",
"helmet": "^0.4.0",
"method-override": "^2.1.3"
Expand All @@ -35,10 +35,10 @@
"gulp-mocha": "^1.1.1",
"gulp-nodemon": "^1.0.2",
"gulp-watch": "^1.1.0",
"request": "^2.40.0",
"request": "^2.45.0",
"should": "^4.0.4",<% if(!addServer) { %>
"uglifyify": "^2.5.0",
"vinyl-source-stream": "^0.1.1",<% } %>
"zombie": "^2.0.0-alpha31"
"zombie": "^2.0.7"
}
}
3 changes: 3 additions & 0 deletions app/templates/server/app/customrender.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ module.exports = function configRender(app) {
if (typeof locals === 'object') {
// pass debug indication
locals.debug = config.debug;
// server url for base
locals.baseUrl = config.baseUrl;
// pass csrf
locals.csrf = req.csrfToken();
}
if (locals === undefined) {
locals = {
debug: config.debug,
csrf: req.csrfToken(),
baseUrl: config.baseUrl,
};
}
render.call(res, view, locals, cb);
Expand Down
6 changes: 6 additions & 0 deletions app/templates/server/views/core/layout.dust
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html ng-app="app">
<head>
<base href="{baseUrl}">
<!-- meta stuff -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
Expand All @@ -23,6 +24,11 @@
<!-- main app script -->
<script src="/dist/app.min.js"></script>

<!-- shared vars -->
<script type="text/javascript">
window.csrf = '{csrf}';
</script>

<!-- include GA -->
{>"helpers/ga.dust"/}
</body>
Expand Down
2 changes: 1 addition & 1 deletion module/templates/directive.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function <%= camelizedName %>Directive() {
return {
restrict: 'E',
templateUrl: '<%= camelizedNameLower %>/directive-template.html',
templateUrl: '/<%= camelizedNameLower %>/directive-template.html',
controller: require('./directive-controller'),
};
};
2 changes: 1 addition & 1 deletion module/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(app) {
<% } %><% if(addController) { %>
// register controller with route
app.register.route('<%= controllerPath %>', {
templateUrl: '<%= camelizedNameLower %>/template.html',
templateUrl: '/<%= camelizedNameLower %>/template.html',
controller: require('./controller'),
});<% } %>
};

0 comments on commit 776a581

Please sign in to comment.