Merge pull request #814 from jessopb/permanentURIs

bugfixes around display of permanentURIs
This commit is contained in:
Shawn K 2018-12-06 20:57:25 -06:00 committed by GitHub
commit c299d369b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 14 deletions

View file

@ -9,6 +9,8 @@ import HorizontalSplit from '@components/HorizontalSplit';
import siteConfig from '@config/siteConfig.json'; import siteConfig from '@config/siteConfig.json';
import createCanonicalLink from '../../../../utils/createCanonicalLink'; import createCanonicalLink from '../../../../utils/createCanonicalLink';
import AssetInfoFooter from '../../components/AssetInfoFooter/index'; import AssetInfoFooter from '../../components/AssetInfoFooter/index';
import { createPermanentURI } from '@clientutils/createPermanentURI';
const { details: { host } } = siteConfig; const { details: { host } } = siteConfig;
class AssetInfo extends React.Component { class AssetInfo extends React.Component {
@ -121,7 +123,7 @@ class AssetInfo extends React.Component {
content={ content={
<ClickToCopy <ClickToCopy
id={'lbry-permanent-url'} id={'lbry-permanent-url'}
value={`${channelName}#${certificateId}/${name}`} value={`${createPermanentURI(asset)}`}
/> />
} }
/> />
@ -142,7 +144,7 @@ class AssetInfo extends React.Component {
</a> </a>
<a <a
className={'link--primary'} className={'link--primary'}
href={`https://open.lbry.io/${channelName}#${certificateId}/${name}`} href={`https://open.lbry.io/${createPermanentURI(asset)}`}
download={name} download={name}
> >
LBRY URL LBRY URL

View file

@ -1,14 +1,14 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import View from './view'; import View from './view';
import {selectAsset} from '../../selectors/show'; import {selectAsset} from '../../selectors/show';
import {buildURI} from '../../utils/buildURI'; import {createPermanentURI} from '@clientutils/createPermanentURI';
const mapStateToProps = props => { const mapStateToProps = props => {
const { show, publish } = props; const { show, publish } = props;
const asset = selectAsset(show); const asset = selectAsset(show);
let uri; let uri;
if (asset) { if (asset) {
uri = `lbry://${buildURI(asset)}`; uri = `lbry://${createPermanentURI(asset)}`;
} }
return { return {
disabled : publish.disabled, disabled : publish.disabled,

View file

@ -1,10 +0,0 @@
export const buildURI = asset => {
let channelName, certificateId, name, claimId;
if (asset.claimData) {
({ channelName, certificateId, name, claimId } = asset.claimData);
}
if (channelName) {
return `${channelName}:${certificateId}/${name}`;
}
return `${claimId}/${name}`;
};

View file

@ -0,0 +1,24 @@
/*
{ channelName, certificateId, name, claimId } = { claimData } = asset
permanentUrl for a channel
@channelName#certificateId
permanentUrl for an asset in a channel
@channelName#certificateId/name
permanentUrl for an asset published anonymously
name#claimId
*/
export const createPermanentURI = asset => {
let channelName, certificateId, name, claimId;
if (asset.claimData) {
({ channelName, certificateId, name, claimId } = asset.claimData);
}
else return 'Error: unknown asset at createPermanentURI.js';
if (channelName) {
return `${channelName}#${certificateId}/${name}`;
}
return `${name}#${claimId}`;
};

View file

@ -34,6 +34,11 @@ module.exports = () => {
moduleAliases['@config'] = resolve('site/config'); moduleAliases['@config'] = resolve('site/config');
moduleAliases['@private'] = resolve('site/private'); moduleAliases['@private'] = resolve('site/private');
// aliases for utils
moduleAliases['@globalutils'] = resolve('utils');
moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`);
// moduleAliases['@serverutils'] = resolve('server/utils');
// create specific aliases for locally defined components in the following folders // create specific aliases for locally defined components in the following folders
moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases); moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases);
moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases); moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases);
@ -48,6 +53,7 @@ module.exports = () => {
moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`); moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`);
moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`); moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`);
// return finished aliases // return finished aliases
return moduleAliases; return moduleAliases;
}; };