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
DOMAIN=lbry.tv
## SHARE_DOMAIN_URL=https://lbry.xy
SHARE_DOMAIN_URL=https://open.lbry.com
URL=https://lbry.tv
# UI
SITE_TITLE=lbry.tv

View file

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

View file

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

View file

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