parent
634706beec
commit
df0b1b910a
2 changed files with 21 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -164,7 +164,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
|||
[[package]]
|
||||
name = "based"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.hydrar.de/jmarya/based#38373021611149d2ebc6d33a269375ec240527cb"
|
||||
source = "git+https://git.hydrar.de/jmarya/based#d6555edc29de66ff5190b716a1f8ebac8dbb2110"
|
||||
dependencies = [
|
||||
"bcrypt",
|
||||
"chrono",
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{io::Read, path::PathBuf};
|
|||
|
||||
use based::{
|
||||
page::Shell,
|
||||
request::{assets::DataResponse, respond_html, RequestContext, StringResponse},
|
||||
request::{assets::DataResponse, RequestContext, StringResponse},
|
||||
};
|
||||
use maud::{html, PreEscaped};
|
||||
use rocket::{get, State};
|
||||
|
@ -36,7 +36,7 @@ pub async fn favicon_route(domain: &str) -> Option<DataResponse> {
|
|||
|
||||
Some(DataResponse::new(
|
||||
buf,
|
||||
"image/x-icon",
|
||||
"image/x-icon".to_string(),
|
||||
Some(60 * 60 * 24 * 5),
|
||||
))
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ pub async fn render_website(
|
|||
path: PathBuf,
|
||||
time: Option<&str>,
|
||||
arc: &State<WebsiteArchive>,
|
||||
) -> Option<StringResponse> {
|
||||
) -> Option<DataResponse> {
|
||||
let document = arc.get_domain(domain).path(path.to_str().unwrap());
|
||||
|
||||
let content = document
|
||||
|
@ -186,7 +186,11 @@ pub async fn render_website(
|
|||
.await;
|
||||
|
||||
if let Some(content) = content {
|
||||
return Some(respond_html(&content));
|
||||
return Some(DataResponse::new(
|
||||
content.as_bytes().to_vec(),
|
||||
"text/html".to_string(),
|
||||
Some(60 * 60 * 24),
|
||||
));
|
||||
} else {
|
||||
if std::env::var("DOWNLOAD_ON_DEMAND")
|
||||
.unwrap_or("false".to_string())
|
||||
|
@ -196,14 +200,18 @@ pub async fn render_website(
|
|||
arc.archive_url(&format!("https://{domain}/{}", path.to_str().unwrap()))
|
||||
.await;
|
||||
|
||||
return Some(respond_html(
|
||||
&document
|
||||
let content = document
|
||||
.render_local(if time.is_some() {
|
||||
Some(time.unwrap().to_string())
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.await?,
|
||||
.await?;
|
||||
|
||||
return Some(DataResponse::new(
|
||||
content.as_bytes().to_vec(),
|
||||
"text/html".to_string(),
|
||||
Some(60 * 60 * 24),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue