feat: render wml decks with paginated card sub-documents
This commit is contained in:
parent
36b868e094
commit
1de4674b09
17 changed files with 1519 additions and 5 deletions
|
|
@ -139,6 +139,30 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
|
|||
}
|
||||
respond(&mut stream, 200, "OK", listener.media_type(&format), body, &headers, head_only)
|
||||
}
|
||||
Ok(Resolution::Found(Resource::Part { parent_url, slug, page })) => {
|
||||
match page.part(&format, &slug) {
|
||||
Some(body) => respond(
|
||||
&mut stream,
|
||||
200,
|
||||
"OK",
|
||||
listener.media_type(&format),
|
||||
body,
|
||||
&[("Vary", "Accept")],
|
||||
head_only,
|
||||
),
|
||||
// This format does not address that sub-document, so the parent
|
||||
// is where the content actually is.
|
||||
None => respond(
|
||||
&mut stream,
|
||||
301,
|
||||
"Moved Permanently",
|
||||
"text/plain; charset=utf-8",
|
||||
b"",
|
||||
&[("Location", parent_url.as_str()), ("Vary", "Accept")],
|
||||
head_only,
|
||||
),
|
||||
}
|
||||
}
|
||||
Ok(Resolution::Found(Resource::Raw { path, media_type })) => {
|
||||
let meta = std::fs::metadata(&path)?;
|
||||
write_head(&mut stream, 200, "OK", media_type, meta.len(), &[])?;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
|
|||
let mut file = std::fs::File::open(&path)?;
|
||||
std::io::copy(&mut file, &mut stream)?;
|
||||
}
|
||||
// resolve_flat never yields a redirect; it is matched for completeness.
|
||||
// resolve_flat follows redirects and sub-documents to real content, so
|
||||
// neither reaches here; they are matched for completeness.
|
||||
Ok(_) => stream.write_all(b"Not found\n")?,
|
||||
Err(err) => {
|
||||
log::warn!("{} nex {}: {err}", listener.name, for_log(path));
|
||||
|
|
|
|||
|
|
@ -58,6 +58,15 @@ pub fn serve(listener: &Listener, mut stream: TcpStream) -> Result<()> {
|
|||
}
|
||||
None => status(&mut stream, 5, "Not rendered", b""),
|
||||
},
|
||||
Ok(Resolution::Found(Resource::Part { parent_url, slug, page })) => {
|
||||
match page.part(format, &slug) {
|
||||
Some(body) => {
|
||||
let media_type = listener.media_type(format);
|
||||
status(&mut stream, 2, media_type, body)
|
||||
}
|
||||
None => status(&mut stream, 3, &parent_url, b""),
|
||||
}
|
||||
}
|
||||
Ok(Resolution::Found(Resource::Raw { path, media_type })) => {
|
||||
write!(stream, "2 {media_type}\r\n")?;
|
||||
let mut file = std::fs::File::open(&path)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue