From 467a966bc828ce69165df0b28f2f5da8bcbb5262 Mon Sep 17 00:00:00 2001 From: Ben Ramey Date: Tue, 25 Mar 2014 22:10:41 -0500 Subject: [PATCH] Sprucing up homepage, real e-mail --- api/models/Run.js | 37 ++++++----- .../controllers/create-run-controller.coffee | 11 ++-- assets/linker/templates/create-run.jade | 63 +++++++++---------- views/layout.jade | 10 +-- 4 files changed, 60 insertions(+), 61 deletions(-) diff --git a/api/models/Run.js b/api/models/Run.js index 7a86dae..9ba0ce6 100644 --- a/api/models/Run.js +++ b/api/models/Run.js @@ -40,30 +40,29 @@ module.exports = { } }); - var inviteeEmails = []; - - for (var i in values.invitees) { - var invitee = values.invitees[i]; - var emailStr = invitee.name + " <" + invitee.email + ">"; - inviteeEmails.push(emailStr); - } - var options = { from: values.creatorName + " <" + values.creatorEmail + ">", - to: inviteeEmails.join(","), - subject: "A lunch run!", - text: "You've been invited to a lunch run!" + subject: "You've been invited to a lunch run!", + text: "You've been invited to " + values.creatorName + "'s lunch run: '" + + values.name + "'! \n\n Put in your order here:\nhttp://www.lunchrun.me/#/run/" + + values.id + "/order/" }; - console.log(options); + for (var idx in values.invitees) { + var invitee = values.invitees[idx]; + var specificOptions = options; + specificOptions.to = invitee.name + " <" + invitee.email + ">"; + specificOptions.text += invitee.name; - transport.sendMail(options, function(err, response) { - if (err) { - console.log(err); - } else { - console.log("message sent from: " + values.creatorEmail); - } - }); + console.log(specificOptions); + transport.sendMail(specificOptions, function(err, response) { + if (err) { + console.log(err); + } else { + console.log("message sent from: " + values.creatorEmail); + } + }); + } transport.close(); diff --git a/assets/linker/js/controllers/create-run-controller.coffee b/assets/linker/js/controllers/create-run-controller.coffee index acdca08..5c9800b 100644 --- a/assets/linker/js/controllers/create-run-controller.coffee +++ b/assets/linker/js/controllers/create-run-controller.coffee @@ -3,18 +3,19 @@ lunchControllers = angular.module 'lunchControllers' lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket', CreateRunController = ($scope, $http, $location, socket) -> $scope.run = - name: 'run name', - creatorName: 'ben ramey' - creatorEmail: 'ben.ramey@gmail.com' - invitees: [{name: 'bob', email: 'bob@bob.com'}] - restaurant: 'subway' + invitees: [] $scope.addInvitee = () -> $scope.run.invitees.push {} + $scope.removeInvitee = (index) -> + $scope.run.invitees.splice index, 1 + $scope.create = (run) -> data = angular.copy run socket.post '/run', data, (response) -> $location.path '/run/' + response.id $scope.$apply() + + $scope.addInvitee() ] diff --git a/assets/linker/templates/create-run.jade b/assets/linker/templates/create-run.jade index d890150..1547aa0 100644 --- a/assets/linker/templates/create-run.jade +++ b/assets/linker/templates/create-run.jade @@ -1,34 +1,33 @@ div.create-run-form(ng-controller='CreateRunCtrl') - h2 Create a lunch run - form.row(name='form',novalidate,role='form') - fieldset.col-xs-12.col-sm-6.col-md-6.col-lg-6 - legend You and your run - div.form-group - label(for='name') Name your run - input#name.form-control(type='text',ng-model='run.name',required) - div.form-group - label(for='creatorName') Your name - input#creatorName.form-control(type='text',ng-model='run.creatorName',required) - div.form-group - label(for='creatorEmail') Your email - input#creatorEmail.form-control(type='email',ng-model='run.creatorEmail',required) - div.form-group - label(for='restaurant') Restaurant - input#restaurant.form-control(type='text',ng-model='run.restaurant') - div.form-group - label(for='menuUrl') Menu URL - input#menuUrl.form-control(type='url',ng-model='run.menuUrl') - fieldset.col-xs-12.col-sm-6.col-md-6.col-lg-6 - legend Who's going? - div.form-group - label Invitees - span(ng-repeat='i in run.invitees') - .form-group - label Name - input.form-control(ng-model='i.name',required) - .form-group - label Email - input.form-control(ng-model='i.email',required) - button.btn.btn-default(ng-click='addInvitee()') Add + h2.text-center Create a lunch run + form(name='form',novalidate,role='form') + div.row + fieldset.col-xs-12.col-sm-6.col-md-6.col-lg-6 + legend.text-center You and your run + div.form-group + input#name.form-control(type='text',ng-model='run.name',required,placeholder='Name your run') + div.form-group + input#creatorName.form-control(type='text',ng-model='run.creatorName',required,placeholder='Your name') + div.form-group + input#creatorEmail.form-control(type='email',ng-model='run.creatorEmail',required,placeholder='Your email') + div.form-group + input#restaurant.form-control(type='text',ng-model='run.restaurant',placeholder='Restaurant') + div.form-group + input#menuUrl.form-control(type='url',ng-model='run.menuUrl',placeholder='Menu URL') + fieldset.col-xs-12.col-sm-6.col-md-6.col-lg-6 + legend.text-center Who's going? + div.row(ng-repeat='i in run.invitees') + .form-group.col-sm-4 + input.form-control(ng-model='i.name',required,placeholder='Name') + .form-group.col-sm-7 + input.form-control(ng-model='i.email',required,placeholder='Email') + .form-group.col-sm-1 + button.btn.btn-sm.btn-warning(ng-click='removeInvitee($index)') + span.glyphicon.glyphicon-remove + button.btn.btn-default(ng-click='addInvitee()') + span.glyphicon.glyphicon-plus + | Invite another! - button.btn.btn-primary(ng-click="create(run)",ng-disabled="form.$invalid") Create + .clearfix + button.btn.btn-lg.btn-primary.btn-block(ng-click="create(run)",ng-disabled="form.$invalid") + | Create diff --git a/views/layout.jade b/views/layout.jade index 6629089..2dceab6 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -1,7 +1,7 @@ doctype html html(lang="en",ng-app="lunchApp") head - title Prandium + title Lunch Run Me! meta(charset='utf-8') meta(http-equiv="X-UA-Compatible",content="IE-edge") meta(name="viewport",content="width=device-width,initial-scale=1") @@ -17,11 +17,11 @@ html(lang="en",ng-app="lunchApp") body - #page + #page.container #main-cell - header - h1 Prandium - small ...where lunch runs are fun + header.page-header + h1.text-center Lunch Run Me! + small  ...where lunch runs are fun div(ng-view)