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]]
|
[[package]]
|
||||||
name = "based"
|
name = "based"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.hydrar.de/jmarya/based#38373021611149d2ebc6d33a269375ec240527cb"
|
source = "git+https://git.hydrar.de/jmarya/based#d6555edc29de66ff5190b716a1f8ebac8dbb2110"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{io::Read, path::PathBuf};
|
||||||
|
|
||||||
use based::{
|
use based::{
|
||||||
page::Shell,
|
page::Shell,
|
||||||
request::{assets::DataResponse, respond_html, RequestContext, StringResponse},
|
request::{assets::DataResponse, RequestContext, StringResponse},
|
||||||
};
|
};
|
||||||
use maud::{html, PreEscaped};
|
use maud::{html, PreEscaped};
|
||||||
use rocket::{get, State};
|
use rocket::{get, State};
|
||||||
|
@ -36,7 +36,7 @@ pub async fn favicon_route(domain: &str) -> Option<DataResponse> {
|
||||||
|
|
||||||
Some(DataResponse::new(
|
Some(DataResponse::new(
|
||||||
buf,
|
buf,
|
||||||
"image/x-icon",
|
"image/x-icon".to_string(),
|
||||||
Some(60 * 60 * 24 * 5),
|
Some(60 * 60 * 24 * 5),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ pub async fn render_website(
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
time: Option<&str>,
|
time: Option<&str>,
|
||||||
arc: &State<WebsiteArchive>,
|
arc: &State<WebsiteArchive>,
|
||||||
) -> Option<StringResponse> {
|
) -> Option<DataResponse> {
|
||||||
let document = arc.get_domain(domain).path(path.to_str().unwrap());
|
let document = arc.get_domain(domain).path(path.to_str().unwrap());
|
||||||
|
|
||||||
let content = document
|
let content = document
|
||||||
|
@ -186,7 +186,11 @@ pub async fn render_website(
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Some(content) = content {
|
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 {
|
} else {
|
||||||
if std::env::var("DOWNLOAD_ON_DEMAND")
|
if std::env::var("DOWNLOAD_ON_DEMAND")
|
||||||
.unwrap_or("false".to_string())
|
.unwrap_or("false".to_string())
|
||||||
|
@ -196,14 +200,18 @@ pub async fn render_website(
|
||||||
arc.archive_url(&format!("https://{domain}/{}", path.to_str().unwrap()))
|
arc.archive_url(&format!("https://{domain}/{}", path.to_str().unwrap()))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
return Some(respond_html(
|
let content = document
|
||||||
&document
|
.render_local(if time.is_some() {
|
||||||
.render_local(if time.is_some() {
|
Some(time.unwrap().to_string())
|
||||||
Some(time.unwrap().to_string())
|
} else {
|
||||||
} else {
|
None
|
||||||
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