summaryrefslogtreecommitdiffstats
path: root/client/config
diff options
context:
space:
mode:
Diffstat (limited to 'client/config')
-rw-r--r--client/config/accounts.js13
-rw-r--r--client/config/router.js97
2 files changed, 64 insertions, 46 deletions
diff --git a/client/config/accounts.js b/client/config/accounts.js
index e12dd8bc..3852e580 100644
--- a/client/config/accounts.js
+++ b/client/config/accounts.js
@@ -9,20 +9,25 @@ AccountsTemplates.addFields([{
}, emailField, passwordField]);
AccountsTemplates.configure({
+ defaultLayout: 'userFormsLayout',
+ defaultContentRegion: 'content',
confirmPassword: false,
enablePasswordChange: true,
sendVerificationEmail: true,
showForgotPasswordLink: true,
onLogoutHook: function() {
- Router.go('Home');
+ var homePage = 'home';
+ if (FlowRouter.getRouteName() === homePage) {
+ FlowRouter.reload();
+ } else {
+ FlowRouter.go(homePage);
+ }
}
});
_.each(['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'],
function(routeName) {
- AccountsTemplates.configureRoute(routeName, {
- layoutTemplate: 'userFormsLayout'
- });
+ AccountsTemplates.configureRoute(routeName);
});
// We display the form to change the password in a popup window that already
diff --git a/client/config/router.js b/client/config/router.js
index 97871e23..e251aea0 100644
--- a/client/config/router.js
+++ b/client/config/router.js
@@ -1,44 +1,57 @@
-// XXX Switch to Flow-Router?
-var previousRoute;
-
-Router.configure({
- loadingTemplate: 'spinner',
- notFoundTemplate: 'notfound',
- layoutTemplate: 'defaultLayout',
-
- onBeforeAction: function() {
- var options = this.route.options;
-
- var loggedIn = Tracker.nonreactive(function() {
- return !! Meteor.userId();
- });
-
- // Redirect logged in users to Boards view when they try to open Login or
- // signup views.
- if (loggedIn && options.redirectLoggedInUsers) {
- return this.redirect('Boards');
- }
-
- // Authenticated
- if (! loggedIn && options.authenticated) {
- return this.redirect('atSignIn');
- }
-
- // We want to execute our EscapeActions.executeUpTo method any time the
- // route is changed, but not if the stays the same but only the parameters
- // change (eg when a user is navigation from a card A to a card B). Iron-
- // Router onBeforeAction is a reactive context (which is a bad desig choice
- // as explained in
- // https://github.com/meteorhacks/flow-router#routercurrent-is-evil) so we
- // need to use Tracker.nonreactive
- Tracker.nonreactive(function() {
- if (! options.noEscapeActions &&
- ! (previousRoute && previousRoute.options.noEscapeActions))
- EscapeActions.executeAll();
- });
-
- previousRoute = this.route;
-
- this.next();
+FlowRouter.route('/', {
+ name: 'home',
+ triggersEnter: [AccountsTemplates.ensureSignedIn],
+ action: function() {
+ EscapeActions.executeAll();
+ Filter.reset();
+
+ Session.set('currentBoard', '');
+
+ BlazeLayout.render('defaultLayout', { content: 'boardList' });
+ }
+});
+
+FlowRouter.route('/b/:id/:slug', {
+ name: 'board',
+ action: function(params) {
+ EscapeActions.executeAll();
+
+ Session.set('currentBoard', params.id);
+ Session.set('currentCard', null);
+
+ BlazeLayout.render('defaultLayout', { content: 'board' });
+ }
+});
+
+FlowRouter.route('/b/:boardId/:slug/:cardId', {
+ name: 'card',
+ action: function(params) {
+ Session.set('currentBoard', params.boardId);
+ Session.set('currentCard', params.cardId);
+ EscapeActions.executeUpTo('popup');
+
+ BlazeLayout.render('defaultLayout', { content: 'board' });
+ }
+});
+
+FlowRouter.notFound = {
+ action: function() {
+ BlazeLayout.render('defaultLayout', { content: 'notFound' });
}
+}
+
+// We maintain a list of redirections to ensure that we don't break old URLs
+// when we change our routing scheme.
+var redirections = {
+ '/boards': '/',
+ '/boards/:id/:slug': '/b/:id/:slug',
+ '/boards/:id/:slug/:cardId': '/b/:id/:slug/:cardId'
+};
+
+_.each(redirections, function(newPath, oldPath) {
+ FlowRouter.route(oldPath, {
+ triggersEnter: [function(context, redirect) {
+ redirect(FlowRouter.path(newPath, context.params));
+ }]
+ });
});