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 +++++++++++++++++++++++++++++++++-- public/javascripts/admin_interface.js | 17 +++++++++++++++- public/stylesheets/admin.css | 4 ++++ 4 files changed, 62 insertions(+), 3 deletions(-) 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 %> +
+
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index f8148e2..ea3ab3d 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js @@ -16,7 +16,7 @@ $(document).ready(function () { theme_advanced_buttons1 : "bold, italic, underline, bullist, numlist, link, unlink, formatselect, code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", - extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial]", + extended_valid_elements : "aggregate[tags|limit|order_by|order_direction|partial|conditions]", relative_urls : false, entity_encoding : "raw", oninit : cccms.setup_autosave() @@ -44,21 +44,36 @@ $(document).ready(function () { if ($('#recent_changes_toggle').length != 0) { $('#current_drafts_table').hide(); + $('#admin_sitemap_table').hide(); $('#recent_changes_toggle').attr("class", "selected"); $('#recent_changes_toggle').bind("click", function(){ $('#recent_changes_toggle').attr("class", "selected"); $('#current_drafts_toggle').attr("class", "unselected"); + $('#admin_sitemap_toggle').attr("class", "unselected"); $('#recent_changes_table').show(); $('#current_drafts_table').hide(); + $('#admin_sitemap_table').hide(); return false; }); $('#current_drafts_toggle').bind("click", function(){ $('#recent_changes_toggle').attr("class", "unselected"); $('#current_drafts_toggle').attr("class", "selected"); + $('#admin_sitemap_toggle').attr("class", "unselected"); $('#current_drafts_table').show(); $('#recent_changes_table').hide(); + $('#admin_sitemap_table').hide(); + return false; + }); + + $('#admin_sitemap_toggle').bind("click", function(){ + $('#recent_changes_toggle').attr("class", "unselected"); + $('#current_drafts_toggle').attr("class", "unselected"); + $('#admin_sitemap_toggle').attr("class", "selected"); + $('#current_drafts_table').hide(); + $('#recent_changes_table').hide(); + $('#admin_sitemap_table').show(); return false; }); } diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index f95fa18..fbb8a3f 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -170,6 +170,10 @@ table.node_table .actions { text-transform: lowercase; } +#admin_sitemap_table .node_id:before { + content: "• "; +} + /* Revisions */ table#revisions { -- cgit v1.3