diff --git a/src/editor/assets/styles.css b/src/editor/assets/styles.css index 3bef4a0..e9e0fb3 100644 --- a/src/editor/assets/styles.css +++ b/src/editor/assets/styles.css @@ -19,7 +19,7 @@ a { font-size: .8rem; padding: .2rem .4rem; } -body, input, textarea { font-family: 'Roboto', sans-serif; } +body, input, select, textarea { font-family: 'Roboto', sans-serif; } button, input { font-size: 1rem; } body { background-color: var(--bg-1); @@ -204,6 +204,14 @@ pre.error { white-space: normal; } .processing { color: orange; } +select { + background-color: var(--bg-2); + border: none; + border-radius: .2rem; + color: var(--fg-1); + font-size: 1rem; + padding: .3rem .6rem; +} .split { display: flex; flex-grow: 1; @@ -216,6 +224,18 @@ pre.error { width: 100%; } .updates { color: red; } +.versions { + list-style: none; + padding-left: 0; +} +.versions li {} +.versions li:not(:first-child) { margin-top: .5rem; } +.versions .file_name { color: var(--fg-1); } +.versions .metadata { color: var(--fg-3); } +.versions .reasons { + color: var(--fg-1); + cursor: help; +} .video { column-gap: .5rem; display: flex; diff --git a/src/editor/endpoints/video.rs b/src/editor/endpoints/video.rs index 3a40cce..d9d62ac 100644 --- a/src/editor/endpoints/video.rs +++ b/src/editor/endpoints/video.rs @@ -48,17 +48,17 @@ use crate::util::{ supported_video_extension, validate_slug }; +#[derive(Deserialize)] +pub struct DownsizeForm { + codec: String, + width: String +} #[derive(Deserialize)] pub struct PosterUpdateForm { description: String } -#[derive(Deserialize)] -pub struct DownsizeForm { - width: String -} - pub enum VideoFormFeedback<'a> { Move { slug: Field @@ -144,8 +144,12 @@ pub async fn downsize( None => return Either::Right(not_found(&context, &format!("Video {} not found.", &path.path))) }; + // TODO: Safety validation of these maybe + let codec = &form.codec; + let width = &form.width; + // TODO: Build programmatically in code instead of parsing from format string - let video_format_string = format!("video:h264:mp4:speed:1.0:{}", form.width); + let video_format_string = format!("video:{codec}:mp4:speed:1.0:{width}"); let video_format = VideoFormat::parse(&video_format_string).unwrap(); let job_kind = JobKind::VideoFormat { format: video_format, video: Arc::clone(&video) }; @@ -166,8 +170,14 @@ fn downsize_form(video: &Video) -> String { let candidate_widths = [240, 480, 720, 1280, 1920]; for width in candidate_widths { if width < widest_width { + let selected = if widest_width < 720 && width == 480 || width == 720 { + "selected" + } else { + "" + }; + let option = formatdoc!(r#" - + "#); options.push(option); } @@ -186,7 +196,13 @@ fn downsize_form(video: &Video) -> String { - + + "#) @@ -219,29 +235,38 @@ pub fn edit_page( let versions = video.versions .iter() .map(|version| { - let video_meta = match &version.video_meta { + let (browser_support, video_meta) = match &version.video_meta { Some(video_meta) => { let duration = precise_duration(video_meta.duration); let height = video_meta.height; let size = human_size(version.file_meta.size); let width = video_meta.width; - let browser_support = match video_meta.browser_support.analysis() { - Some(Ok(message)) => format!("[Very likely playable in browsers: {message}]"), - Some(Err(message)) => format!("[Unfit for browser playback: {message}]"), - None => "[Might be incompatible with and not play in people's browsers]".to_string(), + let (browser_support, reasons) = match video_meta.browser_support.analysis() { + Some(Ok(message)) => ("Good browser support", message), + Some(Err(message)) => ("Not supported for playback by browsers", message), + None => ("Browser support unclear", String::from("Hyper 8 could not determine whether this video's format is generally compatible with browsers or not")) }; - format!("{width}×{height} {duration} {size} {browser_support}") + ( + format!(r#"