Commit 2253cc6652cb77781b7cd71fd9dfa2773858a1db
1 parent
111ae542
Exists in
master
and in
29 other branches
diff-article-versions: display differences between two article versions
AI2822
Showing
3 changed files
with
23 additions
and
16 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -124,8 +124,11 @@ class ContentViewerController < ApplicationController |
124 | 124 | end |
125 | 125 | end |
126 | 126 | |
127 | - def differences_between_article_versions(version1, version2) | |
128 | - Diffy::Diff.new('version1', 'version2').to_s(:html) | |
127 | + def versions_diff | |
128 | + path = params[:page].join('/') | |
129 | + @page = profile.articles.find_by_path(path) | |
130 | + @v1, @v2 = @page.versions.find_by_version(params[:v1]).body, @page.versions.find_by_version(params[:v2]).body | |
131 | + p params | |
129 | 132 | end |
130 | 133 | |
131 | 134 | def article_versions | ... | ... |
app/views/content_viewer/article_versions.rhtml
... | ... | @@ -2,19 +2,20 @@ |
2 | 2 | |
3 | 3 | <p><%= _('This is the list of all versions of this content. Select a version to see it and then revert to it.') %>.</p> |
4 | 4 | |
5 | -<ul class='article-versions'> | |
6 | - <% @versions.each do |v| %> | |
7 | - <li> | |
8 | - <%= radio_button_tag :first, "#{v.version}" %> | |
9 | - <%= radio_button_tag :end, "#{v.version}" %> | |
10 | - <%= link_to(_("Version #{v.version}"), @page.url.merge(:version => v.version)) %> | |
11 | - <%= @page.version == v.version ? _('(current)') : '' %> | |
12 | - <span class='updated-by'><%= _('by %{author}') % {:author => link_to(@page.author_name(v.version), @page.author_url)} %></span> | |
13 | - <div class='updated-on'><%= show_time(v.updated_at) %></div> | |
14 | - </li> | |
15 | - <% end %> | |
16 | -</ul> | |
5 | +<% form_tag({:controller => 'content_viewer', :action => 'versions_diff', :profile => profile.identifier, :page => @page.path.split('/')}) do %> | |
6 | + <ul class='article-versions'> | |
7 | + <% @versions.each do |v| %> | |
8 | + <li> | |
9 | + <%= radio_button_tag 'v1', v.version %> | |
10 | + <%= radio_button_tag 'v2', v.version %> | |
11 | + <%= link_to(_("Version #{v.version}"), @page.url.merge(:version => v.version)) %> | |
12 | + <%= @page.version == v.version ? _('(current)') : '' %> | |
13 | + <span class='updated-by'><%= _('by %{author}') % {:author => link_to(@page.author_name(v.version), @page.author_url)} %></span> | |
14 | + <div class='updated-on'><%= show_time(v.updated_at) %></div> | |
15 | + </li> | |
16 | + <% end %> | |
17 | + </ul> | |
17 | 18 | |
18 | -<%= button_to "Show differences between selected versions", :id => "diff-versions", | |
19 | - :class => "diff-versions", :method => :get %> | |
19 | + <%= submit_button(:search, _('Show differences between selected versions')) %> | |
20 | +<% end %> | |
20 | 21 | <%= pagination_links @versions, :param_name => 'npage' %> | ... | ... |
config/routes.rb
... | ... | @@ -129,6 +129,9 @@ ActionController::Routing::Routes.draw do |map| |
129 | 129 | map.connect ':profile/*page/versions', :controller => 'content_viewer', :action => 'article_versions', :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } |
130 | 130 | map.connect '*page/versions', :controller => 'content_viewer', :action => 'article_versions' |
131 | 131 | |
132 | + map.connect ':profile/*page/versions_diff', :controller => 'content_viewer', :action => 'versions_diff', :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } | |
133 | + map.connect '*page/versions_diff', :controller => 'content_viewer', :action => 'versions_diff' | |
134 | + | |
132 | 135 | # match requests for profiles that don't have a custom domain |
133 | 136 | map.homepage ':profile/*page', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } |
134 | 137 | ... | ... |