diff --git a/.meteor/packages b/.meteor/packages index ea2dfba..cb790e7 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -11,4 +11,7 @@ accounts-password iron:router mrt:moment mizzao:bootstrap-3 +spiderable +kevohagan:sweetalert +accounts-twitter diff --git a/.meteor/versions b/.meteor/versions index f6518ee..5b3b842 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,5 +1,7 @@ accounts-base@1.1.1 +accounts-oauth@1.1.1 accounts-password@1.0.2 +accounts-twitter@1.0.1 application-configuration@1.0.2 autoupdate@1.1.1 base64@1.0.0 @@ -29,6 +31,7 @@ iron:layout@0.4.1 iron:router@0.9.4 jquery@1.0.0 json@1.0.0 +kevohagan:sweetalert@0.0.1 livedata@1.0.10 localstorage@1.0.0 logging@1.0.3 @@ -42,6 +45,8 @@ mongo@1.0.6 mrt:moment@2.8.1 natestrauser:font-awesome@4.2.0 npm-bcrypt@0.7.7 +oauth1@1.1.0 +oauth@1.1.0 observe-sequence@1.0.2 ordered-dict@1.0.0 random@1.0.0 @@ -55,10 +60,12 @@ session@1.0.2 sha@1.0.0 spacebars-compiler@1.0.2 spacebars@1.0.2 +spiderable@1.0.3 srp@1.0.0 standard-app-packages@1.0.2 templating@1.0.7 tracker@1.0.2 +twitter@1.1.0 ui@1.0.3 underscore@1.0.0 url@1.0.0 diff --git a/README.md b/README.md index de7f82a..9fbba55 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,19 @@ In the mails sent by Homework, the website links point to the `ROOT_URL` environment variable as [explained on the Meteor docs](http://docs.meteor.com/#meteor_absoluteurl). +#### Twitter Authentication + +Create this file: `server/settings.coffee` with this content: + +```coffeescript +Meteor.startup -> + Accounts.loginServiceConfiguration.remove service : 'twitter' + Accounts.loginServiceConfiguration.insert + service: 'twitter' + consumerKey: 'Your API key' + secret: 'Your API secret' +``` + ### License The MIT License (MIT) diff --git a/client/client.coffee b/client/client.coffee index d425ab6..84ea7b4 100644 --- a/client/client.coffee +++ b/client/client.coffee @@ -1,5 +1,5 @@ # Homework - Client Side -version = "1.1.4" +version = "1.1.5" # Utilities tick = new Deps.Dependency() Meteor.setInterval (-> tick.changed();), 15000 @@ -8,9 +8,17 @@ notes = new Meteor.Collection "notes" userSub = Meteor.subscribe 'user' getUser = -> Meteor.user() deleteAccount = -> - Meteor.call 'deleteMe', (r) -> if r is yes then Router.go 'home' + swal { + title: 'Are you sure?' + text: 'Do you want to permanently delete all your data?' + type: 'warning' + showCancelButton: yes + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes!" + }, -> Meteor.call 'deleteMe', (r) -> if r is yes then Router.go 'home' amIValid = -> return no unless getUser() + return yes if getUser().username return yes for mail in getUser().emails when mail.verified is yes; no # Common Helpers for the Templates @@ -18,7 +26,9 @@ UI.registerHelper "version", -> version UI.registerHelper "status", -> Meteor.status() UI.registerHelper "loading", -> Meteor.loggingIn() or !Meteor.status().connected UI.registerHelper "email", -> - if getUser() then return getUser().emails[0].address + if getUser() + if getUser().username then return getUser().username + else return getUser().emails[0].address UI.registerHelper "verified", -> amIValid() Meteor.startup -> @@ -115,13 +125,18 @@ Router.map -> # Some utility callbacks logoutCallback = (err) -> - if err then errCallback err - else Router.go 'home'; Meteor.unsubscribe "my-notes" + if err then errCallback err else Router.go 'home' errCallback = (err) -> if err.reason showError msg: err.reason else showErrror msg: err +Template.homepage.events + 'click #twitter': -> Meteor.loginWithTwitter (e) -> + if e? then errCallback e + else + Router.go 'notes' + swal 'Ok', 'Logged In', 'success' Template.reconnect.time = -> tick.depend() if Meteor.status().retryTime @@ -134,7 +149,7 @@ Template.menu.events 'click .go-archive': -> Router.go 'archive' # Account Page -Template.account.dateformat = -> getUser().dateformat +Template.account.dateformat = -> if getUser() then return getUser().dateformat Template.account.events 'click #reset-settings': (e,t) -> t.find('#set-date-format').value = "MM/DD/YYYY" @@ -211,34 +226,14 @@ Template.editor.events t.find('.date').value = moment().add(1,'days').format(getUser().dateformat) 'keypress .title': (e,t) -> saveCurrentNote t, e -# Notifications (not used yet) -alerts = [] -alertDep = new Deps.Dependency -# Show a notification -notify = (data) -> - alerts.push - title: data.title - msg: data.msg - type: data.type or "danger" - alertDep.changed() -# Clear all notifications -clearNotifications = -> alerts.clear(); alertDep.changed() -# Get all the notifications -Template.notifications.notification = -> alertDep.depend(); alerts -Template.notifications.events - 'click .close-notification': (e,template) -> - alerts.splice alerts.indexOf(this), 1 - alertDep.changed() - # "Error" visualization template -errorDep = new Deps.Dependency; shownError = undefined showError = (err) -> - if err? - shownError = err; shownError.type = err.type or "danger" - else shownError = undefined - errorDep.changed() -Template.error.error = -> errorDep.depend(); shownError -Template.error.events 'click .close': -> showError() + return unless err? + type = err.type or 'error' + if !err.title? + title = if type is 'error' then 'Error' else 'Ok' + else title = err.title + swal title, err.msg, type # Verify Email page Template.verifyEmail.token = -> Router.current().params.token diff --git a/client/view/style.css b/client/view/style.css index d1df5e7..3507219 100644 --- a/client/view/style.css +++ b/client/view/style.css @@ -5,6 +5,10 @@ input { max-width: 400px; } +#twitter { + margin-bottom: 1em; +} + .page-header { text-align: center; } diff --git a/client/view/templates.html b/client/view/templates.html index e1fd49e..04dd294 100644 --- a/client/view/templates.html +++ b/client/view/templates.html @@ -17,8 +17,8 @@ - - + +