From bdd8f0b5e960c1f1a997a96a5b77a830880b4308 Mon Sep 17 00:00:00 2001 From: Kendrick Coleman Date: Fri, 24 Apr 2015 00:11:20 -0400 Subject: [PATCH] updated for working ECS --- .travis.yml | 6 ++++++ manifest.yml | 10 +++++++++ routes/infophotos.js | 49 +++++++++++++++++++++++++++----------------- 3 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 .travis.yml create mode 100644 manifest.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cabaadb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "0.12" + - "0.10" +services: + - mongodb \ No newline at end of file diff --git a/manifest.yml b/manifest.yml new file mode 100644 index 0000000..9d0353d --- /dev/null +++ b/manifest.yml @@ -0,0 +1,10 @@ +--- +applications: +- name: emcphotobooth + memory: 512M + instances: 1 + path: . + domain: cfapps.io + command: npm install && npm start + services: + - kcoleman-emcphotobooth-mongo \ No newline at end of file diff --git a/routes/infophotos.js b/routes/infophotos.js index 45a3870..fc40a94 100644 --- a/routes/infophotos.js +++ b/routes/infophotos.js @@ -148,10 +148,10 @@ router.route('/') res.format({ html: function(){ res.render('infophotos/thanks', { - title: "Photobooth Registration Success" + title: "Photo Booth Registration Success" }); /* If it worked, set the header so the address bar doesn't still say /adduser - res.location("Photobooth Registration Success"); + res.location("Photo Booth Registration Success"); // And forward to success page res.redirect("../");*/ }, @@ -173,7 +173,7 @@ router.route('/') /* GET New Infophoto page. */ router.get('/new', function(req, res) { - res.render('infophotos/new', { title: 'Photobooth Registration' }); + res.render('infophotos/new', { title: 'Photo Booth Registration' }); }); /* GET List of Pictures to be taken */ @@ -208,7 +208,7 @@ router.get('/takepic/:uniqueurl', function(req, res) { res.format({ html: function(){ res.render('infophotos/takepic', { - title: "Photobooth", + title: "Photo Booth", "infophoto" : infophoto }); } @@ -220,22 +220,32 @@ router.get('/takepic/:uniqueurl', function(req, res) { /* POST Add Picture to ECS/S3 */ router.post('/addpic/:uniqueurl', function(req, res) { buf = new Buffer(req.body.photo.replace(/^data:image\/\w+;base64,/, ""),'base64') - var s3 = new AWS.S3({accessKeyId: S3accessKeyId, secretAccessKey: S3secretAccessKey, endpoint: S3endpoint, signatureVersion: 'v2'}); + var s3 = new AWS.S3({ + accessKeyId: S3accessKeyId, + secretAccessKey: S3secretAccessKey, + endpoint: S3endpoint + }); var params = { - Bucket: 'emcphotobooth', /* required */ - Key: req.params.uniqueurl + '/' + req.body.number + '.jpeg', /* required */ - ACL: 'public-read', + Bucket: 'emcphotobooth', + Key: req.params.uniqueurl + '/' + req.body.number + '.jpeg', Body: buf, - ContentType: 'image/jpeg', - ContentEncoding: 'base64' + ACL: 'public-read', + ContentType: 'image/jpeg' }; s3.putObject(params, function(err, data) { - if (err) console.log(err, err.stack); // an error occurred - else console.log(data); // successful response + if (err) { + console.log(err, err.stack); // an error occurred + } + else { + console.log(data); // successful response + } }); mongoose.model('Infophoto').findOneAndUpdate({uniqueurl : req.params.uniqueurl}, - {$push: {'photos': 'https://' + S3url + '/emcphotobooth/' + req.params.uniqueurl + '/' + req.body.number + '.jpeg'}}, + /* IF AWS */ + //{$push: {'photos': 'https://' + S3url + '/emcphotobooth/' + req.params.uniqueurl + '/' + req.body.number + '.jpeg'}}, + /* IF ViPROnline */ + {$push: {'photos': 'http://' + S3url + '/' + req.params.uniqueurl + '/' + req.body.number + '.jpeg'}}, {safe: true, upsert: true}, function(err, model) { //console.log(err); @@ -257,10 +267,10 @@ router.post('/addpic/:uniqueurl', function(req, res) { /* POST Send Email */ router.post('/sendmail/:uniqueurl', function(req, res) { var mailOptions = { - from: 'EMC Code Photobooth ', // sender address + from: 'EMC Code Photo Booth ', // sender address to: req.body.email, // list of receivers - subject: 'Your EMC {code} Photobooth Photos!', // Subject line - html: '

EMC {code} Photobooth Photos

EMC World Las Vegas

May 4-7, 2015

Thanks for checking out EMC {code} while you were at EMC World! EMC is committed to the open source movement. EMC is constantly releasing new open source bits and it all lives on the EMC {code} Github page. Also be sure to check out the EMC {code} Blog frequently for information on some of our latest projects.

Want to relive those Photobooth moments? Go check out your photos at ' + req.params.uniqueurl + '

' + subject: 'Your EMC {code} Photo Booth Photos!', // Subject line + html: '

EMC {code} Photo Booth Photos

EMC World Las Vegas

May 4-7, 2015

Thanks for checking out EMC {code} while you were at EMC World! EMC is committed to the open source movement. EMC is constantly releasing new open source bits and it all lives on the EMC {code} Github page. Also be sure to check out the EMC {code} Blog frequently for information on some of our latest projects.

Want to relive those Photo Booth moments? Go check out your photos at ' + req.params.uniqueurl + '

' }; // send mail with defined transport object @@ -283,13 +293,14 @@ router.post('/sendmail/:uniqueurl', function(req, res) { /* POST Send Tweet */ router.post('/sendtweet/:uniqueurl', function(req, res) { + console.log('sending tweet'); var twitid = req.body.twitid.toString(); if(twitid.charAt(0) != '@'){ twitid = '@' + twitid; } //get the image from S3/ECS that will post a photo to twitter as well - request.get('https://' + S3url + '/emcphotobooth/' + req.params.uniqueurl + '/photo2.jpeg', function (error, response, photoboothPic) { + request.get('http://' + S3url + '/' + req.params.uniqueurl + '/photo2.jpeg', function (error, response, photoboothPic) { if (!error && response.statusCode == 200) { //post the image to twitter twitterClient.post('media/upload', { media: photoboothPic }, function (err, media, response) { @@ -298,7 +309,7 @@ router.post('/sendtweet/:uniqueurl', function(req, res) { console.log(err); } else { var status = { - status: twitid + ' Check out your EMC World Photobooth Photos at http://emccodephotobooth.cfapps.io/infophotos/' + req.params.uniqueurl + ' #devopsemc', + status: twitid + ' Check out your EMC World Photo Booth Photos at http://emcphotobooth.cfapps.io/infophotos/' + req.params.uniqueurl + ' #DevOpsEMC', media_ids: media.media_id_string } @@ -372,7 +383,7 @@ router.route('/:uniqueurl') res.format({ html: function(){ res.render('infophotos/show', { - title: "Photobooth for " + infophoto.fname, + title: "Photo Booth for " + infophoto.fname, "infophoto" : infophoto }); },