diff options
| -rw-r--r-- | app/helpers/nodes_helper.rb | 4 | ||||
| -rw-r--r-- | app/views/nodes/sitemap.html.erb | 24 | ||||
| -rw-r--r-- | lib/ccc_conventions.rb | 1 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 36 | ||||
| -rw-r--r-- | 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 | |||
| 70 | path = node.unique_path | 70 | path = node.unique_path |
| 71 | CccConventions::NODE_KINDS.select { |_, config| config[:parent_match]&.call(path) } | 71 | CccConventions::NODE_KINDS.select { |_, config| config[:parent_match]&.call(path) } |
| 72 | end | 72 | end |
| 73 | |||
| 74 | def sitemap_node_open?(node) | ||
| 75 | !CccConventions::SITEMAP_COLLAPSED_PATHS.include?(node.unique_name) | ||
| 76 | end | ||
| 77 | end | 73 | 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 @@ | |||
| 15 | 15 | ||
| 16 | <% @sitemap.each_with_index do |(node, level), index| %> | 16 | <% @sitemap.each_with_index do |(node, level), index| %> |
| 17 | <% while open_details.any? && open_details.last >= level %> | 17 | <% while open_details.any? && open_details.last >= level %> |
| 18 | </details> | 18 | <% closing = open_details.pop %> |
| 19 | <% open_details.pop %> | 19 | <% if closing.zero? %></div><% else %></details><% end %> |
| 20 | <% end %> | 20 | <% end %> |
| 21 | 21 | ||
| 22 | <% unless level.zero? %> | 22 | <% unless level.zero? %> |
| @@ -52,12 +52,22 @@ | |||
| 52 | 52 | ||
| 53 | <% next_level = @sitemap[index + 1]&.last %> | 53 | <% next_level = @sitemap[index + 1]&.last %> |
| 54 | <% if next_level && next_level > level %> | 54 | <% if next_level && next_level > level %> |
| 55 | <details<%= ' open' if sitemap_node_open?(node) %>> | 55 | <% if level.zero? %> |
| 56 | <summary> | 56 | <%# Root's children are the top level: a tree does not hide its own |
| 57 | <%= t(".descendants", :count => @sitemap_descendant_counts[node.id]) %> | 57 | first rank behind a toggle. A plain div keeps the closing-tag |
| 58 | </summary> | 58 | bookkeeping symmetric with the details branches. %> |
| 59 | <div class="sitemap_children"> | ||
| 60 | <% else %> | ||
| 61 | <details> | ||
| 62 | <summary> | ||
| 63 | <%= t(".descendants", :count => @sitemap_descendant_counts[node.id]) %> | ||
| 64 | </summary> | ||
| 65 | <% end %> | ||
| 59 | <% open_details.push(level) %> | 66 | <% open_details.push(level) %> |
| 60 | <% end %> | 67 | <% end %> |
| 61 | <% end %> | 68 | <% end %> |
| 62 | <% open_details.length.times { %></details><% } %> | 69 | <% while open_details.any? %> |
| 70 | <% closing = open_details.pop %> | ||
| 71 | <% if closing.zero? %></div><% else %></details><% end %> | ||
| 72 | <% end %> | ||
| 63 | </div> | 73 | </div> |
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 | |||
| 2 | TRASH_SLUG = "trash" | 2 | TRASH_SLUG = "trash" |
| 3 | ERFA_PARENT_NAME = "club/erfas" | 3 | ERFA_PARENT_NAME = "club/erfas" |
| 4 | CHAOSTREFF_PARENT_NAME = "club/chaostreffs" | 4 | CHAOSTREFF_PARENT_NAME = "club/chaostreffs" |
| 5 | SITEMAP_COLLAPSED_PATHS = %w[updates club/erfas club/chaostreffs disclosure].freeze | ||
| 6 | RESTRICTED_SUBTREES = %w[updates disclosure].freeze | 5 | RESTRICTED_SUBTREES = %w[updates disclosure].freeze |
| 7 | 6 | ||
| 8 | NODE_KINDS = { | 7 | 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"] { | |||
| 1442 | max-width: 60rem; | 1442 | max-width: 60rem; |
| 1443 | } | 1443 | } |
| 1444 | 1444 | ||
| 1445 | #sitemap .node_title a { | ||
| 1446 | font-weight: bold; | ||
| 1447 | } | ||
| 1448 | |||
| 1445 | #sitemap .title_with_flags { | 1449 | #sitemap .title_with_flags { |
| 1446 | align-items: start; | 1450 | align-items: start; |
| 1447 | } | 1451 | } |
| @@ -1454,7 +1458,7 @@ form.button_to button[type="submit"] { | |||
| 1454 | display: flex; | 1458 | display: flex; |
| 1455 | align-items: center; | 1459 | align-items: center; |
| 1456 | gap: 0.3rem; | 1460 | gap: 0.3rem; |
| 1457 | margin-top: 0.15rem; | 1461 | margin-top: 0.25rem; |
| 1458 | font-size: 0.875rem; | 1462 | font-size: 0.875rem; |
| 1459 | color: var(--text-muted); | 1463 | color: var(--text-muted); |
| 1460 | } | 1464 | } |
| @@ -1492,38 +1496,34 @@ form.button_to button[type="submit"] { | |||
| 1492 | border-bottom: 1px solid var(--hairline); | 1496 | border-bottom: 1px solid var(--hairline); |
| 1493 | } | 1497 | } |
| 1494 | 1498 | ||
| 1495 | #sitemap > .sitemap_node { | 1499 | #sitemap details { |
| 1496 | border-bottom-width: 8px; | ||
| 1497 | margin-bottom: 0.75rem; | ||
| 1498 | } | ||
| 1499 | |||
| 1500 | #sitemap > details > summary { | ||
| 1501 | display: none; | ||
| 1502 | } | ||
| 1503 | |||
| 1504 | #sitemap details details { | ||
| 1505 | margin-left: 0.75rem; | 1500 | margin-left: 0.75rem; |
| 1506 | padding-left: 0.5rem; | 1501 | padding-left: 0.5rem; |
| 1507 | } | 1502 | } |
| 1508 | 1503 | ||
| 1509 | @media(min-width:1016px) { | 1504 | @media(min-width:1016px) { |
| 1510 | #sitemap details details { | 1505 | #sitemap details { |
| 1511 | margin-left: 1.5rem; | 1506 | margin-left: 1.5rem; |
| 1512 | border-left: 1px solid var(--hairline); | 1507 | border-left: 1px solid var(--hairline); |
| 1513 | padding-left: 0.75rem; | 1508 | padding-left: 0.75rem; |
| 1514 | } | 1509 | } |
| 1515 | } | 1510 | } |
| 1516 | 1511 | ||
| 1512 | /* The two margin-left rules make the triangle align optically with the | ||
| 1513 | globe above it, so the two meta lines read as one block under the | ||
| 1514 | title. Tuned by eye at both indent widths. Re-check if the indent | ||
| 1515 | changes. */ | ||
| 1517 | #sitemap summary { | 1516 | #sitemap summary { |
| 1518 | padding: 0.10rem 0 0.5rem 0; | 1517 | padding: 0 0 0.5rem 0; |
| 1519 | margin-left: -0.25rem; | 1518 | font-size: 0.875rem; |
| 1520 | margin-top: -0.1rem; | 1519 | margin-left: 1rem; |
| 1521 | color: var(--text-muted); | 1520 | color: var(--text-muted); |
| 1522 | } | 1521 | } |
| 1523 | 1522 | ||
| 1524 | #sitemap details:not([open]) > summary { | 1523 | @media (min-width: 1016px) { |
| 1525 | color: var(--accent); | 1524 | #sitemap summary { |
| 1526 | font-weight: bold; | 1525 | margin-left: -0.1rem; |
| 1526 | } | ||
| 1527 | } | 1527 | } |
| 1528 | 1528 | ||
| 1529 | .aligned_action_row { | 1529 | .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 | |||
| 22 | page = FakePage.new([]) | 22 | page = FakePage.new([]) |
| 23 | assert_nil default_event_tag_list(page) | 23 | assert_nil default_event_tag_list(page) |
| 24 | end | 24 | end |
| 25 | |||
| 26 | test "sitemap_node_open? is false for a configured collapsed path" do | ||
| 27 | club = Node.root.children.create!(:slug => "club") | ||
| 28 | erfas = club.children.create!(:slug => "erfas") | ||
| 29 | assert_equal false, sitemap_node_open?(erfas) | ||
| 30 | end | ||
| 31 | |||
| 32 | test "sitemap_node_open? is true for anything not configured as collapsed" do | ||
| 33 | node = Node.root.children.create!(:slug => "sitemap_open_test") | ||
| 34 | assert_equal true, sitemap_node_open?(node) | ||
| 35 | end | ||
| 36 | end | 25 | end |
