diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-12 02:15:44 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-12 02:15:44 +0200 |
| commit | 45bf65d04d046c0ea4a1150096b2a9b846d6c0b8 (patch) | |
| tree | 24dad426779cb3b0ac59c405245aac1d28109982 /app/helpers | |
| parent | 13c8cb415813e90c883a44b0c0888382161de92a (diff) | |
Give the sitemap its own view, with collapse and descendant counts
Extracted from admin#index's inline table into NodesController#sitemap.
Nested <details>/<summary> per branch, one linear pass over the
existing flat [node, level] list (no added queries) -- each node's own
descendant count computed the same way, via a small stack rather than
re-walking the tree per node. Branches under updates/, club/erfas,
club/chaostreffs, and disclosure start collapsed by default
(CccConventions::SITEMAP_COLLAPSED_PATHS); any branch currently
collapsed, whether by that default or because someone just closed it,
is highlighted via a plain :not([open]) selector -- no state tracked
outside the DOM itself.
Dropped the update?-post exclusion this view used to rely on -- no
longer needed now that updates/ collapses instead of being filtered
out, so its real children (previously silently absent) now show up
correctly. admin#index's own, separate @sitemap query is unchanged;
that view has no collapse mechanism to compensate and wasn't part of
this.
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/nodes_helper.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index a89f879..1268b63 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb | |||
| @@ -12,7 +12,6 @@ module NodesHelper | |||
| 12 | end | 12 | end |
| 13 | end | 13 | end |
| 14 | 14 | ||
| 15 | |||
| 16 | def truncated_title_for_node node | 15 | def truncated_title_for_node node |
| 17 | if (title = title_for_node node) && title.size > 20 | 16 | if (title = title_for_node node) && title.size > 20 |
| 18 | "<span title='#{title}'>#{truncate(title, 40)}</span>" | 17 | "<span title='#{title}'>#{truncate(title, 40)}</span>" |
| @@ -63,4 +62,8 @@ module NodesHelper | |||
| 63 | path = node.unique_path | 62 | path = node.unique_path |
| 64 | CccConventions::NODE_KINDS.select { |_, config| config[:parent_match]&.call(path) } | 63 | CccConventions::NODE_KINDS.select { |_, config| config[:parent_match]&.call(path) } |
| 65 | end | 64 | end |
| 65 | |||
| 66 | def sitemap_node_open?(node) | ||
| 67 | !CccConventions::SITEMAP_COLLAPSED_PATHS.include?(node.unique_name) | ||
| 68 | end | ||
| 66 | end | 69 | end |
