Staging #1066

Merged
jessopb merged 55 commits from staging into release 2020-05-16 17:08:51 +02:00
14 changed files with 125 additions and 121 deletions
Showing only changes of commit 0c2f030894 - Show all commits

View file

@ -23,6 +23,7 @@
"publishing": { "publishing": {
"primaryClaimAddress": null, "primaryClaimAddress": null,
"uploadDirectory": "/home/lbry/Uploads", "uploadDirectory": "/home/lbry/Uploads",
"lbrynetHome": "/home/lbry",
"thumbnailChannel": null, "thumbnailChannel": null,
"thumbnailChannelId": null, "thumbnailChannelId": null,
"additionalClaimAddresses": [], "additionalClaimAddresses": [],
@ -39,6 +40,18 @@
"maxSizeGif": 50000000, "maxSizeGif": 50000000,
"maxSizeVideo": 50000000 "maxSizeVideo": 50000000
}, },
"serving": {
"markdownSettings": {
"skipHtml": true,
"privilegedDisallowedTypesDescriptions": ["Image"],
"privilegedDisallowedTypesMain": [],
"publicDisallowedTypesDescriptions": ["Image"],
"publicDisallowedTypesMain": []
},
"customFileExtensions": {
"application/example-type": "example"
}
},
"startup": { "startup": {
"performChecks": true, "performChecks": true,
"performUpdates": true "performUpdates": true

View file

@ -5,19 +5,10 @@
} }
.asset-document { .asset-document {
$asset-info-width: 1000px;
max-width: $asset-info-width;
width: 100%; width: 100%;
padding: $thin-padding; padding: $thin-padding;
height: fit-content; height: fit-content;
box-sizing: border-box;
@media (max-width: $break-point-tablet) {
margin: $primary-padding $secondary-padding;
}
@media (max-width: $break-point-mobile) {
margin: $primary-padding 0;
}
} }
.asset-display { .asset-display {
height: fit-content; height: fit-content;

View file

@ -2,13 +2,17 @@
padding-top: $thin-padding; padding-top: $thin-padding;
padding-bottom: $thin-padding; padding-bottom: $thin-padding;
display: inline-block; display: inline-block;
font-size: 12px; font-weight: bold;
font-size: $text-medium;
width: 100%;
box-sizing: border-box;
} }
.label-radio { .label-radio {
padding-left: $thin-padding; padding-left: $thin-padding;
padding-right: $thin-padding; padding-right: $thin-padding;
cursor: pointer; cursor: pointer;
font-weight: bold;
} }
@media (max-width: $break-point-tablet ) { @media (max-width: $break-point-tablet ) {

View file

@ -8,14 +8,14 @@
h6 { h6 {
font-size: inherit; font-size: inherit;
font-weight: 600; font-weight: 600;
margin-bottom: var(--spacing-vertical-medium); margin-bottom: $tertiary-padding;
padding-top: var(--spacing-vertical-medium); padding-top: $tertiary-padding;
} }
// Paragraphs // Paragraphs
p { p {
font-size: 1.15rem; font-size: 1.15rem;
margin-bottom: var(--spacing-vertical-medium); margin-bottom: $tertiary-padding;
white-space: pre-line; white-space: pre-line;
svg { svg {
@ -28,15 +28,24 @@
} }
} }
blockquote {
border-radius: 8px;
background: $blockquote-background;
padding: $tertiary-padding;
min-width: 60%;
}
// Strikethrough text // Strikethrough text
del { del {
} }
// Tables // Tables
table { table {
width: 100%;
margin-bottom: 1.2rem; margin-bottom: 1.2rem;
padding: var(--spacing-vertical-medium);
background-color: $base-color; background-color: $base-color;
border-spacing: 0;
border: .5px solid $chrome-color;
tr { tr {
td, td,
@ -45,15 +54,32 @@
th:first-of-type, th:first-of-type,
td:last-of-type, td:last-of-type,
th:last-of-type { th:last-of-type {
padding: var(--spacing-vertical-medium); padding: $thin-padding $tertiary-padding;
text-overflow: ellipsis;
} }
td:last-of-type {
text-align: right;
}
th {
background: $chrome-color;
}
}
tr:nth-child(even){
background: $chrome-color;
} }
} }
// Image // Image
img { img {
margin-bottom: var(--spacing-vertical-medium); margin-bottom: $tertiary-padding;
padding-top: var(--spacing-vertical-medium); margin-top: $tertiary-padding;
padding: $secondary-padding;
object-fit: scale-down;
max-width: 100%;
border: $subtle-border;
box-sizing: border-box;
} }
// Horizontal Rule // Horizontal Rule
@ -77,8 +103,8 @@
} }
code { code {
margin-bottom: var(--spacing-vertical-medium); margin-bottom: $tertiary-padding;
padding: var(--spacing-vertical-medium); padding: $tertiary-padding;
background-color: $subtle-border-color; background-color: $subtle-border-color;
color: $text-color; color: $text-color;
@ -94,7 +120,7 @@
// Lists // Lists
ul, ul,
ol { ol {
margin-bottom: var(--spacing-vertical-medium); margin-bottom: $thin-padding;
> li { > li {
list-style-position: outside; list-style-position: outside;
@ -106,7 +132,7 @@
} }
li { li {
margin-left: var(--spacing-vertical-large); margin-left: $primary-padding;
p { p {
display: inline-block; display: inline-block;

View file

@ -4,21 +4,21 @@
.row-labeled { .row-labeled {
display: flex; display: flex;
flex-direction: row; flex-direction: column;
flex-wrap: nowrap; flex-wrap: nowrap;
justify-content: flex-start; justify-content: flex-start;
padding-bottom: $tertiary-padding; padding-bottom: $tertiary-padding;
} }
.row-labeled-label { .row-labeled-label {
width: 30%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
flex: 1; flex: 1;
} }
.row-labeled-content { .row-labeled-content {
align-self: center; align-self: center;
width: 70%; width: 100%;
} }
@media (max-width: $break-point-tablet ) { @media (max-width: $break-point-tablet ) {

View file

@ -2,6 +2,7 @@
$base-color: white; //default white $base-color: white; //default white
$card-color: white; //default white $card-color: white; //default white
$chrome-color: lightgray; //default white (navbar) $chrome-color: lightgray; //default white (navbar)
$blockquote-background: #EEEEFF;
$background-color: $base-color; $background-color: $base-color;
//text colors //text colors
@ -11,6 +12,7 @@ $text-color: #333;
$success-color: green; $success-color: green;
$failure-color: red; $failure-color: red;
$grey: #9095A5; $grey: #9095A5;
$blockquote-text: $text-color;
//borders and highlights //borders and highlights

View file

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
// TODO: get markdown settings from siteConfig
class FileViewer extends React.Component { class FileViewer extends React.Component {
@ -38,7 +39,7 @@ class FileViewer extends React.Component {
<div className={'markdown'}> <div className={'markdown'}>
{ {
this.state.fileLoaded && this.state.fileLoaded &&
<ReactMarkdown source={this.state.fileText}/> <ReactMarkdown className={'markdown-preview'} source={this.state.fileText} skipHtml />
} }
{ {
!this.state.fileLoaded && !this.state.fileLoaded &&

View file

@ -64,7 +64,7 @@ class AssetDisplay extends React.Component {
if (typeof contentType === 'string') { if (typeof contentType === 'string') {
fileExt = contentType.split('/')[1] || 'jpg'; fileExt = contentType.split('/')[1] || 'jpg';
} }
const sourceUrl = `${createCanonicalLink({ asset: asset.claimData })}.${fileExt}?${outpoint}`; const sourceUrl = `${createCanonicalLink({ asset: asset.claimData })}.${fileExt}?outpoint=${outpoint}`;
return ( return (
<div className={'asset-display'}> <div className={'asset-display'}>
{(status === LOCAL_CHECK) && {(status === LOCAL_CHECK) &&

View file

@ -22,6 +22,7 @@ class AssetInfo extends React.Component {
const canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId: asset.shortId }}); const canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId: asset.shortId }});
const assetCanonicalUrl = `${host}${canonicalUrl}`; const assetCanonicalUrl = `${host}${canonicalUrl}`;
// Todo Issue #882 centralize all this media type detection // Todo Issue #882 centralize all this media type detection
// Todo get markdown settings from siteConfig
const embedable = contentType.split('/')[0] === 'image' || contentType === 'video/mp4'; const embedable = contentType.split('/')[0] === 'image' || contentType === 'video/mp4';
let channelCanonicalUrl; let channelCanonicalUrl;
@ -37,7 +38,7 @@ class AssetInfo extends React.Component {
{ description && ( { description && (
<RowLabeled <RowLabeled
label={<Label value={'Description'} />} label={<Label value={'Description'} />}
content={<div className='asset-info__description'><ReactMarkdown source={description}/></div>} content={<div className='asset-info__description'><ReactMarkdown className={'markdown-preview'} skipHtml disallowedTypes={['image']} source={description} /></div>}
/> />
)} )}
{editable && ( {editable && (

42
package-lock.json generated
View file

@ -5688,14 +5688,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -5710,20 +5708,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -5840,8 +5835,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -5853,7 +5847,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -5868,7 +5861,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -5876,14 +5868,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -5902,7 +5892,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -5983,8 +5972,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -5996,7 +5984,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -6118,7 +6105,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -8519,16 +8505,16 @@
"integrity": "sha1-Eh+evEnjdm8xGnbh+hyAA8SwOqY=" "integrity": "sha1-Eh+evEnjdm8xGnbh+hyAA8SwOqY="
}, },
"mime-db": { "mime-db": {
"version": "1.36.0", "version": "1.37.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz",
"integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg=="
}, },
"mime-types": { "mime-types": {
"version": "2.1.20", "version": "2.1.21",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
"integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
"requires": { "requires": {
"mime-db": "~1.36.0" "mime-db": "~1.37.0"
} }
}, },
"mimic-fn": { "mimic-fn": {

View file

@ -51,6 +51,7 @@
"inquirer": "^5.2.0", "inquirer": "^5.2.0",
"ip": "^1.1.5", "ip": "^1.1.5",
"make-dir": "^1.3.0", "make-dir": "^1.3.0",
"mime-types": "^2.1.21",
"module-alias": "^2.1.0", "module-alias": "^2.1.0",
"mysql2": "^1.6.4", "mysql2": "^1.6.4",
"npm": "^6.3.0", "npm": "^6.3.0",

View file

@ -1,40 +1,9 @@
const logger = require('winston'); const logger = require('winston');
const mime = require('mime-types');
const {
assetDefaults: { thumbnail: defaultThumbnail },
details: { host },
} = require('@config/siteConfig');
const getterMethods = { const getterMethods = {
generated_extension() { generated_extension() {
switch (this.content_type) { return mime.extension(this.content_type) ? mime.extension(this.content_type) : 'jpg';
case 'image/jpeg':
case 'image/jpg':
return 'jpg';
case 'image/png':
return 'png';
case 'image/gif':
return 'gif';
case 'image/svg+xml':
return 'svg';
case 'video/mp4':
return 'mp4';
case 'text/markdown':
return 'md';
default:
logger.debug('setting unknown file type as file extension jpg');
return 'jpg';
}
},
// TODO: Factor this out.
generated_thumbnail() {
return this.thumbnail_url || defaultThumbnail;
},
generated_channel() {
console.log(this);
//
}, },
}; };

View file

@ -1,15 +1,15 @@
const chainquery = require('chainquery').default; const chainquery = require('chainquery').default;
const db = require('server/models'); const db = require('server/models');
const fetchClaimData = async (params) => { const fetchClaimData = async params => {
let { claimId, claimName: name } = params; let { claimId, claimName: name } = params;
if (claimId === 'none') claimId = null; if (claimId === 'none') claimId = null;
const [cq, local] = await Promise.all([ const [cq, local] = await Promise.all([
chainquery.claim.queries.resolveClaim(name, claimId).then(res => res.dataValues).catch(() => {}), chainquery.claim.queries.resolveClaim(name, claimId).catch(() => {}),
db.Claim.resolveClaim(name, claimId).catch(() => {}), db.Claim.resolveClaim(name, claimId).catch(() => {}),
]); ]);
// Todo: don't use localdb to get post publish content
if (!cq && !local) { if (!cq && !local) {
return null; return null;
} }

View file

@ -1,52 +1,62 @@
const { details: { host } } = require('@config/siteConfig'); const {
details: { host },
assetDefaults: { thumbnail },
} = require('@config/siteConfig');
const chainquery = require('chainquery').default; const chainquery = require('chainquery').default;
const { getClaim } = require('server/lbrynet'); // const { getClaim } = require('server/lbrynet');
const { isBlocked } = require('./blockList'); const { isBlocked } = require('./blockList');
module.exports = async (data, chName = null, chShortId = null) => { module.exports = async (data, chName = null, chShortId = null) => {
// TODO: Refactor getching the channel name out; requires invasive changes. // TODO: Refactor getching the channel name out; requires invasive changes.
const certificateId = data.publisher_id || data.certificateId; const dataVals = data.dataValues ? data.dataValues : data;
let lbrynetClaimResult = null; const txid = dataVals.transaction_hash_id || dataVals.txid;
let lbrynetFileExt = null; let nout;
if (typeof dataVals.vout === 'number') {
nout = dataVals.vout;
} else {
nout = dataVals.nout;
}
const outpoint = `${txid}:${nout}`;
const certificateId = dataVals.publisher_id || dataVals.certificateId;
const fileExt = data.generated_extension || dataVals.fileExt;
let channelShortId = chShortId; let channelShortId = chShortId;
let channelName = chName; let channelName = chName;
// TODO: Factor blocked out
let blocked; let blocked;
const outPoint = `${data.transaction_hash_id}:${data.vout}`;
if (isBlocked(outPoint)) { if (isBlocked(outpoint)) {
blocked = true; blocked = true;
} }
if (!chName && certificateId && !channelName) { if (!chName && certificateId && !channelName) {
channelName = await chainquery.claim.queries.getClaimChannelName(certificateId).catch(() => { channelName = await chainquery.claim.queries.getClaimChannelName(certificateId).catch(() => {});
});
} }
if (!chShortId && certificateId && channelName) { if (!chShortId && certificateId && channelName) {
channelShortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(certificateId, channelName).catch(() => null); channelShortId = await chainquery.claim.queries
.getShortClaimIdFromLongClaimId(certificateId, channelName)
.catch(() => null);
} }
if (!chName && !chShortId && !data.fileExt) { // Find a solution for the legacy application/octet-stream file extensions
const lbrynetUri = `${data.name}#${data.claim_id}`;
lbrynetClaimResult = await getClaim(lbrynetUri).catch(() => {
return 'invalid URI';
});
lbrynetFileExt = lbrynetClaimResult && lbrynetClaimResult.file_name && lbrynetClaimResult.file_name.includes('.') && lbrynetClaimResult.file_name.split('.').slice(-1).pop();
}
return ({ return {
name : data.name, name: dataVals.name,
title : data.title, title: dataVals.title,
certificateId, certificateId,
channelName, channelName,
channelShortId, channelShortId,
contentType: data.content_type || data.contentType, contentType: dataVals.content_type || data.contentType,
claimId : data.claim_id || data.claimId, claimId: dataVals.claim_id || data.claimId,
fileExt : data.generated_extension || data.fileExt || lbrynetFileExt, fileExt: fileExt,
description: data.description, description: dataVals.description,
thumbnail : data.generated_thumbnail || data.thumbnail_url || data.thumbnail, thumbnail: dataVals.thumbnail_url || data.thumbnail || thumbnail,
outpoint : outPoint || data.outpoint, outpoint,
host, host,
pending : Boolean(data.height === 0), pending: Boolean(dataVals.height === 0),
blocked : blocked, blocked: blocked,
}); };
}; };