mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 09:45:10 +00:00
parent
fdc68684ed
commit
0f4bc36bcd
4 changed files with 23 additions and 3 deletions
|
@ -13,6 +13,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
||||||
* Support markdown makeup in claim description
|
* Support markdown makeup in claim description
|
||||||
* Replaced free speech flag (used when image is missing) with labeled color tiles
|
* Replaced free speech flag (used when image is missing) with labeled color tiles
|
||||||
* Added a loading message to file actions
|
* Added a loading message to file actions
|
||||||
|
* URL is auto suggested in Publish Page
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Publishes now uses claims rather than files
|
* Publishes now uses claims rather than files
|
||||||
|
|
|
@ -43,6 +43,7 @@ class PublishForm extends React.PureComponent {
|
||||||
creatingChannel: false,
|
creatingChannel: false,
|
||||||
modal: null,
|
modal: null,
|
||||||
isFee: false,
|
isFee: false,
|
||||||
|
customUrl: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +204,9 @@ class PublishForm extends React.PureComponent {
|
||||||
|
|
||||||
handleNameChange(event) {
|
handleNameChange(event) {
|
||||||
var rawName = event.target.value;
|
var rawName = event.target.value;
|
||||||
|
this.setState({
|
||||||
|
customUrl: Boolean(rawName.length),
|
||||||
|
});
|
||||||
|
|
||||||
this.nameChanged(rawName);
|
this.nameChanged(rawName);
|
||||||
}
|
}
|
||||||
|
@ -445,11 +449,24 @@ class PublishForm extends React.PureComponent {
|
||||||
onFileChange() {
|
onFileChange() {
|
||||||
if (this.refs.file.getValue()) {
|
if (this.refs.file.getValue()) {
|
||||||
this.setState({ hasFile: true });
|
this.setState({ hasFile: true });
|
||||||
|
if (!this.state.customUrl) {
|
||||||
|
let fileName = this._getFileName(this.refs.file.getValue());
|
||||||
|
this.nameChanged(fileName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setState({ hasFile: false });
|
this.setState({ hasFile: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getFileName(fileName) {
|
||||||
|
const path = require("path");
|
||||||
|
const extension = path.extname(fileName);
|
||||||
|
|
||||||
|
fileName = path.basename(fileName, extension);
|
||||||
|
fileName = fileName.replace(lbryuri.REGEXP_INVALID_URI, "");
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
getNameBidHelpText() {
|
getNameBidHelpText() {
|
||||||
if (this.state.prefillDone) {
|
if (this.state.prefillDone) {
|
||||||
return __("Existing claim data was prefilled");
|
return __("Existing claim data was prefilled");
|
||||||
|
|
|
@ -296,7 +296,7 @@ lbry.formatCredits = function(amount, precision) {
|
||||||
lbry.formatName = function(name) {
|
lbry.formatName = function(name) {
|
||||||
// Converts LBRY name to standard format (all lower case, no special characters, spaces replaced by dashes)
|
// Converts LBRY name to standard format (all lower case, no special characters, spaces replaced by dashes)
|
||||||
name = name.replace("/s+/g", "-");
|
name = name.replace("/s+/g", "-");
|
||||||
name = name.toLowerCase().replace(/[^a-z0-9\-]/g, "");
|
name = name.toLowerCase().replace(lbryuri.REGEXP_INVALID_URI, "");
|
||||||
return name;
|
return name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ const CLAIM_ID_MAX_LEN = 40;
|
||||||
|
|
||||||
const lbryuri = {};
|
const lbryuri = {};
|
||||||
|
|
||||||
|
lbryuri.REGEXP_INVALID_URI = /[^A-Za-z0-9-]/g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
||||||
* messages for invalid names.
|
* messages for invalid names.
|
||||||
|
@ -70,7 +72,7 @@ lbryuri.parse = function(uri, requireProto = false) {
|
||||||
contentName = path;
|
contentName = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nameBadChars = (channelName || name).match(/[^A-Za-z0-9-]/g);
|
const nameBadChars = (channelName || name).match(lbryuri.REGEXP_INVALID_URI);
|
||||||
if (nameBadChars) {
|
if (nameBadChars) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
__(
|
__(
|
||||||
|
@ -119,7 +121,7 @@ lbryuri.parse = function(uri, requireProto = false) {
|
||||||
throw new Error(__("Only channel URIs may have a path."));
|
throw new Error(__("Only channel URIs may have a path."));
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathBadChars = path.match(/[^A-Za-z0-9-]/g);
|
const pathBadChars = path.match(lbryuri.REGEXP_INVALID_URI);
|
||||||
if (pathBadChars) {
|
if (pathBadChars) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
__(`Invalid character in path: %s`, pathBadChars.join(", "))
|
__(`Invalid character in path: %s`, pathBadChars.join(", "))
|
||||||
|
|
Loading…
Add table
Reference in a new issue