Add diff for wiki pages
This commit is contained in:
parent
f5b6fbcf18
commit
ad036c948f
6 changed files with 34 additions and 6 deletions
|
@ -130,6 +130,13 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def diff
|
||||||
|
@page = Page.find(params[:id])
|
||||||
|
@old_version = Page::Version.find_by_page_id_and_lock_version params[:id], params[:old]
|
||||||
|
@new_version = Page::Version.find_by_page_id_and_lock_version params[:id], params[:new]
|
||||||
|
@diff = Diffy::Diff.new(@old_version.body, @new_version.body).to_s(:html)
|
||||||
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
@page = Page.find(params[:id])
|
@page = Page.find(params[:id])
|
||||||
@version = Page::Version.find_by_page_id_and_lock_version params[:id], params[:version]
|
@version = Page::Version.find_by_page_id_and_lock_version params[:id], params[:version]
|
||||||
|
|
7
plugins/wiki/app/views/pages/diff.html.haml
Normal file
7
plugins/wiki/app/views/pages/diff.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- title t('.title', title: @page.title, old: @old_version.lock_version, new: @new_version.lock_version)
|
||||||
|
|
||||||
|
%style= Diffy::CSS
|
||||||
|
= raw @diff
|
||||||
|
|
||||||
|
%hr
|
||||||
|
= link_to t('ui.back'), 'javascript:history.go(-1)', class: 'btn btn-primary'
|
|
@ -12,12 +12,16 @@
|
||||||
%li= link_to t('.subpages'), "#subpages", 'data-toggle-this' => '#subpages'
|
%li= link_to t('.subpages'), "#subpages", 'data-toggle-this' => '#subpages'
|
||||||
|
|
||||||
#versions.well.well-small{:style => "display:none"}
|
#versions.well.well-small{:style => "display:none"}
|
||||||
%h3= t '.title_versions'
|
= form_tag diff_page_path(@page), :method => :get do
|
||||||
%ul.unstyled
|
%h3= t '.title_versions'
|
||||||
- @page.versions.reverse.each do |version|
|
%ul.unstyled
|
||||||
%li
|
- @page.versions.reverse.each_with_index do |version, index|
|
||||||
= link_to I18n.l(version.updated_at, :format => t('.date_format')), version_page_path(@page, :version => version.lock_version)
|
%li
|
||||||
= "(#{show_user(User.find_by_id(version.updated_by))})"
|
= radio_button_tag :old, version.lock_version, index == 1
|
||||||
|
= radio_button_tag :new, version.lock_version, index == 0
|
||||||
|
= link_to I18n.l(version.updated_at, :format => t('.date_format')), version_page_path(@page, :version => version.lock_version)
|
||||||
|
= "(#{show_user(User.find_by_id(version.updated_by))})"
|
||||||
|
= submit_tag t('.diff'), class: 'btn'
|
||||||
|
|
||||||
- unless @page.children.empty?
|
- unless @page.children.empty?
|
||||||
#subpages.well.well-small{:style => "display:none"}
|
#subpages.well.well-small{:style => "display:none"}
|
||||||
|
|
6
plugins/wiki/config/locales/de.yml
Normal file
6
plugins/wiki/config/locales/de.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
de:
|
||||||
|
pages:
|
||||||
|
diff:
|
||||||
|
title: "%{title} - Änderung von Version %{old} auf %{new}"
|
||||||
|
show:
|
||||||
|
diff: Versionen vergleichen
|
|
@ -32,6 +32,8 @@ en:
|
||||||
redirect_notice: Redirected from %{page} ...
|
redirect_notice: Redirected from %{page} ...
|
||||||
destroy:
|
destroy:
|
||||||
notice: The page '%{page}' and all subpages have been deleted successfully.
|
notice: The page '%{page}' and all subpages have been deleted successfully.
|
||||||
|
diff:
|
||||||
|
title: "%{title} - changes from version %{old} to %{new}"
|
||||||
edit:
|
edit:
|
||||||
title: Edit page
|
title: Edit page
|
||||||
error_stale_object: Warning, the page has just been edited by someone else. Please try again.
|
error_stale_object: Warning, the page has just been edited by someone else. Please try again.
|
||||||
|
@ -68,6 +70,7 @@ en:
|
||||||
date_format: ! '%d-%m-%y %H:%M'
|
date_format: ! '%d-%m-%y %H:%M'
|
||||||
delete: Delete page
|
delete: Delete page
|
||||||
delete_confirm: ! 'Warning: all subpages will be deleted as well. Are you sure?'
|
delete_confirm: ! 'Warning: all subpages will be deleted as well. Are you sure?'
|
||||||
|
diff: Compare versions
|
||||||
edit: Edit page
|
edit: Edit page
|
||||||
last_updated: Last updated by <b>%{user}</b> on %{when}
|
last_updated: Last updated by <b>%{user}</b> on %{when}
|
||||||
subpages: subpages
|
subpages: subpages
|
||||||
|
|
|
@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
||||||
get :all, :on => :collection
|
get :all, :on => :collection
|
||||||
get :version, :on => :member
|
get :version, :on => :member
|
||||||
get :revert, :on => :member
|
get :revert, :on => :member
|
||||||
|
get :diff, :on => :member
|
||||||
end
|
end
|
||||||
get '/wiki/:permalink' => 'pages#show', :as => 'wiki_page' # , :constraints => {:permalink => /[^\s]+/}
|
get '/wiki/:permalink' => 'pages#show', :as => 'wiki_page' # , :constraints => {:permalink => /[^\s]+/}
|
||||||
get '/wiki' => 'pages#show', :defaults => {:permalink => 'Home'}, :as => 'wiki'
|
get '/wiki' => 'pages#show', :defaults => {:permalink => 'Home'}, :as => 'wiki'
|
||||||
|
|
Loading…
Reference in a new issue