diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/revisions_controller.rb | 34 | ||||
| -rw-r--r-- | app/helpers/revisions_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/admin/index.html.erb | 2 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 2 | ||||
| -rw-r--r-- | app/views/nodes/index.html.erb | 7 | ||||
| -rw-r--r-- | app/views/nodes/show.html.erb | 8 | ||||
| -rw-r--r-- | app/views/revisions/diff.html.erb | 59 | ||||
| -rw-r--r-- | app/views/revisions/index.html.erb | 1 | ||||
| -rw-r--r-- | app/views/revisions/show.html.erb | 18 |
9 files changed, 128 insertions, 5 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 @@ | |||
| 1 | class 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 | |||
| 34 | end | ||
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 @@ | |||
| 1 | module RevisionsHelper | ||
| 2 | end | ||
diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb index 00a5c09..c5bb5de 100644 --- a/app/views/admin/index.html.erb +++ b/app/views/admin/index.html.erb | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | <td><%= draft.node.unique_name %></td> | 14 | <td><%= draft.node.unique_name %></td> |
| 15 | <td><%= draft.user.login rescue "" %></td> | 15 | <td><%= draft.user.login rescue "" %></td> |
| 16 | <td><%= link_to 'Show', node_path(draft.node) %></td> | 16 | <td><%= link_to 'Show', node_path(draft.node) %></td> |
| 17 | <td><%= link_to "Diff revisions", :controller => :revisions, :action => :diff, :id => draft.node.id %></td> | ||
| 18 | <td><%= link_to "Publish", publish_node_path(draft.node), :method => :put, :confirm => "Do you really want to publish?" %></td> | ||
| 17 | </tr> | 19 | </tr> |
| 18 | <% end %> | 20 | <% end %> |
| 19 | </table> | 21 | </table> |
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 2dade0f..577a075 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | <%= link_to 'Show', @node %> | 2 | <%= link_to 'Show', @node %> |
| 3 | <%= link_to 'Back', nodes_path %> | 3 | <%= link_to 'Back', nodes_path %> |
| 4 | <%= link_to 'Publish', publish_node_path, :method => :put %> | 4 | <%= link_to 'Publish', publish_node_path, :method => :put %> |
| 5 | <%= link_to 'Diff revisions', :controller => :revisions, :action => :diff, :id => params[:id] %> | ||
| 6 | |||
| 5 | </div> | 7 | </div> |
| 6 | 8 | ||
| 7 | <h1>Editing page</h1> | 9 | <h1>Editing page</h1> |
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb index a2a42b1..ad60498 100644 --- a/app/views/nodes/index.html.erb +++ b/app/views/nodes/index.html.erb | |||
| @@ -23,15 +23,16 @@ | |||
| 23 | <td><%= node.unique_name %></td> | 23 | <td><%= node.unique_name %></td> |
| 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> |
| 31 | <%= "#{node.draft.user.login}" if node.draft && node.draft.user %> | 32 | <%= "#{node.draft.user.login}" if node.draft && node.draft.user %> |
| 32 | </td> | 33 | </td> |
| 33 | <td> | 34 | <td> |
| 34 | <%= node.head.revision if node.head %> | 35 | <%= node.pages.length %> |
| 35 | </td> | 36 | </td> |
| 36 | </tr> | 37 | </tr> |
| 37 | <% end %> | 38 | <% end %> |
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index 67dd7fc..bbbefe9 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | <h1>Node</h1> | 1 | <h1>Node</h1> |
| 2 | 2 | <p> | |
| 3 | There is no draft to preview. Click <%= link_to 'edit', edit_node_path %> to | 3 | There is no draft to preview. Click <%= link_to 'edit', edit_node_path %> to |
| 4 | create one or view the currently | 4 | create one or view the currently |
| 5 | <%= link_to_path 'published version', @node.unique_path %>. \ No newline at end of file | 5 | <%= link_to_path 'published version', @node.unique_path %>. |
| 6 | </p> | ||
| 7 | <p> | ||
| 8 | View the revisions of this node | ||
| 9 | </p> \ No newline at end of file | ||
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb new file mode 100644 index 0000000..a8a0276 --- /dev/null +++ b/app/views/revisions/diff.html.erb | |||
| @@ -0,0 +1,59 @@ | |||
| 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 | |||
| 10 | <div id="start_title" style="display: none;"> | ||
| 11 | <%= (@start.title) %> | ||
| 12 | </div> | ||
| 13 | |||
| 14 | <div id="end_title" style="display: none;"> | ||
| 15 | <%= (@end.title) %> | ||
| 16 | </div> | ||
| 17 | |||
| 18 | <div id="start_abstract" style="display: none;"> | ||
| 19 | <%= (@start.abstract) %> | ||
| 20 | </div> | ||
| 21 | |||
| 22 | <div id="end_abstract" style="display: none;"> | ||
| 23 | <%= (@end.abstract) %> | ||
| 24 | </div> | ||
| 25 | |||
| 26 | <div id="start_body" style="display: none;"> | ||
| 27 | <%= (@start.body) %> | ||
| 28 | </div> | ||
| 29 | |||
| 30 | <div id="end_body" style="display: none;"> | ||
| 31 | <%= (@end.body) %> | ||
| 32 | </div> | ||
| 33 | |||
| 34 | |||
| 35 | <%= javascript_include_tag 'cacycle_diff' %> | ||
| 36 | <script type="text/javascript" charset="utf-8"> | ||
| 37 | window.onload = function() { | ||
| 38 | title1 = document.getElementById('start_title').innerHTML; | ||
| 39 | title2 = document.getElementById('end_title').innerHTML; | ||
| 40 | abstract1 = document.getElementById('start_abstract').innerHTML; | ||
| 41 | abstract2 = document.getElementById('end_abstract').innerHTML; | ||
| 42 | body1 = document.getElementById('start_body').innerHTML; | ||
| 43 | body2 = document.getElementById('end_body').innerHTML; | ||
| 44 | document.getElementById('diffview_title').innerHTML = WDiffString(title1, title2); | ||
| 45 | document.getElementById('diffview_abstract').innerHTML = WDiffString(abstract1, abstract2); | ||
| 46 | document.getElementById('diffview_body').innerHTML = WDiffString(body1, body2); | ||
| 47 | } | ||
| 48 | </script> | ||
| 49 | |||
| 50 | <div id="diffview"> | ||
| 51 | <h3>Title</h3> | ||
| 52 | <p id="diffview_title"></p> | ||
| 53 | |||
| 54 | <h3>Abstract</h3> | ||
| 55 | <p id="diffview_abstract"></p> | ||
| 56 | |||
| 57 | <h3>Body</h3> | ||
| 58 | <p id="diffview_body"></p> | ||
| 59 | </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..e3134d7 --- /dev/null +++ b/app/views/revisions/index.html.erb | |||
| @@ -0,0 +1 @@ | |||
| <h1>Revisions#index</h1> | |||
diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb new file mode 100644 index 0000000..64979fc --- /dev/null +++ b/app/views/revisions/show.html.erb | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | <div id="subnavigation"> | ||
| 2 | <%= link_to 'Diff revisions', :action => :diff, :id => params[:id] %> | ||
| 3 | <%= link_to 'Edit', edit_node_path(@node) %> | ||
| 4 | </div> | ||
| 5 | |||
| 6 | <h2>Revisions for Node: <%= @node.unique_name %></h2> | ||
| 7 | |||
| 8 | <h3>Current title: <%= @node.head.title %></h3> | ||
| 9 | <table> | ||
| 10 | <% @node.pages.reverse.each do |page| %> | ||
| 11 | <tr> | ||
| 12 | <td><%= page.revision %></td> | ||
| 13 | <td><%= page.title %></td> | ||
| 14 | <td><%= page.user.try(:login) %></td> | ||
| 15 | <td><%= page.updated_at %></td> | ||
| 16 | </tr> | ||
| 17 | <% end %> | ||
| 18 | </table> \ No newline at end of file | ||
