Merge pull request #935 from jessopb/licenseDev2

Adds License and LicenseUrl to AssetInfo and Publish/Edit Forms
This commit is contained in:
jessopb 2019-02-26 03:44:02 -05:00 committed by GitHub
commit a5700be902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 312 additions and 104 deletions

View file

@ -1,6 +1,7 @@
select { select {
margin: 0; margin: 0;
display: inline-block; display: inline-block;
background: $base-color; background: $background-color;
border: 0; border: 0;
color: $text-color;
} }

View file

@ -7,9 +7,6 @@ const ChannelSelectDropdown = ({ selectedChannel, handleSelection, loggedInChann
id='channel-name-select' id='channel-name-select'
value={selectedChannel} value={selectedChannel}
onChange={handleSelection}> onChange={handleSelection}>
{ loggedInChannelName && (
<option value={loggedInChannelName} >{loggedInChannelName}</option>
)}
<option value={LOGIN}>Existing</option> <option value={LOGIN}>Existing</option>
<option value={CREATE}>New</option> <option value={CREATE}>New</option>
</select> </select>

View file

@ -1,23 +1,28 @@
import React from 'react'; import React from 'react';
import RowLabeled from '@components/RowLabeled'; import RowLabeled from '@components/RowLabeled';
import Label from '@components/Label'; import Label from '@components/Label';
import { LICENSES } from '@clientConstants/publish_license_urls';
const PublishLicenseInput = ({ handleSelect }) => { const PublishLicenseInput = ({ handleSelect, license }) => {
return ( return (
<RowLabeled <RowLabeled
label={ label={
<Label value={'License:'} /> <Label value={'License'} />
} }
content={ content={
<select <select
type='text' type='text'
name='license' name='license'
id='publish-license' id='publish-license'
value={license}
onChange={handleSelect} onChange={handleSelect}
> >
<option value=''>Unspecified</option> <option value=''>Unspecified</option>
<option value='Public Domain'>Public Domain</option> {
<option value='Creative Commons'>Creative Commons</option> LICENSES.map(function(item, i){
return <option key={item + 'license key'} value={item}>{item}</option>;
})
}
</select> </select>
} }
/> />

View file

@ -0,0 +1,32 @@
import React from 'react';
import RowLabeled from '@components/RowLabeled';
import Label from '@components/Label';
import { CC_LICENSES } from '@clientConstants/publish_license_urls';
const PublishLicenseUrlInput = ({ handleSelect, licenseUrl }) => {
return (
<RowLabeled
label={
<Label value={'License Url'} />
}
content={
<select
type='text'
name='licenseUrl'
id='publish-license-url'
value={licenseUrl}
onChange={handleSelect}
>
<option value=''>Unspecified</option>
{
CC_LICENSES.map(function(item, i){
return <option key={item.url} value={item.url}>{item.value}</option>
})
}
</select>
}
/>
);
};
export default PublishLicenseUrlInput;

View file

@ -0,0 +1,33 @@
export const CC_LICENSES = [
{
value: 'CC Attr. 4.0 Int',
url: 'https://creativecommons.org/licenses/by/4.0/legalcode',
},
{
value: 'CC Attr-ShareAlike 4.0 Int',
url: 'https://creativecommons.org/licenses/by-sa/4.0/legalcode',
},
{
value: 'CC Attr-NoDerivatives 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nd/4.0/legalcode',
},
{
value: 'CC Attr-NonComm 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nc/4.0/legalcode',
},
{
value: 'CC Attr-NonComm-ShareAlike 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode',
},
{
value: 'CC Attr-NonComm-NoDerivatives 4.0 Int',
url: 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode',
},
];
export const LICENSES = ['Public Domain', 'Other', 'Copyright', 'Creative Commons'];
export const PUBLIC_DOMAIN = 'Public Domain';
export const OTHER = 'other';
export const COPYRIGHT = 'copyright';
export const CREATIVE_COMMONS = 'Creative Commons';

View file

@ -7,7 +7,7 @@ import AssetShareButtons from '@components/AssetShareButtons';
import ClickToCopy from '@components/ClickToCopy'; import ClickToCopy from '@components/ClickToCopy';
import siteConfig from '@config/siteConfig.json'; import siteConfig from '@config/siteConfig.json';
import createCanonicalLink from '@globalutils/createCanonicalLink'; import createCanonicalLink from '@globalutils/createCanonicalLink';
import AssetInfoFooter from '../../components/AssetInfoFooter/index'; import AssetInfoFooter from '@components/AssetInfoFooter/index';
import { createPermanentURI } from '@clientutils/createPermanentURI'; import { createPermanentURI } from '@clientutils/createPermanentURI';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
@ -18,7 +18,20 @@ class AssetInfo extends React.Component {
render () { render () {
const { editable, asset } = this.props; const { editable, asset } = this.props;
const { claimViews, claimData } = asset; const { claimViews, claimData } = asset;
const { channelName, claimId, channelShortId, description, name, fileExt, contentType, host, certificateId } = claimData; const {
channelName,
claimId,
channelShortId,
description,
name,
fileExt,
contentType,
host,
certificateId,
license,
licenseUrl,
transactionTime
} = claimData;
const canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId: asset.shortId }}); const canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId: asset.shortId }});
const assetCanonicalUrl = `${host}${canonicalUrl}`; const assetCanonicalUrl = `${host}${canonicalUrl}`;
@ -55,7 +68,7 @@ class AssetInfo extends React.Component {
{editable && ( {editable && (
<RowLabeled <RowLabeled
label={<Label value={'Edit'} />} label={<Label value={'Edit'} />}
content={<Link to={`/edit${canonicalUrl}`}>{name}</Link>} content={<Link className='link--primary' to={`/edit${canonicalUrl}`}>{name}</Link>}
/> />
)} )}
{channelName && ( {channelName && (
@ -71,6 +84,7 @@ class AssetInfo extends React.Component {
} }
/> />
)} )}
<SpaceBetween>
{claimViews ? ( {claimViews ? (
<RowLabeled <RowLabeled
label={ label={
@ -83,7 +97,22 @@ class AssetInfo extends React.Component {
} }
/> />
) : null} ) : null}
{license && (
<RowLabeled
label={
<Label value={'License'} />
}
content={
<div className='text'>
{licenseUrl ? (
<a className={'link--primary'} href={licenseUrl} target={'_blank'}>{license}</a>
) : (
<span>{license}</span> )}
</div>
}
/>
)}
</SpaceBetween>
<RowLabeled <RowLabeled
label={ label={
<Label value={'Share'} /> <Label value={'Share'} />

View file

@ -1,14 +1,15 @@
import {connect} from 'react-redux'; import { connect } from 'react-redux';
import {updateMetadata, toggleMetadataInputs} from '../../actions/publish'; import { updateMetadata, toggleMetadataInputs } from '../../actions/publish';
import View from './view'; import View from './view';
const mapStateToProps = ({ publish }) => { const mapStateToProps = ({ publish }) => {
return { return {
showMetadataInputs: publish.showMetadataInputs, showMetadataInputs: publish.showMetadataInputs,
description : publish.metadata.description, description: publish.metadata.description,
license : publish.metadata.license, license: publish.metadata.license,
nsfw : publish.metadata.nsfw, licenseUrl: publish.metadata.licenseUrl,
isUpdate : publish.isUpdate, nsfw: publish.metadata.nsfw,
isUpdate: publish.isUpdate,
}; };
}; };
@ -17,10 +18,13 @@ const mapDispatchToProps = dispatch => {
onMetadataChange: (name, value) => { onMetadataChange: (name, value) => {
dispatch(updateMetadata(name, value)); dispatch(updateMetadata(name, value));
}, },
onToggleMetadataInputs: (value) => { onToggleMetadataInputs: value => {
dispatch(toggleMetadataInputs(value)); dispatch(toggleMetadataInputs(value));
}, },
}; };
}; };
export default connect(mapStateToProps, mapDispatchToProps)(View); export default connect(
mapStateToProps,
mapDispatchToProps
)(View);

View file

@ -1,9 +1,9 @@
import React from 'react'; import React from 'react';
import PublishDescriptionInput from '@components/PublishDescriptionInput'; import PublishDescriptionInput from '@components/PublishDescriptionInput';
import PublishLicenseInput from '@components/PublishLicenseInput'; import PublishLicenseInput from '@components/PublishLicenseInput';
import PublishLicenseUrlInput from '@components/PublishLicenseUrlInput';
import PublishNsfwInput from '@components/PublishNsfwInput'; import PublishNsfwInput from '@components/PublishNsfwInput';
import ButtonSecondary from '@components/ButtonSecondary'; import ButtonSecondary from '@components/ButtonSecondary';
import Row from '@components/Row';
class PublishMetadataInputs extends React.Component { class PublishMetadataInputs extends React.Component {
constructor (props) { constructor (props) {
@ -25,22 +25,32 @@ class PublishMetadataInputs extends React.Component {
const name = event.target.name; const name = event.target.name;
const selectedOption = event.target.selectedOptions[0].value; const selectedOption = event.target.selectedOptions[0].value;
this.props.onMetadataChange(name, selectedOption); this.props.onMetadataChange(name, selectedOption);
if (name === 'license' && selectedOption !== 'Creative Commons'){
this.props.onMetadataChange('licenseUrl', '');
}
} }
render () { render () {
const { showMetadataInputs, description, isUpdate, nsfw } = this.props; const { showMetadataInputs, description, isUpdate, nsfw, license, licenseUrl } = this.props;
return ( return (
<div> <div>
{(showMetadataInputs || isUpdate) && ( {(showMetadataInputs || isUpdate) && (
<React.Fragment> <React.Fragment>
<PublishDescriptionInput <PublishDescriptionInput
description={this.props.description} description={description}
handleInput={this.handleInput} handleInput={this.handleInput}
/> />
<PublishLicenseInput <PublishLicenseInput
handleSelect={this.handleSelect} handleSelect={this.handleSelect}
license={license}
/> />
{ (this.props.license === 'Creative Commons') && (
<PublishLicenseUrlInput
handleSelect={this.handleSelect}
licenseUrl={licenseUrl}
/>
)}
<PublishNsfwInput <PublishNsfwInput
nsfw={this.props.nsfw} nsfw={nsfw}
handleInput={this.handleInput} handleInput={this.handleInput}
/> />
</React.Fragment> </React.Fragment>

View file

@ -9,7 +9,7 @@ class EditPage extends React.Component {
onHandleShowPageUri(match.params); onHandleShowPageUri(match.params);
setUpdateTrue(); setUpdateTrue();
if (asset) { if (asset) {
['title', 'description', 'license', 'nsfw'].forEach(meta => updateMetadata(meta, asset.claimData[meta])); ['title', 'description', 'license', 'licenseUrl', 'nsfw'].forEach(meta => updateMetadata(meta, asset.claimData[meta]));
} }
setHasChanged(false); setHasChanged(false);
} }

View file

@ -19,40 +19,42 @@ if (siteConfig) {
// create initial state // create initial state
const initialState = { const initialState = {
disabled : disabledConfig, disabled: disabledConfig,
disabledMessage : disabledMessageConfig, disabledMessage: disabledMessageConfig,
publishInChannel : false, publishInChannel: false,
selectedChannel : LOGIN, selectedChannel: LOGIN,
showMetadataInputs: false, showMetadataInputs: false,
status : { status: {
status : null, status: null,
message: null, message: null,
}, },
error: { error: {
file : null, file: null,
url : null, url: null,
channel: null, channel: null,
}, },
file : null, file: null,
claim : '', claim: '',
metadata: { metadata: {
title : '', title: '',
description: '', description: '',
license : '', license: '',
nsfw : false, licenseUrl: '',
nsfw: false,
}, },
isUpdate : false, isUpdate: false,
hasChanged: false, hasChanged: false,
thumbnail : null, thumbnail: null,
thumbnailChannel, thumbnailChannel,
thumbnailChannelId, thumbnailChannelId,
}; };
export default function (state = initialState, action) { export default function(state = initialState, action) {
switch (action.type) { switch (action.type) {
case actions.FILE_SELECTED: case actions.FILE_SELECTED:
return Object.assign({}, state.isUpdate ? state : initialState, { // note: clears to initial state return Object.assign({}, state.isUpdate ? state : initialState, {
file : action.data, // note: clears to initial state
file: action.data,
hasChanged: true, hasChanged: true,
}); });
case actions.FILE_CLEAR: case actions.FILE_CLEAR:
@ -66,13 +68,13 @@ export default function (state = initialState, action) {
}); });
case actions.CLAIM_UPDATE: case actions.CLAIM_UPDATE:
return Object.assign({}, state, { return Object.assign({}, state, {
claim : action.data, claim: action.data,
hasChanged: true, hasChanged: true,
}); });
case actions.SET_PUBLISH_IN_CHANNEL: case actions.SET_PUBLISH_IN_CHANNEL:
return Object.assign({}, state, { return Object.assign({}, state, {
publishInChannel: action.channel, publishInChannel: action.channel,
hasChanged : true, hasChanged: true,
}); });
case actions.PUBLISH_STATUS_UPDATE: case actions.PUBLISH_STATUS_UPDATE:
return Object.assign({}, state, { return Object.assign({}, state, {
@ -96,7 +98,7 @@ export default function (state = initialState, action) {
case actions.THUMBNAIL_NEW: case actions.THUMBNAIL_NEW:
return { return {
...state, ...state,
thumbnail : action.data, thumbnail: action.data,
hasChanged: true, hasChanged: true,
}; };
case actions.SET_UPDATE_TRUE: case actions.SET_UPDATE_TRUE:
@ -112,4 +114,4 @@ export default function (state = initialState, action) {
default: default:
return state; return state;
} }
}; }

View file

@ -1,9 +1,16 @@
export const createPublishMetadata = (claim, { type }, { title, description, license, nsfw }, publishInChannel, selectedChannel) => { export const createPublishMetadata = (
claim,
{ type },
{ title, description, license, licenseUrl, nsfw },
publishInChannel,
selectedChannel
) => {
let metadata = { let metadata = {
name: claim, name: claim,
title, title,
description, description,
license, license,
licenseUrl,
nsfw, nsfw,
type, type,
}; };

View file

@ -6,7 +6,7 @@ const {
const getterMethods = { const getterMethods = {
generated_extension() { generated_extension() {
logger.info('trying to generate extension', this.content_type); logger.debug('trying to generate extension', this.content_type);
if (customFileExtensions.hasOwnProperty(this.content_type)) { if (customFileExtensions.hasOwnProperty(this.content_type)) {
return customFileExtensions[this.content_type]; return customFileExtensions[this.content_type];
} else { } else {
@ -136,6 +136,14 @@ export default (sequelize, { BOOLEAN, DATE, DECIMAL, ENUM, INTEGER, STRING, TEXT
type: STRING, type: STRING,
set() {}, set() {},
}, },
license: {
type: STRING,
set() {},
},
license_url: {
type: STRING,
set() {},
},
}, },
{ {
freezeTableName: true, freezeTableName: true,

View file

@ -1,8 +1,10 @@
const chainquery = require('chainquery').default; const chainquery = require('chainquery').default;
const logger = require('winston');
const getClaimData = require('server/utils/getClaimData'); const getClaimData = require('server/utils/getClaimData');
const { returnPaginatedChannelClaims } = require('./channelPagination.js'); const { returnPaginatedChannelClaims } = require('./channelPagination.js');
const getChannelClaims = async (channelName, channelLongId, page) => { const getChannelClaims = async (channelName, channelLongId, page) => {
logger.debug(`getChannelClaims: ${channelName}, ${channelLongId}, ${page}`);
let channelShortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId( let channelShortId = await chainquery.claim.queries.getShortClaimIdFromLongClaimId(
channelLongId, channelLongId,
channelName channelName

View file

@ -1,6 +1,17 @@
const logger = require('winston'); const logger = require('winston');
const { details, publishing } = require('@config/siteConfig'); const { details, publishing } = require('@config/siteConfig');
const createPublishParams = (filePath, name, title, description, license, nsfw, thumbnail, channelName, channelClaimId) => { const createPublishParams = (
filePath,
name,
title,
description,
license,
licenseUrl,
nsfw,
thumbnail,
channelName,
channelClaimId
) => {
// provide defaults for title // provide defaults for title
if (title === null || title.trim() === '') { if (title === null || title.trim() === '') {
title = name; title = name;
@ -13,17 +24,22 @@ const createPublishParams = (filePath, name, title, description, license, nsfw,
if (license === null || license.trim() === '') { if (license === null || license.trim() === '') {
license = ''; // default to empty string license = ''; // default to empty string
} }
// provide default for licenseUrl
if (licenseUrl === null || licenseUrl.trim() === '') {
licenseUrl = ''; // default to empty string
}
// create the basic publish params // create the basic publish params
const publishParams = { const publishParams = {
name, name,
file_path: filePath, file_path: filePath,
bid : publishing.fileClaimBidAmount, bid: publishing.fileClaimBidAmount,
metadata : { metadata: {
description, description,
title, title,
author : details.title, author: details.title,
language: 'en', language: 'en',
license, license,
licenseUrl,
nsfw, nsfw,
}, },
claim_address: publishing.primaryClaimAddress, claim_address: publishing.primaryClaimAddress,

View file

@ -1,27 +1,28 @@
const logger = require('winston'); const logger = require('winston');
const { details, publishing } = require('@config/siteConfig'); const { details, publishing } = require('@config/siteConfig');
const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, nsfw) => { const createThumbnailPublishParams = (thumbnailFilePath, claimName, license, licenseUrl, nsfw) => {
if (!thumbnailFilePath) { if (!thumbnailFilePath) {
return; return;
} }
logger.debug(`Creating Thumbnail Publish Parameters`); logger.debug(`Creating Thumbnail Publish Parameters`);
// create the publish params // create the publish params
return { return {
name : `${claimName}-thumb`, name: `${claimName}-thumb`,
file_path: thumbnailFilePath, file_path: thumbnailFilePath,
bid : publishing.fileClaimBidAmount, bid: publishing.fileClaimBidAmount,
metadata : { metadata: {
title : `${claimName} thumbnail`, title: `${claimName} thumbnail`,
description: `a thumbnail for ${claimName}`, description: `a thumbnail for ${claimName}`,
author : details.title, author: details.title,
language : 'en', language: 'en',
license, license,
licenseUrl,
nsfw, nsfw,
}, },
claim_address: publishing.primaryClaimAddress, claim_address: publishing.primaryClaimAddress,
channel_name : publishing.thumbnailChannel, channel_name: publishing.thumbnailChannel,
channel_id : publishing.thumbnailChannelId, channel_id: publishing.thumbnailChannelId,
}; };
}; };

View file

@ -1,10 +1,15 @@
const logger = require('winston'); const logger = require('winston');
const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig'); const {
details: { host },
publishing: { disabled, disabledMessage },
} = require('@config/siteConfig');
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js'); const { sendGATimingEvent } = require('server/utils/googleAnalytics.js');
const isApprovedChannel = require('@globalutils/isApprovedChannel'); const isApprovedChannel = require('@globalutils/isApprovedChannel');
const { publishing: { publishOnlyApproved, approvedChannels } } = require('@config/siteConfig'); const {
publishing: { publishOnlyApproved, approvedChannels },
} = require('@config/siteConfig');
const { handleErrorResponse } = require('../../../utils/errorHandlers.js'); const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
@ -55,6 +60,7 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
fileType, fileType,
gaStartTime, gaStartTime,
license, license,
licenseUrl,
name, name,
nsfw, nsfw,
thumbnail, thumbnail,
@ -69,18 +75,34 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
// validate the body and files of the request // validate the body and files of the request
try { try {
// validateApiPublishRequest(body, files); // validateApiPublishRequest(body, files);
({name, nsfw, license, title, description, thumbnail} = parsePublishApiRequestBody(body)); ({
({fileName, filePath, fileExtension, fileType, thumbnailFileName, thumbnailFilePath, thumbnailFileType} = parsePublishApiRequestFiles(files)); name,
({channelName, channelId, channelPassword} = body); nsfw,
license,
licenseUrl,
title,
description,
thumbnail,
} = parsePublishApiRequestBody(body));
({
fileName,
filePath,
fileExtension,
fileType,
thumbnailFileName,
thumbnailFilePath,
thumbnailFileType,
} = parsePublishApiRequestFiles(files));
({ channelName, channelId, channelPassword } = body);
} catch (error) { } catch (error) {
return res.status(400).json({success: false, message: error.message}); return res.status(400).json({ success: false, message: error.message });
} }
// check channel authorization // check channel authorization
authenticateUser(channelName, channelId, channelPassword, user) authenticateUser(channelName, channelId, channelPassword, user)
.then(({ channelName, channelClaimId }) => { .then(({ channelName, channelClaimId }) => {
if (publishOnlyApproved && !isApprovedChannel({ longId: channelClaimId }, approvedChannels)) { if (publishOnlyApproved && !isApprovedChannel({ longId: channelClaimId }, approvedChannels)) {
const error = { const error = {
name : UNAPPROVED_CHANNEL, name: UNAPPROVED_CHANNEL,
message: 'This spee.ch instance only allows publishing to approved channels', message: 'This spee.ch instance only allows publishing to approved channels',
}; };
throw error; throw error;
@ -88,14 +110,25 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
return Promise.all([ return Promise.all([
checkClaimAvailability(name), checkClaimAvailability(name),
createPublishParams(filePath, name, title, description, license, nsfw, thumbnail, channelName, channelClaimId), createPublishParams(
createThumbnailPublishParams(thumbnailFilePath, name, license, nsfw), filePath,
name,
title,
description,
license,
licenseUrl,
nsfw,
thumbnail,
channelName,
channelClaimId
),
createThumbnailPublishParams(thumbnailFilePath, name, license, licenseUrl, nsfw),
]); ]);
}) })
.then(([ claimAvailable, publishParams, thumbnailPublishParams ]) => { .then(([claimAvailable, publishParams, thumbnailPublishParams]) => {
if (!claimAvailable) { if (!claimAvailable) {
const error = { const error = {
name : CLAIM_TAKEN, name: CLAIM_TAKEN,
message: 'That claim name is already taken', message: 'That claim name is already taken',
}; };
throw error; throw error;
@ -110,12 +143,18 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
.then(publishResults => { .then(publishResults => {
logger.info('Publish success >', publishResults); logger.info('Publish success >', publishResults);
claimData = publishResults; claimData = publishResults;
({claimId} = claimData); ({ claimId } = claimData);
if (channelName) { if (channelName) {
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimData.certificateId, channelName); logger.info(`api/claim/publish: claimData.certificateId ${claimData.certificateId}`);
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(
claimData.certificateId,
channelName
);
} else { } else {
return chainquery.claim.queries.getShortClaimIdFromLongClaimId(claimId, name, claimData).catch(() => { return chainquery.claim.queries
.getShortClaimIdFromLongClaimId(claimId, name, claimData)
.catch(() => {
return claimId.slice(0, 1); return claimId.slice(0, 1);
}); });
} }
@ -131,13 +170,13 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
res.status(200).json({ res.status(200).json({
success: true, success: true,
message: 'publish completed successfully', message: 'publish completed successfully',
data : { data: {
name, name,
claimId, claimId,
url : `${host}${canonicalUrl}`, // for backwards compatability with app url: `${host}${canonicalUrl}`, // for backwards compatability with app
showUrl : `${host}${canonicalUrl}`, showUrl: `${host}${canonicalUrl}`,
serveUrl: `${host}${canonicalUrl}${fileExtension}`, serveUrl: `${host}${canonicalUrl}${fileExtension}`,
pushTo : canonicalUrl, pushTo: canonicalUrl,
claimData, claimData,
}, },
}); });

View file

@ -1,15 +1,26 @@
const parsePublishApiRequestBody = ({name, nsfw, license, title, description, thumbnail}) => { const parsePublishApiRequestBody = ({
name,
nsfw,
license,
licenseUrl,
title,
description,
thumbnail,
}) => {
// validate name // validate name
if (!name) { if (!name) {
throw new Error('no name field found in request'); throw new Error('no name field found in request');
} }
const invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name); const invalidNameCharacters = /[^A-Za-z0-9,-]/.exec(name);
if (invalidNameCharacters) { if (invalidNameCharacters) {
throw new Error('The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"'); throw new Error(
'The claim name you provided is not allowed. Only the following characters are allowed: A-Z, a-z, 0-9, and "-"'
);
} }
// optional parameters // optional parameters
nsfw = (nsfw === 'true'); nsfw = nsfw === 'true';
license = license || null; license = license || null;
licenseUrl = licenseUrl || null;
title = title || null; title = title || null;
description = description || null; description = description || null;
thumbnail = thumbnail || null; thumbnail = thumbnail || null;
@ -18,6 +29,7 @@ const parsePublishApiRequestBody = ({name, nsfw, license, title, description, th
name, name,
nsfw, nsfw,
license, license,
licenseUrl,
title, title,
description, description,
thumbnail, thumbnail,

View file

@ -19,10 +19,11 @@ const createCanonicalLink = require('@globalutils/createCanonicalLink');
route to update a claim through the daemon route to update a claim through the daemon
*/ */
const updateMetadata = ({ nsfw, license, title, description }) => { const updateMetadata = ({ nsfw, license, licenseUrl, title, description }) => {
const update = {}; const update = {};
if (nsfw) update['nsfw'] = nsfw; if (nsfw) update['nsfw'] = nsfw;
if (license) update['license'] = license; if (license) update['license'] = license;
if (licenseUrl) update['license_url'] = licenseUrl;
if (title) update['title'] = title; if (title) update['title'] = title;
if (description) update['description'] = description; if (description) update['description'] = description;
return update; return update;
@ -65,6 +66,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
thumbnail, thumbnail,
fileExtension, fileExtension,
license, license,
licenseUrl,
name, name,
nsfw, nsfw,
thumbnailFileName, thumbnailFileName,
@ -127,10 +129,11 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
description: claimRecord.description, description: claimRecord.description,
nsfw: claimRecord.nsfw, nsfw: claimRecord.nsfw,
license: claimRecord.license, license: claimRecord.license,
licenseUrl: claimRecord.license_url,
language: 'en', language: 'en',
author: details.title, author: details.title,
}, },
updateMetadata({ title, description, nsfw, license }) updateMetadata({ title, description, nsfw, license, licenseUrl })
); );
const publishParams = { const publishParams = {
name, name,

View file

@ -1,10 +1,12 @@
const logger = require('winston'); const logger = require('winston');
const transformImage = require('./transformImage'); const transformImage = require('./transformImage');
const isValidQueryObject = require('../../../utils/isValidQueryObj');
const isValidQueryObject = require('server/utils/isValidQueryObj');
const { const {
serving: { dynamicFileSizing }, serving: { dynamicFileSizing },
} = require('@config/siteConfig'); } = require('@config/siteConfig');
const { enabled: dynamicEnabled } = dynamicFileSizing; const { enabled: dynamicEnabled } = dynamicFileSizing;
const serveFile = async ({ filePath, fileType }, res, originalUrl) => { const serveFile = async ({ filePath, fileType }, res, originalUrl) => {
const queryObject = {}; const queryObject = {};
// TODO: replace quick/dirty try catch with better practice // TODO: replace quick/dirty try catch with better practice

View file

@ -59,5 +59,8 @@ module.exports = async (data, chName = null, chShortId = null) => {
host, host,
pending: Boolean(dataVals.height === 0), pending: Boolean(dataVals.height === 0),
blocked: blocked, blocked: blocked,
license: dataVals.license,
licenseUrl: dataVals.license_url,
transactionTime: dataVals.transaction_time,
}; };
}; };

View file

@ -39,6 +39,9 @@ module.exports = () => {
moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`); moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`);
// moduleAliases['@serverutils'] = resolve('server/utils'); // moduleAliases['@serverutils'] = resolve('server/utils');
// aliases for constants
moduleAliases['@clientConstants'] = resolve(`${DEFAULT_ROOT}/constants`);
// 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);
@ -53,7 +56,6 @@ 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;
}; };