feat: fetch and alt mime types for markdown #45

Merged
treadful merged 10 commits from feat/raw into main 2025-10-25 06:03:59 +00:00
Owner

This PR got out of hand.

  • implements text/plain and application/octet-stream for fetching markdown files
  • implements jot fetch
  • adds PathJoin trait for making path strings
  • refactors server routes into their own modules
  • other minor shit

Closes #19

This PR got out of hand. - implements text/plain and application/octet-stream for fetching markdown files - implements `jot fetch` - adds PathJoin trait for making path strings - refactors server routes into their own modules - other minor shit Closes #19
feat: implements text/plain and application/octet-stream fetching for markdown files
All checks were successful
/ test-and-check (pull_request) Successful in 17m8s
6c464abe7f
feat: impl PathJoin for &str
All checks were successful
/ test-and-check (pull_request) Successful in 2m9s
666714c9b2
style: func ordering
All checks were successful
/ test-and-check (pull_request) Successful in 2m7s
6c855e4a3a
style: match > if
All checks were successful
/ test-and-check (pull_request) Successful in 2m18s
8b7045ded2
treadful left a comment
Author
Owner

This entire thing depends on local file paths when it's very likely this would be used to fetch when local files do not exist. This either requires prior knowledge, or fudging your way through paths given by jot objects. Walking the directory is also useless in this case.

It would also not be useful in the case of multiple clients using the same key. For instance, Alice updates x.text and Bob fetches it. Bob would have to have prior knowledge of the file.

Consider refactoring this entire thing to work off a list objects response from the server instead of local file paths. Though it would still need to work on local filesytem paths...

Use cases:

  1. Alice accidentally deleted test.txt. Alice runs jot fetch test.txt
  2. Bob copied his key from his old computer to his new one. He wants to fetch the entire contents of the directory again (assuming the same path on disk). jot fetch /home/bob/jot
  3. Chris and Diane share a key and use it to collaborate on some notes. Chris makes an update, Diane intends to fetch it, so she runs jot fetch .

This PR would work for 1, and not for 2 and 3.

This entire thing depends on local file paths when it's very likely this would be used to fetch when local files do not exist. This either requires prior knowledge, or fudging your way through paths given by `jot objects`. Walking the directory is also useless in this case. It would also not be useful in the case of multiple clients using the same key. For instance, Alice updates `x.text` and Bob fetches it. Bob would have to have prior knowledge of the file. Consider refactoring this entire thing to work off a list objects response from the server instead of local file paths. Though it would still need to work on local filesytem paths... Use cases: 1) Alice accidentally deleted `test.txt`. Alice runs `jot fetch test.txt` 2) Bob copied his key from his old computer to his new one. He wants to fetch the entire contents of the directory again (assuming the same path on disk). `jot fetch /home/bob/jot` 3) Chris and Diane share a key and use it to collaborate on some notes. Chris makes an update, Diane intends to fetch it, so she runs `jot fetch .` This PR would work for 1, and not for 2 and 3.
@ -200,28 +200,104 @@ async fn key_path(req: &mut Request, res: &mut Response) {
let short_id = req.param::<String>("short_id").unwrap();
let subpath = req.param::<String>("subpath").unwrap();
// TODO: break this whole block up
Author
Owner

this worth doing now?

this worth doing now?
treadful marked this conversation as resolved
jot/src/join.rs Outdated
@ -0,0 +1,81 @@
pub trait PathJoin {
Author
Owner

document this

document this
treadful marked this conversation as resolved
Author
Owner

@treadful wrote in #45 (comment):

Consider refactoring this entire thing to work off a list objects response from the server instead of local file paths. Though it would still need to work on local filesytem paths...

Also, jot objects should list full local paths as well.

@treadful wrote in https://source.treadful.dev/treadful/jot/pulls/45#issuecomment-268: > Consider refactoring this entire thing to work off a list objects response from the server instead of local file paths. Though it would still need to work on local filesytem paths... Also, `jot objects` should list full local paths as well.
docs: minor documentation for PathJoin trait
All checks were successful
/ test-and-check (pull_request) Successful in 2m58s
e9374464e8
refactor: move most of the route logic to routes module
All checks were successful
/ test-and-check (pull_request) Successful in 2m46s
407e2f8d74
treadful changed title from feat: implements text/plain and application/octet-stream fetching for markdown files to feat: fetch and alt mime types for markdown 2025-10-25 06:03:41 +00:00
treadful deleted branch feat/raw 2025-10-25 06:03:59 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
treadful/jot!45
No description provided.