added twitter embed route
This commit is contained in:
parent
7f0df2511b
commit
e304a99ba7
7 changed files with 30 additions and 25 deletions
|
@ -62,7 +62,7 @@ function checkLocalDbForClaims (name, shortUrl) {
|
||||||
|
|
||||||
function createOpenGraphInfo ({ fileType, claimId, name, fileName, fileExt }) {
|
function createOpenGraphInfo ({ fileType, claimId, name, fileName, fileExt }) {
|
||||||
return {
|
return {
|
||||||
twitterPlayerUrl: `https://spee.ch/twitterPlayer/${claimId}/${name}`,
|
embedUrl : `https://spee.ch/embed/${claimId}/${name}`,
|
||||||
showUrl : `https://spee.ch/${claimId}/${name}`,
|
showUrl : `https://spee.ch/${claimId}/${name}`,
|
||||||
source : `https://spee.ch/${claimId}/${name}${fileExt}`,
|
source : `https://spee.ch/${claimId}/${name}${fileExt}`,
|
||||||
directFileUrl: `https://spee.ch/media/${fileName}`,
|
directFileUrl: `https://spee.ch/media/${fileName}`,
|
||||||
|
|
|
@ -36,12 +36,12 @@ module.exports = (app) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// route to display all free public claims at a given name
|
// route to display all free public claims at a given name
|
||||||
app.get('/twitterPlayer/:claimId/:fileName', ({ params }, res) => {
|
app.get('/embed/:claimId/:fileName', ({ params }, res) => {
|
||||||
const claimId = params.claimId;
|
const claimId = params.claimId;
|
||||||
const fileName = params.fileName;
|
const fileName = params.fileName;
|
||||||
const fileExtension = '.mp4';
|
const fileExtension = '.mp4';
|
||||||
// get and render the content
|
// get and render the content
|
||||||
res.status(200).render('twitterPlayer', { layout: 'twitterPlayer', claimId, fileName, fileExtension });
|
res.status(200).render('embed', { layout: 'embed', claimId, fileName, fileExtension });
|
||||||
});
|
});
|
||||||
// route to display all free public claims at a given name
|
// route to display all free public claims at a given name
|
||||||
app.get('/:name/all', ({ ip, originalUrl, params }, res) => {
|
app.get('/:name/all', ({ ip, originalUrl, params }, res) => {
|
||||||
|
|
|
@ -82,12 +82,12 @@ const hbs = expressHandlebars.create({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addTwitterCard (mimeType, source, twitterPlayerUrl, directFileUrl) {
|
addTwitterCard (mimeType, source, embedUrl, directFileUrl) {
|
||||||
let basicTwitterTags = `<meta name="twitter:site" content="@lbryio" />`;
|
let basicTwitterTags = `<meta name="twitter:site" content="@lbryio" />`;
|
||||||
if (mimeType === 'video/mp4') {
|
if (mimeType === 'video/mp4') {
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`${basicTwitterTags} <meta name="twitter:card" content="player" />
|
`${basicTwitterTags} <meta name="twitter:card" content="player" />
|
||||||
<meta name="twitter:player" content="${twitterPlayerUrl}>
|
<meta name="twitter:player" content="${embedUrl}>
|
||||||
<meta name="twitter:player:width" content="480" />
|
<meta name="twitter:player:width" content="480" />
|
||||||
<meta name="twitter:player:height" content="480" />
|
<meta name="twitter:player:height" content="480" />
|
||||||
<meta name="twitter:player:stream" content="${directFileUrl}" />
|
<meta name="twitter:player:stream" content="${directFileUrl}" />
|
||||||
|
|
21
views/layouts/embed.handlebars
Normal file
21
views/layouts/embed.handlebars
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
video {
|
||||||
|
width:100%;
|
||||||
|
max-width:600px;
|
||||||
|
height:auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{{{body}}}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="/assets/css/generalStyle.css" type="text/css">
|
<link rel="stylesheet" href="/assets/css/generalStyle.css" type="text/css">
|
||||||
<link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css">
|
<link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css">
|
||||||
<meta property="fb:app_id" content="1371961932852223">
|
<meta property="fb:app_id" content="1371961932852223">
|
||||||
{{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.twitterPlayerUrl openGraphInfo.directFileUrl}}}
|
{{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}}
|
||||||
{{{addOpenGraph fileInfo.name fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source}}}
|
{{{addOpenGraph fileInfo.name fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source}}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
video {
|
|
||||||
width:100%;
|
|
||||||
max-width:600px;
|
|
||||||
height:auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
{{{body}}}
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in a new issue