mygit

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

commit e88eea30a74b94f48c9d60cb1f6cbaa4e082896d
parent de8f763fa7f7cbcaf1a0e70ce5049336ae57c38f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 17 Mar 2021 08:56:15 -0700

Add (dead) links to files on tree page

Diffstat:
Msrc/main.rs | 14+++++++++++++-
Atemplates/file.html | 7+++++++
Mtemplates/tree.html | 3++-
3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -329,6 +329,18 @@ async fn repo_commit(req: Request<()>) -> tide::Result { Ok(tmpl.into()) } +#[derive(Template)] +#[template(path = "file.html")] // using the template in this path, relative +struct RepoFileTemplate<'a> { + repo: &'a Repository, +} + +async fn repo_file(req: Request<()>) -> tide::Result { + let repo = repo_from_request(req.param("repo_name")?)?; + let tmpl = RepoFileTemplate { repo: &repo }; + Ok(tmpl.into()) +} + mod filters { use super::*; @@ -396,7 +408,7 @@ async fn main() -> Result<(), std::io::Error> { app.at("/:repo_name/log/:ref").get(repo_log); // ref optional app.at("/:repo_name/tree").get(repo_tree); app.at("/:repo_name/tree/:ref").get(repo_tree); - // app.at("/:repo_name/tree/:ref/item/:file").get(repo_file); + app.at("/:repo_name/tree/:ref/item/:file").get(repo_file); // Raw files, patch files app.listen("127.0.0.1:8081").await?; Ok(()) diff --git a/templates/file.html b/templates/file.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block content %} + {% include "repo-navbar.html" %} + <h2>abranch</h2> + <pre class="code"> file text goes here</pre> +{% endblock %} diff --git a/templates/tree.html b/templates/tree.html @@ -10,7 +10,8 @@ {{ entry.filemode()|unix_perms }} </td> <td> - {{ entry.name().unwrap() }} + <a href="/{{repo|repo_name|urlencode_strict}}/tree/{{ spec }}/item/{{entry.name().unwrap()}}"> + {{ entry.name().unwrap() }}</a> </td> <td> filesize here