From 8199b48ae5d31b008f10dff173352bd8ba2d8890 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 5 Feb 2025 23:04:13 +0100 Subject: Enhance admin view by sitemap --- app/controllers/admin_controller.rb | 7 +++++++ app/views/admin/index.html.erb | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index cdfe564..7c1375a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -17,6 +17,13 @@ class AdminController < ApplicationController "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days ] ) + + all_nodes = Node.root.self_and_descendants + @sitemap_depth = {} + Node.each_with_level(all_nodes) do |node, level| + @sitemap_depth[node.id] = level + end + @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } end def search diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index 526aa88..8c8271f 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb @@ -1,6 +1,7 @@

recent changes current drafts + site map

@@ -64,9 +65,41 @@ <%= node.lock_owner.login if node.lock_owner %> - <%= node.draft ? node.draft.revision : node.head.revision %> + <%= node.draft ? node.draft.revision : ( node.head ? node.head.revision : "EMPTY" ) %> <% end %> -
\ No newline at end of file + + +
+ +

Sitemap

+ + + + + + + + + <% @sitemap.each do |node| %> + <% if !node.nil? %> + "> + + + + + + <% end %> + <% end %> +
IDTitleActionsLocked by
<%= node.id %> +

<%= link_to title_for_node(node), node_path(node) %>

+

<%= link_to_path(node.unique_name, node.unique_name) %>

+
+ <%= link_to 'show', node_path(node) %> + <%= link_to 'Revisions', node_revisions_path(node) %> + + <%= node.lock_owner.login if node.lock_owner %> +
+
-- cgit v1.3