parent
0e5ca89f1d
commit
3ed87eaba2
3 changed files with 19 additions and 2 deletions
|
@ -198,7 +198,7 @@ impl Document {
|
|||
|
||||
let mut buf = Vec::new();
|
||||
std::fs::File::open(file_path)
|
||||
.unwrap()
|
||||
.ok()?
|
||||
.read_to_end(&mut buf)
|
||||
.unwrap();
|
||||
let content = String::from_utf8_lossy(&buf);
|
||||
|
|
|
@ -41,7 +41,8 @@ async fn launch() -> _ {
|
|||
pages::render_website,
|
||||
pages::domain_info_route,
|
||||
pages::favicon_route,
|
||||
pages::vector_search
|
||||
pages::vector_search,
|
||||
pages::render_txt_website
|
||||
],
|
||||
)
|
||||
.manage(arc)
|
||||
|
|
|
@ -135,6 +135,22 @@ pub async fn domain_info_route(
|
|||
render_page(content, ctx).await
|
||||
}
|
||||
|
||||
#[get("/txt/<domain>/<path..>?<time>")]
|
||||
pub async fn render_txt_website(
|
||||
domain: &str,
|
||||
path: PathBuf,
|
||||
time: Option<&str>,
|
||||
arc: &State<WebsiteArchive>,
|
||||
) -> Option<String> {
|
||||
let document = arc.get_domain(domain).path(path.to_str().unwrap());
|
||||
|
||||
let content = document
|
||||
.render_local(time.map(|time| time.to_string()))
|
||||
.await;
|
||||
|
||||
content.map(|content_html| html2md::parse_html(&content_html))
|
||||
}
|
||||
|
||||
/// Return archived version of `domain` / `path` at `time`
|
||||
#[get("/s/<domain>/<path..>?<time>")]
|
||||
pub async fn render_website(
|
||||
|
|
Loading…
Add table
Reference in a new issue