diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/admin_controller.rb | 7 | ||||
| -rw-r--r-- | app/views/admin/index.html.erb | 37 |
2 files changed, 42 insertions, 2 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 | |||
| 17 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days | 17 | "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days |
| 18 | ] | 18 | ] |
| 19 | ) | 19 | ) |
| 20 | |||
| 21 | all_nodes = Node.root.self_and_descendants | ||
| 22 | @sitemap_depth = {} | ||
| 23 | Node.each_with_level(all_nodes) do |node, level| | ||
| 24 | @sitemap_depth[node.id] = level | ||
| 25 | end | ||
| 26 | @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } | ||
| 20 | end | 27 | end |
| 21 | 28 | ||
| 22 | def search | 29 | 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 @@ | |||
| 1 | <p id="overview_toggle"> | 1 | <p id="overview_toggle"> |
| 2 | <a href="#" id="recent_changes_toggle" class="button">recent changes</a> | 2 | <a href="#" id="recent_changes_toggle" class="button">recent changes</a> |
| 3 | <a href="#" id="current_drafts_toggle" class="button">current drafts</a> | 3 | <a href="#" id="current_drafts_toggle" class="button">current drafts</a> |
| 4 | <a href="#" id="admin_sitemap_toggle" class="button">site map</a> | ||
| 4 | </p> | 5 | </p> |
| 5 | 6 | ||
| 6 | <div id="recent_changes_table"> | 7 | <div id="recent_changes_table"> |
| @@ -64,9 +65,41 @@ | |||
| 64 | <%= node.lock_owner.login if node.lock_owner %> | 65 | <%= node.lock_owner.login if node.lock_owner %> |
| 65 | </td> | 66 | </td> |
| 66 | <td> | 67 | <td> |
| 67 | <%= node.draft ? node.draft.revision : node.head.revision %> | 68 | <%= node.draft ? node.draft.revision : ( node.head ? node.head.revision : "EMPTY" ) %> |
| 68 | </td> | 69 | </td> |
| 69 | </tr> | 70 | </tr> |
| 70 | <% end %> | 71 | <% end %> |
| 71 | </table> | 72 | </table> |
| 72 | </div> \ No newline at end of file | 73 | </div> |
| 74 | |||
| 75 | <div id="admin_sitemap_table"> | ||
| 76 | |||
| 77 | <h1>Sitemap</h1> | ||
| 78 | |||
| 79 | <table class="node_table"> | ||
| 80 | <tr class="header"> | ||
| 81 | <th class="node_id">ID</th> | ||
| 82 | <th class="title">Title</th> | ||
| 83 | <th class="actions">Actions</th> | ||
| 84 | <th class="editor">Locked by</th> | ||
| 85 | </tr> | ||
| 86 | <% @sitemap.each do |node| %> | ||
| 87 | <% if !node.nil? %> | ||
| 88 | <tr class="<%= cycle("even", "odd") %>"> | ||
| 89 | <td class="node_id" style="padding-left: <%= @sitemap_depth[node.id] * 30 %>px;"><%= node.id %></td> | ||
| 90 | <td class="title" style="padding-left: <%= @sitemap_depth[node.id] * 30 %>px;"> | ||
| 91 | <h4><%= link_to title_for_node(node), node_path(node) %></h4> | ||
| 92 | <p><%= link_to_path(node.unique_name, node.unique_name) %></p> | ||
| 93 | </td> | ||
| 94 | <td class="actions"> | ||
| 95 | <%= link_to 'show', node_path(node) %> | ||
| 96 | <%= link_to 'Revisions', node_revisions_path(node) %> | ||
| 97 | </td> | ||
| 98 | <td> | ||
| 99 | <%= node.lock_owner.login if node.lock_owner %> | ||
| 100 | </td> | ||
| 101 | </tr> | ||
| 102 | <% end %> | ||
| 103 | <% end %> | ||
| 104 | </table> | ||
| 105 | </div> | ||
