provide share domain url configuration

This commit is contained in:
jessop 2020-08-29 13:58:38 -04:00 committed by Sean Yesmunt
parent 254a2f5138
commit ee217404da
4 changed files with 19 additions and 16 deletions

View file

@ -13,6 +13,8 @@ WELCOME_VERSION=1.0
# Custom Site info # Custom Site info
DOMAIN=lbry.tv DOMAIN=lbry.tv
## SHARE_DOMAIN_URL=https://lbry.xy
SHARE_DOMAIN_URL=https://open.lbry.com
URL=https://lbry.tv URL=https://lbry.tv
# UI # UI
SITE_TITLE=lbry.tv SITE_TITLE=lbry.tv

View file

@ -12,6 +12,7 @@ const config = {
LBRY_WEB_BUFFER_API: process.env.LBRY_WEB_BUFFER_API, LBRY_WEB_BUFFER_API: process.env.LBRY_WEB_BUFFER_API,
WELCOME_VERSION: process.env.WELCOME_VERSION, WELCOME_VERSION: process.env.WELCOME_VERSION,
DOMAIN: process.env.DOMAIN, DOMAIN: process.env.DOMAIN,
SHARE_DOMAIN_URL: process.env.SHARE_DOMAIN_URL,
URL: process.env.URL, URL: process.env.URL,
SITE_TITLE: process.env.SITE_TITLE, SITE_TITLE: process.env.SITE_TITLE,
SITE_NAME: process.env.SITE_NAME, SITE_NAME: process.env.SITE_NAME,

View file

@ -8,12 +8,8 @@ import { generateDownloadUrl } from 'util/web';
import { useIsMobile } from 'effects/use-screensize'; import { useIsMobile } from 'effects/use-screensize';
import { FormField } from 'component/common/form'; import { FormField } from 'component/common/form';
import { hmsToSeconds, secondsToHms } from 'util/time'; import { hmsToSeconds, secondsToHms } from 'util/time';
import { import { generateLbryContentUrl, generateLbryWebUrl, generateEncodedLbryURL, generateShareUrl } from 'util/url';
generateLbryContentUrl, import { SHARE_DOMAIN_URL } from 'config';
generateLbryWebUrl,
generateEncodedLbryURL,
generateOpenDotLbryDotComUrl,
} from 'util/url';
const IOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); const IOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
const SUPPORTS_SHARE_API = typeof navigator.share !== 'undefined'; const SUPPORTS_SHARE_API = typeof navigator.share !== 'undefined';
@ -47,12 +43,16 @@ function SocialShare(props: Props) {
const isAudio = isStream && claim.value.stream_type === 'audio'; const isAudio = isStream && claim.value.stream_type === 'audio';
const showStartAt = isVideo || isAudio; const showStartAt = isVideo || isAudio;
const rewardsApproved = user && user.is_reward_approved; const rewardsApproved = user && user.is_reward_approved;
const OPEN_URL = 'https://open.lbry.com/';
const lbryUrl: string = generateLbryContentUrl(canonicalUrl, permanentUrl); const lbryUrl: string = generateLbryContentUrl(canonicalUrl, permanentUrl);
const lbryWebUrl: string = generateLbryWebUrl(lbryUrl); const lbryWebUrl: string = generateLbryWebUrl(lbryUrl);
const encodedLbryURL: string = generateEncodedLbryURL(OPEN_URL, lbryWebUrl, includeStartTime, startTimeSeconds); const encodedLbryURL: string = generateEncodedLbryURL(
const openDotLbryDotComUrl: string = generateOpenDotLbryDotComUrl( SHARE_DOMAIN_URL,
OPEN_URL, lbryWebUrl,
includeStartTime,
startTimeSeconds
);
const shareUrl: string = generateShareUrl(
SHARE_DOMAIN_URL,
lbryWebUrl, lbryWebUrl,
canonicalUrl, canonicalUrl,
permanentUrl, permanentUrl,
@ -74,7 +74,7 @@ function SocialShare(props: Props) {
return ( return (
<React.Fragment> <React.Fragment>
<CopyableText copyable={openDotLbryDotComUrl} /> <CopyableText copyable={shareUrl} />
{showStartAt && ( {showStartAt && (
<div className="section__start-at"> <div className="section__start-at">
<FormField <FormField

View file

@ -85,14 +85,14 @@ exports.generateLbryWebUrl = lbryUrl => {
return lbryUrl.replace(/#/g, ':'); return lbryUrl.replace(/#/g, ':');
}; };
exports.generateEncodedLbryURL = (openUrl, lbryWebUrl, includeStartTime, startTime) => { exports.generateEncodedLbryURL = (domain, lbryWebUrl, includeStartTime, startTime) => {
const queryParam = includeStartTime ? `?t=${startTime}` : ''; const queryParam = includeStartTime ? `?t=${startTime}` : '';
const encodedPart = encodeURIComponent(`${lbryWebUrl}${queryParam}`); const encodedPart = encodeURIComponent(`${lbryWebUrl}${queryParam}`);
return `${openUrl}${encodedPart}`; return `${domain}/${encodedPart}`;
}; };
exports.generateOpenDotLbryDotComUrl = ( exports.generateShareUrl = (
openUrl, domain,
lbryWebUrl, lbryWebUrl,
canonicalUrl, canonicalUrl,
permanentUrl, permanentUrl,
@ -111,6 +111,6 @@ exports.generateOpenDotLbryDotComUrl = (
} }
const urlParamsString = urlParams.toString(); const urlParamsString = urlParams.toString();
const url = `${openUrl}${lbryWebUrl}` + (urlParamsString === '' ? '' : `?${urlParamsString}`); const url = `${domain}/${lbryWebUrl}` + (urlParamsString === '' ? '' : `?${urlParamsString}`);
return url; return url;
}; };