summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-03-15 19:28:04 +0100
committerhukl <contact@smyck.org>2009-03-15 19:28:04 +0100
commit4ff20fb57936af76fd97242df3f8c6fe474b7a4a (patch)
tree16956c885147b610a004bd66e4aabbd986d5a935 /app
parent82741f65fc387e898e5e17f16a057b34bb6dddab (diff)
parent7f82b8e23ec9b76d0b8a417b2d2b577aeaf7a55f (diff)
Merge branch 'revisions'
Diffstat (limited to 'app')
-rw-r--r--app/controllers/revisions_controller.rb34
-rw-r--r--app/helpers/revisions_helper.rb2
-rw-r--r--app/views/nodes/index.html.erb3
-rw-r--r--app/views/revisions/diff.html.erb27
-rw-r--r--app/views/revisions/index.html.erb2
-rw-r--r--app/views/revisions/show.html.erb17
6 files changed, 84 insertions, 1 deletions
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb
new file mode 100644
index 0000000..565a25f
--- /dev/null
+++ b/app/controllers/revisions_controller.rb
@@ -0,0 +1,34 @@
1class RevisionsController < ApplicationController
2
3 layout 'admin'
4
5 def index
6 end
7
8 def diff
9 @node = Node.find(params[:id])
10
11 if @node.pages.length > 1
12 params[:start] ||= @node.pages.all[-1].revision
13 params[:end] ||= @node.pages.all[-2].revision
14 else
15 params[:start], params[:end] = 1, 1
16 end
17
18 @start = Page.find( :first, :conditions => {
19 :node_id => params[:id],
20 :revision => params[:start]
21 })
22
23 @end = Page.find( :first, :conditions => {
24 :node_id => params[:id],
25 :revision => params[:end]
26 })
27
28 end
29
30 def show
31 @node = Node.find(params[:id])
32 end
33
34end
diff --git a/app/helpers/revisions_helper.rb b/app/helpers/revisions_helper.rb
new file mode 100644
index 0000000..fdb51f8
--- /dev/null
+++ b/app/helpers/revisions_helper.rb
@@ -0,0 +1,2 @@
1module RevisionsHelper
2end
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb
index a2a42b1..31cd53c 100644
--- a/app/views/nodes/index.html.erb
+++ b/app/views/nodes/index.html.erb
@@ -24,7 +24,8 @@
24 <td> 24 <td>
25 <%= link_to 'Show', node_path(node) %> 25 <%= link_to 'Show', node_path(node) %>
26 <%= link_to 'Edit', edit_node_path(node) %> 26 <%= link_to 'Edit', edit_node_path(node) %>
27 <%= link_to 'Destroy', node, :method => :delete, :confirm => "Are you sure you want to delete this node?" %> 27 <%= link_to 'Revision', :controller => :revisions, :action => :show, :id => node.id %>
28 <%# link_to 'Destroy', node, :method => :delete, :confirm => "Are you sure you want to delete this node?" %>
28 <%= link_to 'Unlock', unlock_node_path(node), :method => :put, :confirm => "Are you sure you want to unlock?" %> 29 <%= link_to 'Unlock', unlock_node_path(node), :method => :put, :confirm => "Are you sure you want to unlock?" %>
29 </td> 30 </td>
30 <td> 31 <td>
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb
new file mode 100644
index 0000000..bcbf560
--- /dev/null
+++ b/app/views/revisions/diff.html.erb
@@ -0,0 +1,27 @@
1<h1>Revisions#diff</h1>
2
3<% form_tag url_for(:action => :diff), :method => :get do %>
4 <%= select_tag :start, options_for_select(@node.pages.map{|x| x.revision}, params[:start].to_i) %>
5 <%= select_tag :end, options_for_select(@node.pages.map{|x| x.revision}, params[:end].to_i) %>
6 <%= submit_tag 'Diff' %>
7<% end %>
8
9<div id="start_text" style="display: none;">
10 <%= (@start.body) %>
11</div>
12
13<div id="end_text" style="display: none;">
14 <%= (@end.body) %>
15</div>
16
17
18<%= javascript_include_tag 'cacycle_diff' %>
19<script type="text/javascript" charset="utf-8">
20 window.onload = function() {
21 text1 = document.getElementById('start_text').innerHTML;
22 text2 = document.getElementById('end_text').innerHTML;
23 document.getElementById('diffview').innerHTML = WDiffString(text1, text2);
24 }
25</script>
26
27<div id="diffview"></div> \ No newline at end of file
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb
new file mode 100644
index 0000000..b41a77c
--- /dev/null
+++ b/app/views/revisions/index.html.erb
@@ -0,0 +1,2 @@
1<h1>Revisions#index</h1>
2<p>Find me in app/views/revisions/index.html.erb</p>
diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb
new file mode 100644
index 0000000..c63e7e8
--- /dev/null
+++ b/app/views/revisions/show.html.erb
@@ -0,0 +1,17 @@
1<div id="subnavigation">
2 <%= link_to 'Diff revisions', :action => :diff, :id => params[:id] %>
3</div>
4
5<h2>Revisions for Node: <%= @node.unique_name %></h2>
6
7<h3>Current title: <%= @node.head.title %></h3>
8<table>
9<% @node.pages.reverse.each do |page| %>
10 <tr>
11 <td><%= page.revision %></td>
12 <td><%= page.title %></td>
13 <td><%= page.user.try(:login) %></td>
14 <td><%= page.updated_at %></td>
15 </tr>
16<% end %>
17</table> \ No newline at end of file