diff options
Diffstat (limited to 'explorer/tree.sh')
-rwxr-xr-x | explorer/tree.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/explorer/tree.sh b/explorer/tree.sh new file mode 100755 index 0000000..1620d2d --- /dev/null +++ b/explorer/tree.sh | |||
@@ -0,0 +1,17 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | tree -J ../theories -P "*.v" | jq --arg "current" "$1" -r ' | ||
4 | ("../" * ($current | [ scan("/+") ] | length)) as $prefix | | ||
5 | def make_item_link(prefix): | ||
6 | (if $current == prefix + .name then " class=\"current\"" else "" end) as $extra | | ||
7 | "<a href=\"\($prefix)\(prefix)\(.name | @uri).html\"\($extra)>\(.name | @html)</a>"; | ||
8 | def handle_item(prefix): | ||
9 | if .type == "directory" then | ||
10 | "<li>\(.name | @html)<ul>" + | ||
11 | (.name as $dir | .contents | map(handle_item("\(prefix)\($dir)/")) | add) + | ||
12 | "</ul></li>" | ||
13 | else | ||
14 | "<li>\(make_item_link(prefix))</li>" | ||
15 | end; | ||
16 | .[0].contents | map(handle_item("")) | add | ||
17 | ' | ||