Merge pull request #1578 from tpoliaw/no-edit-compare
Let compare versions be used in no-edit mode
This commit is contained in:
+24
-23
@@ -459,7 +459,30 @@ module Precious
|
|||||||
mustache :latest_changes
|
mustache :latest_changes
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/compare/*' do
|
get %r{
|
||||||
|
/compare/ # match any URL beginning with /compare/
|
||||||
|
(.+) # extract the full path (including any directories)
|
||||||
|
/ # match the final slash
|
||||||
|
([^.]+) # match the first SHA1
|
||||||
|
\.{2,3} # match .. or ...
|
||||||
|
(.+) # match the second SHA1
|
||||||
|
}x do |path, start_version, end_version|
|
||||||
|
wikip = wiki_page(path)
|
||||||
|
@path = wikip.path
|
||||||
|
@name = wikip.fullname
|
||||||
|
@versions = [start_version, end_version]
|
||||||
|
wiki = wikip.wiki
|
||||||
|
@page = wikip.page
|
||||||
|
@diff = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
||||||
|
if @diff.empty?
|
||||||
|
@message = 'Could not compare these two revisions, no differences were found.'
|
||||||
|
mustache :error
|
||||||
|
else
|
||||||
|
mustache :compare
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/compare/*' do
|
||||||
@file = clean_url(encodeURIComponent(params[:splat].first))
|
@file = clean_url(encodeURIComponent(params[:splat].first))
|
||||||
@versions = params[:versions] || []
|
@versions = params[:versions] || []
|
||||||
if @versions.size == 1
|
if @versions.size == 1
|
||||||
@@ -483,28 +506,6 @@ module Precious
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get %r{
|
|
||||||
/compare/ # match any URL beginning with /compare/
|
|
||||||
(.+) # extract the full path (including any directories)
|
|
||||||
/ # match the final slash
|
|
||||||
([^.]+) # match the first SHA1
|
|
||||||
\.{2,3} # match .. or ...
|
|
||||||
(.+) # match the second SHA1
|
|
||||||
}x do |path, start_version, end_version|
|
|
||||||
wikip = wiki_page(path)
|
|
||||||
@path = wikip.path
|
|
||||||
@name = wikip.fullname
|
|
||||||
@versions = [start_version, end_version]
|
|
||||||
wiki = wikip.wiki
|
|
||||||
@page = wikip.page
|
|
||||||
@diff = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
|
||||||
if @diff.empty?
|
|
||||||
@message = 'Could not compare these two revisions, no differences were found.'
|
|
||||||
mustache :error
|
|
||||||
else
|
|
||||||
mustache :compare
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
get %r{
|
get %r{
|
||||||
/commit/ # match any URL beginning with /show/
|
/commit/ # match any URL beginning with /show/
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
{{>pagination}}
|
{{>pagination}}
|
||||||
|
|
||||||
<form name="selection-form" id="selection-form" method="post" action="{{compare_path}}/{{escaped_url_path}}"></form>
|
<form name="selection-form" id="selection-form" method="get" action="{{compare_path}}/{{escaped_url_path}}"></form>
|
||||||
|
|
||||||
<div id="page-history-list" class="Box Box--condensed flex-auto">
|
<div id="page-history-list" class="Box Box--condensed flex-auto">
|
||||||
<form id="version-form">
|
<form id="version-form">
|
||||||
|
|||||||
+3
-3
@@ -957,17 +957,17 @@ context 'Frontend with base path' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'compare view' do
|
test 'compare view' do
|
||||||
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => ['f25eccd98e9b667f9e22946f3e2f945378b8a72d', '5bc1aaec6149e854078f1d0f8b71933bbc6c2e43']
|
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d&versions[]=5bc1aaec6149e854078f1d0f8b71933bbc6c2e43'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/5bc1aaec6149e854078f1d0f8b71933bbc6c2e43...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
|
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/5bc1aaec6149e854078f1d0f8b71933bbc6c2e43...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
|
||||||
|
|
||||||
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => ['f25eccd98e9b667f9e22946f3e2f945378b8a72d']
|
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/b0d108328459e44fff4a76cd19b10ddc34adce4b...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
|
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/b0d108328459e44fff4a76cd19b10ddc34adce4b...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
|
||||||
|
|
||||||
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => []
|
get '/wiki/gollum/compare/Bilbo-Baggins.md'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
|
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
|
||||||
|
|||||||
Reference in New Issue
Block a user