DTP Base provides a scalable and secure Node.js application development harness ready for production service.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

75 lines
3.8 KiB

block twitter-card
-
var twCardType = 'summary_large_image';
var twCardImg = `https://${site.domain}/img/social-cards/${site.domain}.png?v=${pkg.version}`;
var twTitle = pageTitle || `${site.name} | ${site.description}`;
var twDescription = pageDescription || site.description;
var twPlayerEmbedUrl, twPlayerStreamUrl, twPlayerWidth, twPlayerHeight;
if ((currentView === 'dvr') && (viewName === 'home-player')) {
// use default social card assigned above
twTitle = pageTitle;
twDescription = pageDescription;
} else if (episode && episode.images && episode.images.thumbnail) {
if (clip && clip.images && clip.images.thumbnail) {
twCardImg = `https://${site.domain}/image/${clip.images.thumbnail._id || clip.images.thumbnail}`;
twTitle = clip.title;
twDescription = clip.description;
twCardType = 'player';
twPlayerEmbedUrl = `https://${site.domain}/dvr/${clip.episode._id}/clip/${clip._id}/embed`;
twPlayerStreamUrl = `https://${site.domain}/dvr/${clip.episode._id}/clip/${clip._id}/media`;
twPlayerWidth = 960;
twPlayerHeight = 540;
} else {
twCardImg = `https://${site.domain}/image/${episode.images.thumbnail._id || episode.images.thumbnail}`;
twTitle = episode.title;
twDescription = episode.description;
}
} else if (clip && clip.images && clip.images.thumbnail) {
twCardImg = `https://${site.domain}/image/${clip.images.thumbnail._id || clip.images.thumbnail}`;
twTitle = clip.title;
twDescription = clip.description;
twCardType = 'player';
twPlayerEmbedUrl = `https://${site.domain}/dvr/${clip.episode._id}/clip/${clip._id}/embed`;
twPlayerStreamUrl = `https://${site.domain}/dvr/${clip.episode._id}/clip/${clip._id}/media`;
twPlayerWidth = 960;
twPlayerHeight = 540;
} else if (video && video.images && video.images.thumbnail) {
twCardImg = `https://${site.domain}/image/${video.images.thumbnail._id || video.images.thumbnail}`;
twTitle = video.title;
twDescription = video.description;
} else if (userProfile) {
twCardImg = getUserPictureUrl(userProfile, 'large');
twTitle = pageTitle;
twDescription = pageDescription;
} else if (channel && channel.images && channel.images.thumbnail) {
twCardImg = `https://${site.domain}/image/${channel.images.thumbnail._id || channel.images.thumbnail}`;
twTitle = channel.name;
twDescription = channel.description;
} else if (advertisement && advertisement.content) {
twTitle = advertisement.content.title;
if (advertisement.content.body) {
twDescription = marked.parse(advertisement.content.body, { renderer: fullMarkdownRenderer }).trim();
}
switch (advertisement.content.mediaType) {
case 'Image':
twCardImg = `https://${site.domain}/image/${advertisement.content.media._id}`;
break;
case 'Video':
if (advertisement.content && advertisement.content.media && advertisement.content.media.images && advertisement.content.media.images.thumbnail) {
twCardImg = `https://${site.domain}/image/${advertisement.content.media.images.thumbnail._id || advertisement.content.media.images.thumbnail}`;
}
break;
}
}
meta(name='twitter:card', content= twCardType)
meta(name='twitter:image' content= twCardImg)
meta(name='twitter:title', content= twTitle)
if twDescription && (twDescription.length > 0)
meta(name='twitter:description', content= twDescription)
if twCardType === 'player'
meta(name='twitter:player', content= twPlayerEmbedUrl)
meta(name='twitter:player:stream', content= twPlayerStreamUrl)
meta(name='twitter:player:width', content= twPlayerWidth)
meta(name='twitter:player:height', content= twPlayerHeight)