From 20dc54ba054082c0dbd2caf0fefad99fa6cc693f Mon Sep 17 00:00:00 2001 From: jessop Date: Thu, 6 Dec 2018 21:28:28 -0500 Subject: [PATCH] bugfixes around display of permanentURIs --- client/src/containers/AssetInfo/view.jsx | 6 ++++-- client/src/containers/PublishTool/index.js | 4 ++-- client/src/utils/buildURI.js | 10 --------- client/src/utils/createPermanentURI.js | 24 ++++++++++++++++++++++ utils/createModuleAliases.js | 6 ++++++ 5 files changed, 36 insertions(+), 14 deletions(-) delete mode 100644 client/src/utils/buildURI.js create mode 100644 client/src/utils/createPermanentURI.js diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index 6876d8a1..8b76b907 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -9,6 +9,8 @@ import HorizontalSplit from '@components/HorizontalSplit'; import siteConfig from '@config/siteConfig.json'; import createCanonicalLink from '../../../../utils/createCanonicalLink'; import AssetInfoFooter from '../../components/AssetInfoFooter/index'; +import { createPermanentURI } from '@clientutils/createPermanentURI'; + const { details: { host } } = siteConfig; class AssetInfo extends React.Component { @@ -121,7 +123,7 @@ class AssetInfo extends React.Component { content={ } /> @@ -142,7 +144,7 @@ class AssetInfo extends React.Component { LBRY URL diff --git a/client/src/containers/PublishTool/index.js b/client/src/containers/PublishTool/index.js index 0e0d4b4f..335553d9 100644 --- a/client/src/containers/PublishTool/index.js +++ b/client/src/containers/PublishTool/index.js @@ -1,14 +1,14 @@ import {connect} from 'react-redux'; import View from './view'; import {selectAsset} from '../../selectors/show'; -import {buildURI} from '../../utils/buildURI'; +import {createPermanentURI} from '@clientutils/createPermanentURI'; const mapStateToProps = props => { const { show, publish } = props; const asset = selectAsset(show); let uri; if (asset) { - uri = `lbry://${buildURI(asset)}`; + uri = `lbry://${createPermanentURI(asset)}`; } return { disabled : publish.disabled, diff --git a/client/src/utils/buildURI.js b/client/src/utils/buildURI.js deleted file mode 100644 index b6fb599c..00000000 --- a/client/src/utils/buildURI.js +++ /dev/null @@ -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}`; -}; diff --git a/client/src/utils/createPermanentURI.js b/client/src/utils/createPermanentURI.js new file mode 100644 index 00000000..10f570e4 --- /dev/null +++ b/client/src/utils/createPermanentURI.js @@ -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}`; +}; diff --git a/utils/createModuleAliases.js b/utils/createModuleAliases.js index b9129f47..00506bb9 100644 --- a/utils/createModuleAliases.js +++ b/utils/createModuleAliases.js @@ -34,6 +34,11 @@ module.exports = () => { moduleAliases['@config'] = resolve('site/config'); 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 moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases); moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases); @@ -48,6 +53,7 @@ module.exports = () => { moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`); moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`); + // return finished aliases return moduleAliases; }; -- 2.45.2