Open graph #132

Merged
bones7242 merged 14 commits from open-graph into master 2017-08-08 07:09:36 +02:00
3 changed files with 29 additions and 18 deletions
Showing only changes of commit 9015c186c9 - Show all commits

View file

@ -48,20 +48,8 @@ const hbs = expressHandlebars.create({
</script>`
);
},
addOpenGraph (title, url, type, source, mimeType) {
if (type === 'image') {
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}" />
<meta property="og:image:type" content="${mimeType}" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
<meta property="og:type" content="article" />`
);
} else if (type === 'video') {
addOpenGraph (title, url, source, mimeType) {
if (mimeType === 'video/mp4') {
return new Handlebars.SafeString(
`<meta property="og:title" content="${title}"/>
<meta property="og:url" content="${url}" />
@ -73,8 +61,33 @@ const hbs = expressHandlebars.create({
<meta property="og:image:height" content="315" />
<meta property="og:type" content="video" />
<meta property="og:video" content="${source}" />
<meta property="og:video:secure_url" content="${source}" />
<meta property="og:video:type" content="${mimeType}" />`
);
} 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}" />
<meta property="og:image:type" content="${mimeType}" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
<meta property="og:type" content="video.other" />`
);
} 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}" />
<meta property="og:image:type" content="${mimeType}" />
<meta property="og:image:width" content="600" />
<meta property="og:image:height" content="315" />
<meta property="og:type" content="article" />`
);
}
},
addTwitterCard (assetType, source) {

View file

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

View file

@ -6,10 +6,8 @@
{{!--fallback--}}
Your browser does not support the <code>video</code> element.
</video>
{{addOpenGraph fileInfo.name links.showUrl 'video' links.source fileInfo.fileType }}
{{else}}
<img class="show-asset-lite" src="/media/{{fileInfo.fileName}}" alt="{{fileInfo.fileName}}"/>
{{addOpenGraph fileInfo.name links.showUrl 'image' links.source fileInfo.fileType }}
<img class="show-asset-lite" src="/media/{{fileInfo.fileName}}" alt="{
{{/ifConditional}}
</a>
</div>