diff --git a/flake.nix b/flake.nix index c6bb4d9..a2a2506 100644 --- a/flake.nix +++ b/flake.nix @@ -54,7 +54,6 @@ ./src ./statics ./templates - ./grammar ./themes ./build.rs ]; diff --git a/grammar/fortran/highlights.scm b/grammar/fortran/highlights.scm deleted file mode 100644 index 418e40d..0000000 --- a/grammar/fortran/highlights.scm +++ /dev/null @@ -1,197 +0,0 @@ -(identifier) @variable -(string_literal) @string -(number_literal) @number -(boolean_literal) @boolean -(comment) @comment - -[ - (intrinsic_type) - "allocatable" - "attributes" - "device" - "dimension" - "endtype" - "global" - "grid_global" - "host" - "import" - "in" - "inout" - "intent" - "optional" - "out" - "pointer" - "type" - "value" - ] @type - -[ - "contains" - "private" - "public" - ] @include - -[ - (none) - "implicit" - ] @attribute - -[ - "endfunction" - "endprogram" - "endsubroutine" - "function" - "procedure" - "subroutine" - ] @keyword.function - -[ - (default) - (procedure_qualifier) - "abstract" - "bind" - "call" - "class" - "continue" - "cycle" - "endenum" - "endinterface" - "endmodule" - "endprocedure" - "endprogram" - "endsubmodule" - "enum" - "enumerator" - "equivalence" - "exit" - "extends" - "format" - "goto" - "include" - "interface" - "intrinsic" - "non_intrinsic" - "module" - "namelist" - "only" - "parameter" - "print" - "procedure" - "program" - "read" - "stop" - "submodule" - "use" - "write" - ] @keyword - -"return" @keyword.return - -[ - "else" - "elseif" - "elsewhere" - "endif" - "endwhere" - "if" - "then" - "where" - ] @conditional - -[ - "do" - "enddo" - "forall" - "while" - ] @repeat - -[ - "*" - "+" - "-" - "/" - "=" - "<" - ">" - "<=" - ">=" - "==" - "/=" - ] @operator - -[ - "\\.and\\." - "\\.or\\." - "\\.lt\\." - "\\.gt\\." - "\\.ge\\." - "\\.le\\." - "\\.eq\\." - "\\.eqv\\." - "\\.neqv\\." - ] @keyword.operator - -;; Brackets -[ - "(" - ")" - "[" - "]" - "<<<" - ">>>" - ] @punctuation.bracket - -;; Delimiter -[ - "::" - "," - "%" - ] @punctuation.delimiter - -(parameters - (identifier) @parameter) - -(program_statement - (name) @namespace) - -(module_statement - (name) @namespace) - -(submodule_statement - (module_name) (name) @namespace) - -(function_statement - (name) @function) - -(subroutine_statement - (name) @function) - -(module_procedure_statement - (name) @function) - -(end_program_statement - (name) @namespace) - -(end_module_statement - (name) @namespace) - -(end_submodule_statement - (name) @namespace) - -(end_function_statement - (name) @function) - -(end_subroutine_statement - (name) @function) - -(end_module_procedure_statement - (name) @function) - -(subroutine_call - (identifier) @function) - -(keyword_argument - name: (identifier) @keyword) - -(derived_type_member_expression - (type_member) @property) diff --git a/grammar/html/highlights.scm b/grammar/html/highlights.scm deleted file mode 100644 index 99f39c9..0000000 --- a/grammar/html/highlights.scm +++ /dev/null @@ -1,20 +0,0 @@ -(tag_name) @tag -(erroneous_end_tag_name) @tag.error -(doctype) @constant -(attribute_name) @attribute -(comment) @comment - -[ - "\"" - (attribute_value) -] @string - -[ - "<" - ">" - "" - "/>" - " { - let object = item + let mut object = item .object() .context("Expected item in tree to be object but it wasn't")?; @@ -209,11 +209,36 @@ impl OpenRepository { path, name: item.filename().to_string(), }), - Kind::Tree => TreeItem::Tree(Tree { - mode: item.mode().0, - path, - name: item.filename().to_string(), - }), + Kind::Tree => { + let mut children = PathBuf::new(); + + // if the tree only has one child, flatten it down + while let Ok(Some(Ok(item))) = object + .try_into_tree() + .iter() + .map(gix::Tree::iter) + .flatten() + .at_most_one() + { + let nested_object = item.object().context( + "Expected item in tree to be object but it wasn't", + )?; + + if nested_object.kind != Kind::Tree { + break; + } + + object = nested_object; + children.push(item.filename().to_path_lossy()); + } + + TreeItem::Tree(Tree { + mode: item.mode().0, + path, + children, + name: item.filename().to_string(), + }) + } _ => continue, }); } @@ -602,6 +627,7 @@ pub struct Submodule { pub struct Tree { pub mode: u16, pub name: String, + pub children: PathBuf, pub path: PathBuf, } diff --git a/src/methods/repo/tree.rs b/src/methods/repo/tree.rs index 485c2da..b80f89d 100644 --- a/src/methods/repo/tree.rs +++ b/src/methods/repo/tree.rs @@ -5,6 +5,7 @@ use std::{ use askama::Template; use axum::{extract::Query, response::IntoResponse, Extension}; +use itertools::Itertools; use serde::Deserialize; use crate::{ diff --git a/templates/repo/tree.html b/templates/repo/tree.html index faa1be6..fcad7db 100644 --- a/templates/repo/tree.html +++ b/templates/repo/tree.html @@ -19,7 +19,11 @@ {% match item -%} {%- when crate::git::TreeItem::Tree with (tree) -%}
{{ tree.mode|file_perms }}
{{ tree.name }}
{{ tree.name }} + {%- for child in tree.children.ancestors().collect_vec().into_iter().rev() -%} + {%- if let Some(file_name) = child.file_name() %} / {{ file_name.to_string_lossy() }}{%- endif -%} + {%- endfor -%} +