281 unfurl show links #303

Merged
bones7242 merged 12 commits from 281-unfurl-show-links into master 2017-12-15 17:01:23 +01:00
4 changed files with 35 additions and 33 deletions
Showing only changes of commit d6d11ea807 - Show all commits

View file

@ -17,27 +17,27 @@ module.exports = {
return new Handlebars.SafeString(gaCode); return new Handlebars.SafeString(gaCode);
}, },
addOpenGraph ({ ogTitle, contentType, ogDescription, thumbnail, showUrl, source, ogThumbnailContentType }) { addOpenGraph ({ ogTitle, contentType, ogDescription, thumbnail, showUrl, source, ogThumbnailContentType }) {
const ogTitleTag = `<meta property="og:title" content="${ogTitle}" >`; const ogTitleTag = `<meta property="og:title" content="${ogTitle}" />`;
const ogUrlTag = `<meta property="og:url" content="${showUrl}" >`; const ogUrlTag = `<meta property="og:url" content="${showUrl}" />`;
const ogSiteNameTag = `<meta property="og:site_name" content="Spee.ch" >`; const ogSiteNameTag = `<meta property="og:site_name" content="Spee.ch" />`;
const ogDescriptionTag = `<meta property="og:description" content="${ogDescription}" >`; const ogDescriptionTag = `<meta property="og:description" content="${ogDescription}" />`;
const ogImageWidthTag = '<meta property="og:image:width" content="600" >'; const ogImageWidthTag = '<meta property="og:image:width" content="600" />';
const ogImageHeightTag = '<meta property="og:image:height" content="315" >'; const ogImageHeightTag = '<meta property="og:image:height" content="315" />';
const basicTags = `${ogTitleTag} ${ogUrlTag} ${ogSiteNameTag} ${ogDescriptionTag} ${ogImageWidthTag} ${ogImageHeightTag}`; const basicTags = `${ogTitleTag} ${ogUrlTag} ${ogSiteNameTag} ${ogDescriptionTag} ${ogImageWidthTag} ${ogImageHeightTag}`;
let ogImageTag = `<meta property="og:image" content="${source}" >`; let ogImageTag = `<meta property="og:image" content="${source}" />`;
let ogImageTypeTag = `<meta property="og:image:type" content="${contentType}" >`; let ogImageTypeTag = `<meta property="og:image:type" content="${contentType}" />`;
let ogTypeTag = `<meta property="og:type" content="article" >`; let ogTypeTag = `<meta property="og:type" content="article" />`;
if (contentType === 'video/mp4') { if (contentType === 'video/mp4') {
const ogVideoTag = `<meta property="og:video" content="${source}" >`; const ogVideoTag = `<meta property="og:video" content="${source}" />`;
const ogVideoSecureUrlTag = `<meta property="og:video:secure_url" content="${source}" >`; const ogVideoSecureUrlTag = `<meta property="og:video:secure_url" content="${source}" />`;
const ogVideoTypeTag = `<meta property="og:video:type" content="${contentType}" >`; const ogVideoTypeTag = `<meta property="og:video:type" content="${contentType}" />`;
ogImageTag = `<meta property="og:image" content="${thumbnail}" >`; ogImageTag = `<meta property="og:image" content="${thumbnail}" />`;
ogImageTypeTag = `<meta property="og:image:type" content="${ogThumbnailContentType}" >`; ogImageTypeTag = `<meta property="og:image:type" content="${ogThumbnailContentType}" />`;
ogTypeTag = `<meta property="og:type" content="video" >`; ogTypeTag = `<meta property="og:type" content="video" />`;
return new Handlebars.SafeString(`${basicTags} ${ogImageTag} ${ogImageTypeTag} ${ogTypeTag} ${ogVideoTag} ${ogVideoSecureUrlTag} ${ogVideoTypeTag}`); return new Handlebars.SafeString(`${basicTags} ${ogImageTag} ${ogImageTypeTag} ${ogTypeTag} ${ogVideoTag} ${ogVideoSecureUrlTag} ${ogVideoTypeTag}`);
} else { } else {
if (contentType === 'image/gif') { 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}`); return new Handlebars.SafeString(`${basicTags} ${ogImageTag} ${ogImageTypeTag} ${ogTypeTag}`);
} }

View file

@ -48,11 +48,13 @@ function clientAcceptsHtml ({accept}) {
return accept && accept.match(/text\/html/); return accept && accept.match(/text\/html/);
} }
function requestIsFromBrowser (headers) {
return headers['user-agent'] && headers['user-agent'].match(/Mozilla/);
};
function clientWantsAsset ({accept, range}) { function clientWantsAsset ({accept, range}) {
const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/) && !accept.match(/text\/\*/); const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/) && !accept.match(/text\/\*/);
const videoIsWanted = false; // accept && range; const videoIsWanted = accept && range;
logger.debug('image is wanted:', imageIsWanted);
logger.debug('video is wanted:', videoIsWanted);
return imageIsWanted || videoIsWanted; return imageIsWanted || videoIsWanted;
} }
@ -65,8 +67,8 @@ function determineResponseType (isServeRequest, headers) {
} }
} else { } else {
responseType = SHOW; responseType = SHOW;
if (clientWantsAsset(headers)) { // this is in case someone embeds a show url if (clientWantsAsset(headers) && requestIsFromBrowser(headers)) { // this is in case someone embeds a show url
logger.debug('Show request actually want\'s an asset!'); logger.debug('Show request actually wants an asset!');
responseType = SERVE; responseType = SERVE;
} }
} }

View file

@ -4,12 +4,12 @@
{{ placeCommonHeaderTags }} {{ placeCommonHeaderTags }}
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@spee_ch" /> <meta name="twitter:site" content="@spee_ch" />
<meta property="og:title" content="{{this.channelName}} on Spee.ch"> <meta property="og:title" content="{{this.channelName}} on Spee.ch" />
<meta property="og:site_name" content="Spee.ch"> <meta property="og:site_name" content="Spee.ch" />
<meta property="og:type" content="website"> <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: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:url" content="http://spee.ch/{{this.channelName}}:{{this.longChannelId}}" />
<meta property="og:description" content="View images and videos from {{this.channelName}}"> <meta property="og:description" content="View images and videos from {{this.channelName}}" />
<!--google font--> <!--google font-->
<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
<!-- google analytics --> <!-- google analytics -->

View file

@ -4,12 +4,12 @@
{{ placeCommonHeaderTags }} {{ placeCommonHeaderTags }}
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@spee_ch" /> <meta name="twitter:site" content="@spee_ch" />
<meta property="og:title" content="Spee.ch"> <meta property="og:title" content="Spee.ch" />
<meta property="og:site_name" content="Spee.ch"> <meta property="og:site_name" content="Spee.ch" />
<meta property="og:type" content="website"> <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:image" content="https://spee.ch/assets/img/Speech_Logo_Main@OG-02.jpg" />
<meta property="og:url" content="http://spee.ch/"> <meta property="og:url" content="http://spee.ch/" />
<meta property="og:description" content="Open-source, decentralized image and video sharing."> <meta property="og:description" content="Open-source, decentralized image and video sharing." />
<!--google font--> <!--google font-->
<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
<!-- google analytics --> <!-- google analytics -->