Merge branch '5.x' into remove_livepreview
This commit is contained in:
@@ -105,6 +105,13 @@ MSG
|
||||
opts.on("--no-edit", "Disable the feature of editing pages.") do
|
||||
wiki_options[:allow_editing] = false
|
||||
end
|
||||
end
|
||||
opts.on("--follow-renames", "Follow pages across renames in the History view. Default except on jruby.") do
|
||||
wiki_options[:follow_renames] = true
|
||||
end
|
||||
opts.on("--no-follow-renames", "Do not follow pages across renames in the History view.") do
|
||||
wiki_options[:follow_renames] = false
|
||||
end
|
||||
opts.on("--allow-uploads [MODE]", [:dir, :page], "Enable file uploads.",
|
||||
"If set to 'dir', Gollum will store all uploads in the '<git-repo>/uploads/' directory.",
|
||||
"If set to 'page', Gollum will store each upload at the currently edited page.") do |mode|
|
||||
|
||||
+1
-1
@@ -390,7 +390,7 @@ module Precious
|
||||
@page = wiki_page(params[:splat].first).page
|
||||
@page_num = [params[:page].to_i, 1].max
|
||||
unless @page.nil?
|
||||
@versions = @page.versions :page => @page_num
|
||||
@versions = @page.versions(:page => @page_num, :follow => settings.wiki_options.fetch(:follow_renames, git_adapter == 'rjgit' ? false : true))
|
||||
mustache :history
|
||||
else
|
||||
redirect to("/")
|
||||
|
||||
@@ -6,6 +6,10 @@ module Precious
|
||||
|
||||
EMOJI_PATHNAME = Pathname.new(Gemojione.images_path).freeze
|
||||
|
||||
def git_adapter
|
||||
defined?(Gollum::GIT_ADAPTER) ? Gollum::GIT_ADAPTER : DEFAULT_ADAPTER.match(/(.*)_adapter/)[1]
|
||||
end
|
||||
|
||||
def join_page_name(name, ext)
|
||||
"#{name}#{ext}"
|
||||
end
|
||||
|
||||
@@ -11,5 +11,9 @@ module Precious
|
||||
def format
|
||||
@page.format.to_s
|
||||
end
|
||||
|
||||
def id
|
||||
@page.sha
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,6 @@ module Precious
|
||||
:date_full => v.authored_date,
|
||||
:files => v.stats.files.map { |f,*rest|
|
||||
page_path = extract_renamed_path_destination(f)
|
||||
page_path = remove_page_extentions(page_path)
|
||||
{ :file => f,
|
||||
:link => "#{page_path}/#{v.id}"
|
||||
}
|
||||
@@ -32,13 +31,6 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
def remove_page_extentions(page_path)
|
||||
Gollum::Markup.formats.values.each do |format|
|
||||
page_path = page_path.gsub(/\.#{format[:regexp]}$/, '')
|
||||
end
|
||||
return page_path
|
||||
end
|
||||
|
||||
def extract_renamed_path_destination(file)
|
||||
return file.gsub(/{.* => (.*)}/, '\1').gsub(/.* => (.*)/, '\1')
|
||||
end
|
||||
|
||||
@@ -9,3 +9,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc
|
||||
7d6aeab8b84c895f21f6c66b84a457b0fced9693 563cc3701db990caf63e4ce9c3697a062890ca48 James Dabbs <jamesdabbs@gmail.com> 1361843315 -0500 push
|
||||
563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence <charles@charlespence.net> 1363478075 -0400 push
|
||||
874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe <techwiz96@gmail.com> 1421012322 -0500 push
|
||||
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto <dawa.ometto@phil.uu.nl> 1492034760 +0200 push
|
||||
|
||||
@@ -9,3 +9,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc
|
||||
7d6aeab8b84c895f21f6c66b84a457b0fced9693 563cc3701db990caf63e4ce9c3697a062890ca48 James Dabbs <jamesdabbs@gmail.com> 1361843315 -0500 push
|
||||
563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence <charles@charlespence.net> 1363478075 -0400 push
|
||||
874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe <techwiz96@gmail.com> 1421012322 -0500 push
|
||||
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto <dawa.ometto@phil.uu.nl> 1492034760 +0200 push
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
x�Ž1
|
||||
Ã0E;ûÚÁ‘í8‚R:tïÔ(¶LM‚B¯ß�#txÃÿ§:Ï“:wÑM0 1S°T�“„ YË„˜Ša�;³ò&‹Br‘.NÒ•˜
|
||||
õ1æ>µ'™¢çÎEÄð®cÝàÉ_†×,ªnù�¦žòXÇéÓì{³|îÐzBë|=\-ZkÒùRåßÞ¼×Ì*ù˜W6?K
|
||||
@@ -1 +1 @@
|
||||
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e
|
||||
f803c64d11407b23797325e3843f3f378b78f611
|
||||
|
||||
+1
-12
@@ -90,15 +90,4 @@ def context(*args, &block)
|
||||
klass.class_eval &block
|
||||
end
|
||||
|
||||
$contexts = []
|
||||
|
||||
# Commit file to wiki, overwriting previous versions of that file
|
||||
def commit_test_file(wiki, dir, filename, ext, content)
|
||||
committer = Gollum::Committer.new(wiki, :message => "Added testfile", :parent => wiki.repo.head.commit)
|
||||
committer.add_to_index(dir, filename, ext, content, true)
|
||||
committer.after_commit do |committer, sha|
|
||||
wiki.clear_cache
|
||||
committer.update_working_dir(dir, filename, ext)
|
||||
end
|
||||
committer.commit
|
||||
end
|
||||
$contexts = []
|
||||
+19
-19
@@ -123,7 +123,7 @@ context "Frontend" do
|
||||
post "/edit/A", :header => 'header',
|
||||
:footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def'
|
||||
follow_redirect!
|
||||
assert_equal "/A", last_request.fullpath
|
||||
assert_equal "/A.md", last_request.fullpath
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -150,7 +150,7 @@ context "Frontend" do
|
||||
post "/rename/B", :rename => "/C", :message => 'def'
|
||||
|
||||
follow_redirect!
|
||||
assert_equal '/C', last_request.fullpath
|
||||
assert_equal '/C.md', last_request.fullpath
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -189,7 +189,7 @@ context "Frontend" do
|
||||
post "/rename/G/H", :rename => "/I/C", :message => 'def'
|
||||
|
||||
follow_redirect!
|
||||
assert_equal '/I/C', last_request.fullpath
|
||||
assert_equal '/I/C.md', last_request.fullpath
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -206,7 +206,7 @@ context "Frontend" do
|
||||
post "/rename/G/H", :rename => "K/C", :message => 'def'
|
||||
|
||||
follow_redirect!
|
||||
assert_equal '/G/K/C', last_request.fullpath
|
||||
assert_equal '/G/K/C.md', last_request.fullpath
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -272,7 +272,7 @@ context "Frontend" do
|
||||
end
|
||||
|
||||
test "create redirects to page if already exists" do
|
||||
name = "A"
|
||||
name = "A.md"
|
||||
get "/create/#{name}"
|
||||
follow_redirect!
|
||||
assert_equal "/#{name}", last_request.fullpath
|
||||
@@ -548,19 +548,6 @@ context "Frontend" do
|
||||
assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body
|
||||
end
|
||||
|
||||
test "show revision of specific file" do
|
||||
shas = {}
|
||||
["First revision of testfile", "Second revision of testfile"].each do |content|
|
||||
new_commit = commit_test_file(@wiki, "revisions", "testfile", "log", content)
|
||||
shas[new_commit] = content
|
||||
end
|
||||
shas.each do |sha, content|
|
||||
get "revisions/testfile.log/#{sha}"
|
||||
assert last_response.ok?
|
||||
assert_match /#{content}/, last_response.body
|
||||
end
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
@@ -689,12 +676,25 @@ context "Frontend with lotr" do
|
||||
|
||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
|
||||
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
|
||||
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
||||
|
||||
get "/Mordor/Orc"
|
||||
assert_match /not so big smelly creatures/, last_response.body
|
||||
end
|
||||
|
||||
test "show revision of specific file" do
|
||||
old_sha = "df26e61e707116f81ebc6b935ec6d1676b7e96c4"
|
||||
update_sha = "f803c64d11407b23797325e3843f3f378b78f611"
|
||||
|
||||
get "Data.csv/#{old_sha}"
|
||||
assert last_response.ok?
|
||||
assert_no_match /Samwise,Gamgee/, last_response.body
|
||||
|
||||
get "Data.csv/#{update_sha}"
|
||||
assert last_response.ok?
|
||||
assert_match /Samwise,Gamgee/, last_response.body
|
||||
end
|
||||
|
||||
test "existing emoji" do
|
||||
get "/emoji/heart"
|
||||
assert_equal 200, last_response.status
|
||||
|
||||
@@ -4,6 +4,15 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
||||
context "Precious::Helpers" do
|
||||
include Precious::Helpers
|
||||
|
||||
test "return git adapter" do
|
||||
if defined?(Gollum::GIT_ADAPTER)
|
||||
result = Gollum::GIT_ADAPTER
|
||||
else
|
||||
Gollum::GIT_ADAPTER = result = 'grit'
|
||||
end
|
||||
assert_equal result, git_adapter
|
||||
end
|
||||
|
||||
test "extracting paths from URLs" do
|
||||
assert_nil extract_path('Eye-Of-Sauron')
|
||||
assert_equal 'Mordor', extract_path('Mordor/Sauron')
|
||||
|
||||
@@ -21,10 +21,10 @@ context "Precious::Views::LatestChanges" do
|
||||
body = last_response.body
|
||||
|
||||
assert body.include?('<span class="username">Charles Pence</span>'), "/latest_changes should include the Author Charles Pence"
|
||||
assert body.include?('a8ad3c0'), "/latest_changes should include the :latest_changes_count commit"
|
||||
assert !body.include?('60f12f4'), "/latest_changes should not include more than latest_changes_count commits"
|
||||
assert body.include?('1db89eb'), "/latest_changes should include the :latest_changes_count commit"
|
||||
assert !body.include?('a8ad3c0'), "/latest_changes should not include more than latest_changes_count commits"
|
||||
assert body.include?('<a href="Data-Two.csv/874f597a5659b4c3b153674ea04e406ff393975e">Data-Two.csv</a>'), "/latest_changes include links to modified files in #{body}"
|
||||
assert body.include?('<a href="Hobbit/874f597a5659b4c3b153674ea04e406ff393975e">Hobbit.md</a>'), "/latest_changes should include links to modified pages in #{body}"
|
||||
assert body.include?('<a href="Hobbit.md/874f597a5659b4c3b153674ea04e406ff393975e">Hobbit.md</a>'), "/latest_changes should include links to modified pages in #{body}"
|
||||
end
|
||||
|
||||
test "extract destination file name in case of path renaming" do
|
||||
@@ -33,13 +33,6 @@ context "Precious::Views::LatestChanges" do
|
||||
assert_equal "newDirectoryName/fileName.md", view.extract_renamed_path_destination("{oldDirectoryName => newDirectoryName}/fileName.md")
|
||||
end
|
||||
|
||||
test "remove page extentions" do
|
||||
view = Precious::Views::LatestChanges.new
|
||||
assert_equal "page", view.remove_page_extentions("page.wiki")
|
||||
assert_equal "page-wiki", view.remove_page_extentions("page-wiki.md")
|
||||
assert_equal "file.any_extention", view.remove_page_extentions("file.any_extention")
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
+11
-1
@@ -51,6 +51,16 @@ context "Precious::Views::Page" do
|
||||
EOS
|
||||
end
|
||||
|
||||
test 'page has sha id' do
|
||||
title = 'test'
|
||||
@wiki.write_page(title, :markdown, 'Test' + "\n # 3", commit_details)
|
||||
page = @wiki.page(title)
|
||||
|
||||
@view = Precious::Views::Page.new
|
||||
@view.instance_variable_set :@page, page
|
||||
assert_equal "594e928cc5dcb6d833dfb86bb36076fd4a84eea7", @view.id
|
||||
end
|
||||
|
||||
test "h1 title can be disabled" do
|
||||
title = 'H1'
|
||||
@wiki.write_page(title, :markdown, '# 1 & 2 <script>alert("js")</script>' + "\n # 3", commit_details)
|
||||
@@ -63,6 +73,6 @@ EOS
|
||||
|
||||
# Title is based on file name when h1_title is false.
|
||||
actual = @view.title
|
||||
assert_equal 'H1', title
|
||||
assert_equal title, actual
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user