mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Performer and Movie UI fixes and improvements (#447)
* Improve gender display * Sanitise performer URLs * Refactor editable text into separate module * Make movie duration DurationInput * Fix clearing sometimes not firing onChange * Set movie duration as string * Fix TextUtil.fileSize * Improve scene URL
This commit is contained in:
@@ -20,7 +20,7 @@ const fileSize = (bytes: number = 0, precision: number = 2) => {
|
||||
unit++;
|
||||
}
|
||||
|
||||
return `${bytes.toFixed(+precision)} ${Units[unit]}`;
|
||||
return `${count.toFixed(+precision)} ${Units[unit]}`;
|
||||
};
|
||||
|
||||
const secondsToTimestamp = (seconds: number) => {
|
||||
@@ -83,6 +83,33 @@ const resolution = (height: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
const twitterURL = new URL("https://www.twitter.com");
|
||||
const instagramURL = new URL("https://www.instagram.com");
|
||||
|
||||
const sanitiseURL = (url?: string, siteURL?: URL) => {
|
||||
if (!url) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (url.startsWith("http://") || url.startsWith("https://")) {
|
||||
// just return the entire URL
|
||||
return url;
|
||||
}
|
||||
|
||||
if (siteURL) {
|
||||
// if url starts with the site host, then prepend the protocol
|
||||
if (url.startsWith(siteURL.host)) {
|
||||
return siteURL.protocol + url;
|
||||
}
|
||||
|
||||
// otherwise, construct the url from the protocol, host and passed url
|
||||
return siteURL.protocol + siteURL.host + "/" + url;
|
||||
}
|
||||
|
||||
// just prepend the protocol - assume https
|
||||
return "https://" + url;
|
||||
}
|
||||
|
||||
const TextUtils = {
|
||||
truncate,
|
||||
fileSize,
|
||||
@@ -91,6 +118,9 @@ const TextUtils = {
|
||||
age: getAge,
|
||||
bitRate,
|
||||
resolution,
|
||||
sanitiseURL,
|
||||
twitterURL,
|
||||
instagramURL,
|
||||
};
|
||||
|
||||
export default TextUtils;
|
||||
|
||||
Reference in New Issue
Block a user