This commit is contained in:
Hubert 2021-07-24 08:27:53 +02:00
parent f9bc5b2e39
commit ba19d67f66
2 changed files with 17 additions and 4 deletions

View File

@ -45,7 +45,7 @@ where for <'a> &'a TS : IntoIterator<Item = &'a Entry>,
{
repo : Repository,
browse : TS,
root_query : GitWebQ,
query : GitWebQ,
breadcrumb: BREADCRUMB,
user_opt : Option<User>,
revisions_nbr : u32,
@ -68,16 +68,29 @@ impl GitWebQ {
res.commit = commit;
return res;
}
fn clone_with_path(&self, path : Option<String>) -> GitWebQ {
let mut res = self.clone();
res.path = path;
return res;
}
fn clone_with_branch(&self, branch : Option<String>) -> GitWebQ {
let mut res = self.clone();
res.branch = branch;
return res;
}
fn root_query(&self) -> GitWebQ {
self.clone_with_path(None)
}
fn add_path(&self, name : &&String) -> GitWebQ {
match &self.path {
None => {self.clone_with_path(Some(name.to_string()))}
Some(path) => {self.clone_with_path()}
}
}
}
impl Display for GitWebQ{
@ -158,7 +171,7 @@ pub async fn git_main<T : AuthValidator>(
Ok(GitMainTemplate {
repo,
browse : entries,
root_query : query_struct.clone_with_path(None),
query : query_struct,
breadcrumb: path,
user_opt : user,
revisions_nbr : gitrepo.get_revisions_nbr(),

View File

@ -60,7 +60,7 @@
<div class="w3-cell-row">
<div class="w3-cell">
<ul class="breadcrumb">
<li><a href="{{root_query}}">{{repo.name}}.git</a></li>
<li><a href="{{query.root_query()}}">{{repo.name}}.git</a></li>
{% for (dir, prev) in breadcrumb %}
<li><a href="{{prev}}">{{dir}}</a></li>
{% endfor %}
@ -77,7 +77,7 @@
{% for entry in browse %}
{% match entry %}
{% when Entry::Dir with (name) %}
<li><i class="fa fa-folder"></i> {{ name }}</li>
<li><i class="fa fa-folder"></i> <a href="{{query.add_path(name)}}">{{ name }}</a></li>
{% when Entry::File with (name) %}
<li><i class="fa fa-file"></i> {{ name }}</li>
{% endmatch %}