Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 404419d1c3 | |||
| 4ee94a6574 | |||
| f929df0419 | |||
| 57587dafbe | |||
| 31a95e81b3 | |||
| 70a4e9551b | |||
| e1a705f975 | |||
| 9057ec82d8 | |||
| 1b53e36666 | |||
| 10fa5c7bd2 |
+3
-3
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.8.7"
|
s.required_ruby_version = ">= 1.8.7"
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '2.4.1'
|
s.version = '2.4.3'
|
||||||
s.date = '2012-11-19'
|
s.date = '2012-11-29'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
|
|
||||||
s.summary = "A simple, Git-powered wiki."
|
s.summary = "A simple, Git-powered wiki."
|
||||||
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|||||||
s.add_dependency('sanitize', '~> 2.0.3')
|
s.add_dependency('sanitize', '~> 2.0.3')
|
||||||
s.add_dependency('nokogiri', '~> 1.5.5')
|
s.add_dependency('nokogiri', '~> 1.5.5')
|
||||||
s.add_dependency('useragent', '~> 0.4.13')
|
s.add_dependency('useragent', '~> 0.4.13')
|
||||||
s.add_dependency('stringex', '~> 1.4.0')
|
s.add_dependency('stringex', '~> 1.5.0')
|
||||||
|
|
||||||
s.add_development_dependency('RedCloth', '~> 4.2.9')
|
s.add_development_dependency('RedCloth', '~> 4.2.9')
|
||||||
s.add_development_dependency('mocha', '~> 0.13.0')
|
s.add_development_dependency('mocha', '~> 0.13.0')
|
||||||
|
|||||||
+6
-1
@@ -23,8 +23,13 @@ require File.expand_path('../gollum/sanitization', __FILE__)
|
|||||||
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
||||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||||
|
|
||||||
|
# Set ruby to UTF-8 mode
|
||||||
|
# Do not remove because of warning.
|
||||||
|
# This is required for Ruby 1.8.7 which gollum still supports.
|
||||||
|
$KCODE = 'U'
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '2.4.1'
|
VERSION = '2.4.3'
|
||||||
|
|
||||||
def self.assets_path
|
def self.assets_path
|
||||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ class String
|
|||||||
# _Header => header which causes errors
|
# _Header => header which causes errors
|
||||||
def to_url
|
def to_url
|
||||||
return nil if self.nil?
|
return nil if self.nil?
|
||||||
return self if ['_Header', '_Footer', '_Sidebar'].include? self
|
upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar']
|
||||||
upstream_to_url
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ module Precious
|
|||||||
# Wraps page formatted data to Nokogiri::HTML document.
|
# Wraps page formatted data to Nokogiri::HTML document.
|
||||||
#
|
#
|
||||||
def build_document(content)
|
def build_document(content)
|
||||||
Nokogiri::HTML(%{<div id="gollum-root">} + content + %{</div>})
|
Nokogiri::HTML::fragment(%{<div id="gollum-root">} + content.to_s + %{</div>}, 'UTF-8')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds header node inside Nokogiri::HTML document.
|
# Finds header node inside Nokogiri::HTML document.
|
||||||
@@ -134,7 +134,7 @@ module Precious
|
|||||||
def page_header_from_content(content)
|
def page_header_from_content(content)
|
||||||
doc = build_document(content)
|
doc = build_document(content)
|
||||||
title = find_header_node(doc)
|
title = find_header_node(doc)
|
||||||
Sanitize.clean(title.to_html).strip unless title.empty?
|
Sanitize.clean(title.to_xhtml(:encoding => 'UTF-8')).strip unless title.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns page content without title if it was extracted.
|
# Returns page content without title if it was extracted.
|
||||||
@@ -143,7 +143,8 @@ module Precious
|
|||||||
doc = build_document(content)
|
doc = build_document(content)
|
||||||
title = find_header_node(doc)
|
title = find_header_node(doc)
|
||||||
title.remove unless title.empty?
|
title.remove unless title.empty?
|
||||||
doc.css("div#gollum-root").inner_html
|
# .inner_html will cause href escaping on UTF-8
|
||||||
|
doc.css("div#gollum-root").children.to_xhtml(:encoding => 'UTF-8')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -126,7 +126,11 @@ module Gollum
|
|||||||
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
||||||
tail.add_child(node)
|
tail.add_child(node)
|
||||||
end
|
end
|
||||||
toc = toc.to_xml(@to_xml) if toc != nil
|
if toc != nil
|
||||||
|
# convert to HTML first before XHTML
|
||||||
|
toc = Nokogiri::HTML::fragment toc.to_s
|
||||||
|
toc = toc.to_xhtml(:encoding => 'UTF-8')
|
||||||
|
end
|
||||||
[doc, toc]
|
[doc, toc]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,47 @@ context "Frontend" do
|
|||||||
FileUtils.rm_rf(@path)
|
FileUtils.rm_rf(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "urls transform unicode" do
|
||||||
|
header = '_Header'
|
||||||
|
footer = '_Footer'
|
||||||
|
sidebar = '_Sidebar'
|
||||||
|
|
||||||
|
# header, footer, and sidebar must be preserved
|
||||||
|
# or gollum will not recognize them
|
||||||
|
assert_equal header, header.to_url
|
||||||
|
assert_equal footer, footer.to_url
|
||||||
|
assert_equal sidebar, sidebar.to_url
|
||||||
|
|
||||||
|
# spaces are converted to dashes in URLs
|
||||||
|
# and in file names saved to disk
|
||||||
|
# urls are not case sensitive
|
||||||
|
assert_equal 'title-space', 'Title Space'.to_url
|
||||||
|
|
||||||
|
# ascii only file names prevent UTF8 issues
|
||||||
|
# when using git repos across operating systems
|
||||||
|
# as this test demonstrates, translation is not
|
||||||
|
# great
|
||||||
|
assert_equal 'm-plus-f', 'μ†ℱ'.to_url
|
||||||
|
end
|
||||||
|
|
||||||
|
test "utf-8 kcode" do
|
||||||
|
assert_equal 'μ†ℱ'.scan(/./), ["μ", "†", "ℱ"]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "UTF-8 headers href preserved" do
|
||||||
|
page = 'utfh1'
|
||||||
|
text = '한글'
|
||||||
|
|
||||||
|
# don't use h1 or it will be promoted to replace file name
|
||||||
|
# which doesn't generate a normal header link
|
||||||
|
@wiki.write_page(page, :markdown, '## ' + text,
|
||||||
|
{ :name => 'user1', :email => 'user1' });
|
||||||
|
|
||||||
|
get page
|
||||||
|
|
||||||
|
assert_match /<h2>#{text}<a class="anchor" id="#{text}" href="##{text}"><\/a><\/h2>/, last_response.body
|
||||||
|
end
|
||||||
|
|
||||||
test "retain edit information" do
|
test "retain edit information" do
|
||||||
page1 = 'page1'
|
page1 = 'page1'
|
||||||
user1 = 'user1'
|
user1 = 'user1'
|
||||||
|
|||||||
@@ -41,6 +41,28 @@ context "Unicode Support" do
|
|||||||
assert_equal '', anchors[0].text
|
assert_equal '', anchors[0].text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_h1 text, page
|
||||||
|
@wiki.write_page(page, :markdown, "# " + text)
|
||||||
|
|
||||||
|
page = @wiki.page(page)
|
||||||
|
assert_equal Gollum::Page, page.class
|
||||||
|
assert_equal '# ' + text, utf8(page.raw_data)
|
||||||
|
|
||||||
|
output = page.formatted_data
|
||||||
|
|
||||||
|
# UTF-8 headers should not be encoded.
|
||||||
|
assert_match /<h1>#{text}<a class="anchor" id="#{text}" href="##{text}"><\/a><\/h1>/, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create and read non-latin page with anchor" do
|
||||||
|
# href="#한글"
|
||||||
|
# href="#%ED%95%9C%EA%B8%80"
|
||||||
|
check_h1 '한글', '1'
|
||||||
|
# href="#한글"
|
||||||
|
# href="#Synht%C3%A8se"
|
||||||
|
check_h1 'Synhtèse', '2'
|
||||||
|
end
|
||||||
|
|
||||||
test "create and read non-latin page with anchor 2" do
|
test "create and read non-latin page with anchor 2" do
|
||||||
@wiki.write_page("test", :markdown, "# \"La\" faune d'Édiacara")
|
@wiki.write_page("test", :markdown, "# \"La\" faune d'Édiacara")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user