mygit

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

commit bb1c5c16b5de906a048e03762fe6699ecfe37790
parent ed057e5fec48ecba7ef42ee9ac96e878a22304a1
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Sat,  3 Apr 2021 12:46:07 +0200

add link to raw file view

Diffstat:
Msrc/main.rs | 6+++---
Mtemplates/file.html | 3++-
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,6 +1,6 @@ use anyhow::Result; use askama::Template; -use git2::{Commit, Diff, Reference, Repository, Tree, TreeEntry}; +use git2::{Commit, Diff, Reference, Repository, Tree}; use once_cell::sync::Lazy; use serde::Deserialize; use std::fs::{self, File}; @@ -433,7 +433,7 @@ async fn repo_commit(req: Request<()>) -> tide::Result { #[template(path = "file.html")] // using the template in this path, relative struct RepoFileTemplate<'a> { repo: &'a Repository, - tree_entry: &'a TreeEntry<'a>, + path: &'a Path, file_text: &'a str, spec: &'a str, } @@ -498,7 +498,7 @@ async fn repo_file(req: Request<()>) -> tide::Result { RepoFileTemplate { repo: &repo, - tree_entry: &tree_entry, + path, file_text: &output, spec: &spec, } diff --git a/templates/file.html b/templates/file.html @@ -2,6 +2,7 @@ {% block content %} {% include "repo-navbar.html" %} - <h3>{{tree_entry.name().unwrap()}}@<a href="/{{repo|repo_name|urlencode_strict}}/tree/{{spec}}">{{spec}}</a></h3> + <a href="/{{repo|repo_name|urlencode_strict}}/tree/{{spec}}/raw/{{path.display()}}" style="float:right;">raw</a> + <h3>{{path.display()}}@<a href="/{{repo|repo_name|urlencode_strict}}/tree/{{spec}}">{{spec}}</a></h3> {{file_text|safe}} {% endblock %}