From 0f8a3066c55b6ecb9d95b3e9306eee5262928b14 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 6 Aug 2026 21:15:03 +0200 Subject: Re-structure sitemap, all subpages collapsed by default, visually tightened --- app/helpers/nodes_helper.rb | 4 ---- app/views/nodes/sitemap.html.erb | 24 ++++++++++++++------- lib/ccc_conventions.rb | 1 - public/stylesheets/admin.css | 36 ++++++++++++++++---------------- test/models/helpers/nodes_helper_test.rb | 11 ---------- 5 files changed, 35 insertions(+), 41 deletions(-) diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index 48f44f8b..fa3cc443 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb @@ -70,8 +70,4 @@ module NodesHelper path = node.unique_path CccConventions::NODE_KINDS.select { |_, config| config[:parent_match]&.call(path) } end - - def sitemap_node_open?(node) - !CccConventions::SITEMAP_COLLAPSED_PATHS.include?(node.unique_name) - end end diff --git a/app/views/nodes/sitemap.html.erb b/app/views/nodes/sitemap.html.erb index 49a59d4c..3b9328da 100644 --- a/app/views/nodes/sitemap.html.erb +++ b/app/views/nodes/sitemap.html.erb @@ -15,8 +15,8 @@ <% @sitemap.each_with_index do |(node, level), index| %> <% while open_details.any? && open_details.last >= level %> - - <% open_details.pop %> + <% closing = open_details.pop %> + <% if closing.zero? %><% else %><% end %> <% end %> <% unless level.zero? %> @@ -52,12 +52,22 @@ <% next_level = @sitemap[index + 1]&.last %> <% if next_level && next_level > level %> - > - - <%= t(".descendants", :count => @sitemap_descendant_counts[node.id]) %> - + <% if level.zero? %> + <%# Root's children are the top level: a tree does not hide its own + first rank behind a toggle. A plain div keeps the closing-tag + bookkeeping symmetric with the details branches. %> +
+ <% else %> +
+ + <%= t(".descendants", :count => @sitemap_descendant_counts[node.id]) %> + + <% end %> <% open_details.push(level) %> <% end %> <% end %> -<% open_details.length.times { %>
<% } %> +<% while open_details.any? %> + <% closing = open_details.pop %> + <% if closing.zero? %>
<% else %><% end %> +<% end %> diff --git a/lib/ccc_conventions.rb b/lib/ccc_conventions.rb index 52549c9e..bb7b2033 100644 --- a/lib/ccc_conventions.rb +++ b/lib/ccc_conventions.rb @@ -2,7 +2,6 @@ module CccConventions TRASH_SLUG = "trash" ERFA_PARENT_NAME = "club/erfas" CHAOSTREFF_PARENT_NAME = "club/chaostreffs" - SITEMAP_COLLAPSED_PATHS = %w[updates club/erfas club/chaostreffs disclosure].freeze RESTRICTED_SUBTREES = %w[updates disclosure].freeze NODE_KINDS = { diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 334e0bd5..50ea1d51 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -1442,6 +1442,10 @@ form.button_to button[type="submit"] { max-width: 60rem; } +#sitemap .node_title a { + font-weight: bold; +} + #sitemap .title_with_flags { align-items: start; } @@ -1454,7 +1458,7 @@ form.button_to button[type="submit"] { display: flex; align-items: center; gap: 0.3rem; - margin-top: 0.15rem; + margin-top: 0.25rem; font-size: 0.875rem; color: var(--text-muted); } @@ -1492,38 +1496,34 @@ form.button_to button[type="submit"] { border-bottom: 1px solid var(--hairline); } -#sitemap > .sitemap_node { - border-bottom-width: 8px; - margin-bottom: 0.75rem; -} - -#sitemap > details > summary { - display: none; -} - -#sitemap details details { +#sitemap details { margin-left: 0.75rem; padding-left: 0.5rem; } @media(min-width:1016px) { - #sitemap details details { + #sitemap details { margin-left: 1.5rem; border-left: 1px solid var(--hairline); padding-left: 0.75rem; } } +/* The two margin-left rules make the triangle align optically with the + globe above it, so the two meta lines read as one block under the + title. Tuned by eye at both indent widths. Re-check if the indent + changes. */ #sitemap summary { - padding: 0.10rem 0 0.5rem 0; - margin-left: -0.25rem; - margin-top: -0.1rem; + padding: 0 0 0.5rem 0; + font-size: 0.875rem; + margin-left: 1rem; color: var(--text-muted); } -#sitemap details:not([open]) > summary { - color: var(--accent); - font-weight: bold; +@media (min-width: 1016px) { + #sitemap summary { + margin-left: -0.1rem; + } } .aligned_action_row { diff --git a/test/models/helpers/nodes_helper_test.rb b/test/models/helpers/nodes_helper_test.rb index 5ab924fd..5d91a885 100644 --- a/test/models/helpers/nodes_helper_test.rb +++ b/test/models/helpers/nodes_helper_test.rb @@ -22,15 +22,4 @@ class NodesHelperTest < ActionView::TestCase page = FakePage.new([]) assert_nil default_event_tag_list(page) end - - test "sitemap_node_open? is false for a configured collapsed path" do - club = Node.root.children.create!(:slug => "club") - erfas = club.children.create!(:slug => "erfas") - assert_equal false, sitemap_node_open?(erfas) - end - - test "sitemap_node_open? is true for anything not configured as collapsed" do - node = Node.root.children.create!(:slug => "sitemap_open_test") - assert_equal true, sitemap_node_open?(node) - end end -- cgit v1.3