added twitter player card

This commit is contained in:
bill bittner 2017-08-07 15:22:09 -07:00
parent 35cf994149
commit 53709661c8
2 changed files with 15 additions and 26 deletions

View file

@ -49,13 +49,13 @@ const hbs = expressHandlebars.create({
);
},
addOpenGraph (title, url, source, mimeType) {
if (mimeType === 'video/mp4') {
return new Handlebars.SafeString(
`<meta property="og:title" content="${title}"/>
let basicTags = `<meta property="og:title" content="${title}"/>
<meta property="og:url" content="${url}" />
<meta property="og:site_name" content="Spee.ch" />
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
<meta property="og:image" content="https://spee.ch/assets/img/content-freedom-large.png" />
<meta property="og:description" content="View or download ${title} from spee.ch: the open-source, decentralized content host." />`;
if (mimeType === 'video/mp4') {
return new Handlebars.SafeString(
`${basicTags} <meta property="og:image" content="https://spee.ch/assets/img/content-freedom-large.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
@ -66,11 +66,7 @@ const hbs = expressHandlebars.create({
);
} else if (mimeType === 'image/gif') {
return new Handlebars.SafeString(
`<meta property="og:title" content="${title}"/>
<meta property="og:url" content="${url}" />
<meta property="og:site_name" content="Spee.ch" />
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
<meta property="og:image" content="${source}" />
`${basicTags} <meta property="og:image" content="${source}" />
<meta property="og:image:type" content="${mimeType}" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
@ -78,11 +74,7 @@ const hbs = expressHandlebars.create({
);
} else {
return new Handlebars.SafeString(
`<meta property="og:title" content="${title}"/>
<meta property="og:url" content="${url}" />
<meta property="og:site_name" content="Spee.ch" />
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
<meta property="og:image" content="${source}" />
`${basicTags} <meta property="og:image" content="${source}" />
<meta property="og:image:type" content="${mimeType}" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
@ -90,24 +82,21 @@ const hbs = expressHandlebars.create({
);
}
},
addTwitterCard (source, mimeType) {
addTwitterCard (source, mimeType, fileName, showUrl) {
let basicTwitterTags = `<meta name="twitter:card" content="player" />
<meta name="twitter:site" content="@lbryio" />`;
if (mimeType === 'video/mp4') {
return new Handlebars.SafeString(
`<meta name="twitter:card" content="player" />
<meta name="twitter:site" content="@lbryio" />
<meta name="twitter:image" content="https://spee.ch/assets/img/content-freedom-large.png" />
<meta name="twitter:player" content="https://yoursite.com/container.html"/ >
`${basicTwitterTags} <meta name="twitter:player" content="${showUrl}"/ >
<meta name="twitter:player:width" content="480" />
<meta name="twitter:player:height" content="480" />
<meta name="twitter:player:stream" content="${source}" />
<meta name="twitter:player:stream:content_type" content="video/mp4; codecs=&quot;avc1.42E01E1, mp4a.40.2&quot;" />
<meta name="twitter:player:stream" content="https://spee.ch/media/${fileName}" />
<meta name="twitter:player:stream:content_type" content="video/mp4" />
`
);
} else {
return new Handlebars.SafeString(
`<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@lbryio" />
<meta name="twitter:creator" content="@lbryio" />`
`${basicTwitterTags} <meta name="twitter:card" content="summary_large_image" />`
);
}
},

View file

@ -8,7 +8,7 @@
<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}}}
{{{addTwitterCard openGraphInfo.source fileInfo.fileType fileInfo.fileName openGraphInfo.showUrl}}}
{{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}}
</head>
<body>