diff options
| author | Fuwn <[email protected]> | 2024-06-27 06:38:11 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-27 06:38:11 -0700 |
| commit | af250377be913502f816e3186c91618045f9f0f9 (patch) | |
| tree | 2f19a0528a160a789be6c4280531203e60413567 /src/modules | |
| parent | fix(finger): paragraph joining (diff) | |
| download | locus-af250377be913502f816e3186c91618045f9f0f9.tar.xz locus-af250377be913502f816e3186c91618045f9f0f9.zip | |
feat(finger): proxy content as pre-formatted
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/finger.rs | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/modules/finger.rs b/src/modules/finger.rs index 99fecc5..c4acba5 100644 --- a/src/modules/finger.rs +++ b/src/modules/finger.rs @@ -48,6 +48,8 @@ To visit my personal Finger server, <finger://fuwn.me>, you would visit <gemini: let mut response = String::new(); + response.push_str("```\n"); + loop { let bytes_read = match stream.read(&mut buffer).await { Ok(0) => break, @@ -63,30 +65,34 @@ To visit my personal Finger server, <finger://fuwn.me>, you would visit <gemini: response.push_str(&unsafe { let content = std::str::from_utf8_unchecked(&buffer[..bytes_read]) .replace("finger://", "gemini://fuwn.me/finger/"); - let mut lines = content.lines().peekable(); - let mut result = String::new(); - - while let Some(line) = lines.next() { - if !line.is_empty() { - result.push_str(line); - - if lines - .peek() - .map_or(false, |&next_line| !next_line.is_empty()) - { - result.push(' '); - } else { - result.push('\n'); - } - } else { - result.push('\n'); - } - } - - result + // let mut lines = content.lines().peekable(); + // let mut result = String::new(); + + // while let Some(line) = lines.next() { + // if !line.is_empty() { + // result.push_str(line); + + // if lines + // .peek() + // .map_or(false, |&next_line| !next_line.is_empty()) + // { + // result.push(' '); + // } else { + // result.push('\n'); + // } + // } else { + // result.push('\n'); + // } + // } + + // result + + content }); } + response.push_str("\n```"); + Response::success(response) } else { Response::bad_request("Invalid URI") |