diff --git a/client/src/components/ChannelInfoDisplay/index.jsx b/client/src/components/ChannelInfoDisplay/index.jsx index 051ad1c4..033f96c3 100644 --- a/client/src/components/ChannelInfoDisplay/index.jsx +++ b/client/src/components/ChannelInfoDisplay/index.jsx @@ -3,9 +3,7 @@ import React from 'react'; const ChannelInfoDisplay = ({name, longId, shortId}) => { return (
-

channel name: {name}

-

full channel id: {longId}

-

short channel id: {shortId}

+

{name}:{shortId}

); }; diff --git a/client/src/containers/AssetBlocked/view.jsx b/client/src/containers/AssetBlocked/view.jsx index de79a14a..aa69d5d3 100644 --- a/client/src/containers/AssetBlocked/view.jsx +++ b/client/src/containers/AssetBlocked/view.jsx @@ -1,10 +1,7 @@ import React from 'react'; -import createCanonicalLink from '../../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; import HorizontalSplit from '@components/HorizontalSplit'; -/* -This component shouldn't be necessary after pagination is reworked, -though it might be useful for channel_mine situations. -*/ + class BlockedLeft extends React.PureComponent { render () { return ( @@ -19,7 +16,7 @@ class BlockedRight extends React.PureComponent { render () { return ( -

In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.

+

In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content.

Click here for more information.

); @@ -53,6 +50,6 @@ class AssetBlocked extends React.Component { ); } -}; +} export default AssetBlocked; diff --git a/client/src/containers/AssetDisplay/view.jsx b/client/src/containers/AssetDisplay/view.jsx index 2102f12b..19309351 100644 --- a/client/src/containers/AssetDisplay/view.jsx +++ b/client/src/containers/AssetDisplay/view.jsx @@ -2,7 +2,7 @@ import React from 'react'; import Row from '@components/Row'; import ProgressBar from '@components/ProgressBar'; import { LOCAL_CHECK, UNAVAILABLE, ERROR, AVAILABLE } from '../../constants/asset_display_states'; -import createCanonicalLink from '../../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; class AvailableContent extends React.Component { render () { @@ -95,6 +95,6 @@ class AssetDisplay extends React.Component { ); } -}; +} export default AssetDisplay; diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index b11e8da9..7adaf446 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -7,7 +7,7 @@ import AssetShareButtons from '@components/AssetShareButtons'; import ClickToCopy from '@components/ClickToCopy'; import HorizontalSplit from '@components/HorizontalSplit'; import siteConfig from '@config/siteConfig.json'; -import createCanonicalLink from '../../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; import AssetInfoFooter from '../../components/AssetInfoFooter/index'; import { createPermanentURI } from '@clientutils/createPermanentURI'; @@ -109,7 +109,7 @@ class AssetInfo extends React.Component { ) : ( `} + value={`${name}`} /> )} diff --git a/client/src/containers/Dropzone/index.js b/client/src/containers/Dropzone/index.js index dfd0f8cd..6bb2a66b 100644 --- a/client/src/containers/Dropzone/index.js +++ b/client/src/containers/Dropzone/index.js @@ -3,7 +3,7 @@ import { selectFile, updateError, clearFile } from '../../actions/publish'; import { selectAsset } from '../../selectors/show'; import View from './view'; import siteConfig from '@config/siteConfig.json'; -import createCanonicalLink from '../../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; const { assetDefaults: { thumbnail: defaultThumbnail } } = siteConfig; diff --git a/client/src/containers/NavigationLinks/view.jsx b/client/src/containers/NavigationLinks/view.jsx index f6e4e087..7a9268d5 100644 --- a/client/src/containers/NavigationLinks/view.jsx +++ b/client/src/containers/NavigationLinks/view.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { NavLink, withRouter } from 'react-router-dom'; import NavBarChannelOptionsDropdown from '@components/NavBarChannelOptionsDropdown'; -import createCanonicalLink from '../../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; const VIEW = 'VIEW'; const LOGOUT = 'LOGOUT'; diff --git a/client/src/containers/SEO/view.jsx b/client/src/containers/SEO/view.jsx index bc6ab3dc..e8ecdefb 100644 --- a/client/src/containers/SEO/view.jsx +++ b/client/src/containers/SEO/view.jsx @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import createPageTitle from '../../utils/createPageTitle'; import createMetaTags from '../../utils/createMetaTags'; import oEmbed from '../../utils/oEmbed.js'; -import createCanonicalLink from '../../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; import siteConfig from '@config/siteConfig.json'; const { details: { host } } = siteConfig; diff --git a/client/src/utils/createAssetMetaTags.js b/client/src/utils/createAssetMetaTags.js index 980a0df4..6b03f353 100644 --- a/client/src/utils/createAssetMetaTags.js +++ b/client/src/utils/createAssetMetaTags.js @@ -1,7 +1,7 @@ import siteConfig from '@config/siteConfig.json'; import determineContentTypeFromExtension from './determineContentTypeFromExtension'; import createMetaTagsArray from './createMetaTagsArray'; -import createCanonicalLink from '../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; const { details: { diff --git a/client/src/utils/createChannelMetaTags.js b/client/src/utils/createChannelMetaTags.js index b5f530d6..7f259d88 100644 --- a/client/src/utils/createChannelMetaTags.js +++ b/client/src/utils/createChannelMetaTags.js @@ -1,7 +1,7 @@ import siteConfig from '@config/siteConfig.json'; import determineContentTypeFromExtension from './determineContentTypeFromExtension'; import createMetaTagsArray from './createMetaTagsArray'; -import createCanonicalLink from '../../../utils/createCanonicalLink'; +import createCanonicalLink from '@globalutils/createCanonicalLink'; const { details: { diff --git a/server/controllers/api/claim/publish/index.js b/server/controllers/api/claim/publish/index.js index 71418afa..b795bde0 100644 --- a/server/controllers/api/claim/publish/index.js +++ b/server/controllers/api/claim/publish/index.js @@ -3,7 +3,7 @@ const logger = require('winston'); const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig'); const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js'); -const isApprovedChannel = require('../../../../../utils/isApprovedChannel'); +const isApprovedChannel = require('@globalutils/isApprovedChannel'); const { publishing: { publishOnlyApproved, approvedChannels } } = require('@config/siteConfig'); const { handleErrorResponse } = require('../../../utils/errorHandlers.js'); @@ -18,7 +18,7 @@ const parsePublishApiRequestFiles = require('./parsePublishApiRequestFiles.js'); const authenticateUser = require('./authentication.js'); const chainquery = require('chainquery').default; -const createCanonicalLink = require('../../../../../utils/createCanonicalLink'); +const createCanonicalLink = require('@globalutils/createCanonicalLink'); const CLAIM_TAKEN = 'CLAIM_TAKEN'; const UNAPPROVED_CHANNEL = 'UNAPPROVED_CHANNEL'; @@ -115,7 +115,7 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res) if (channelName) { return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimData.certificateId, channelName); } else { - return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimId, name, claimData).catch(error => { + return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimId, name, claimData).catch(() => { return claimId.slice(0, 1); }); } diff --git a/server/controllers/api/claim/update/index.js b/server/controllers/api/claim/update/index.js index 17f998b4..4a2524c5 100644 --- a/server/controllers/api/claim/update/index.js +++ b/server/controllers/api/claim/update/index.js @@ -10,7 +10,7 @@ const parsePublishApiRequestFiles = require('../publish/parsePublishApiRequestFi const authenticateUser = require('../publish/authentication.js'); const createThumbnailPublishParams = require('../publish/createThumbnailPublishParams.js'); const chainquery = require('chainquery').default; -const createCanonicalLink = require('../../../../../utils/createCanonicalLink'); +const createCanonicalLink = require('@globalutils/createCanonicalLink'); /* route to update a claim through the daemon @@ -153,7 +153,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res) if (channelName) { return chainquery.claim.queries.getShortClaimIdFromLongClaimId(result.certificateId, channelName); } else { - return chainquery.claim.queries.getShortClaimIdFromLongClaimId(result.claimId, name, result).catch(error => { + return chainquery.claim.queries.getShortClaimIdFromLongClaimId(result.claimId, name, result).catch(() => { return result.claimId.slice(0, 1); }); } diff --git a/server/index.js b/server/index.js index 0ec835cf..be209d33 100644 --- a/server/index.js +++ b/server/index.js @@ -36,7 +36,7 @@ const { const { sessionKey } = require('@private/authConfig.json'); // configure.js doesn't handle new keys in config.json files yet. Make sure it doens't break. -let bLE; +let finalBlockListEndpoint; function Server () { this.initialize = () => { @@ -176,30 +176,29 @@ function Server () { return; } if (blockListEndpoint) { - bLE = blockListEndpoint; + finalBlockListEndpoint = blockListEndpoint; } else if (!blockListEndpoint) { if (typeof (blockListEndpoint) !== 'string') { logger.warn('blockListEndpoint is null due to outdated siteConfig file. \n' + 'Continuing with default LBRY blocklist api endpoint. \n ' + - '(Specify /"blockListEndpoint" : ""/ to disable.') - bLE = 'https://api.lbry.io/file/list_blocked'; + '(Specify /"blockListEndpoint" : ""/ to disable.'); + finalBlockListEndpoint = 'https://api.lbry.io/file/list_blocked'; } } logger.info(`Peforming updates...`); - if (!bLE) { - logger.info('Configured for no Block List') - db.Tor.refreshTable().then( (updatedTorList) => { + if (!finalBlockListEndpoint) { + logger.info('Configured for no Block List'); + db.Tor.refreshTable().then((updatedTorList) => { logger.info('Tor list updated, length:', updatedTorList.length); }); } else { - return Promise.all([ - db.Blocked.refreshTable(bLE), + db.Blocked.refreshTable(finalBlockListEndpoint), db.Tor.refreshTable()]) .then(([updatedBlockedList, updatedTorList]) => { logger.info('Blocked list updated, length:', updatedBlockedList.length); logger.info('Tor list updated, length:', updatedTorList.length); - }) + }); } }; this.start = () => { diff --git a/server/render/handleShowRender.jsx b/server/render/handleShowRender.jsx index ca0082f1..f304222f 100644 --- a/server/render/handleShowRender.jsx +++ b/server/render/handleShowRender.jsx @@ -12,10 +12,8 @@ import * as httpContext from 'express-http-context'; import Reducers from '@reducers'; import GAListener from '@components/GAListener'; import App from '@app'; -import Sagas from '@sagas'; -import Actions from '@actions'; -const createCanonicalLink = require('../../utils/createCanonicalLink'); +const createCanonicalLink = require('@globalutils/createCanonicalLink'); const getCanonicalUrlFromShow = show => { const requestId = show.requestList[show.request.id]; @@ -49,19 +47,18 @@ export default (req, res) => { action = false, saga = false, } = httpContext.get('routeData'); - + if (action === 'fallback') { res.status(404); } const runSaga = (action !== false && saga !== false); const renderPage = (store) => { - // Workaround, remove when a solution for async httpContext exists const showState = store.getState().show; const assetKeys = Object.keys(showState.assetList); - if(assetKeys.length !== 0) { + if (assetKeys.length !== 0) { res.claimId = showState.assetList[assetKeys[0]].claimId; } else { const channelKeys = Object.keys(showState.channelList); @@ -118,17 +115,17 @@ export default (req, res) => { .then(() => { // redirect if request does not use canonical url const canonicalUrl = getCanonicalUrlFromShow(store.getState().show); - + if (!canonicalUrl) { res.status(404); } - + if (canonicalUrl && canonicalUrl !== req.originalUrl) { console.log(`redirecting ${req.originalUrl} to ${canonicalUrl}`); res.redirect(canonicalUrl); } - - return renderPage(store) + + return renderPage(store); }); } else { const store = createStore(Reducers); diff --git a/server/utils/getMediaDimensions.js b/server/utils/getMediaDimensions.js index fc5e79a1..d130fd40 100644 --- a/server/utils/getMediaDimensions.js +++ b/server/utils/getMediaDimensions.js @@ -18,7 +18,7 @@ async function getMediaDimensions (fileType, filePath) { [ height, width ] = await getVideoHeightAndWidth(filePath); break; default: - logger.error('unable to create File data for unspported file type:', fileType); + logger.error('unable to create File dimension data for unspported file type:', fileType); break; } return {