Commit f6b57621a1f302d5da77e82b469cc31b2fe149ef

Authored by Ryan Glover
Exists in master

Merge branch 'refactor/convert_to_javascript'

... ... @@ -4,7 +4,6 @@
4 4 # but you can also edit it by hand.
5 5  
6 6 standard-app-packages
7   -coffeescript
8 7 underscore
9 8 accounts-password
10 9 accounts-base
... ... @@ -16,4 +15,3 @@ pinglamb:bootstrap3
16 15 cmather:handlebars-server
17 16 themeteorchef:jquery-validation
18 17 particle4dev:sass@0.3.0
19   -
... ...
... ... @@ -11,7 +11,6 @@ boilerplate-generator@1.0.1
11 11 callback-hook@1.0.1
12 12 check@1.0.2
13 13 cmather:handlebars-server@2.0.0
14   -coffeescript@1.0.4
15 14 ctl-helper@1.0.4
16 15 ctl@1.0.2
17 16 ddp@1.0.11
... ...
... ... @@ -11,7 +11,6 @@ For more detail on updates, [read the Changelog](https://github.com/themeteorche
11 11 - Audit Argument Checks - `meteor add audit-argument-checks`
12 12 - Bootstrap 3 - `meteor add pinglamb:bootstrap3`
13 13 - Check - `meteor add check`
14   -- CoffeeScript - `meteor add coffeescript`
15 14 - Handlebars Server - `meteor add cmather:handlebars-server`
16 15 - Iron Router - `meteor add iron:router`
17 16 - jQuery - `meteor add jquery`
... ... @@ -28,23 +27,23 @@ Base comes with a pre-defined file structure common to all projects along with s
28 27 ---/client
29 28 ------/controllers
30 29 ---------/authenticated
31   -------------header.coffee
  30 +------------header.js
32 31 ---------/public
33   -------------login.coffee
34   -------------signup.coffee
35   -------------recover-password.coffee
36   -------------reset-password.coffee
  32 +------------login.js
  33 +------------signup.js
  34 +------------recover-password.js
  35 +------------reset-password.js
37 36 ------/helpers
38   ----------helpers-ui.coffee
  37 +---------helpers-ui.js
39 38 ------/includes
40 39 ---------_header.html
41 40 ------/layouts
42 41 ---------layout-default.html
43 42 ------/routes
44   ----------filters.coffee
45   ----------routes-global.coffee
46   ----------routes-authenticated.coffee
47   ----------routes-public.coffee
  43 +---------filters.js
  44 +---------routes-global.js
  45 +---------routes-authenticated.js
  46 +---------routes-public.js
48 47 ------/stylesheets
49 48 ---------/sass
50 49 ------------/globals
... ... @@ -66,15 +65,15 @@ Base comes with a pre-defined file structure common to all projects along with s
66 65 ------------reset-password.html
67 66 ------------signup.html
68 67 ---/collections
69   -------example.coffee
  68 +------example.js
70 69 ---/lib
71 70 ---/packages
72 71 ------ (See List Above)
73 72 ---/public
74 73 ---/server
75 74 ------/admin
76   ----------accounts.coffee
77   ----------startup.coffee
  75 +---------accounts.js
  76 +---------startup.js
78 77 ------/data
79 78 ---------/insert
80 79 ---------/update
... ... @@ -82,12 +81,14 @@ Base comes with a pre-defined file structure common to all projects along with s
82 81 ------/email
83 82 ---------/send
84 83 ---------/templates
85   -------------reset-password.coffee
  84 +------------reset-password.js
86 85 ------/publications
87 86 ```
88 87  
89   -### Language & Formatting
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.
  88 +### JavaScript & CSS
  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 93 ### Functionality
93 94  
... ... @@ -114,11 +115,11 @@ A complete authentication pattern complete with:
114 115  
115 116 - Signup (at /signup)
116 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 119 - Password Recovery (at /recover-password and /reset-password)
119 120  
120 121 ###### Validation
121 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 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,26 +0,0 @@
1   -###
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   -)
client/controllers/authenticated/header.js
... ... @@ -0,0 +1,44 @@
  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 +});
... ...
client/controllers/public/login.coffee
... ... @@ -1,48 +0,0 @@
1   -###
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   -)
client/controllers/public/login.js
... ... @@ -0,0 +1,74 @@
  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 +});
... ...
client/controllers/public/recover-password.coffee
... ... @@ -1,42 +0,0 @@
1   -###
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   -)
client/controllers/public/recover-password.js
... ... @@ -0,0 +1,66 @@
  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 +});
... ...
client/controllers/public/reset-password.coffee
... ... @@ -1,55 +0,0 @@
1   -###
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   -)
client/controllers/public/reset-password.js
... ... @@ -0,0 +1,77 @@
  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 +});
... ...
client/controllers/public/signup.coffee
... ... @@ -1,50 +0,0 @@
1   -###
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   -)
client/controllers/public/signup.js
... ... @@ -0,0 +1,76 @@
  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 +});
... ...
client/helpers/helpers-ui.coffee
... ... @@ -1,13 +0,0 @@
1   -###
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   -)
client/helpers/helpers-ui.js
... ... @@ -0,0 +1,15 @@
  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 +});
... ...
client/routes/filters.coffee
... ... @@ -1,43 +0,0 @@
1   -###
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   -]
client/routes/filters.js
... ... @@ -0,0 +1,58 @@
  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 +});
... ...
client/routes/routes-authenticated.coffee
... ... @@ -1,7 +0,0 @@
1   -Router.route('index',
2   - path: '/'
3   - template: 'index'
4   - onBeforeAction: ->
5   - # Code to run before route goes here.
6   - @next()
7   -)
client/routes/routes-authenticated.js
... ... @@ -0,0 +1,13 @@
  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 +});
... ...
client/routes/routes-global.coffee
... ... @@ -1,4 +0,0 @@
1   -Router.configure(
2   - notFoundTemplate: 'notFound'
3   - layoutTemplate: 'layoutDefault'
4   -)
client/routes/routes-global.js
... ... @@ -0,0 +1,9 @@
  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 +});
... ...
client/routes/routes-public.coffee
... ... @@ -1,32 +0,0 @@
1   -Router.route('signup',
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   -)
client/routes/routes-public.js
... ... @@ -0,0 +1,41 @@
  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 +});
... ...
collections/example.coffee
... ... @@ -1,25 +0,0 @@
1   -@Example = new Meteor.Collection 'example'
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   - # ...
collections/example.js
... ... @@ -0,0 +1,33 @@
  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 +});
... ...
server/admin/startup.coffee
... ... @@ -1,29 +0,0 @@
1   -###
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   -
server/admin/startup.js
... ... @@ -0,0 +1,32 @@
  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 +}
... ...
server/email/templates/reset-password.coffee
... ... @@ -1,18 +0,0 @@
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 = (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."
server/email/templates/reset-password.js
... ... @@ -0,0 +1,20 @@
  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 +}
... ...