Skip to content

Commit

Permalink
add next page, fix https
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Mar 1, 2017
1 parent a57c7ac commit 30040d5
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 15 deletions.
5 changes: 1 addition & 4 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
env: flex
runtime: nodejs
env_variables:
image: 'apple'

runtime: custom
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"pubnub": "^4.4.4",
"serve-favicon": "^2.4.0",
"swig": "^1.4.2",
"uuid": "^3.0.1"
"uuid": "^3.0.1",
"yes-https": "^0.0.3"
},
"devDependencies": {},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function takepicture() {
return response.json();
}).then((result) => {
console.log(result);
window.location.href = result.url;
window.location.href = '/next?url=' + encodeURIComponent(result.url);
}).catch((err) => {
console.error('There was a problem :(');
console.error(err);
Expand Down
18 changes: 10 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const PubNub = require('pubnub');
const multer = require('multer');
const uuid = require('uuid');
const fs = require('fs');
const yes = require('yes-https');
const gm = require('gm');
const child_process = require('child_process');
const cloudSettings = {
Expand All @@ -25,6 +26,7 @@ const bucket = storage.bucket('photobooth-next');

// configure express
const app = express();
app.use(yes());
const upload = multer();
app.set('views', path.join(__dirname, 'views'));
app.engine('html', swig.renderFile);
Expand Down Expand Up @@ -52,6 +54,12 @@ app.get('/dashboard', (req, res, next) => {
});
});

app.get('/next', (req, res, next) => {

res.render('next', {
url: req.query.url
});
});


// find objects in the picture with the cloud vision API
Expand Down Expand Up @@ -91,19 +99,13 @@ app.post('/sendpic', upload.array(), (req, res, next) => {
console.error(err);
return next(err);
}
let expiration = new Date();
expiration.setDate(expiration.getDate() + 1);
let config = {
action: 'read',
expires: expiration
}
file.getSignedUrl(config, (err, url) => {
file.makePublic((err, data) => {
if (err) {
console.error(err);
return next(err);
}
res.json({
url: url
url: file.metadata.mediaLink
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script src="script.js"></script>
</head>
<body>
<div id="message">Your card is on it's way!</div>
<div id="message">Your card is on its way!</div>
<div class="camera">
<video id="video">Video stream not available.</video>
<button id="startbutton"></button>
Expand Down
41 changes: 41 additions & 0 deletions views/next.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<html>
<head>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@GoogleCloud">
<meta name="twitter:creator" content="@JustinBeckwith">
<meta name="twitter:title" content="You can do that on App Engine!?">
<meta name="twitter:description" content="I came to GCP Next 2017 to learn all about App Engine. You can too!">
<meta name="twitter:image" content="{{url}}">
<script>//window.location.href='https://cloud.google.com/appengine'</script>
</head>
<body>
<a class="twitter-share-button"
data-size="large"
href="https://twitter.com/intent/tweet?text=I%20came%20to%20GCP%20Next%202017%20to%20learn%20all%20about%20App%20Engine.%20You%20can%20too!">
Tweet
</a>
<div style="margin-top:15px;">
<a href="https://cloud.google.com/appengine">
<img src="{{url}}">
</a>
<div>
<script>
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);

t._e = [];
t.ready = function(f) {
t._e.push(f);
};

return t;
}(document, "script", "twitter-wjs"));
</script>
</body>
</html>
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2256,3 +2256,7 @@ yargs@~3.5.4:
decamelize "^1.0.0"
window-size "0.1.0"
wordwrap "0.0.2"

yes-https@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/yes-https/-/yes-https-0.0.3.tgz#d95927d619271169c7c977c753dd510252e3bae6"

0 comments on commit 30040d5

Please sign in to comment.