Remove :header_hashtags option and adjust tests
This commit is contained in:
@@ -14,7 +14,6 @@ require 'gollum/frontend/views/editable'
|
|||||||
# require 'gollum/frontend/app'
|
# require 'gollum/frontend/app'
|
||||||
# Precious::App.set(:wiki_options, {
|
# Precious::App.set(:wiki_options, {
|
||||||
# :universal_toc => false,
|
# :universal_toc => false,
|
||||||
# :header_hashtags => true
|
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# See the wiki.rb file for more details on wiki options
|
# See the wiki.rb file for more details on wiki options
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ module Gollum
|
|||||||
anchor['class'] = 'anchor'
|
anchor['class'] = 'anchor'
|
||||||
anchor['id'] = id
|
anchor['id'] = id
|
||||||
anchor['href'] = '#' + id
|
anchor['href'] = '#' + id
|
||||||
h.child.before(anchor)
|
h.add_child(anchor)
|
||||||
|
|
||||||
# Build TOC
|
# Build TOC
|
||||||
toc ||= Nokogiri::XML::Node.new('ul', doc)
|
toc ||= Nokogiri::XML::Node.new('ul', doc)
|
||||||
|
|||||||
@@ -139,9 +139,6 @@ module Gollum
|
|||||||
# site.
|
# site.
|
||||||
# options - Optional Hash:
|
# options - Optional Hash:
|
||||||
# :universal_toc - Table of contents on all pages. Default: false
|
# :universal_toc - Table of contents on all pages. Default: false
|
||||||
# :header_hashtags - Show links to headers. Default: true
|
|
||||||
# (Pages may be rendered slightly faster without
|
|
||||||
# the toc and hashtags)
|
|
||||||
# :base_path - String base path for all Wiki links.
|
# :base_path - String base path for all Wiki links.
|
||||||
# Default: "/"
|
# Default: "/"
|
||||||
# :page_class - The page Class. Default: Gollum::Page
|
# :page_class - The page Class. Default: Gollum::Page
|
||||||
@@ -175,7 +172,6 @@ module Gollum
|
|||||||
@history_sanitization = options[:history_sanitization] ||
|
@history_sanitization = options[:history_sanitization] ||
|
||||||
self.class.history_sanitization
|
self.class.history_sanitization
|
||||||
@universal_toc = options.fetch(:universal_toc, false)
|
@universal_toc = options.fetch(:universal_toc, false)
|
||||||
@header_hashtags = options.fetch(:header_hashtags, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||||
@@ -542,9 +538,6 @@ module Gollum
|
|||||||
# Toggles display of universal table of contents
|
# Toggles display of universal table of contents
|
||||||
attr_reader :universal_toc
|
attr_reader :universal_toc
|
||||||
|
|
||||||
# Create hashtag link for headers to jump to sections
|
|
||||||
attr_reader :header_hashtags
|
|
||||||
|
|
||||||
# Normalize the data.
|
# Normalize the data.
|
||||||
#
|
#
|
||||||
# data - The String data to be normalized.
|
# data - The String data to be normalized.
|
||||||
|
|||||||
+8
-7
@@ -6,7 +6,7 @@ context "Markup" do
|
|||||||
@path = testpath("examples/test.git")
|
@path = testpath("examples/test.git")
|
||||||
FileUtils.rm_rf(@path)
|
FileUtils.rm_rf(@path)
|
||||||
Grit::Repo.init_bare(@path)
|
Grit::Repo.init_bare(@path)
|
||||||
Gollum::Wiki.default_options = {:header_hashtags => false, :universal_toc => false}
|
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||||
@wiki = Gollum::Wiki.new(@path)
|
@wiki = Gollum::Wiki.new(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -556,14 +556,15 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
|
|
||||||
test "id with prefix ok" do
|
test "id with prefix ok" do
|
||||||
content = "h2(example#wiki-foo). xxxx"
|
content = "h2(example#wiki-foo). xxxx"
|
||||||
output = %(<h2 class="example" id="wiki-foo">xxxx</h2>)
|
output = %(<h2 class="example" id="wiki-foo">xxxx<a class=\"anchor\" id=\"xxxx\" href=\"#xxxx\"></a></h2>)
|
||||||
compare(content, output, :textile)
|
compare(content, output, :textile)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "id prefix added" do
|
test "id prefix added" do
|
||||||
content = "h2(#foo). xxxx[1]\n\nfn1.footnote"
|
content = "h2(#foo). xxxx[1]\n\nfn1.footnote"
|
||||||
output = "<h2 id=\"wiki-foo\">xxxx" +
|
output = "<h2 id=\"wiki-foo\">xxxx" +
|
||||||
"<sup class=\"footnote\" id=\"wiki-fnr1\"><a href=\"#wiki-fn1\">1</a></sup></h2>" +
|
"<sup class=\"footnote\" id=\"wiki-fnr1\"><a href=\"#wiki-fn1\">1</a></sup>" +
|
||||||
|
"<a class=\"anchor\" id=\"xxxx1\" href=\"#xxxx1\"></a></h2>" +
|
||||||
"\n<p class=\"footnote\" id=\"wiki-fn1\"><a href=\"#wiki-fnr1\"><sup>1</sup></a> footnote</p>"
|
"\n<p class=\"footnote\" id=\"wiki-fn1\"><a href=\"#wiki-fnr1\"><sup>1</sup></a> footnote</p>"
|
||||||
compare(content, output, :textile)
|
compare(content, output, :textile)
|
||||||
end
|
end
|
||||||
@@ -601,11 +602,11 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
test "asciidoc header" do
|
test "asciidoc header" do
|
||||||
compare("= Book Title\n\n== Heading", '<div class="sect1"><h2 id="wiki-_heading">Heading</h2><div class="sectionbody"></div></div>', 'asciidoc')
|
compare("= Book Title\n\n== Heading", '<div class="sect1"><h2 id="wiki-_heading">Heading<a class="anchor" id="Heading" href="#Heading"></a></h2><div class="sectionbody"></div></div>', 'asciidoc')
|
||||||
end
|
end
|
||||||
|
|
||||||
test "internal links with asciidoc" do
|
test "internal links with asciidoc" do
|
||||||
compare("= Book Title\n\n[[anid]]\n== Heading", '<div class="sect1"><h2 id="wiki-anid">Heading</h2><div class="sectionbody"></div></div>', 'asciidoc')
|
compare("= Book Title\n\n[[anid]]\n== Heading", '<div class="sect1"><h2 id="wiki-anid">Heading<a class="anchor" id="Heading" href="#Heading"></a></h2><div class="sectionbody"></div></div>', 'asciidoc')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ context "Page" do
|
|||||||
page = @wiki.page('Bilbo Baggins')
|
page = @wiki.page('Bilbo Baggins')
|
||||||
assert_equal Gollum::Page, page.class
|
assert_equal Gollum::Page, page.class
|
||||||
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
|
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
|
||||||
assert page.formatted_data =~ /<h1>Bilbo Baggins<\/h1>\n\n<p>Bilbo Baggins/
|
assert page.formatted_data =~ %r{<h1>Bilbo Baggins<a class="anchor" id="Bilbo-Baggins" href="#Bilbo-Baggins"></a>\n</h1>\n\n<p>Bilbo Baggins}
|
||||||
assert_equal 'Bilbo-Baggins.md', page.path
|
assert_equal 'Bilbo-Baggins.md', page.path
|
||||||
assert_equal :markdown, page.format
|
assert_equal :markdown, page.format
|
||||||
assert_equal @wiki.repo.commits.first.id, page.version.id
|
assert_equal @wiki.repo.commits.first.id, page.version.id
|
||||||
|
|||||||
+4
-18
@@ -92,14 +92,14 @@ end
|
|||||||
context "Wiki page previewing" do
|
context "Wiki page previewing" do
|
||||||
setup do
|
setup do
|
||||||
@path = testpath("examples/lotr.git")
|
@path = testpath("examples/lotr.git")
|
||||||
Gollum::Wiki.default_options = {:header_hashtags => false, :universal_toc => false}
|
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||||
@wiki = Gollum::Wiki.new(@path)
|
@wiki = Gollum::Wiki.new(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "preview_page" do
|
test "preview_page" do
|
||||||
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
||||||
assert_equal "# Bilbo", page.raw_data
|
assert_equal "# Bilbo", page.raw_data
|
||||||
assert_equal "<h1>Bilbo</h1>", page.formatted_data
|
assert_equal %Q{<h1>Bilbo<a class="anchor" id="Bilbo" href="#Bilbo"></a>\n</h1>}, page.formatted_data
|
||||||
assert_equal "Test.md", page.filename
|
assert_equal "Test.md", page.filename
|
||||||
assert_equal "Test", page.name
|
assert_equal "Test", page.name
|
||||||
end
|
end
|
||||||
@@ -108,32 +108,18 @@ end
|
|||||||
context "Wiki TOC" do
|
context "Wiki TOC" do
|
||||||
setup do
|
setup do
|
||||||
@path = testpath("examples/lotr.git")
|
@path = testpath("examples/lotr.git")
|
||||||
options = {:header_hashtags => false, :universal_toc => true}
|
options = {:universal_toc => true}
|
||||||
@wiki = Gollum::Wiki.new(@path, options)
|
@wiki = Gollum::Wiki.new(@path, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "toc_generation" do
|
test "toc_generation" do
|
||||||
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
||||||
assert_equal "# Bilbo", page.raw_data
|
assert_equal "# Bilbo", page.raw_data
|
||||||
assert_equal '<h1><a class="anchor" id="Bilbo" href="#Bilbo"></a>Bilbo</h1>', page.formatted_data.gsub(/\n/,"")
|
assert_equal '<h1>Bilbo<a class="anchor" id="Bilbo" href="#Bilbo"></a></h1>', page.formatted_data.gsub(/\n/,"")
|
||||||
assert_equal '<ul><li><a href="#Bilbo">Bilbo</a></li></ul>', page.toc_data.gsub(/\n */,"")
|
assert_equal '<ul><li><a href="#Bilbo">Bilbo</a></li></ul>', page.toc_data.gsub(/\n */,"")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Wiki header hashtags" do
|
|
||||||
setup do
|
|
||||||
@path = testpath("examples/lotr.git")
|
|
||||||
options = {:header_hashtags => true, :universal_toc => false}
|
|
||||||
@wiki = Gollum::Wiki.new(@path, options)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "header_hashtags" do
|
|
||||||
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
|
||||||
assert_equal "# Bilbo", page.raw_data
|
|
||||||
assert_equal '<h1><a class="anchor" id="Bilbo" href="#Bilbo"></a>Bilbo</h1>', page.formatted_data.gsub(/\n/,"")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "Wiki page writing" do
|
context "Wiki page writing" do
|
||||||
setup do
|
setup do
|
||||||
@path = testpath("examples/test.git")
|
@path = testpath("examples/test.git")
|
||||||
|
|||||||
Reference in New Issue
Block a user