~/selfhut

66cb40220680cfab9d87428932f1cbd94cc2d0d9 — Arthur Melton b07f13c4 2 years ago
robots.txt
2 files changed, 11 insertions(+), 3 deletions(-)

M src/main.rs
M static/robots.txt
M src/main.rs => src/main.rs +9 -1
@@ 8,6 8,7 @@ mod utils;


use utils::config;

use std::path::Path;
use rocket::fs::relative;

use crate::repository::raw;

@@ 23,6 24,7 @@ fn rocket() -> _ {

            "/",
            routes![
                file_server,
                robots,
                index::index,
                summary::repository,
                tree::tree_main,

@@ 36,6 38,12 @@ fn rocket() -> _ {


#[get("/static/<path..>")]
async fn file_server(path: PathBufWithDotfiles) -> Option<rocket::fs::NamedFile> {
    let path = std::path::Path::new(relative!("static")).join(path.get());
    let path = Path::new(relative!("static")).join(path.get());
    rocket::fs::NamedFile::open(path).await.ok()
}

#[get("/robots.txt")]
async fn robots() -> Option<rocket::fs::NamedFile> {
    let path = Path::new(relative!("static")).join(Path::new("robots.txt"));
    rocket::fs::NamedFile::open(path).await.ok()
}

M static/robots.txt => static/robots.txt +2 -2
@@ 1,5 1,5 @@

User-agent: *
Disallow: /*?*
Disallow: /*.tar.gz$
Disallow: /*/blame/*
Disallow: /*/log/*
Disallow: /*/*/blame/*
Disallow: /*/*/log/*