Diff
templates/repo/tree.html | 76 ++++++++++++++++++++++++++++++++++++++++++++++------------------------------
src/database/schema/tree.rs | 2 +-
src/methods/repo/tree.rs | 8 ++++++++
3 files changed, 51 insertions(+), 35 deletions(-)
@@ -1,4 +1,5 @@
{% import "macros/breadcrumbs.html" as breadcrumbs %}
{% import "macros/sidebar_toggle.html" as sidebar_toggle %}
{% extends "repo/base.html" %}
{% block tree_nav_class %}active{% endblock %}
@@ -8,40 +9,47 @@
{% endblock %}
{% block content %}
<div class="table-responsive">
<table class="repositories">
<thead>
<tr>
<th style="width: 10rem;">Mode</th>
<th>Name</th>
</tr>
</thead>
{% call sidebar_toggle::sidebar_toggle("Open file browser") %}
<div class="two-col">
<div class="sidebar">
{{ FileTree::new(full_tree.get(), &self.repo, Default::default(), query, Some(repo_path)).render()?|safe }}
</div>
<tbody>
{% for (name, name_split, item) in items -%}
<tr>
<td>
<pre>{{ item.get().mode.to_native()|file_perms }}</pre>
</td>
{% set local_name = name.get()[*name_split..] -%}
{% set local_name = local_name.strip_prefix('/').unwrap_or(local_name) -%}
{% match item.get().kind -%}
{%- when ArchivedTreeItemKind::Tree -%}
<td>
<pre><a class="nested-tree" href="/{{ repo.display() }}/tree/{{ name.get() }}{{ query }}">{{ local_name }}</a></pre>
</td>
{%- when ArchivedTreeItemKind::File -%}
<td>
<pre><a href="/{{ repo.display() }}/tree/{{ name.get() }}{{ query }}">{{ local_name }}</a></pre>
</td>
{%- when ArchivedTreeItemKind::Submodule with (submodule) -%}
<td>
<pre>🔗 <a href="{{ submodule.url }}">{{ local_name }}</a> @ {{ submodule.oid|hex }}</pre>
</td>
{%- endmatch %}
</tr>
{% endfor -%}
</tbody>
</table>
<div class="table-responsive">
<table class="repositories">
<thead>
<tr>
<th style="width: 10rem;">Mode</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{% for (name, name_split, item) in items -%}
<tr>
<td>
<pre>{{ item.get().mode.to_native()|file_perms }}</pre>
</td>
{% set local_name = name.get()[*name_split..] -%}
{% set local_name = local_name.strip_prefix('/').unwrap_or(local_name) -%}
{% match item.get().kind -%}
{%- when ArchivedTreeItemKind::Tree -%}
<td>
<pre><a class="nested-tree" href="/{{ repo.display() }}/tree/{{ name.get() }}{{ query }}">{{ local_name }}</a></pre>
</td>
{%- when ArchivedTreeItemKind::File -%}
<td>
<pre><a href="/{{ repo.display() }}/tree/{{ name.get() }}{{ query }}">{{ local_name }}</a></pre>
</td>
{%- when ArchivedTreeItemKind::Submodule with (submodule) -%}
<td>
<pre>🔗 <a href="{{ submodule.url }}">{{ local_name }}</a> @ {{ submodule.oid|hex }}</pre>
</td>
{%- endmatch %}
</tr>
{% endfor -%}
</tbody>
</table>
</div>
</div>
{% endblock %}
@@ -42,7 +42,7 @@
.cf_handle(TREE_FAMILY)
.context("tree column family missing")?;
let Some(data) = database.get_pinned_cf(cf, tree_oid.as_slice())? else {
let Some(data) = database.get_cf(cf, tree_oid.as_slice())? else {
return Ok(None);
};
@@ -94,6 +94,7 @@
pub query: UriQuery,
pub repo_path: PathBuf,
pub branch: Option<Arc<str>>,
pub full_tree: YokedSortedTree,
}
#[derive(Template)]
@@ -212,12 +213,19 @@
}
}
LookupResult::Children(items) => {
let db = db_orig.clone();
let full_tree = tokio::task::spawn_blocking(move || SortedTree::get(tree_id, &db))
.await
.context("failed to join on tokio task")??
.context("missing file tree")?;
ResponseEither::Left(ResponseEither::Left(into_response(TreeView {
repo,
items,
branch: query.branch.clone(),
query,
repo_path: child_path.unwrap_or_default(),
full_tree,
})))
}
})