493 twitter video #531

Merged
bones7242 merged 6 commits from 493-twitter-video into master 2018-07-17 19:38:18 +02:00
6 changed files with 72 additions and 15 deletions

View file

@ -16,7 +16,6 @@ checkForConfig('siteConfig');
const express = require('express'); const express = require('express');
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
const expressHandlebars = require('express-handlebars'); const expressHandlebars = require('express-handlebars');
const Handlebars = require('handlebars');
const helmet = require('helmet'); const helmet = require('helmet');
const cookieSession = require('cookie-session'); const cookieSession = require('cookie-session');
const http = require('http'); const http = require('http');
@ -81,11 +80,15 @@ function Server () {
app.use(speechPassport.session()); app.use(speechPassport.session());
// configure handlebars & register it with express app // configure handlebars & register it with express app
const hbs = expressHandlebars.create({ const viewsPath = Path.resolve(process.cwd(), 'node_modules/spee.ch/server/views');
app.engine('handlebars', expressHandlebars({
async: false,
dataType: 'text',
defaultLayout: 'embed', defaultLayout: 'embed',
handlebars : Handlebars, partialsDir: Path.join(viewsPath, '/partials'),
}); layoutsDir: Path.join(viewsPath, '/layouts')
app.engine('handlebars', hbs.engine); }));
app.set('views', viewsPath);
app.set('view engine', 'handlebars'); app.set('view engine', 'handlebars');
// set the routes on the app // set the routes on the app
skhameneh commented 2018-07-17 19:34:23 +02:00 (Migrated from github.com)
Review

what will it take to allow async?

what will it take to allow async?
bones7242 commented 2018-07-17 19:37:45 +02:00 (Migrated from github.com)
Review

hmm, I actually can't remember why I set it to false other than it was probably recommended in the express-handlebars implementation examples. I'll look into that.

hmm, I actually can't remember why I set it to `false` other than it was probably recommended in the `express-handlebars` implementation examples. I'll look into that.

View file

@ -3,8 +3,11 @@ const { details: { host } } = require('@config/siteConfig');
const sendVideoEmbedPage = ({ params }, res) => { const sendVideoEmbedPage = ({ params }, res) => {
const claimId = params.claimId; const claimId = params.claimId;
const name = params.name; const name = params.name;
// test setting response headers
console.log('removing x-frame-options');
res.removeHeader('X-Frame-Options');
// get and render the content // get and render the content
res.status(200).render('embed', { layout: 'embed', host, claimId, name }); res.status(200).render('embed', { host, claimId, name });
}; };
module.exports = sendVideoEmbedPage; module.exports = sendVideoEmbedPage;

View file

@ -1 +1,4 @@
<video width="100%" controls src="{{host}}/asset/{{name}}/{{claimId}}" type="video/mp4"></video> <video controls>
<source src="{{host}}/asset/{{name}}/{{claimId}}" type="video/mp4">
Your browser does not support video
</video>

View file

@ -1,16 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<body id="embed-video-player"> <body>
<style type="text/css"> <style type="text/css">
video { video {
width:100%; width:100%;
max-width:600px; max-width:600px;
height:auto; height:auto;
} }
</style> </style>
{{{body}}} {{{ body }}}
</body> </body>
</html> </html>

View file

@ -9,12 +9,16 @@
</head> </head>
<body> <body>
<img src="https://media.giphy.com/media/vwEHGjx71HSytx5mY8/giphy-facebook_s.jpg" alt="test embed"/> <img src="https://media.giphy.com/media/vwEHGjx71HSytx5mY8/giphy-facebook_s.jpg" alt="test embed"/>
<p>no identifier, no ending</p> <p>no identifier, no ending</p>
<img src="https://dev1.spee.ch/typingcat" alt="no identifier, no ending"/> <img src="https://dev1.spee.ch/typingcat" alt="no identifier, no ending"/>
<p>no identifier, yes ending</p> <p>no identifier, yes ending</p>
<img src="https://dev1.spee.ch/typingcat.gif" alt="no identifier, yes ending"/> <img src="https://dev1.spee.ch/typingcat.gif" alt="no identifier, yes ending"/>
<p>yes identifier, no ending</p> <p>yes identifier, no ending</p>
<img src="https://dev1.spee.ch/8/typingcat" alt="yes identifier, no ending"/> <img src="https://dev1.spee.ch/8/typingcat" alt="yes identifier, no ending"/>
<p>yes identifier, yes ending</p> <p>yes identifier, yes ending</p>
<img src="https://dev1.spee.ch/8/typingcat.gif" alt="yes identifier, yes ending"/> <img src="https://dev1.spee.ch/8/typingcat.gif" alt="yes identifier, yes ending"/>
</body> </body>

44
test/test-iframe.html Normal file
View file

@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
iframe {
width: 100%;
}
</style>
</head>
<body>
<p>i frame: weather.gov</p>
<iframe src="http://www.weather.gov/"></iframe>
<p>i frame: dev1.spee.ch video direct embed page</p>
<iframe src="https://dev1.spee.ch/video-embed/sn123ow-1/c3cadc36688ca37c7526536cfed4448e31bacf56">
iframe not supported
</iframe>
<p>i frame: dev1.spee.ch image direct asset</p>
<iframe src="https://dev1.spee.ch/asset/donut-pla2tter/d8d93f3818f4cb8398637706fb20cc57c441261f">
iframe not supported
</iframe>
<p>i frame: image from internet</p>
<iframe src="https://c.static-nike.com/a/images/t_PDP_1280_v1/f_auto/kod3bxfy7vx99bca26cb/elite-competition-8p-basketball-721MyM.jpg">
iframe not supported
</iframe>
<p>i frame: giphy </p>
<iframe src="https://media.giphy.com/media/vwEHGjx71HSytx5mY8/giphy-facebook_s.jpg">
iframe not supported
</iframe>
<p>i frame: giphy 2</p>
<iframe src="https://media.giphy.com/media/vwEHGjx71HSytx5mY8/giphy-facebook_s">
iframe not supported
</iframe>
</body>
</html>