mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit d6b9cb2efb5146efd512fb51f2f94b422dba885d
parent 539680d61acb8198f03dc7ca621709f309e4c9c2
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Sat, 20 Mar 2021 21:46:51 +0100

use actual repository description

Diffstat:
Msrc/main.rs | 10++++++++++
Mtemplates/index.html | 2+-
Mtemplates/repo-navbar.html | 2+-
3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -449,6 +449,16 @@ mod filters { .to_str() .ok_or(askama::Error::Fmt(std::fmt::Error)) } + + pub fn description(repo: &Repository) -> askama::Result<String> { + Ok(fs::read_to_string(repo.path().join("description")) + .unwrap_or_default() + // only use first line + .lines() + .next() + .unwrap_or_default() + .to_string()) + } } #[async_std::main] diff --git a/templates/index.html b/templates/index.html @@ -7,7 +7,7 @@ {% for repo in repos %} <tr> <td class="repo-link"><a href="{{repo|repo_name|urlencode_strict}}">{{repo|repo_name}}</a></td> - <td class="repo-description">a cool repository</td> + <td class="repo-description">{{repo|description}}</td> <td class="repo-last-updated">updated 2021-02-01</td> </tr> {% endfor %} diff --git a/templates/repo-navbar.html b/templates/repo-navbar.html @@ -1,5 +1,5 @@ <h1><a href="/">index</a>/{{repo|repo_name}}</h1> -<div>My cool repo</div> +<div>{{repo|description}}</div> <div class="clone-url">git clone git.alexwennerberg.com/repo </div> <div class="navbar"><a href="/{{repo|repo_name|urlencode_strict}}">README</a> | <a href="/{{repo|repo_name|urlencode_strict}}/tree">tree</a> | <a href="/{{repo|repo_name|urlencode_strict}}/log">log</a> | <a href="/{{repo|repo_name|urlencode_strict}}/refs">refs</a></div> <hr class='thin'>