diff --git a/src/main.rs b/src/main.rs index f6f33c7..9d5ea87 100644 --- a/src/main.rs +++ b/src/main.rs @@ -276,7 +276,7 @@ fn handle_connection( let mut pk_path = path.clone(); let mut data_path = path.clone(); - let (pki_path, audio_path, start_level, relative_path, partial) = if relative_path.is_empty() { + let (pki_path, audio_path, start_level, relative_path) = if relative_path.is_empty() { if access == Access::Full { pk_path.push("index.pk"); data_path.push("index.dat"); @@ -285,7 +285,7 @@ fn handle_connection( data_path.push("partial.dat"); } - (None, None, 0, String::new(), None) + (None, None, 0, String::new()) } else { let mut pki_path = path.clone(); let mut audio_path = path.clone(); @@ -298,12 +298,6 @@ fn handle_connection( return; } - let (path, num) = if let Some((path, num)) = path.rsplit_once('=') { - (path, num.parse::().ok()) - } else { - (path.as_ref(), None) - }; - pk_path.push(format!("{path}.pk")); if access == Access::Full { pki_path.push(format!("{path}.pki")); @@ -313,7 +307,7 @@ fn handle_connection( audio_path.push(format!("{path}.mp3")); data_path.push(format!("{path}.dat")); - (Some(pki_path), Some(audio_path), 1, path.to_string(), num) + (Some(pki_path), Some(audio_path), 1, path.to_string()) }; let file_paths = DocumentPaths { @@ -373,7 +367,6 @@ fn handle_connection( &relative_path, &path, file_paths, - partial, start_level, cookie, access != Access::Full, @@ -422,7 +415,6 @@ fn handle_relative_connection( relative_path: &str, path: &Path, file_paths: DocumentPaths, - partial: Option, start_level: usize, cookie: Option<&str>, censored: bool, @@ -572,89 +564,17 @@ fn handle_relative_connection( let lines = BufReader::new(pk_file).lines(); - if let Some(i) = partial { - let mut last_empty = true; - let mut block = 0; - let lines: Vec<_> = lines.map(Result::unwrap_or_default).collect(); - let mut lines = lines.into_iter(); - if i > 0 { - for line in lines.by_ref() { - let empty = line.trim().is_empty(); - if empty == last_empty { - continue; - } - if empty { - block += 1; - if block == i { - break; - } - } - last_empty = empty; - } - } - - for line in lines.clone() { - let empty = line.trim().is_empty(); - if empty == last_empty { - continue; - } - if empty { - block += 1; - } - last_empty = empty; - } - - let _ = writeln!(stream, "

{title} ({}/{})

", i + 1, block); - - let _ = writeln!( - stream, - "< Stop >

" - ); - if i > 0 { - let prev = i - 1; - let _ = writeln!(stream, "< Prev"); - } else { - let _ = writeln!(stream, "< Prev"); - } - - if i + 1 < block { - let next = i + 1; - let _ = writeln!(stream, "Next >"); - } else { - let _ = writeln!(stream, "Next >"); - } - - let _ = writeln!(stream, "
"); - - let mut has_text = false; - convert_extended( - lines.take_while(|line| { - let empty = line.trim().is_empty(); - if !empty { - has_text = true; - } - !empty || !has_text - }), - &mut stream, - Settings::default() - .with_handler(handle_entry) - .with_start_level(start_level) - .with_use_textboxes(true), - ); - } else { - if !title.is_empty() { - let _ = writeln!(stream, "

{title}

"); - } - let _ = writeln!(stream, "< Play >"); - convert_extended( - lines.map(Result::unwrap_or_default), - &mut stream, - Settings::default() - .with_handler(handle_entry) - .with_start_level(start_level) - .with_use_textboxes(true), - ); + if !title.is_empty() { + let _ = writeln!(stream, "

{title}

"); } + convert_extended( + lines.map(Result::unwrap_or_default), + &mut stream, + Settings::default() + .with_handler(handle_entry) + .with_start_level(start_level) + .with_use_textboxes(true), + ); section(&mut stream);