From 74d70c9b306120069f8e1d5501bf6a636befc6f9 Mon Sep 17 00:00:00 2001 From: fazo96 Date: Fri, 14 Nov 2014 08:46:04 +0100 Subject: [PATCH] upgraded to meteor 1.0 and iron router 1.0 --- .meteor/release | 2 +- .meteor/versions | 57 ++++++++++-------- client/client.coffee | 140 +++++++++++++++++++++++-------------------- 3 files changed, 106 insertions(+), 93 deletions(-) diff --git a/.meteor/release b/.meteor/release index 7057f80..87bf495 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@0.9.4 +METEOR@1.0 diff --git a/.meteor/versions b/.meteor/versions index 03f4840..8b252e9 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,20 +1,20 @@ accounts-base@1.1.2 accounts-oauth@1.1.2 -accounts-password@1.0.3 +accounts-password@1.0.4 accounts-twitter@1.0.2 application-configuration@1.0.3 -autoupdate@1.1.2 +autoupdate@1.1.3 base64@1.0.1 binary-heap@1.0.1 blaze-tools@1.0.1 -blaze@2.0.2 +blaze@2.0.3 boilerplate-generator@1.0.1 callback-hook@1.0.1 check@1.0.2 coffeescript@1.0.4 ctl-helper@1.0.4 ctl@1.0.2 -ddp@1.0.10 +ddp@1.0.11 deps@1.0.5 ejson@1.0.4 email@1.0.4 @@ -23,31 +23,36 @@ follower-livedata@1.0.2 geojson-utils@1.0.1 html-tools@1.0.2 htmljs@1.0.2 -http@1.0.7 +http@1.0.8 id-map@1.0.1 -iron:core@0.3.4 -iron:dynamic-template@0.4.1 -iron:layout@0.4.1 -iron:router@0.9.4 +iron:controller@1.0.0 +iron:core@1.0.0 +iron:dynamic-template@1.0.0 +iron:layout@1.0.0 +iron:location@1.0.1 +iron:middleware-stack@1.0.0 +iron:router@1.0.1 +iron:url@1.0.0 jquery@1.0.1 json@1.0.1 -kevohagan:sweetalert@0.0.1 -less@1.0.10 +kevohagan:sweetalert@0.3.1 +launch-screen@1.0.0 +less@1.0.11 livedata@1.0.11 localstorage@1.0.1 -logging@1.0.4 -meteor-platform@1.1.2 -meteor@1.1.2 -minifiers@1.1.1 -minimongo@1.0.4 -mizzao:bootstrap-3@3.2.0_1 +logging@1.0.5 +meteor-platform@1.2.0 +meteor@1.1.3 +minifiers@1.1.2 +minimongo@1.0.5 +mizzao:bootstrap-3@3.3.0 mobile-status-bar@1.0.1 -mongo@1.0.7 +mongo@1.0.8 mrt:moment@2.8.1 natestrauser:font-awesome@4.2.0 npm-bcrypt@0.7.7 -oauth1@1.1.1 -oauth@1.1.1 +oauth1@1.1.2 +oauth@1.1.2 observe-sequence@1.0.3 ordered-dict@1.0.1 perak:markdown@1.0.4 @@ -58,17 +63,17 @@ reload@1.1.1 retry@1.0.1 routepolicy@1.0.2 service-configuration@1.0.2 -session@1.0.3 +session@1.0.4 sha@1.0.1 spacebars-compiler@1.0.3 spacebars@1.0.3 -spiderable@1.0.4 +spiderable@1.0.5 srp@1.0.1 -templating@1.0.8 +templating@1.0.9 tracker@1.0.3 -twitter@1.1.1 +twitter@1.1.2 ui@1.0.4 underscore@1.0.1 -url@1.0.1 +url@1.0.2 webapp-hashing@1.0.1 -webapp@1.1.3 +webapp@1.1.4 diff --git a/client/client.coffee b/client/client.coffee index 553e26c..c8a79e8 100644 --- a/client/client.coffee +++ b/client/client.coffee @@ -27,57 +27,63 @@ docController = RouteController.extend loggedOutController = RouteController.extend onBeforeAction: -> if Meteor.user() then Router.go 'profile', user: Meteor.user().username + @next() action: -> @render() if Meteor.loggingIn() then @render 'spinner', to: 'outside' loggedInController = RouteController.extend action: -> if !Meteor.user() then @render '404' else @render() -Router.map -> - @route 'home', - path: '/' - action: -> - if !@ready() then @render 'spinner', to: 'outside' - @render() - @route 'doc', - path: '/d/:_id' - controller: docController - @route 'userDoc', - path: '/@:user/:_id' - controller: docController - @route 'src', - path:'/src/:_id' - controller: docController - @route 'verify', - path: '/verify/:token?' - template: 'loading' - onBeforeAction: -> - Accounts.verifyEmail @params.token, (err) -> - if err then errCallback err - else Router.go 'profile', user: Meteor.user().username - @route 'edit', - path: '/edit/:_id' - template: 'editor' - controller: loggedInController - waitOn: -> Meteor.subscribe 'doc', @params._id - data: -> docs.findOne @params._id - @route 'profile', - path: '/@:user' - waitOn: -> - [Meteor.subscribe('docs', @params.user), - Meteor.subscribe('user', @params.user)] - data: -> Meteor.users.findOne username: @params.user - action: -> - if Meteor.loggingIn() then @render 'loading' - else if @ready() - if !@data() then @render '404' else @render() - else @render 'loading' - @route 'new', template: 'editor' - @route 'signup', controller: loggedOutController - @route 'signin', - path: 'login' - controller: loggedOutController - @route '404', path: '*' +Router.route '/', + name: 'home' + action: -> + if !@ready() then @render 'spinner', to: 'outside' + @render('home') +Router.route '/d/:_id', + name: 'doc' + controller: docController +Router.route '/@:user/:_id', + name: 'userDoc' + controller: docController +Router.route '/src/:_id', + name: 'src' + controller: docController +Router.route '/verify/:token?', + name: 'verify' + template: 'loading' + onBeforeAction: -> + Accounts.verifyEmail @params.token, (err) -> + if err then errCallback err + else Router.go 'profile', user: Meteor.user().username + @next() +Router.route '/edit/:_id', + name: 'edit' + template: 'editor' + controller: loggedInController + waitOn: -> Meteor.subscribe 'doc', @params._id + data: -> docs.findOne @params._id +Router.route '/@:user', + name: 'profile' + waitOn: -> + [Meteor.subscribe('docs', @params.user), + Meteor.subscribe('user', @params.user)] + data: -> Meteor.users.findOne username: @params.user + action: -> + if Meteor.loggingIn() then @render 'loading' + else if @ready() + if !@data() then @render '404' else @render() + else @render 'loading' +Router.route '/new', + name: 'new' + template: 'editor' +Router.route '/signup', + name: 'signup' + controller: loggedOutController +Router.route '/login', + name: 'signin' + template: 'signin' + controller: loggedOutController +Router.route '/(.*)', name: '404' share.notify = notify = (opt) -> if opt.type? then type = opt.type @@ -92,8 +98,10 @@ errCallback = (err) -> notify title: err.code or 'Error', msg: err.reason, type: 'error' else notify title: 'Error', msg: err, type: 'error' -Template.magicIcon.notHome = -> Router.current().route.name isnt 'home' -Template.layout.showSpinner = -> Meteor.status().connected is yes +Template.magicIcon.helpers + notHome: -> Router.current().route.getName() isnt 'home' +Template.layout.helpers + showSpinner: -> Meteor.status().connected is yes Template.home.events 'click #twitter-login': -> if Meteor.user() then return notify msg: "You're already Logged In!" @@ -102,8 +110,9 @@ Template.home.events else Meteor.subscribe 'user' notify type: 'success', msg: 'Logged in' -Template.editor.isPublic = -> return "checked" if @public is yes -Template.editor.showTitleChecked = -> return "checked" unless @showTitle is no +Template.editor.helpers + isPublic: -> return "checked" if @public is yes + showTitleChecked: -> return "checked" unless @showTitle is no Template.editor.events 'click #upload': (e,t) -> if Meteor.loggingIn() @@ -133,11 +142,10 @@ Template.editor.events else notify type:'success', msg:'Document created successfully!' if id then Router.go 'doc', _id: id -Template.profile.isMe = -> - Meteor.user() and Meteor.user()._id is @_id -Template.profile.noDocs = -> docs.find(owner: @_id).count() is 0 -Template.profile.documents = -> - docs.find {owner: @_id}, sort: dateCreated: -1 +Template.profile.helpers + isMe: -> Meteor.user() and Meteor.user()._id is @_id + noDocs: -> docs.find(owner: @_id).count() is 0 + documents: -> docs.find {owner: @_id}, sort: dateCreated: -1 Template.profile.events 'click #resend': -> Meteor.call 'sendVerificationEmail', (e,r) -> @@ -155,17 +163,17 @@ Template.profile.events if e then errCallback e else notify type: 'success', msg: 'Account deleted' -Template.doc.valid = -> @text? -Template.doc.source = -> Router.current().route.name is 'src' -Template.doc.rows = -> ""+@text.split('\n').length -Template.doc.owned = -> Meteor.user() and Meteor.user()._id is @owner -Template.doc.privateUrl = -> -Template.doc.ownerName = -> - if Router.current().route.name is 'userDoc' - return Router.current().params.user -Template.doc.expirationDays = -> - if @owner then return 'never' - else return moment.unix(@dateCreated).add(7,'days').fromNow() +Template.doc.helpers + valid: -> @text? + source: -> Router.current().route.getName() is 'src' + rows: -> ""+@text.split('\n').length + owned: -> Meteor.user() and Meteor.user()._id is @owner + ownerName: -> + if Router.current().route.getName() is 'userDoc' + return Router.current().params.user + expirationDays: -> + if @owner then return 'never' + else return moment.unix(@dateCreated).add(7,'days').fromNow() Template.doc.events 'click #edit-doc': -> Router.go 'edit', _id: @_id 'click #del-doc': -> @@ -181,7 +189,7 @@ Template.doc.events if err then errCallback err else notify type:'success', msg:'Document removed' 'click #src-doc': -> - if Router.current().route.name is 'src' + if Router.current().route.getName() is 'src' Router.go 'doc', _id: @_id else Router.go 'src', _id: @_id