Remove :header_hashtags option and adjust tests

This commit is contained in:
kristi
2012-05-14 00:38:27 -07:00
parent 4fa2cdf8d9
commit b0ba205532
6 changed files with 14 additions and 35 deletions
-1
View File
@@ -14,7 +14,6 @@ require 'gollum/frontend/views/editable'
# require 'gollum/frontend/app'
# Precious::App.set(:wiki_options, {
# :universal_toc => false,
# :header_hashtags => true
# }
#
# See the wiki.rb file for more details on wiki options
+1 -1
View File
@@ -83,7 +83,7 @@ module Gollum
anchor['class'] = 'anchor'
anchor['id'] = id
anchor['href'] = '#' + id
h.child.before(anchor)
h.add_child(anchor)
# Build TOC
toc ||= Nokogiri::XML::Node.new('ul', doc)
-7
View File
@@ -139,9 +139,6 @@ module Gollum
# site.
# options - Optional Hash:
# :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.
# Default: "/"
# :page_class - The page Class. Default: Gollum::Page
@@ -175,7 +172,6 @@ module Gollum
@history_sanitization = options[:history_sanitization] ||
self.class.history_sanitization
@universal_toc = options.fetch(:universal_toc, false)
@header_hashtags = options.fetch(:header_hashtags, true)
end
# 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
attr_reader :universal_toc
# Create hashtag link for headers to jump to sections
attr_reader :header_hashtags
# Normalize the data.
#
# data - The String data to be normalized.
+8 -7
View File
@@ -6,7 +6,7 @@ context "Markup" do
@path = testpath("examples/test.git")
FileUtils.rm_rf(@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)
end
@@ -556,14 +556,15 @@ np.array([[2,2],[1,3]],np.float)
test "id with prefix ok" do
content = "h2(example#wiki-foo). xxxx"
output = %(<h2 class="example" id="wiki-foo">xxxx</h2>)
compare(content, output, :textile)
end
output = %(<h2 class="example" id="wiki-foo">xxxx<a class=\"anchor\" id=\"xxxx\" href=\"#xxxx\"></a></h2>)
compare(content, output, :textile)
end
test "id prefix added" do
content = "h2(#foo). xxxx[1]\n\nfn1.footnote"
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>"
compare(content, output, :textile)
end
@@ -601,11 +602,11 @@ np.array([[2,2],[1,3]],np.float)
#########################################################################
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
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
+1 -1
View File
@@ -16,7 +16,7 @@ context "Page" do
page = @wiki.page('Bilbo Baggins')
assert_equal Gollum::Page, page.class
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 :markdown, page.format
assert_equal @wiki.repo.commits.first.id, page.version.id
+4 -18
View File
@@ -92,14 +92,14 @@ end
context "Wiki page previewing" do
setup do
@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)
end
test "preview_page" do
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
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", page.name
end
@@ -108,32 +108,18 @@ end
context "Wiki TOC" do
setup do
@path = testpath("examples/lotr.git")
options = {:header_hashtags => false, :universal_toc => true}
options = {:universal_toc => true}
@wiki = Gollum::Wiki.new(@path, options)
end
test "toc_generation" 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/,"")
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 */,"")
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
setup do
@path = testpath("examples/test.git")