281 unfurl show links #303
4 changed files with 35 additions and 33 deletions
|
@ -17,27 +17,27 @@ module.exports = {
|
|||
return new Handlebars.SafeString(gaCode);
|
||||
},
|
||||
addOpenGraph ({ ogTitle, contentType, ogDescription, thumbnail, showUrl, source, ogThumbnailContentType }) {
|
||||
const ogTitleTag = `<meta property="og:title" content="${ogTitle}" >`;
|
||||
const ogUrlTag = `<meta property="og:url" content="${showUrl}" >`;
|
||||
const ogSiteNameTag = `<meta property="og:site_name" content="Spee.ch" >`;
|
||||
const ogDescriptionTag = `<meta property="og:description" content="${ogDescription}" >`;
|
||||
const ogImageWidthTag = '<meta property="og:image:width" content="600" >';
|
||||
const ogImageHeightTag = '<meta property="og:image:height" content="315" >';
|
||||
const ogTitleTag = `<meta property="og:title" content="${ogTitle}" />`;
|
||||
const ogUrlTag = `<meta property="og:url" content="${showUrl}" />`;
|
||||
const ogSiteNameTag = `<meta property="og:site_name" content="Spee.ch" />`;
|
||||
const ogDescriptionTag = `<meta property="og:description" content="${ogDescription}" />`;
|
||||
const ogImageWidthTag = '<meta property="og:image:width" content="600" />';
|
||||
const ogImageHeightTag = '<meta property="og:image:height" content="315" />';
|
||||
const basicTags = `${ogTitleTag} ${ogUrlTag} ${ogSiteNameTag} ${ogDescriptionTag} ${ogImageWidthTag} ${ogImageHeightTag}`;
|
||||
let ogImageTag = `<meta property="og:image" content="${source}" >`;
|
||||
let ogImageTypeTag = `<meta property="og:image:type" content="${contentType}" >`;
|
||||
let ogTypeTag = `<meta property="og:type" content="article" >`;
|
||||
let ogImageTag = `<meta property="og:image" content="${source}" />`;
|
||||
let ogImageTypeTag = `<meta property="og:image:type" content="${contentType}" />`;
|
||||
let ogTypeTag = `<meta property="og:type" content="article" />`;
|
||||
if (contentType === 'video/mp4') {
|
||||
const ogVideoTag = `<meta property="og:video" content="${source}" >`;
|
||||
const ogVideoSecureUrlTag = `<meta property="og:video:secure_url" content="${source}" >`;
|
||||
const ogVideoTypeTag = `<meta property="og:video:type" content="${contentType}" >`;
|
||||
ogImageTag = `<meta property="og:image" content="${thumbnail}" >`;
|
||||
ogImageTypeTag = `<meta property="og:image:type" content="${ogThumbnailContentType}" >`;
|
||||
ogTypeTag = `<meta property="og:type" content="video" >`;
|
||||
const ogVideoTag = `<meta property="og:video" content="${source}" />`;
|
||||
const ogVideoSecureUrlTag = `<meta property="og:video:secure_url" content="${source}" />`;
|
||||
const ogVideoTypeTag = `<meta property="og:video:type" content="${contentType}" />`;
|
||||
ogImageTag = `<meta property="og:image" content="${thumbnail}" />`;
|
||||
ogImageTypeTag = `<meta property="og:image:type" content="${ogThumbnailContentType}" />`;
|
||||
ogTypeTag = `<meta property="og:type" content="video" />`;
|
||||
return new Handlebars.SafeString(`${basicTags} ${ogImageTag} ${ogImageTypeTag} ${ogTypeTag} ${ogVideoTag} ${ogVideoSecureUrlTag} ${ogVideoTypeTag}`);
|
||||
} else {
|
||||
if (contentType === 'image/gif') {
|
||||
ogTypeTag = `<meta property="og:type" content="video.other" >`;
|
||||
ogTypeTag = `<meta property="og:type" content="video.other" />`;
|
||||
};
|
||||
return new Handlebars.SafeString(`${basicTags} ${ogImageTag} ${ogImageTypeTag} ${ogTypeTag}`);
|
||||
}
|
||||
|
|
|
@ -48,11 +48,13 @@ function clientAcceptsHtml ({accept}) {
|
|||
return accept && accept.match(/text\/html/);
|
||||
}
|
||||
|
||||
function requestIsFromBrowser (headers) {
|
||||
return headers['user-agent'] && headers['user-agent'].match(/Mozilla/);
|
||||
};
|
||||
|
||||
function clientWantsAsset ({accept, range}) {
|
||||
const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/) && !accept.match(/text\/\*/);
|
||||
const videoIsWanted = false; // accept && range;
|
||||
logger.debug('image is wanted:', imageIsWanted);
|
||||
logger.debug('video is wanted:', videoIsWanted);
|
||||
const videoIsWanted = accept && range;
|
||||
return imageIsWanted || videoIsWanted;
|
||||
}
|
||||
|
||||
|
@ -65,8 +67,8 @@ function determineResponseType (isServeRequest, headers) {
|
|||
}
|
||||
} else {
|
||||
responseType = SHOW;
|
||||
if (clientWantsAsset(headers)) { // this is in case someone embeds a show url
|
||||
logger.debug('Show request actually want\'s an asset!');
|
||||
if (clientWantsAsset(headers) && requestIsFromBrowser(headers)) { // this is in case someone embeds a show url
|
||||
logger.debug('Show request actually wants an asset!');
|
||||
responseType = SERVE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
{{ placeCommonHeaderTags }}
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="@spee_ch" />
|
||||
<meta property="og:title" content="{{this.channelName}} on Spee.ch">
|
||||
<meta property="og:site_name" content="Spee.ch">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:image" content="https://spee.ch/assets/img/Speech_Logo_Main@OG-02.jpg">
|
||||
<meta property="og:url" content="http://spee.ch/{{this.channelName}}:{{this.longChannelId}}">
|
||||
<meta property="og:description" content="View images and videos from {{this.channelName}}">
|
||||
<meta property="og:title" content="{{this.channelName}} on Spee.ch" />
|
||||
<meta property="og:site_name" content="Spee.ch" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:image" content="https://spee.ch/assets/img/Speech_Logo_Main@OG-02.jpg" />
|
||||
<meta property="og:url" content="http://spee.ch/{{this.channelName}}:{{this.longChannelId}}" />
|
||||
<meta property="og:description" content="View images and videos from {{this.channelName}}" />
|
||||
<!--google font-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
|
||||
<!-- google analytics -->
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
{{ placeCommonHeaderTags }}
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="@spee_ch" />
|
||||
<meta property="og:title" content="Spee.ch">
|
||||
<meta property="og:site_name" content="Spee.ch">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:image" content="https://spee.ch/assets/img/Speech_Logo_Main@OG-02.jpg">
|
||||
<meta property="og:url" content="http://spee.ch/">
|
||||
<meta property="og:description" content="Open-source, decentralized image and video sharing.">
|
||||
<meta property="og:title" content="Spee.ch" />
|
||||
<meta property="og:site_name" content="Spee.ch" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:image" content="https://spee.ch/assets/img/Speech_Logo_Main@OG-02.jpg" />
|
||||
<meta property="og:url" content="http://spee.ch/" />
|
||||
<meta property="og:description" content="Open-source, decentralized image and video sharing." />
|
||||
<!--google font-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
|
||||
<!-- google analytics -->
|
||||
|
|
Loading…
Reference in a new issue