~/selfhut

80cce62362da37a52b215ec79455e1a38a54532f — Arthur Melton 47885f67 2 years ago
favicon support
2 files changed, 11 insertions(+), 1 deletions(-)

M README.md
M src/main.rs
M README.md => README.md +2 -1
@@ 12,7 12,8 @@ Simpily run the binary and a website is going to be hosted at port 8000. I would

also recoment using something like nginx to change the port and to do caching. If 
you want to change the config (this would make sense because at default it only
has a example user), edit the file in `$(XDG_CONFIG_HOME)/git-server/git-server.toml`
to your liking.
to your liking. To add a `favicon.ico` you need to add it to 
`$(XDG_CONFIG_HOME)/git-server/favicon.ico`. 

## Config


M src/main.rs => src/main.rs +9 -0
@@ 30,6 30,7 @@ fn rocket() -> _ {

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

@@ 60,3 61,11 @@ 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()
}

#[get("/favicon.ico")]
async fn favicon() -> Option<rocket::fs::NamedFile> {
    let mut path = dirs::config_dir().expect("Could not get the config directory");
    path.push("git-server");
    path.push("favicon.ico"); 
    rocket::fs::NamedFile::open(path).await.ok()
}