Open graph #132
2 changed files with 15 additions and 26 deletions
39
speech.js
39
speech.js
|
@ -49,13 +49,13 @@ const hbs = expressHandlebars.create({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
addOpenGraph (title, url, source, mimeType) {
|
addOpenGraph (title, url, source, mimeType) {
|
||||||
if (mimeType === 'video/mp4') {
|
let basicTags = `<meta property="og:title" content="${title}"/>
|
||||||
return new Handlebars.SafeString(
|
|
||||||
`<meta property="og:title" content="${title}"/>
|
|
||||||
<meta property="og:url" content="${url}" />
|
<meta property="og:url" content="${url}" />
|
||||||
<meta property="og:site_name" content="Spee.ch" />
|
<meta property="og:site_name" content="Spee.ch" />
|
||||||
<meta property="og:description" content="Spee.ch: open-source, decentralized content hosting." />
|
<meta property="og:description" content="View or download ${title} from spee.ch: the open-source, decentralized content host." />`;
|
||||||
<meta property="og:image" content="https://spee.ch/assets/img/content-freedom-large.png" />
|
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:type" content="image/png" />
|
||||||
<meta property="og:image:width" content="600" />
|
<meta property="og:image:width" content="600" />
|
||||||
<meta property="og:image:height" content="315" />
|
<meta property="og:image:height" content="315" />
|
||||||
|
@ -66,11 +66,7 @@ const hbs = expressHandlebars.create({
|
||||||
);
|
);
|
||||||
} else if (mimeType === 'image/gif') {
|
} else if (mimeType === 'image/gif') {
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<meta property="og:title" content="${title}"/>
|
`${basicTags} <meta property="og:image" content="${source}" />
|
||||||
<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}" />
|
|
||||||
<meta property="og:image:type" content="${mimeType}" />
|
<meta property="og:image:type" content="${mimeType}" />
|
||||||
<meta property="og:image:width" content="600" />
|
<meta property="og:image:width" content="600" />
|
||||||
<meta property="og:image:height" content="315" />
|
<meta property="og:image:height" content="315" />
|
||||||
|
@ -78,11 +74,7 @@ const hbs = expressHandlebars.create({
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<meta property="og:title" content="${title}"/>
|
`${basicTags} <meta property="og:image" content="${source}" />
|
||||||
<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}" />
|
|
||||||
<meta property="og:image:type" content="${mimeType}" />
|
<meta property="og:image:type" content="${mimeType}" />
|
||||||
<meta property="og:image:width" content="600" />
|
<meta property="og:image:width" content="600" />
|
||||||
<meta property="og:image:height" content="315" />
|
<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') {
|
if (mimeType === 'video/mp4') {
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<meta name="twitter:card" content="player" />
|
`${basicTwitterTags} <meta name="twitter:player" content="${showUrl}"/ >
|
||||||
<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"/ >
|
|
||||||
<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="${source}" />
|
<meta name="twitter:player:stream" content="https://spee.ch/media/${fileName}" />
|
||||||
<meta name="twitter:player:stream:content_type" content="video/mp4; codecs="avc1.42E01E1, mp4a.40.2"" />
|
<meta name="twitter:player:stream:content_type" content="video/mp4" />
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<meta name="twitter:card" content="summary_large_image" />
|
`${basicTwitterTags} <meta name="twitter:card" content="summary_large_image" />`
|
||||||
<meta name="twitter:site" content="@lbryio" />
|
|
||||||
<meta name="twitter:creator" content="@lbryio" />`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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 openGraphInfo.source fileInfo.fileType}}}
|
{{{addTwitterCard openGraphInfo.source fileInfo.fileType fileInfo.fileName openGraphInfo.showUrl}}}
|
||||||
{{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}}
|
{{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in a new issue