From 262f4e0c2abfefbd6965358fdfd9a8c332a38d57 Mon Sep 17 00:00:00 2001 From: hukl Date: Wed, 7 Oct 2009 23:36:03 +0200 Subject: refactored revsions controller to act as a nested resource of nodes. boy that cleaned up some stuff quite a bit. also having tests for that is just feeling great --- app/views/nodes/edit.html.erb | 2 +- app/views/nodes/index.html.erb | 2 +- app/views/nodes/show.html.erb | 2 +- app/views/revisions/diff.html.erb | 6 +-- app/views/revisions/index.html.erb | 45 ++++++++++++++++++- app/views/revisions/show.html.erb | 88 ++++++++++++++++++++------------------ 6 files changed, 97 insertions(+), 48 deletions(-) (limited to 'app/views') diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 0635dac..0063dd9 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -3,7 +3,7 @@ <%= link_to 'Show', @node %> <%= link_to 'Preview', preview_page_path(@draft) %> <%= link_to 'Publish', publish_node_path, :method => :put, :confirm => "Publish this draft?" %> - <%= link_to 'Revisions', revision_path(params[:id]) %> + <%= link_to 'Revisions', node_revisions_path(@node) %> <% end %>
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb index 0603c08..d78a997 100644 --- a/app/views/nodes/index.html.erb +++ b/app/views/nodes/index.html.erb @@ -21,7 +21,7 @@ <%= link_to 'show', node_path(node) %> - <%= link_to 'Revisions', :controller => :revisions, :action => :show, :id => node.id %> + <%= link_to 'Revisions', node_revisions_path(node) %> <%# link_to 'Destroy', node, :method => :delete, :confirm => "Are you sure you want to delete this node?" %> <%= link_to 'Unlock', unlock_node_path(node), :method => :put, :confirm => "Are you sure you want to unlock?" %> diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index 8d8a985..8f56c7c 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb @@ -1,7 +1,7 @@ <% content_for :subnavigation do %> <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %> <%= link_to 'Preview', preview_page_path(@page) %> - <%= link_to 'Revisions', revision_path(params[:id]) %> + <%= link_to 'Revisions', node_revisions_path(@node) %> <%= link_to 'Unlock', unlock_node_path(@node), :method => :put, :confirm => "Are you sure you want to unlock?" %> <% end %> diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb index 9428b7a..f7ad79c 100644 --- a/app/views/revisions/diff.html.erb +++ b/app/views/revisions/diff.html.erb @@ -1,11 +1,11 @@ <% content_for :subnavigation do %> - <%= link_to 'Edit', edit_node_path(@node) %> - <%= link_to 'Revisions', revision_path(params[:id]) %> + <%= link_to 'Edit', edit_node_path(@node) %> + <%= link_to 'Revisions', node_revisions_path(@node) %> <% end %>

Revisions#diff

-<% form_tag diff_revision_path do %> +<% form_tag diff_node_revisions_path do %> <%= select_tag :start_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:start_revision].to_i) %> <%= select_tag :end_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:end_revision].to_i) %> <%= submit_tag 'Diff' %> diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb index e3134d7..dbb612b 100644 --- a/app/views/revisions/index.html.erb +++ b/app/views/revisions/index.html.erb @@ -1 +1,44 @@ -

Revisions#index

+<% content_for :subnavigation do %> + <%= link_to 'Edit', edit_node_path(@node) %> +<% end %> + +

Revisions for Node: <%= @node.unique_name %>

+ +<% form_tag diff_node_revisions_path(@node) do %> + + + + + + + + + + +<% @node.pages.reverse.each do |page| %> + + + + + + + + + + +<% end %> + + + +
FirstLastRev.TitleUserDate
<%= radio_button_tag :start_revision, page.revision %><%= radio_button_tag :end_revision, page.revision %><%= page.revision %><%= page.title %><%= page.user.try(:login) %><%= page.updated_at %> + <%= link_to 'show', node_revision_path(@node, page) %> + + <%= link_to( + 'restore', + restore_node_revision_path(@node, page), + :method => :put, + :confirm => "Restore this revision?" + ) %> +
<%= submit_tag 'Diff revisions' %>
+ +<% end %> \ No newline at end of file diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb index ebda18d..154d31b 100644 --- a/app/views/revisions/show.html.erb +++ b/app/views/revisions/show.html.erb @@ -1,44 +1,50 @@ <% content_for :subnavigation do %> - <%= link_to 'Edit', edit_node_path(@node) %> + <%= link_to 'show all revisions', node_revisions_path(@node) %> <% end %> -

Revisions for Node: <%= @node.unique_name %>

- -<% form_tag diff_revision_path do %> - - - - - - - - - - -<% @node.pages.reverse.each do |page| %> - - - - - - - - - - -<% end %> - - - -
FirstLastRev.TitleUserDate
<%= radio_button_tag :start_revision, page.revision %><%= radio_button_tag :end_revision, page.revision %><%= page.revision %><%= page.title %><%= page.user.try(:login) %><%= page.updated_at %> - <%= link_to 'show', node_path(page.node) %> - - <%= link_to( - 'restore', - restore_revision_path(page), - :method => :put, - :confirm => "Restore this revision?" - ) %> -
<%= submit_tag 'Diff revisions' %>
- -<% end %> \ No newline at end of file +
+ + + + + + + + + + <% if @page.node.locked? %> + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Path<%= @page.public_link %>
Author<%= @page.user.try(:login) %>
Locked by<%= @page.node.lock_owner.login %>
Last updated<%= @page.updated_at %>
Published at<%= @page.published_at %>
Revision<%= @page.revision %>
Title<%= @page.title %>
Abstract<%= @page.abstract %>
Body<%= @page.body %>
+
\ No newline at end of file -- cgit v1.3