Commit f6b57621a1f302d5da77e82b469cc31b2fe149ef

Authored by Ryan Glover
Exists in master

Merge branch 'refactor/convert_to_javascript'

1 # Meteor packages used by this project, one per line. 1 # Meteor packages used by this project, one per line.
2 # 2 #
3 # 'meteor add' and 'meteor remove' will edit this file for you, 3 # 'meteor add' and 'meteor remove' will edit this file for you,
4 # but you can also edit it by hand. 4 # but you can also edit it by hand.
5 5
6 standard-app-packages 6 standard-app-packages
7 coffeescript
8 underscore 7 underscore
9 accounts-password 8 accounts-password
10 accounts-base 9 accounts-base
11 jquery 10 jquery
12 check 11 check
13 audit-argument-checks 12 audit-argument-checks
14 iron:router 13 iron:router
15 pinglamb:bootstrap3 14 pinglamb:bootstrap3
16 cmather:handlebars-server 15 cmather:handlebars-server
17 themeteorchef:jquery-validation 16 themeteorchef:jquery-validation
18 particle4dev:sass@0.3.0 17 particle4dev:sass@0.3.0
19
20 18
1 accounts-base@1.1.2 1 accounts-base@1.1.2
2 accounts-password@1.0.4 2 accounts-password@1.0.4
3 application-configuration@1.0.3 3 application-configuration@1.0.3
4 audit-argument-checks@1.0.1 4 audit-argument-checks@1.0.1
5 autoupdate@1.1.3 5 autoupdate@1.1.3
6 base64@1.0.1 6 base64@1.0.1
7 binary-heap@1.0.1 7 binary-heap@1.0.1
8 blaze-tools@1.0.1 8 blaze-tools@1.0.1
9 blaze@2.0.3 9 blaze@2.0.3
10 boilerplate-generator@1.0.1 10 boilerplate-generator@1.0.1
11 callback-hook@1.0.1 11 callback-hook@1.0.1
12 check@1.0.2 12 check@1.0.2
13 cmather:handlebars-server@2.0.0 13 cmather:handlebars-server@2.0.0
14 coffeescript@1.0.4
15 ctl-helper@1.0.4 14 ctl-helper@1.0.4
16 ctl@1.0.2 15 ctl@1.0.2
17 ddp@1.0.11 16 ddp@1.0.11
18 deps@1.0.5 17 deps@1.0.5
19 ejson@1.0.4 18 ejson@1.0.4
20 email@1.0.4 19 email@1.0.4
21 fastclick@1.0.1 20 fastclick@1.0.1
22 follower-livedata@1.0.2 21 follower-livedata@1.0.2
23 geojson-utils@1.0.1 22 geojson-utils@1.0.1
24 handlebars@1.0.1 23 handlebars@1.0.1
25 html-tools@1.0.2 24 html-tools@1.0.2
26 htmljs@1.0.2 25 htmljs@1.0.2
27 http@1.0.8 26 http@1.0.8
28 id-map@1.0.1 27 id-map@1.0.1
29 iron:controller@1.0.3 28 iron:controller@1.0.3
30 iron:core@1.0.3 29 iron:core@1.0.3
31 iron:dynamic-template@1.0.3 30 iron:dynamic-template@1.0.3
32 iron:layout@1.0.3 31 iron:layout@1.0.3
33 iron:location@1.0.3 32 iron:location@1.0.3
34 iron:middleware-stack@1.0.3 33 iron:middleware-stack@1.0.3
35 iron:router@1.0.3 34 iron:router@1.0.3
36 iron:url@1.0.3 35 iron:url@1.0.3
37 jquery@1.0.1 36 jquery@1.0.1
38 json@1.0.1 37 json@1.0.1
39 launch-screen@1.0.0 38 launch-screen@1.0.0
40 livedata@1.0.11 39 livedata@1.0.11
41 localstorage@1.0.1 40 localstorage@1.0.1
42 logging@1.0.5 41 logging@1.0.5
43 meteor-platform@1.2.0 42 meteor-platform@1.2.0
44 meteor@1.1.3 43 meteor@1.1.3
45 minifiers@1.1.2 44 minifiers@1.1.2
46 minimongo@1.0.5 45 minimongo@1.0.5
47 mobile-status-bar@1.0.1 46 mobile-status-bar@1.0.1
48 mongo@1.0.8 47 mongo@1.0.8
49 npm-bcrypt@0.7.7 48 npm-bcrypt@0.7.7
50 observe-sequence@1.0.3 49 observe-sequence@1.0.3
51 ordered-dict@1.0.1 50 ordered-dict@1.0.1
52 particle4dev:sass@0.3.0 51 particle4dev:sass@0.3.0
53 pinglamb:bootstrap3@3.2.1 52 pinglamb:bootstrap3@3.2.1
54 random@1.0.1 53 random@1.0.1
55 reactive-dict@1.0.4 54 reactive-dict@1.0.4
56 reactive-var@1.0.3 55 reactive-var@1.0.3
57 reload@1.1.1 56 reload@1.1.1
58 retry@1.0.1 57 retry@1.0.1
59 routepolicy@1.0.2 58 routepolicy@1.0.2
60 service-configuration@1.0.2 59 service-configuration@1.0.2
61 session@1.0.4 60 session@1.0.4
62 sha@1.0.1 61 sha@1.0.1
63 spacebars-compiler@1.0.3 62 spacebars-compiler@1.0.3
64 spacebars@1.0.3 63 spacebars@1.0.3
65 srp@1.0.1 64 srp@1.0.1
66 standard-app-packages@1.0.3 65 standard-app-packages@1.0.3
67 templating@1.0.9 66 templating@1.0.9
68 themeteorchef:jquery-validation@1.13.1 67 themeteorchef:jquery-validation@1.13.1
69 tracker@1.0.3 68 tracker@1.0.3
70 ui@1.0.4 69 ui@1.0.4
71 underscore@1.0.1 70 underscore@1.0.1
72 url@1.0.2 71 url@1.0.2
73 webapp-hashing@1.0.1 72 webapp-hashing@1.0.1
74 webapp@1.1.4 73 webapp@1.1.4
75 74
1 # The Meteor Chef - Base (@1.0.0) 1 # The Meteor Chef - Base (@1.0.0)
2 A starting point for Meteor apps. 2 A starting point for Meteor apps.
3 3
4 Base is the lazy person's starter kit for Meteor. It includes some commonly used packages (biased to The Meteor Chef) and code for common functionality. This is the starter kit for all Meteor Chef recipes. 4 Base is the lazy person's starter kit for Meteor. It includes some commonly used packages (biased to The Meteor Chef) and code for common functionality. This is the starter kit for all Meteor Chef recipes.
5 5
6 For more detail on updates, [read the Changelog](https://github.com/themeteorchef/base/wiki/Changelog). 6 For more detail on updates, [read the Changelog](https://github.com/themeteorchef/base/wiki/Changelog).
7 7
8 ### Packages Included 8 ### Packages Included
9 - Accounts (Base) - `meteor add accounts-base` 9 - Accounts (Base) - `meteor add accounts-base`
10 - Accounts (Password) - `meteor add accounts-password` 10 - Accounts (Password) - `meteor add accounts-password`
11 - Audit Argument Checks - `meteor add audit-argument-checks` 11 - Audit Argument Checks - `meteor add audit-argument-checks`
12 - Bootstrap 3 - `meteor add pinglamb:bootstrap3` 12 - Bootstrap 3 - `meteor add pinglamb:bootstrap3`
13 - Check - `meteor add check` 13 - Check - `meteor add check`
14 - CoffeeScript - `meteor add coffeescript`
15 - Handlebars Server - `meteor add cmather:handlebars-server` 14 - Handlebars Server - `meteor add cmather:handlebars-server`
16 - Iron Router - `meteor add iron:router` 15 - Iron Router - `meteor add iron:router`
17 - jQuery - `meteor add jquery` 16 - jQuery - `meteor add jquery`
18 - jQuery Validation - `meteor add themeteorchef:jquery-validation` 17 - jQuery Validation - `meteor add themeteorchef:jquery-validation`
19 - Sass - `meteor add particle4dev:sass` 18 - Sass - `meteor add particle4dev:sass`
20 - Underscore - `meteor add underscore` 19 - Underscore - `meteor add underscore`
21 20
22 ### File Structure 21 ### File Structure
23 Base comes with a pre-defined file structure common to all projects along with some skeleton files for getting started quickly. Here's what it looks like: 22 Base comes with a pre-defined file structure common to all projects along with some skeleton files for getting started quickly. Here's what it looks like:
24 23
25 ``` 24 ```
26 /root 25 /root
27 ---/.meteor 26 ---/.meteor
28 ---/client 27 ---/client
29 ------/controllers 28 ------/controllers
30 ---------/authenticated 29 ---------/authenticated
31 ------------header.coffee 30 ------------header.js
32 ---------/public 31 ---------/public
33 ------------login.coffee 32 ------------login.js
34 ------------signup.coffee 33 ------------signup.js
35 ------------recover-password.coffee 34 ------------recover-password.js
36 ------------reset-password.coffee 35 ------------reset-password.js
37 ------/helpers 36 ------/helpers
38 ---------helpers-ui.coffee 37 ---------helpers-ui.js
39 ------/includes 38 ------/includes
40 ---------_header.html 39 ---------_header.html
41 ------/layouts 40 ------/layouts
42 ---------layout-default.html 41 ---------layout-default.html
43 ------/routes 42 ------/routes
44 ---------filters.coffee 43 ---------filters.js
45 ---------routes-global.coffee 44 ---------routes-global.js
46 ---------routes-authenticated.coffee 45 ---------routes-authenticated.js
47 ---------routes-public.coffee 46 ---------routes-public.js
48 ------/stylesheets 47 ------/stylesheets
49 ---------/sass 48 ---------/sass
50 ------------/globals 49 ------------/globals
51 ---------------_extends.scss 50 ---------------_extends.scss
52 ------------/modules 51 ------------/modules
53 ------------/vendor 52 ------------/vendor
54 ------------/views 53 ------------/views
55 ---------------/authenticated 54 ---------------/authenticated
56 ---------------/public 55 ---------------/public
57 ------------------_login.scss 56 ------------------_login.scss
58 ---------application.scss 57 ---------application.scss
59 -------/views 58 -------/views
60 ---------/authenticated 59 ---------/authenticated
61 ------------index.html 60 ------------index.html
62 ---------/public 61 ---------/public
63 ------------login.html 62 ------------login.html
64 ------------not-found.html 63 ------------not-found.html
65 ------------recover-password.html 64 ------------recover-password.html
66 ------------reset-password.html 65 ------------reset-password.html
67 ------------signup.html 66 ------------signup.html
68 ---/collections 67 ---/collections
69 ------example.coffee 68 ------example.js
70 ---/lib 69 ---/lib
71 ---/packages 70 ---/packages
72 ------ (See List Above) 71 ------ (See List Above)
73 ---/public 72 ---/public
74 ---/server 73 ---/server
75 ------/admin 74 ------/admin
76 ---------accounts.coffee 75 ---------accounts.js
77 ---------startup.coffee 76 ---------startup.js
78 ------/data 77 ------/data
79 ---------/insert 78 ---------/insert
80 ---------/update 79 ---------/update
81 ---------/remove 80 ---------/remove
82 ------/email 81 ------/email
83 ---------/send 82 ---------/send
84 ---------/templates 83 ---------/templates
85 ------------reset-password.coffee 84 ------------reset-password.js
86 ------/publications 85 ------/publications
87 ``` 86 ```
88 87
89 ### Language & Formatting 88 ### JavaScript & CSS
90 There are two considerations when using Base: JavaScript is written in [CoffeeScript](http://coffeescript.org) and CSS is written using [Sass](http://sass-lang.com). I prefer this setup because it allows me to move a little quicker than I do when writing in the native languages. This may not be for everybody, but I recommend giving both a shot because they make it much easier to write code. 89 Prior to v2.0.0, Base was written in CoffeeScript. At the request of the community, Base was ported _back_ to native JavaScript.
90
91 CSS in Base is written using [Sass](http://sass-lang.com).
91 92
92 ### Functionality 93 ### Functionality
93 94
94 ###### Bootstrap (@3.2.0) 95 ###### Bootstrap (@3.2.0)
95 Base makes use of the [Bootstrap](http://getbootstrap.com) Front-End Framework. It may not be your bag of chips and is *definitely not required*. If you want to swap it out, you'll need to unhook the markup in each of the included template files in `/client/views` and uninstall the Bootstrap3 package by running `meteor remove pinglamb:bootstrap3` in your terminal. 96 Base makes use of the [Bootstrap](http://getbootstrap.com) Front-End Framework. It may not be your bag of chips and is *definitely not required*. If you want to swap it out, you'll need to unhook the markup in each of the included template files in `/client/views` and uninstall the Bootstrap3 package by running `meteor remove pinglamb:bootstrap3` in your terminal.
96 97
97 In respect to UI, Base uses Bootstrap's `.navbar` element, as well as its `.container` and a few `.row`/`.col-<size>-<columns>` wrappers. You'll also find the `.btn` class and its modifiers (`.success, .warning, etc.`) in use throughout the app. All of these applications are merely presentational and can be changed (or removed) as you see fit. 98 In respect to UI, Base uses Bootstrap's `.navbar` element, as well as its `.container` and a few `.row`/`.col-<size>-<columns>` wrappers. You'll also find the `.btn` class and its modifiers (`.success, .warning, etc.`) in use throughout the app. All of these applications are merely presentational and can be changed (or removed) as you see fit.
98 99
99 ###### Basic Routing 100 ###### Basic Routing
100 A collection of pre-defined routes and templates for common functionality (see Authenticate below). Also includes a set of common route filters for managing user access. Routes bundled include: 101 A collection of pre-defined routes and templates for common functionality (see Authenticate below). Also includes a set of common route filters for managing user access. Routes bundled include:
101 102
102 ``` 103 ```
103 - / (Authenticated) 104 - / (Authenticated)
104 - /login (Public) 105 - /login (Public)
105 - /signup (Public) 106 - /signup (Public)
106 - /recover-password (Public) 107 - /recover-password (Public)
107 - /reset-password (Public) 108 - /reset-password (Public)
108 ``` 109 ```
109 110
110 This also includes a UI helper called `currentRoute` which allows you to add an `active` class to menu items in your UI to reflect the user's current position. 111 This also includes a UI helper called `currentRoute` which allows you to add an `active` class to menu items in your UI to reflect the user's current position.
111 112
112 ###### Authentication 113 ###### Authentication
113 A complete authentication pattern complete with: 114 A complete authentication pattern complete with:
114 115
115 - Signup (at /signup) 116 - Signup (at /signup)
116 - Login (at /login) 117 - Login (at /login)
117 - Logout (no path, implemented as a dropdown item/click event in /client/controllers/header.coffee) 118 - Logout (no path, implemented as a dropdown item/click event in /client/controllers/header.js)
118 - Password Recovery (at /recover-password and /reset-password) 119 - Password Recovery (at /recover-password and /reset-password)
119 120
120 ###### Validation 121 ###### Validation
121 Validation via [jQuery Validation](http://jqueryvalidation.org). This applies to all of the public templates: login, signup, recover password, and reset password. 122 Validation via [jQuery Validation](http://jqueryvalidation.org). This applies to all of the public templates: login, signup, recover password, and reset password.
122 123
123 ###### Automatic Admin User Creation 124 ###### Automatic Admin User Creation
124 When developing, having a handful of user accounts to test your application with can come in handy. Base comes with an automated account generation script located in `server/admin/startup.coffee` that creates accounts based on an array of specified users. **Note: by default this creates one Admin user on server startup, so make sure to customize or remove this user so the public can't access your app**. 125 When developing, having a handful of user accounts to test your application with can come in handy. Base comes with an automated account generation script located in `server/admin/startup.js` that creates accounts based on an array of specified users. **Note: by default this creates one Admin user on server startup, so make sure to customize or remove this user so the public can't access your app**.
client/controllers/authenticated/header.coffee
1 ### File was deleted
2 Controller: Header
3 Template: /client/includes/_header.html
4 ###
5
6 # Created
7 Template.header.created = ->
8 # Code to run when template is created goes here.
9
10 # Rendered
11 Template.header.rendered = ->
12 # Code to run when template is rendered goes here.
13
14 # Helpers
15 Template.header.helpers(
16 example: ->
17 # Code to run for helper function.
18 )
19
20 # Events
21 Template.header.events(
22 'click .logout': (e,t) ->
23 Meteor.logout((error)->
24 alert error.reason if error
25 )
26 )
27 1 ###
client/controllers/authenticated/header.js
File was created 1 /*
2 * Controller: Header
3 * Template: /client/includes/_header.html
4 */
5
6 /*
7 * Created
8 */
9
10 Template.header.created = function(){
11 // Code to run when template is created goes here.
12 }
13
14 /*
15 * Rendered
16 */
17
18 Template.header.rendered = function() {
19 // Code to run when template is rendered goes here.
20 }
21
22 /*
23 * Helpers
24 */
25
26 Template.header.helpers({
27 example: function(){
28 // Code to run for helper function.
29 }
30 });
31
32 /*
33 * Events
34 */
35
36 Template.header.events({
37 'click .logout': function(){
38 Meteor.logout(function(error){
39 if(error){
40 alert(error.reason);
41 }
42 });
43 }
44 });
45
client/controllers/public/login.coffee
1 ### File was deleted
2 Controller: Login
3 Template: /client/views/public/login.html
4 ###
5
6 # Created
7 Template.login.created = ->
8 # Code to run when template is created goes here.
9
10 # Rendered
11 Template.login.rendered = ->
12 $('#application-login').validate(
13 rules:
14 emailAddress:
15 required: true
16 email: true
17 password:
18 required: true
19 messages:
20 emailAddress:
21 required: "Please enter your email address to login."
22 email: "Please enter a valid email address."
23 password:
24 required: "Please enter your password to login."
25 submitHandler: ->
26 # Grab the user's details.
27 user =
28 email: $('[name="emailAddress"]').val()
29 password: $('[name="password"]').val()
30
31 # Log the user in.
32 Meteor.loginWithPassword(user.email, user.password, (error)->
33 alert error.reason if error
34 )
35 )
36
37 # Helpers
38 Template.login.helpers(
39 example: ->
40 # Code to run for helper function.
41 )
42
43 # Events
44 Template.login.events(
45 'submit form': (e,t) ->
46 # Prevent form from submitting.
47 e.preventDefault()
48 )
49 1 ###
client/controllers/public/login.js
File was created 1 /*
2 * Controller: Login
3 * Template: /client/views/public/login.html
4 */
5
6 /*
7 * Created
8 */
9
10 Template.login.created = function(){
11 // Code to run when template is created goes here.
12 }
13
14 /*
15 * Rendered
16 */
17
18 Template.login.rendered = function(){
19 $('#application-login').validate({
20 rules: {
21 emailAddress: {
22 required: true,
23 email: true
24 },
25 password: {
26 required: true
27 }
28 },
29 messages: {
30 emailAddress: {
31 required: "Please enter your email address to login.",
32 email: "Please enter a valid email address."
33 },
34 password: {
35 required: "Please enter your password to login."
36 }
37 },
38 submitHandler: function(){
39 // Grab the user's details.
40 user = {
41 email: $('[name="emailAddress"]').val(),
42 password: $('[name="password"]').val()
43 }
44
45 // Log the user in.
46 Meteor.loginWithPassword(user.email, user.password, function(error){
47 if(error){
48 alert(error.reason);
49 }
50 });
51 }
52 });
53 }
54
55 /*
56 * Helpers
57 */
58
59 Template.login.helpers({
60 example: function(){
61 // Code to run for helper function.
62 }
63 });
64
65 /*
66 * Events
67 */
68
69 Template.login.events({
70 'submit form': function(e){
71 // Prevent form from submitting.
72 e.preventDefault();
73 }
74 });
75
client/controllers/public/recover-password.coffee
1 ### File was deleted
2 Controller: Recover Password
3 Template: /client/views/public/recover-password.html
4 ###
5
6 # Created
7 Template.recoverPassword.created = ->
8 # Code to run when template is created goes here.
9
10 # Rendered
11 Template.recoverPassword.rendered = ->
12 $('#application-recover-password').validate(
13 rules:
14 emailAddress:
15 required: true
16 email: true
17 messages:
18 emailAddress:
19 required: "Please enter your email address to recover your password."
20 email: "Please enter a valid email address."
21 submitHandler: ->
22 # Grab the user's details.
23 email = $('[name="emailAddress"]').val()
24
25 # Call the send reset password email method.
26 Accounts.forgotPassword(email: email, (error)->
27 alert error.reason if error
28 )
29 )
30
31 # Helpers
32 Template.recoverPassword.helpers(
33 example: ->
34 # Code to run for helper function.
35 )
36
37 # Events
38 Template.recoverPassword.events(
39 'submit form': (e) ->
40 # Prevent form from submitting.
41 e.preventDefault()
42 )
43 1 ###
client/controllers/public/recover-password.js
File was created 1 /*
2 * Controller: Recover Password
3 * Template: /client/views/public/recover-password.html
4 */
5
6 /*
7 * Created
8 */
9
10 Template.recoverPassword.created = function(){
11 // Code to run when template is created goes here.
12 }
13
14 /*
15 * Rendered
16 */
17
18
19 Template.recoverPassword.rendered = function(){
20 $('#application-recover-password').validate({
21 rules: {
22 emailAddress: {
23 required: true,
24 email: true
25 }
26 },
27 messages: {
28 emailAddress: {
29 required: "Please enter your email address to recover your password.",
30 email: "Please enter a valid email address."
31 }
32 },
33 submitHandler: function(){
34 // Grab the user's email address.
35 var email = $('[name="emailAddress"]').val();
36
37 // Call the send reset password email method.
38 Accounts.forgotPassword({email: email}, function(error){
39 if(error){
40 alert(error.reason);
41 }
42 });
43 }
44 });
45 }
46
47 /*
48 * Helpers
49 */
50
51 Template.recoverPassword.helpers({
52 example: function(){
53 // Code to run for helper function.
54 }
55 });
56
57 /*
58 * Events
59 */
60
61 Template.recoverPassword.events({
62 'submit form': function(e){
63 // Prevent form from submitting.
64 e.preventDefault();
65 }
66 });
67
client/controllers/public/reset-password.coffee
1 ### File was deleted
2 Controller: Reset Password
3 Template: /client/views/public/reset-password.html
4 ###
5
6 # Created
7 Template.resetPassword.created = ->
8 # Code to run when template is created goes here.
9
10 # Rendered
11 Template.resetPassword.rendered = ->
12 $('#application-reset-password').validate(
13 rules:
14 newPassword:
15 required: true
16 minlength: 6
17 repeatNewPassword:
18 required: true
19 minlength: 6
20 equalTo: "[name='newPassword']"
21 messages:
22 newPassword:
23 required: "Please enter a new password."
24 minlength: "Please use at least six characters."
25 repeatNewPassword:
26 required: "Please repeat your new password."
27 equalTo: "Your password do not match. Please try again."
28 submitHandler: ->
29 # Grab the user's reset token and new password.
30 token = Session.get 'resetPasswordToken'
31 password =
32 newPassword: $('[name="newPassword"]').val()
33 repeatPassword: $('[name="repeatNewPassword"]').val()
34
35 # Reset the user's password.
36 Accounts.resetPassword(token, password.newPassword, (error)->
37 if error
38 alert error.reason
39 else
40 Session.set 'resetPasswordToken', null
41 )
42 )
43
44 # Helpers
45 Template.resetPassword.helpers(
46 example: ->
47 # Code to run for helper function.
48 )
49
50 # Events
51 Template.resetPassword.events(
52 'submit form': (e) ->
53 # Prevent form from submitting.
54 e.preventDefault()
55 )
56 1 ###
client/controllers/public/reset-password.js
File was created 1 /*
2 * Controller: Reset Password
3 * Template: /client/views/public/reset-password.html
4 */
5
6 /*
7 * Created
8 */
9
10 Template.resetPassword.created = function(){
11 // Code to run when template is created goes here.
12 }
13
14 /*
15 * Rendered
16 */
17
18 Template.resetPassword.rendered = function(){
19 $('#application-reset-password').validate({
20 rules: {
21 newPassword: {
22 required: true,
23 minlength: 6
24 },
25 repeatNewPassword: {
26 required: true,
27 minlength: 6,
28 equalTo: "[name='newPassword']"
29 }
30 },
31 messages: {
32 newPassword: {
33 required: "Please enter a new password.",
34 minlength: "Please use at least six characters."
35 },
36 repeatNewPassword: {
37 required: "Please repeat your new password.",
38 equalTo: "Your password do not match. Please try again."
39 }
40 },
41 submitHandler: function(){
42 // Grab the user's reset token and new password.
43 var token = Session.get('resetPasswordToken'),
44 password = $('[name="newPassword"]').val();
45
46 // Reset the user's password.
47 Accounts.resetPassword(token, password, function(error){
48 if(error){
49 alert(error.reason);
50 } else {
51 Session.set('resetPasswordToken', null);
52 }
53 });
54 }
55 });
56 }
57
58 /*
59 * Helpers
60 */
61
62 Template.resetPassword.helpers({
63 example: function(){
64 // Code to run for helper function.
65 }
66 });
67
68 /*
69 * Events
70 */
71
72 Template.resetPassword.events({
73 'submit form': function(e){
74 // Prevent form from submitting.
75 e.preventDefault();
76 }
77 });
78
client/controllers/public/signup.coffee
1 ### File was deleted
2 Controller: Signup
3 Template: /client/views/public/signup.html
4 ###
5
6 # Created
7 Template.signup.created = ->
8 # Code to run when template is created goes here.
9
10 # Rendered
11 Template.signup.rendered = ->
12 $('#application-signup').validate(
13 rules:
14 emailAddress:
15 required: true
16 email: true
17 password:
18 required: true
19 minlength: 6
20 messages:
21 emailAddress:
22 required: "Please enter your email address to sign up."
23 email: "Please enter a valid email address."
24 password:
25 required: "Please enter a password to sign up."
26 minlength: "Please use at least six characters."
27 submitHandler: ->
28 # Grab the user's details.
29 user =
30 email: $('[name="emailAddress"]').val()
31 password: $('[name="password"]').val()
32
33 # Create the user's account.
34 Accounts.createUser({email: user.email, password: user.password}, (error)->
35 alert error.reason if error
36 )
37 )
38
39 # Helpers
40 Template.signup.helpers(
41 example: ->
42 # Code to run for helper function.
43 )
44
45 # Events
46 Template.signup.events(
47 'submit form': (e) ->
48 # Prevent form from submitting.
49 e.preventDefault()
50 )
51 1 ###
client/controllers/public/signup.js
File was created 1 /*
2 * Controller: Signup
3 * Template: /client/views/public/signup.html
4 */
5
6 /*
7 * Created
8 */
9
10 Template.signup.created = function(){
11 // Code to run when template is created goes here.
12 }
13
14 /*
15 * Rendered
16 */
17
18 Template.signup.rendered = function(){
19 $('#application-signup').validate({
20 rules: {
21 emailAddress: {
22 required: true,
23 email: true
24 },
25 password: {
26 required: true,
27 minlength: 6
28 }
29 },
30 messages: {
31 emailAddress: {
32 required: "Please enter your email address to sign up.",
33 email: "Please enter a valid email address."
34 },
35 password: {
36 required: "Please enter a password to sign up.",
37 minlength: "Please use at least six characters."
38 }
39 },
40 submitHandler: function(){
41 // Grab the user's details.
42 user = {
43 email: $('[name="emailAddress"]').val(),
44 password: $('[name="password"]').val()
45 }
46
47 // Create the user's account.
48 Accounts.createUser({email: user.email, password: user.password}, function(error){
49 if(error){
50 alert(error.reason);
51 }
52 });
53 }
54 });
55 }
56
57 /*
58 * Helpers
59 */
60
61 Template.signup.helpers({
62 example: function(){
63 // Code to run for helper function.
64 }
65 });
66
67 /*
68 * Events
69 */
70
71 Template.signup.events({
72 'submit form': function(e){
73 // Prevent form from submitting.
74 e.preventDefault();
75 }
76 });
77
client/helpers/helpers-ui.coffee
1 ### File was deleted
2 UI Helpers
3 Define UI helpers for common template functionality.
4 ###
5
6 # Current Route
7 # Return an active class if the currentRoute session variable name
8 # (set in the appropriate file in /client/routes/) is equal to the name passed
9 # to the helper in the template.
10
11 UI.registerHelper('currentRoute', (route) ->
12 if Session.equals 'currentRoute', route then 'active' else ''
13 )
14 1 ###
client/helpers/helpers-ui.js
File was created 1 /*
2 * UI Helpers
3 * Define UI helpers for common template functionality.
4 */
5
6 /*
7 * Current Route
8 * Return an active class if the currentRoute session variable name
9 * (set in the appropriate file in /client/routes/) is equal to the name passed
10 * to the helper in the template.
11 */
12
13 UI.registerHelper('currentRoute', function(route){
14 Session.equals('currentRoute', route) ? 'active' : '';
15 });
16
client/routes/filters.coffee
1 ### File was deleted
2 Route Filters
3 Filters for managing user access to application routes.
4 ###
5
6 # Define Filters
7
8 ###
9 Filter: Check if a User is Logged In
10 If a user is not logged in and attempts to go to an authenticated route,
11 re-route them to the login screen.
12 ###
13 checkUserLoggedIn = ->
14 if not Meteor.loggingIn() and not Meteor.user()
15 Router.go '/login'
16 else
17 @next()
18
19 ###
20 Filter: Check if a User Exists
21 If a user is logged in and attempts to go to a public route, re-route
22 them to the main "logged in" screen.
23 ###
24 userAuthenticated = ->
25 if not Meteor.loggingIn() and Meteor.user()
26 Router.go '/'
27 else
28 @next()
29
30 # Run Filters
31 Router.onBeforeAction checkUserLoggedIn, except: [
32 'signup',
33 'login',
34 'recover-password',
35 'reset-password'
36 ]
37
38 Router.onBeforeAction userAuthenticated, only: [
39 'signup',
40 'login',
41 'recover-password',
42 'reset-password'
43 ]
44 1 ###
client/routes/filters.js
File was created 1 /*
2 * Route Filters
3 * Filters for managing user access to application routes.
4 */
5
6 /*
7 * Define Filters
8 */
9
10 /*
11 * Filter: Check if a User is Logged In
12 * If a user is not logged in and attempts to go to an authenticated route,
13 * re-route them to the login screen.
14 */
15
16 checkUserLoggedIn = function(){
17 if( !Meteor.loggingIn() && !Meteor.user() ) {
18 Router.go('/login');
19 } else {
20 this.next();
21 }
22 }
23
24 /*
25 * Filter: Check if a User Exists
26 * If a user is logged in and attempts to go to a public route, re-route
27 * them to the main "logged in" screen.
28 */
29
30 userAuthenticated = function(){
31 if( !Meteor.loggingIn() && Meteor.user() ){
32 Router.go('/');
33 } else {
34 this.next();
35 }
36 }
37
38 /*
39 * Run Filters
40 */
41
42 Router.onBeforeAction(checkUserLoggedIn, {
43 except: [
44 'signup',
45 'login',
46 'recover-password',
47 'reset-password'
48 ]
49 });
50
51 Router.onBeforeAction(userAuthenticated, {
52 only: [
53 'signup',
54 'login',
55 'recover-password',
56 'reset-password'
57 ]
58 });
59
client/routes/routes-authenticated.coffee
1 Router.route('index', File was deleted
2 path: '/'
3 template: 'index'
4 onBeforeAction: ->
5 # Code to run before route goes here.
6 @next()
7 )
8 1 Router.route('index',
client/routes/routes-authenticated.js
File was created 1 /*
2 * Routes: Authenticated
3 * Routes that are only visible to authenticated users.
4 */
5
6 Router.route('index', {
7 path: '/',
8 template: 'index',
9 onBeforeAction: function(){
10 // Code to run before route goes here.
11 this.next();
12 }
13 });
14
client/routes/routes-global.coffee
1 Router.configure( File was deleted
2 notFoundTemplate: 'notFound'
3 layoutTemplate: 'layoutDefault'
4 )
5 1 Router.configure(
client/routes/routes-global.js
File was created 1 /*
2 * Routes: Global
3 * Global router configurations that apply to the entire application.
4 */
5
6 Router.configure({
7 notFoundTemplate: 'notFound',
8 layoutTemplate: 'layoutDefault'
9 });
10
client/routes/routes-public.coffee
1 Router.route('signup', File was deleted
2 path: '/signup'
3 template: 'signup'
4 onBeforeAction: ->
5 Session.set 'currentRoute', 'signup'
6 @next()
7 )
8
9 Router.route('login',
10 path: '/login'
11 template: 'login'
12 onBeforeAction: ->
13 Session.set 'currentRoute', 'login'
14 @next()
15 )
16
17 Router.route('recover-password',
18 path: '/recover-password'
19 template: 'recoverPassword'
20 onBeforeAction: ->
21 Session.set 'currentRoute', 'recover-password'
22 @next()
23 )
24
25 Router.route('reset-password',
26 path: '/reset-password/:token'
27 template: 'resetPassword'
28 onBeforeAction: ->
29 Session.set 'currentRoute', 'reset-password'
30 Session.set 'resetPasswordToken', @params.token
31 @next()
32 )
33 1 Router.route('signup',
client/routes/routes-public.js
File was created 1 /*
2 * Routes: Public
3 * Routes that are visible to all (public) users.
4 */
5
6 Router.route('signup', {
7 path: '/signup',
8 template: 'signup',
9 onBeforeAction: function(){
10 Session.set('currentRoute', 'signup');
11 this.next();
12 }
13 });
14
15 Router.route('login', {
16 path: '/login',
17 template: 'login',
18 onBeforeAction: function(){
19 Session.set('currentRoute', 'login');
20 this.next();
21 }
22 });
23
24 Router.route('recover-password', {
25 path: '/recover-password',
26 template: 'recoverPassword',
27 onBeforeAction: function(){
28 Session.set('currentRoute', 'recover-password');
29 this.next();
30 }
31 });
32
33 Router.route('reset-password', {
34 path: '/reset-password/:token',
35 template: 'resetPassword',
36 onBeforeAction: function() {
37 Session.set('currentRoute', 'reset-password');
38 Session.set('resetPasswordToken', this.params.token);
39 this.next();
40 }
41 });
42
collections/example.coffee
1 @Example = new Meteor.Collection 'example' File was deleted
2
3 # Allow
4 Example.allow
5 insert: (userId, doc) ->
6 # ...
7 update: (userId, doc, fields, modifier) ->
8 # ...
9 remove: (userId, doc) ->
10 # ...
11 fetch: ['owner'],
12 transform: () ->
13 # ...
14
15 # Deny
16 Example.deny
17 insert: (userId, doc) ->
18 # ...
19 update: (userId, doc, fields, modifier) ->
20 # ...
21 remove: (userId, doc) ->
22 # ...
23 fetch: ['locked']
24 transform: () ->
25 # ...
26 1 @Example = new Meteor.Collection 'example'
collections/example.js
File was created 1 Example = new Meteor.Collection('example');
2
3 /*
4 * Allow
5 */
6
7 Example.allow({
8 insert: function(userId, doc){
9 // Add your rules here.
10 },
11 update: function(userId, doc, fields, modifier){
12 // Add your rules here.
13 },
14 remove: function(userId, doc){
15 // Add your rules here.
16 }
17 });
18
19 /*
20 * Deny
21 */
22
23 Example.deny({
24 insert: function(userId, doc){
25 // Add your rules here.
26 },
27 update: function(userId, doc, fields, modifier){
28 // Add your rules here.
29 },
30 remove: function(userId, doc){
31 // Add your rules here.
32 }
33 });
34
server/admin/startup.coffee
1 ### File was deleted
2 Startup
3 Collection of methods and functions to run on server startup.
4 ###
5
6 # Generate Test Accounts
7 # Creates a collection of test accounts automatically on startup.
8
9 # Create an array of user accounts.
10 users = [
11 { name: "Admin", email: "admin@admin.com", password: "password" }
12 ]
13
14 # Loop through array of user accounts.
15 for user in users
16
17 # Check if the user already exists in the DB.
18 checkUser = Meteor.users.findOne({"emails.address": user.email});
19
20 # If an existing user is not found, create the account.
21 if not checkUser
22
23 id = Accounts.createUser(
24 email: user.email
25 password: user.password
26 profile:
27 name: user.name
28 )
29
30 1 ###
server/admin/startup.js
File was created 1 /*
2 * Startup
3 * Collection of methods and functions to run on server startup.
4 */
5
6 /*
7 * Generate Test Accounts
8 * Creates a collection of test accounts automatically on startup.
9 */
10
11 // Create an array of user accounts.
12 var users = [
13 { name: "Admin", email: "admin@admin.com", password: "password" }
14 ]
15
16 // Loop through array of user accounts.
17 for(i=0; i < users.length; i++){
18 // Check if the user already exists in the DB.
19 var userEmail = users[i].email,
20 checkUser = Meteor.users.findOne({"emails.address": userEmail});
21
22 // If an existing user is not found, create the account.
23 if( !checkUser ){
24 Accounts.createUser({
25 email: userEmail,
26 password: users[i].password,
27 profile: {
28 name: users[i].name
29 }
30 });
31 }
32 }
33
server/email/templates/reset-password.coffee
1 ### File was deleted
2 Reset Password Email Template
3 Override Meteor defaults when sending a reset password email.
4 ###
5
6 # Set name and from email.
7 Accounts.emailTemplates.resetPassword.siteName = "Application Name"
8 Accounts.emailTemplates.resetPassword.from = "Application Admin Email <admin@application.com>"
9
10 # Set a subject for the reset password email.
11 Accounts.emailTemplates.resetPassword.subject = (user) ->
12 "[Application Name] Reset Your Password"
13
14 # Set the body of the reset password email.
15 Accounts.emailTemplates.resetPassword.text = (user, url) ->
16 email = user.emails[0].address
17 removeHash = url.replace('#/', '')
18 "A password reset has been requested for the account related to this address(#{email}). To reset the password, visit the following link:\n\n #{removeHash}\n\n If you did not request this reset, please ignore this email. If you feel something is wrong, please contact support: admin@application.com."
19 1 ###
server/email/templates/reset-password.js
File was created 1 /*
2 * Reset Password Email Template
3 * Override Meteor defaults when sending a reset password email.
4 */
5
6 // Set name and from email.
7 Accounts.emailTemplates.resetPassword.siteName = "Application Name";
8 Accounts.emailTemplates.resetPassword.from = "Application Admin Email <admin@application.com>";
9
10 // Set a subject for the reset password email.
11 Accounts.emailTemplates.resetPassword.subject = function(user){
12 return "[Application Name] Reset Your Password";
13 }
14
15 // Set the body of the reset password email.
16 Accounts.emailTemplates.resetPassword.text = function(user, url){
17 var email = user.emails[0].address,
18 removeHash = url.replace('#/', '');
19 return "A password reset has been requested for the account related to this address(" + email + "). To reset the password, visit the following link:\n\n" + removeHash + "\n\n If you did not request this reset, please ignore this email. If you feel something is wrong, please contact support: admin@application.com."
20 }
21