added twitter player route

This commit is contained in:
bill bittner 2017-08-07 17:08:03 -07:00
parent 53709661c8
commit 7f0df2511b
7 changed files with 39 additions and 14 deletions

View file

@ -60,11 +60,12 @@ function checkLocalDbForClaims (name, shortUrl) {
});
}
function createOpenGraphInfo ({ fileType, claimId, name, fileExt }) {
function createOpenGraphInfo ({ fileType, claimId, name, fileName, fileExt }) {
return {
type : fileType.substring(0, fileType.indexOf('/')),
twitterPlayerUrl: `https://spee.ch/twitterPlayer/${claimId}/${name}`,
showUrl : `https://spee.ch/${claimId}/${name}`,
source : `https://spee.ch/${claimId}/${name}${fileExt}`,
directFileUrl : `https://spee.ch/media/${fileName}`,
};
}

View file

@ -36,6 +36,14 @@ module.exports = (app) => {
});
});
// route to display all free public claims at a given name
app.get('/twitterPlayer/:claimId/:fileName', ({ params }, res) => {
const claimId = params.claimId;
const fileName = params.fileName;
const fileExtension = '.mp4';
// get and render the content
res.status(200).render('twitterPlayer', { layout: 'twitterPlayer', claimId, fileName, fileExtension });
});
// route to display all free public claims at a given name
app.get('/:name/all', ({ ip, originalUrl, params }, res) => {
// get and render the content
getAllFreePublicClaims(params.name)

View file

@ -48,9 +48,9 @@ const hbs = expressHandlebars.create({
</script>`
);
},
addOpenGraph (title, url, source, mimeType) {
addOpenGraph (title, mimeType, showUrl, source) {
let basicTags = `<meta property="og:title" content="${title}"/>
<meta property="og:url" content="${url}" />
<meta property="og:url" content="${showUrl}" />
<meta property="og:site_name" content="Spee.ch" />
<meta property="og:description" content="View or download ${title} from spee.ch: the open-source, decentralized content host." />`;
if (mimeType === 'video/mp4') {
@ -82,15 +82,15 @@ const hbs = expressHandlebars.create({
);
}
},
addTwitterCard (source, mimeType, fileName, showUrl) {
let basicTwitterTags = `<meta name="twitter:card" content="player" />
<meta name="twitter:site" content="@lbryio" />`;
addTwitterCard (mimeType, source, twitterPlayerUrl, directFileUrl) {
let basicTwitterTags = `<meta name="twitter:site" content="@lbryio" />`;
if (mimeType === 'video/mp4') {
return new Handlebars.SafeString(
`${basicTwitterTags} <meta name="twitter:player" content="${showUrl}"/ >
`${basicTwitterTags} <meta name="twitter:card" content="player" />
<meta name="twitter:player" content="${twitterPlayerUrl}>
<meta name="twitter:player:width" content="480" />
<meta name="twitter:player:height" content="480" />
<meta name="twitter:player:stream" content="https://spee.ch/media/${fileName}" />
<meta name="twitter:player:stream" content="${directFileUrl}" />
<meta name="twitter:player:stream:content_type" content="video/mp4" />
`
);

View file

@ -8,8 +8,8 @@
<link rel="stylesheet" href="/assets/css/generalStyle.css" type="text/css">
<link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css">
<meta property="fb:app_id" content="1371961932852223">
{{{addTwitterCard openGraphInfo.source fileInfo.fileType fileInfo.fileName openGraphInfo.showUrl}}}
{{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}}
{{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.twitterPlayerUrl openGraphInfo.directFileUrl}}}
{{{addOpenGraph fileInfo.name fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source}}}
</head>
<body>
{{{ body }}}

View file

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

View file

@ -9,7 +9,6 @@
{{else}}
<img class="show-asset-lite" src="/media/{{fileInfo.fileName}}" alt="{{fileInfo.fileName}}"/>
{{/ifConditional}}
</a>
</div>

View file

@ -0,0 +1 @@
<video id="video" width="100%" controls src="https://spee.ch/{{claimId}}/{{fileName}}{{fileExtension}}" type="video/mp4"></video>