Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html5Mode #38

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ var MeanGenerator = yeoman.generators.Base.extend({
}, {
name: 'appAuthor',
message: 'What is your company/author name?'
}, {
name: 'html5Mode',
message: 'Enable HTML5 mode?',
default: false
}, {
type: 'confirm',
name: 'addArticleExample',
Expand All @@ -54,6 +58,7 @@ var MeanGenerator = yeoman.generators.Base.extend({
this.appDescription = props.appDescription;
this.appKeywords = props.appKeywords;
this.appAuthor = props.appAuthor;
this.html5Mode = props.html5Mode;
this.addArticleExample = props.addArticleExample;

this.slugifiedAppName = this._.slugify(this.appName);
Expand Down
18 changes: 9 additions & 9 deletions app/templates/app/routes/articles.server.routes.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
'use strict';

/**
* Module dependencies.
*/
var users = require('../../app/controllers/users'),
articles = require('../../app/controllers/articles');

module.exports = function(app) {
/**
* Module dependencies.
*/
var users = require('../../app/controllers/users'),
articles = require('../../app/controllers/articles');

// Article Routes
app.route('/articles')
app.route('/api/articles')
.get(articles.list)
.post(users.requiresLogin, articles.create);

app.route('/articles/:articleId')
app.route('/api/articles/:articleId')
.get(articles.read)
.put(users.requiresLogin, articles.hasAuthorization, articles.update)
.delete(users.requiresLogin, articles.hasAuthorization, articles.delete);

// Finish by binding the article middleware
app.param('articleId', articles.articleByID);
};
};
8 changes: 6 additions & 2 deletions app/templates/app/routes/core.server.routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use strict';

module.exports = function(app) {
// Root routing
/**
* Module dependencies.
*/
var core = require('../../app/controllers/core');

// Core Routes
app.route('/').get(core.index);
};
};
8 changes: 4 additions & 4 deletions app/templates/app/routes/users.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ module.exports = function(app) {
var users = require('../../app/controllers/users');

// Setting up the users profile api
app.route('/users/me').get(users.me);
app.route('/users').put(users.update);
app.route('/users/accounts').delete(users.removeOAuthProvider);
app.route('/api/users/me').get(users.me);
app.route('/api/users').put(users.update);
app.route('/api/users/accounts').delete(users.removeOAuthProvider);

// Setting up the users password api
app.route('/users/password').post(users.changePassword);
app.route('/api/users/password').post(users.changePassword);
app.route('/auth/forgot').post(users.forgot);
app.route('/auth/reset/:token').get(users.validateResetToken);
app.route('/auth/reset/:token').post(users.reset);
Expand Down
6 changes: 3 additions & 3 deletions app/templates/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports.getGlobbedFiles = function(globPatterns, removeRoot) {
* Get the modules JavaScript files
*/
module.exports.getJavaScriptAssets = function(includeTests) {
var output = this.getGlobbedFiles(this.assets.lib.js.concat(this.assets.js), 'public/');
var output = this.getGlobbedFiles(this.assets.lib.js.concat(this.assets.js), 'public');

// To include tests
if (includeTests) {
Expand All @@ -71,6 +71,6 @@ module.exports.getJavaScriptAssets = function(includeTests) {
* Get the modules CSS files
*/
module.exports.getCSSAssets = function() {
var output = this.getGlobbedFiles(this.assets.lib.css.concat(this.assets.css), 'public/');
var output = this.getGlobbedFiles(this.assets.lib.css.concat(this.assets.css), 'public');
return output;
};
};
10 changes: 9 additions & 1 deletion app/templates/config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ module.exports = function(db) {
require(path.resolve(routePath))(app);
});

/**
* Module dependencies.
*/
var core = require('../app/controllers/core');

// Catch-all route
app.route('*').get(core.index);

// Assume 'not found' in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc.
app.use(function(err, req, res, next) {
// If the error object doesn't exists
Expand All @@ -141,4 +149,4 @@ module.exports = function(db) {
});

return app;
};
};
7 changes: 5 additions & 2 deletions app/templates/public/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ var ApplicationConfiguration = (function() {
angular.module(applicationModuleName).requires.push(moduleName);
};

var html5Mode = <%= html5Mode %>;

return {
applicationModuleName: applicationModuleName,
applicationModuleVendorDependencies: applicationModuleVendorDependencies,
registerModule: registerModule
registerModule: registerModule,
html5Mode: html5Mode
};
})();
})();
4 changes: 2 additions & 2 deletions app/templates/public/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfig
// Setting HTML5 Location Mode
angular.module(ApplicationConfiguration.applicationModuleName).config(['$locationProvider',
function($locationProvider) {
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode(ApplicationConfiguration.html5Mode).hashPrefix('!');
}
]);

Expand All @@ -17,4 +17,4 @@ angular.element(document).ready(function() {

//Then init the app
angular.bootstrap(document, [ApplicationConfiguration.applicationModuleName]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ angular.module('articles').config(['$stateProvider',
$stateProvider.
state('listArticles', {
url: '/articles',
templateUrl: 'modules/articles/views/list-articles.client.view.html'
templateUrl: '/modules/articles/views/list-articles.client.view.html'
}).
state('createArticle', {
url: '/articles/create',
templateUrl: 'modules/articles/views/create-article.client.view.html'
templateUrl: '/modules/articles/views/create-article.client.view.html'
}).
state('viewArticle', {
url: '/articles/:articleId',
templateUrl: 'modules/articles/views/view-article.client.view.html'
templateUrl: '/modules/articles/views/view-article.client.view.html'
}).
state('editArticle', {
url: '/articles/:articleId/edit',
templateUrl: 'modules/articles/views/edit-article.client.view.html'
templateUrl: '/modules/articles/views/edit-article.client.view.html'
});
}
]);
]);
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
//Articles service used for communicating with the articles REST endpoints
angular.module('articles').factory('Articles', ['$resource',
function($resource) {
return $resource('articles/:articleId', {
return $resource('/api/articles/:articleId', {
articleId: '@_id'
}, {
update: {
method: 'PUT'
}
});
}
]);
]);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1>Articles</h1>
</div>
<div class="list-group">
<a data-ng-repeat="article in articles" data-ng-href="#!/articles/{{article._id}}" class="list-group-item">
<a data-ng-repeat="article in articles" data-ng-href="/#!/articles/{{article._id}}" class="list-group-item">
<small class="list-group-item-text">
Posted on
<span data-ng-bind="article.created | date:'mediumDate'"></span>
Expand All @@ -17,4 +17,4 @@ <h4 class="list-group-item-heading" data-ng-bind="article.title"></h4>
<div class="alert alert-warning text-center" data-ng-if="articles.$resolved && !articles.length">
No articles yet, why don't you <a href="/#!/articles/create">create one</a>?
</div>
</section>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider',
$stateProvider.
state('home', {
url: '/',
templateUrl: 'modules/core/views/home.client.view.html'
templateUrl: '/modules/core/views/home.client.view.html'
});
}
]);
]);
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
</li>
<li class="divider"></li>
<li>
<a href="/auth/signout">Signout</a>
<a href="/auth/signout" target="_self">Signout</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
20 changes: 10 additions & 10 deletions app/templates/public/modules/users/config/users.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ angular.module('users').config(['$stateProvider',
$stateProvider.
state('profile', {
url: '/settings/profile',
templateUrl: 'modules/users/views/settings/edit-profile.client.view.html'
templateUrl: '/modules/users/views/settings/edit-profile.client.view.html'
}).
state('password', {
url: '/settings/password',
templateUrl: 'modules/users/views/settings/change-password.client.view.html'
templateUrl: '/modules/users/views/settings/change-password.client.view.html'
}).
state('accounts', {
url: '/settings/accounts',
templateUrl: 'modules/users/views/settings/social-accounts.client.view.html'
templateUrl: '/modules/users/views/settings/social-accounts.client.view.html'
}).
state('signup', {
url: '/signup',
templateUrl: 'modules/users/views/authentication/signup.client.view.html'
templateUrl: '/modules/users/views/authentication/signup.client.view.html'
}).
state('signin', {
url: '/signin',
templateUrl: 'modules/users/views/authentication/signin.client.view.html'
templateUrl: '/modules/users/views/authentication/signin.client.view.html'
}).
state('forgot', {
url: '/password/forgot',
templateUrl: 'modules/users/views/password/forgot-password.client.view.html'
templateUrl: '/modules/users/views/password/forgot-password.client.view.html'
}).
state('reset-invlaid', {
url: '/password/reset/invalid',
templateUrl: 'modules/users/views/password/reset-password-invalid.client.view.html'
templateUrl: '/modules/users/views/password/reset-password-invalid.client.view.html'
}).
state('reset-success', {
url: '/password/reset/success',
templateUrl: 'modules/users/views/password/reset-password-success.client.view.html'
templateUrl: '/modules/users/views/password/reset-password-success.client.view.html'
}).
state('reset', {
url: '/password/reset/:token',
templateUrl: 'modules/users/views/password/reset-password.client.view.html'
templateUrl: '/modules/users/views/password/reset-password.client.view.html'
});
}
]);
]);
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ angular.module('users').controller('SettingsController', ['$scope', '$http', '$l
$scope.removeUserSocialAccount = function(provider) {
$scope.success = $scope.error = null;

$http.delete('/users/accounts', {
$http.delete('/api/users/accounts', {
params: {
provider: provider
}
Expand Down Expand Up @@ -59,7 +59,7 @@ angular.module('users').controller('SettingsController', ['$scope', '$http', '$l
$scope.changeUserPassword = function() {
$scope.success = $scope.error = null;

$http.post('/users/password', $scope.passwordDetails).success(function(response) {
$http.post('/api/users/password', $scope.passwordDetails).success(function(response) {
// If successful show success message and clear form
$scope.success = true;
$scope.passwordDetails = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// Users service used for communicating with the users REST endpoint
angular.module('users').factory('Users', ['$resource',
function($resource) {
return $resource('users', {}, {
return $resource('/api/users', {}, {
update: {
method: 'PUT'
}
});
}
]);
]);
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<section class="row" data-ng-controller="AuthenticationController">
<h3 class="col-md-12 text-center">Sign in using your social accounts</h3>
<div class="col-md-12 text-center">
<a href="/auth/facebook" class="undecorated-link">
<a href="/auth/facebook" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/facebook.png">
</a>
<a href="/auth/twitter" class="undecorated-link">
<a href="/auth/twitter" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/twitter.png">
</a>
<a href="/auth/google" class="undecorated-link">
<a href="/auth/google" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/google.png">
</a>
<a href="/auth/linkedin" class="undecorated-link">
<a href="/auth/linkedin" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/linkedin.png">
</a>
<a href="/auth/github" class="undecorated-link">
<a href="/auth/github" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/github.png">
</a>
</div>
Expand Down Expand Up @@ -42,4 +42,4 @@ <h3 class="col-md-12 text-center">Or with your account</h3>
</fieldset>
</form>
</div>
</section>
</section>
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<section class="row" data-ng-controller="AuthenticationController">
<h3 class="col-md-12 text-center">Sign up using your social accounts</h3>
<div class="col-md-12 text-center">
<a href="/auth/facebook" class="undecorated-link">
<a href="/auth/facebook" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/facebook.png">
</a>
<a href="/auth/twitter" class="undecorated-link">
<a href="/auth/twitter" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/twitter.png">
</a>
<a href="/auth/google" class="undecorated-link">
<a href="/auth/google" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/google.png">
</a>
<a href="/auth/linkedin" class="undecorated-link">
<a href="/auth/linkedin" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/linkedin.png">
</a>
<a href="/auth/github" class="undecorated-link">
<a href="/auth/github" class="undecorated-link" target="_self">
<img src="/modules/users/img/buttons/github.png">
</a>
</div>
Expand Down Expand Up @@ -51,4 +51,4 @@ <h3 class="col-md-12 text-center">Or with your email</h3>
</fieldset>
</form>
</div>
</section>
</section>
Loading