mirror of
https://github.com/atlanticbiomedical/website.git
synced 2025-07-01 18:07:27 -04:00
made email from work
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
"masonry": "~3.1.5",
|
||||
"angular-masonry": "~0.9.1",
|
||||
"imagesloaded": "~3.1.8",
|
||||
"jquery-colorbox": "~1.5.14"
|
||||
"jquery-colorbox": "~1.5.14",
|
||||
"angular-foundation": "~0.4.0"
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ gulp.task('vendor', function() {
|
||||
'vendor/angular-resource/angular-resource.js',
|
||||
'vendor/angular-sanitize/angular-sanitize.js',
|
||||
'vendor/angular-ui-router/release/angular-ui-router.js',
|
||||
'vendor/angular-foundation/mm-foundation.min.js',
|
||||
'vendor/angular-foundation/mm-foundation-tpls.min.js',
|
||||
'vendor/lodash/dist/lodash.js',
|
||||
'vendor/masonry/dist/masonry.pkgd.js',
|
||||
'vendor/angular-masonry/angular-masonry.js',
|
||||
@ -47,7 +49,7 @@ gulp.task('js', function() {
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(templates({ standalone: true }));
|
||||
|
||||
var js = gulp.src(['src/**/imdex.js', 'src/**/*.js'])
|
||||
var js = gulp.src(['src/**/index.js', 'src/**/*.js'])
|
||||
.pipe(plumber())
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat('src.js'))
|
||||
|
32
biomed-frontend/src/app/controllers.js
Normal file
32
biomed-frontend/src/app/controllers.js
Normal file
@ -0,0 +1,32 @@
|
||||
angular.module('biomed-frontend')
|
||||
.controller('NavCtrl', function($scope, $modal) {
|
||||
|
||||
$scope.showEmail = function() {
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'app/email.html',
|
||||
controller: 'EmailCtrl'
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
.controller('EmailCtrl', function($scope, $http, $modalInstance) {
|
||||
|
||||
$scope.model = {};
|
||||
|
||||
$scope.send = function() {
|
||||
console.log($scope.model);
|
||||
|
||||
$http.post('/api/email', $scope.model)
|
||||
.success(function() {
|
||||
$modalInstance.close();
|
||||
})
|
||||
.error(function() {
|
||||
$modalInstance.close();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.close = function() {
|
||||
$modalInstance.close();
|
||||
}
|
||||
|
||||
});
|
32
biomed-frontend/src/app/email.html
Normal file
32
biomed-frontend/src/app/email.html
Normal file
@ -0,0 +1,32 @@
|
||||
<div id="emailModal" class="tiny">
|
||||
<div class="row">
|
||||
<div class="large-12 columnns">
|
||||
<div class="small-12 columns">
|
||||
<h2>Email us:</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form data-abide ng-submit="send()">
|
||||
<div class="name-field">
|
||||
<label>Your name <small>required</small>
|
||||
<input type="text" required pattern="[a-zA-Z]+" ng-model="model.name">
|
||||
</label>
|
||||
<small class="error">Name is required and must be a string.</small>
|
||||
</div>
|
||||
<div class="email-field">
|
||||
<label>Email <small>required</small>
|
||||
<input type="email" required ng-model="model.email">
|
||||
</label>
|
||||
<small class="error">An email address is required.</small>
|
||||
</div>
|
||||
<div>
|
||||
<label>Message
|
||||
<textarea ng-model="model.message"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<a class="close()">×</a>
|
||||
</div>
|
@ -3,8 +3,8 @@ angular.module('biomed-frontend', [
|
||||
'ui.router',
|
||||
'ngResource',
|
||||
'angular-loading-bar',
|
||||
'wu.masonry'
|
||||
|
||||
'wu.masonry',
|
||||
'mm.foundation'
|
||||
])
|
||||
.factory('Posts', function($resource) {
|
||||
return $resource('/api/v1/posts/:_id',
|
||||
@ -56,4 +56,4 @@ angular.module('biomed-frontend', [
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!--Top Bar -->
|
||||
<div class="fixed">
|
||||
<nav class="top-bar" data-topbar>
|
||||
<nav class="top-bar" data-topbar ng-controller="NavCtrl">
|
||||
<ul class="title-area">
|
||||
<!-- Title Area -->
|
||||
<li class="name">
|
||||
@ -21,7 +21,7 @@
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a href="#" data-reveal-id="emailModal">Email us</a>
|
||||
<a ng-click="showEmail()">Email us</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
@ -36,40 +36,7 @@
|
||||
</nav>
|
||||
</div>
|
||||
<!--Reveals-->
|
||||
<div id="emailModal" class="reveal-modal tiny" data-reveal>
|
||||
<div class="row">
|
||||
<div class="large-12 columnns">
|
||||
<div class="small-12 columns">
|
||||
<h2>Email us:</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<form data-abide>
|
||||
<div class="name-field">
|
||||
<label>Your name <small>required</small>
|
||||
<input type="text" required pattern="[a-zA-Z]+">
|
||||
</label>
|
||||
<small class="error">Name is required and must be a string.</small>
|
||||
</div>
|
||||
<div class="email-field">
|
||||
<label>Email <small>required</small>
|
||||
<input type="email" required>
|
||||
</label>
|
||||
<small class="error">An email address is required.</small>
|
||||
</div>
|
||||
<div>
|
||||
<label>Message
|
||||
<textarea></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
|
||||
<a class="close-reveal-modal">×</a>
|
||||
</div>
|
||||
<div id="contactModal" class="reveal-modal small" data-reveal>
|
||||
<div class="row">
|
||||
<div class="medium-12 columns">
|
||||
|
@ -7,6 +7,7 @@
|
||||
"body-parser": "~1.9.0",
|
||||
"method-override": "~2.2.0",
|
||||
"mongoose": "~3.8.17",
|
||||
"express-restify-mongoose": "~0.6.10"
|
||||
"express-restify-mongoose": "~0.6.10",
|
||||
"emailjs": "~0.3.12"
|
||||
}
|
||||
}
|
||||
|
@ -3,20 +3,28 @@ var express = require('express');
|
||||
var bodyParser = require('body-parser');
|
||||
var methodOverride = require('method-override');
|
||||
var mongoose = require('mongoose');
|
||||
var email = require('emailjs');
|
||||
var Schema = mongoose.Schema;
|
||||
var restify = require('express-restify-mongoose');
|
||||
|
||||
mongoose.connect('mongodb://localhost/biomed');
|
||||
mongoose.connect('mongodb://localhost/biomed_prod');
|
||||
|
||||
var emailServer = email.server.connect({
|
||||
user: 'api@atlanticbiomedical.com',
|
||||
password: 'success4',
|
||||
host: 'smtp.gmail.com',
|
||||
ssl: true
|
||||
});
|
||||
|
||||
var Post = new Schema({
|
||||
title: { type: String },
|
||||
preview: { type: String },
|
||||
details: { type: String },
|
||||
image: { type: String },
|
||||
gallery: [
|
||||
{ type: String }
|
||||
],
|
||||
status: { type: String }
|
||||
title: { type: String },
|
||||
preview: { type: String },
|
||||
details: { type: String },
|
||||
image: { type: String },
|
||||
gallery: [
|
||||
{ type: String }
|
||||
],
|
||||
status: { type: String }
|
||||
});
|
||||
var PostModel = mongoose.model('Post', Post);
|
||||
|
||||
@ -24,12 +32,33 @@ var app = express();
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(methodOverride());
|
||||
|
||||
app.post('/api/email', function(req, res) {
|
||||
|
||||
if (req.body.name && req.body.email && req.body.message) {
|
||||
|
||||
emailServer.send({
|
||||
from: 'Website <api@atlanticbiomedical.com>',
|
||||
to: 'akirayasha@gmail.com',
|
||||
"reply-to": req.body.email,
|
||||
subject: 'Message from website',
|
||||
text: 'Name: ' + req.body.name + "\n" + "E-Mail: " + req.body.email + "\n\n" + req.body.message
|
||||
}, function(err, message) {
|
||||
if (err) {
|
||||
console.log("Failed to send message from website.", err);
|
||||
}
|
||||
});
|
||||
|
||||
res.json(null);
|
||||
}
|
||||
});
|
||||
|
||||
restify.serve(app, PostModel, {
|
||||
prereq: function(req) {
|
||||
return req.method === 'GET';
|
||||
}
|
||||
prereq: function(req) {
|
||||
return req.method === 'GET';
|
||||
}
|
||||
});
|
||||
|
||||
http.createServer(app).listen(3000, function() {
|
||||
console.log('Express server listening on port 3000');
|
||||
console.log('Express server listening on port 3000');
|
||||
});
|
||||
|
Reference in New Issue
Block a user