gitscope
← rgit / Diff · 84e412c → 84e412c
Changes 84e412c..84e412c
Patch commit
diff --git a/flake.lock b/flake.lock
index d063285..ddc0516 100644
--- a/flake.lock
+++ b/flake.lock
@@ -3,11 +3,11 @@
"advisory-db": {
"flake": false,
"locked": {
- "lastModified": 1743497737,
- "narHash": "sha256-aIyfoxIds4Y54bZ3atFv1YxSvWpXgmy+BUtykv4wBgk=",
+ "lastModified": 1746174207,
+ "narHash": "sha256-/ZPWm1dsz3tXREXGQfa/W6UsQ+J3Pvi0A0U1DZVgLqU=",
"owner": "rustsec",
"repo": "advisory-db",
- "rev": "758fb16a52d7b9776a94856bd9d4ef6140d4946e",
+ "rev": "4584ad9a5ea16ce196317cf4d3593e974fb4a8a1",
"type": "github"
},
"original": {
@@ -18,11 +18,11 @@
},
"crane": {
"locked": {
- "lastModified": 1743649204,
- "narHash": "sha256-uourC72krB5YdGzpHaXOUBXaORkcabPNF+H7sMvZKsw=",
+ "lastModified": 1746291859,
+ "narHash": "sha256-DdWJLA+D5tcmrRSg5Y7tp/qWaD05ATI4Z7h22gd1h7Q=",
"owner": "ipetkov",
"repo": "crane",
- "rev": "8b9ee4e59a737b1dbefbd398caae8595ecffcf6a",
+ "rev": "dfd9a8dfd09db9aad544c4d3b6c47b12562544a5",
"type": "github"
},
"original": {
@@ -69,11 +69,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1743660308,
- "narHash": "sha256-bXfYczbPBb+vCJ9P1zfwzR6UoIIHrLV3vN9NOozXNo8=",
+ "lastModified": 1746282974,
+ "narHash": "sha256-+mBFyA/Viq1m6qZkdRsg1w+SGlI0WGy9qlvVEHSAaho=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "30aa8ad8bf9a0d3a1c200380ddd51012dae4c615",
+ "rev": "328d7e75d76c2fef489056c7195ae3f913a0f5fa",
"type": "github"
},
"original": {
@@ -85,11 +85,11 @@
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1735554305,
- "narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=",
+ "lastModified": 1745377448,
+ "narHash": "sha256-jhZDfXVKdD7TSEGgzFJQvEEZ2K65UMiqW5YJ2aIqxMA=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd",
+ "rev": "507b63021ada5fee621b6ca371c4fca9ca46f52c",
"type": "github"
},
"original": {
@@ -130,11 +130,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
- "lastModified": 1743589519,
- "narHash": "sha256-iBzr7Zb11nQxwX90bO1+Bm1MGlhMSmu4ixgnQFB+j4E=",
+ "lastModified": 1746216483,
+ "narHash": "sha256-4h3s1L/kKqt3gMDcVfN8/4v2jqHrgLIe4qok4ApH5x4=",
"owner": "numtide",
"repo": "treefmt-nix",
- "rev": "18bed671738e36c5504e188aadc18b7e2a6e408f",
+ "rev": "29ec5026372e0dec56f890e50dbe4f45930320fd",
"type": "github"
},
"original": {
diff --git a/src/methods/repo/tree.rs b/src/methods/repo/tree.rs
index 311644b..ac69c7b 100644
--- a/src/methods/repo/tree.rs
+++ b/src/methods/repo/tree.rs
@@ -7,6 +7,7 @@ use serde::Deserialize;
use std::path::PathBuf;
use std::{
fmt::{Display, Formatter},
+ path::Path,
sync::Arc,
};
@@ -58,16 +59,30 @@ pub struct FileTree<'a> {
pub inner: &'a ArchivedSortedTree,
pub base: &'a Repository,
pub path_stack: String,
+ pub query: &'a UriQuery,
+ pub repo_path: Option<&'a Path>,
}
impl<'a> FileTree<'a> {
- pub fn new(inner: &'a ArchivedSortedTree, base: &'a Repository, path_stack: String) -> Self {
+ pub fn new(
+ inner: &'a ArchivedSortedTree,
+ base: &'a Repository,
+ path_stack: String,
+ query: &'a UriQuery,
+ repo_path: Option<&'a Path>,
+ ) -> Self {
Self {
inner,
base,
path_stack,
+ query,
+ repo_path,
}
}
+
+ pub fn get_next_repo_path_if_parent(&self, name: &str) -> Option<&Path> {
+ self.repo_path.and_then(|v| v.strip_prefix(name).ok())
+ }
}
#[derive(Template)]
@@ -86,6 +101,7 @@ pub struct TreeView {
pub struct FileView {
pub repo: Repository,
pub repo_path: PathBuf,
+ pub query: UriQuery,
pub file: FileWithContent,
pub branch: Option<Arc<str>>,
pub full_tree: YokedSortedTree,
@@ -188,9 +204,10 @@ pub async fn handle(
ResponseEither::Left(ResponseEither::Right(into_response(FileView {
repo,
file,
- branch: query.branch,
+ branch: query.branch.clone(),
repo_path: child_path.unwrap_or_default(),
full_tree,
+ query,
})))
}
}
diff --git a/statics/sass/style.scss b/statics/sass/style.scss
index e6adbdc..eecf6c9 100644
--- a/statics/sass/style.scss
+++ b/statics/sass/style.scss
@@ -197,6 +197,14 @@ main {
width: 100%;
text-decoration: none;
color: inherit;
+
+ &.selected {
+ background: rgba(0, 0, 255, .1);
+
+ @media (prefers-color-scheme: dark) {
+ background: rgba(0, 255, 0, .2);
+ }
+ }
}
.dropdown-content {
@@ -204,6 +212,10 @@ main {
padding-left: .4rem;
margin-left: .4rem;
display: none;
+
+ @media (prefers-color-scheme: dark) {
+ border-left: .15rem solid rgba(0, 255, 0, .2);
+ }
}
input[type="checkbox"] {
diff --git a/templates/partials/file_tree.html b/templates/partials/file_tree.html
index 1532235..386b123 100644
--- a/templates/partials/file_tree.html
+++ b/templates/partials/file_tree.html
@@ -1,23 +1,24 @@
<div class="dropdown-link">
- {% for (name, item) in inner.0.iter() -%}
+ {% for (name, item) in inner.0.iter() -%}
+ {% let next_repo_path = get_next_repo_path_if_parent(name.0) -%}
{% match item -%}
{% when ArchivedSortedTreeItem::File -%}
<div class="dropdown-label">
- <a class="link" href="/{{ base.display() }}/tree{{ path_stack }}/{{ name.0 }}">📄 {{ name.0 }}</a>
+ <a class="link{% if next_repo_path.is_some() %} selected{% endif %}" href="/{{ base.display() }}/tree{{ path_stack }}/{{ name.0 }}{{ query }}">📄 {{ name.0 }}</a>
</div>
{% when ArchivedSortedTreeItem::Directory with (inner) -%}
<div class="dropdown-label">
<label>
- <input type="checkbox">
+ <input type="checkbox"{% if next_repo_path.is_some() %} checked{% endif %}>
<div class="dropdown-toggle"><span>›</span></div>
<span class="sr-only">Open directory</span>
</label>
- <a class="link" href="/{{ base.display() }}/tree{{ path_stack }}/{{ name.0 }}">📁 {{ name.0 }}</a>
+ <a class="link" href="/{{ base.display() }}/tree{{ path_stack }}/{{ name.0 }}{{ query }}">📁 {{ name.0 }}</a>
</div>
<div class="dropdown-content">
- {{ FileTree::new(inner, self.base, format!("{}/{}", self.path_stack, name.0)).render()?|safe }}
+ {{ FileTree::new(inner, self.base, format!("{}/{}", self.path_stack, name.0), query, *next_repo_path).render()?|safe }}
</div>
{% endmatch -%}
{% endfor -%}
diff --git a/templates/repo/file.html b/templates/repo/file.html
index c0ed01b..0b64f1a 100644
--- a/templates/repo/file.html
+++ b/templates/repo/file.html
@@ -23,7 +23,7 @@
<div class="two-col">
<div class="sidebar">
- {{ FileTree::new(full_tree.get(), &self.repo, Default::default()).render()?|safe }}
+ {{ FileTree::new(full_tree.get(), &self.repo, Default::default(), query, Some(repo_path)).render()?|safe }}
</div>
<div>