diff --git a/client/client.coffee b/client/client.coffee index 0f118f6..7112808 100644 --- a/client/client.coffee +++ b/client/client.coffee @@ -30,6 +30,17 @@ Router.configure layoutTemplate: 'layout' loadingTemplate: 'loading' notFoundTemplate: '404' + +loggedInController = RouteController.extend + action: -> if @ready then @render() else @render 'loading' + onBeforeAction: -> + if not getUser() then Router.go 'home' + if not amIValid() then Router.go 'verifyEmail' +guestController = RouteController.extend + onBeforeAction: -> + if getUser() + if not amIValid() then Router.go 'verifyEmail' else Router.go 'home' + Router.map -> @route 'home', path: '/' @@ -39,29 +50,29 @@ Router.map -> # Dispatch user to the right landing page based on his account status if getUser() if amIValid() is yes then Router.go 'notes' else Router.go 'verifyEmail' - @route 'login', - onBeforeAction: -> Router.go 'home' if getUser() - @route 'register', - onBeforeAction: -> Router.go 'home' if getUser() - @route 'account', - onBeforeAction: -> if not getUser() then Router.go 'home' + @route 'login', controller: guestController + @route 'register', controller: guestController + @route 'account', controller: loggedInController @route 'notes', path: '/notes/:_id?' - waitOn: -> Meteor.subscribe "my-notes" + waitOn: -> Meteor.subscribe 'my-notes' data: -> notes.findOne _id: @params._id - onBeforeAction: -> if not getUser() then Router.go 'home' + controller: loggedInController @route 'archive', path: '/archive/:_id?' - waitOn: -> Meteor.subscribe "archive" - onBeforeAction: -> if not getUser() then Router.go 'home' + waitOn: -> @notes = Meteor.subscribe 'archive' + onStop: -> @notes.stop() + controller: loggedInController @route 'verifyEmail', path: '/verify/:token?' template: 'verifyEmail' onBeforeAction: -> + # Automatic verification if @params.token? and @params.token isnt "" + @render 'loading' Accounts.verifyEmail @params.token, (err) -> if err - errCallback err; Router.go 'verifyEmail' + errCallback err; Router.go 'verifyEmail', token: @params.token else Router.go 'home' @route 'homepage', action: -> @render '404' @route '404', path: '*' @@ -185,6 +196,7 @@ Template.error.error = -> errorDep.depend(); shownError Template.error.events 'click .close': -> clearError() # Verify Email page +Template.verifyEmail.token = -> Router.current().params.token Template.verifyEmail.events 'click #btn-verify': (e,template) -> t = template.find('#token-field').value; t = t.split("/") diff --git a/client/view/style.css b/client/view/style.css index 36be0c7..fb14007 100644 --- a/client/view/style.css +++ b/client/view/style.css @@ -54,6 +54,13 @@ input { margin-top: -2px; clear:both; } + +@media (max-width: 442px) { + .archive-close-note { + margin-top: -25px; + } +} + .note-date{ float:right; margin-top: -17px; @@ -73,7 +80,6 @@ input { .edit-note { display: inline-block; - float: left; margin-right: 10px; } diff --git a/client/view/templates.html b/client/view/templates.html index d64d21f..36a34ef 100644 --- a/client/view/templates.html +++ b/client/view/templates.html @@ -62,7 +62,7 @@ {{title}} {{content}} - {{/each}} @@ -90,7 +90,7 @@
- +
@@ -162,7 +162,7 @@ Please verify your Email Address
{{email}}

Click the link inside the email we sent you or paste it here:

{{> error}} - +