diff --git a/CHANGELOG.md b/CHANGELOG.md index 649813f47..90b588271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Improve twitter share _community pr!_ ([#6690](https://github.com/lbryio/lbry-desktop/pull/6690)) - Update lighthouse search api _community pr!_ ([#6731](https://github.com/lbryio/lbry-desktop/pull/6731)) - Update sockety api _community pr!_ ([#6747](https://github.com/lbryio/lbry-desktop/pull/6747)) +- Use resolve for OG metadata instead of chainquery _community pr!_ ([#6787](https://github.com/lbryio/lbry-desktop/pull/6787)) ### Fixed - App now supports '#' and ':' for claimId separator ([#6496](https://github.com/lbryio/lbry-desktop/pull/6496)) @@ -29,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix yarn copyenv on windows _community pr!_ ([#6702](https://github.com/lbryio/lbry-desktop/pull/6702)) - Fix unnecessary livestream api calls in channel page _community pr!_ ([#6652](https://github.com/lbryio/lbry-desktop/pull/6652)) - Fix desktop app fails to resolve deep links _community pr!_ ([#6779](https://github.com/lbryio/lbry-desktop/pull/6779)) +- Fix wrong release date on GoogleVideo metadata _community pr!_ ([#6787](https://github.com/lbryio/lbry-desktop/pull/6787)) - Fix markdown line breaking mid word _community pr!_ ([#6805](https://github.com/lbryio/lbry-desktop/pull/6805)) - Added \ and = to reserved symbol warning _community pr!_ ([#6733](https://github.com/lbryio/lbry-desktop/pull/6733)) - Don't break words in chat + fix text overflow past 3 dot menu _community pr!_ ([#6602](https://github.com/lbryio/lbry-desktop/pull/6602)) diff --git a/ui/page/show/view.jsx b/ui/page/show/view.jsx index a1b807496..10fd38710 100644 --- a/ui/page/show/view.jsx +++ b/ui/page/show/view.jsx @@ -12,10 +12,13 @@ import Card from 'component/common/card'; import { formatLbryUrlForWeb } from 'util/url'; import { parseURI, COLLECTIONS_CONSTS } from 'lbry-redux'; -const AbandonedChannelPreview = lazyImport(() => import('component/abandonedChannelPreview' /* webpackChunkName: "abandonedChannelPreview" */)); +const AbandonedChannelPreview = lazyImport(() => + import('component/abandonedChannelPreview' /* webpackChunkName: "abandonedChannelPreview" */) +); const FilePage = lazyImport(() => import('page/file' /* webpackChunkName: "filePage" */)); const LivestreamPage = lazyImport(() => import('page/livestream' /* webpackChunkName: "livestream" */)); const Yrbl = lazyImport(() => import('component/yrbl' /* webpackChunkName: "yrbl" */)); +const isDev = process.env.NODE_ENV !== 'production'; type Props = { isResolvingUri: boolean, @@ -85,7 +88,8 @@ function ShowPage(props: Props) { const canonicalUrlPath = '/' + canonicalUrl.replace(/^lbry:\/\//, '').replace(/#/g, ':'); // Only redirect if we are in lbry.tv land // replaceState will fail if on a different domain (like webcache.googleusercontent.com) - if (canonicalUrlPath !== window.location.pathname && DOMAIN === window.location.hostname) { + const hostname = isDev ? 'localhost' : DOMAIN; + if (canonicalUrlPath !== window.location.pathname && hostname === window.location.hostname) { const urlParams = new URLSearchParams(search); if (urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID)) { const listId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || ''; diff --git a/web/src/html.js b/web/src/html.js index 508819834..724bcc4f4 100644 --- a/web/src/html.js +++ b/web/src/html.js @@ -9,18 +9,23 @@ const { SITE_DESCRIPTION, SITE_NAME, FAVICON, + LBRY_WEB_API, } = require('../../config.js'); + +const { Lbry } = require('lbry-redux'); const { generateEmbedUrl, generateStreamUrl, generateDirectUrl } = require('../../ui/util/web'); const PAGES = require('../../ui/constants/pages'); const { CATEGORY_METADATA } = require('./category-metadata'); -const { getClaim } = require('./chainquery'); -const { parseURI } = require('lbry-redux'); +const { parseURI, normalizeURI } = require('lbry-redux'); const fs = require('fs'); const path = require('path'); const moment = require('moment'); const removeMd = require('remove-markdown'); const { getJsBundleId } = require('../bundle-id.js'); const jsBundleId = getJsBundleId(); +const SDK_API_PATH = `${LBRY_WEB_API}/api/v1`; +const PROXY_URL = `${SDK_API_PATH}/proxy`; +Lbry.setDaemonConnectionString(PROXY_URL); function insertToHead(fullHtml, htmlToInsert) { const beginStr = ''; @@ -40,6 +45,10 @@ function truncateDescription(description) { return description.length > 200 ? description.substr(0, 200) + '...' : description; } +function normalizeClaimUrl(url) { + return normalizeURI(url.replace(/:/g, '#')); +} + function escapeHtmlProperty(property) { return property ? String(property) @@ -122,20 +131,33 @@ function buildBasicOgMetadata() { function buildClaimOgMetadata(uri, claim, overrideOptions = {}) { // Initial setup for claim based og metadata const { claimName } = parseURI(uri); - const claimTitle = escapeHtmlProperty(claim.title ? claim.title : claimName); + const { meta, value, signing_channel } = claim; + const fee = value && value.fee && (Number(value.fee.amount) || 0); + const tags = value && value.tags; + const media = value && (value.video || value.audio || value.image); + const source = value && value.source; + const channel = signing_channel && signing_channel.name; + const thumbnail = value && value.thumbnail && value.thumbnail.url; + const mediaType = source && source.media_type; + const mediaDuration = media && media.duration; + const claimTitle = escapeHtmlProperty((value && value.title) || claimName); + const releaseTime = (value && value.release_time) || (meta && meta.creation_timestamp) || 0; + const claimDescription = - claim.description && claim.description.length > 0 - ? escapeHtmlProperty(truncateDescription(claim.description)) + value && value.description && value.description.length > 0 + ? escapeHtmlProperty(truncateDescription(value.description)) : `View ${claimTitle} on ${SITE_NAME}`; - const claimLanguage = escapeHtmlProperty(claim.language) || 'en_US'; + + const claimLanguage = + value && value.languages && value.languages.length > 0 ? escapeHtmlProperty(value.languages[0]) : 'en_US'; let imageThumbnail; - if (Number(claim.fee) <= 0 && claim.source_media_type && claim.source_media_type.startsWith('image/')) { + if (fee <= 0 && mediaType && mediaType.startsWith('image/')) { imageThumbnail = generateStreamUrl(claim.name, claim.claim_id); } - const claimThumbnail = - escapeHtmlProperty(claim.thumbnail_url) || imageThumbnail || OG_IMAGE_URL || `${URL}/public/v2-og.png`; + + const claimThumbnail = escapeHtmlProperty(thumbnail) || imageThumbnail || OG_IMAGE_URL || `${URL}/public/v2-og.png`; // Allow for ovverriding default claim based og metadata const title = overrideOptions.title || claimTitle; @@ -148,8 +170,9 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) { head += ''; head += `