diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/revisions_controller.rb | 29 | ||||
| -rw-r--r-- | app/helpers/revisions_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/revisions/diff.html.erb | 27 | ||||
| -rw-r--r-- | app/views/revisions/index.html.erb | 2 | ||||
| -rw-r--r-- | app/views/revisions/show.html.erb | 2 |
5 files changed, 62 insertions, 0 deletions
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb new file mode 100644 index 0000000..20991ef --- /dev/null +++ b/app/controllers/revisions_controller.rb | |||
| @@ -0,0 +1,29 @@ | |||
| 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 | params[:start] ||= @node.pages.all[-1].revision | ||
| 12 | params[:end] ||= @node.pages.all[-2].revision | ||
| 13 | |||
| 14 | @start = Page.find( :first, :conditions => { | ||
| 15 | :node_id => params[:id], | ||
| 16 | :revision => params[:start] | ||
| 17 | }) | ||
| 18 | |||
| 19 | @end = Page.find( :first, :conditions => { | ||
| 20 | :node_id => params[:id], | ||
| 21 | :revision => params[:end] | ||
| 22 | }) | ||
| 23 | |||
| 24 | end | ||
| 25 | |||
| 26 | def show | ||
| 27 | end | ||
| 28 | |||
| 29 | 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/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..20fc39c --- /dev/null +++ b/app/views/revisions/show.html.erb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | <h1>Revisions#show</h1> | ||
| 2 | <p>Find me in app/views/revisions/show.html.erb</p> | ||
