1
- use std:: {
2
- fmt:: { Display , Formatter } ,
3
- sync:: Arc ,
4
- } ;
5
-
6
1
use askama:: Template ;
7
2
use axum:: { extract:: Query , response:: IntoResponse , Extension } ;
8
3
use itertools:: Itertools ;
9
4
use serde:: Deserialize ;
5
+ use std:: path:: PathBuf ;
6
+ use std:: {
7
+ fmt:: { Display , Formatter } ,
8
+ sync:: Arc ,
9
+ } ;
10
10
11
11
use crate :: {
12
12
git:: { FileWithContent , PathDestination , TreeItem } ,
@@ -51,13 +51,15 @@ pub struct TreeView {
51
51
pub repo : Repository ,
52
52
pub items : Vec < TreeItem > ,
53
53
pub query : UriQuery ,
54
+ pub repo_path : PathBuf ,
54
55
pub branch : Option < Arc < str > > ,
55
56
}
56
57
57
58
#[ derive( Template ) ]
58
59
#[ template( path = "repo/file.html" ) ]
59
60
pub struct FileView {
60
61
pub repo : Repository ,
62
+ pub repo_path : PathBuf ,
61
63
pub file : FileWithContent ,
62
64
pub branch : Option < Arc < str > > ,
63
65
}
@@ -73,7 +75,7 @@ pub async fn handle(
73
75
74
76
Ok (
75
77
match open_repo
76
- . path ( child_path, query. id . as_deref ( ) , !query. raw )
78
+ . path ( child_path. clone ( ) , query. id . as_deref ( ) , !query. raw )
77
79
. await ?
78
80
{
79
81
PathDestination :: Tree ( items) => {
@@ -82,6 +84,7 @@ pub async fn handle(
82
84
items,
83
85
branch : query. branch . clone ( ) ,
84
86
query,
87
+ repo_path : child_path. unwrap_or_default ( ) ,
85
88
} ) ) )
86
89
}
87
90
PathDestination :: File ( file) if query. raw => ResponseEither :: Right ( file. content ) ,
@@ -90,6 +93,7 @@ pub async fn handle(
90
93
repo,
91
94
file,
92
95
branch : query. branch ,
96
+ repo_path : child_path. unwrap_or_default ( ) ,
93
97
} ) ) )
94
98
}
95
99
} ,
0 commit comments