Merge branch 'master' into special-chars-in-page-names
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
* Support a `:gollum_path` Sinatra setting for `Precious::App`
|
* Support a `:gollum_path` Sinatra setting for `Precious::App`
|
||||||
* Add Wiki#size to efficiently count pages without loading them.
|
* Add Wiki#size to efficiently count pages without loading them.
|
||||||
* Add the correct content type when serving files from the frontend.
|
* Add the correct content type when serving files from the frontend.
|
||||||
|
* Wiki#pages come back sorted by Page#title.
|
||||||
|
* Add --host option and default it to 127.0.0.1.
|
||||||
* Bug Fixes
|
* Bug Fixes
|
||||||
* Increase minimum Sanitize version requirement to 1.1.0.
|
* Increase minimum Sanitize version requirement to 1.1.0.
|
||||||
1.0.x versions of Sanitize require Hpricot instead of Nokogiri
|
1.0.x versions of Sanitize require Hpricot instead of Nokogiri
|
||||||
@@ -19,6 +21,7 @@
|
|||||||
anonymous info.
|
anonymous info.
|
||||||
* Prevent `Gollum::Wiki#write_page` from clobbering existing pages.
|
* Prevent `Gollum::Wiki#write_page` from clobbering existing pages.
|
||||||
* Handle duplicate page errors in frontend.
|
* Handle duplicate page errors in frontend.
|
||||||
|
* Fix bugs trying to retrieve pages with invalid names.
|
||||||
|
|
||||||
# 1.0.1 / 2010-08-12
|
# 1.0.1 / 2010-08-12
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -8,7 +8,7 @@ Gollum is a multi-format Wiki Engine/API/Frontend.
|
|||||||
Basic Command Line Usage:
|
Basic Command Line Usage:
|
||||||
gollum [OPTIONS] [PATH]
|
gollum [OPTIONS] [PATH]
|
||||||
|
|
||||||
PATH The path to the Gollum repository.
|
PATH The path to the Gollum repository (default .).
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
HELP
|
HELP
|
||||||
@@ -18,7 +18,7 @@ require 'rubygems'
|
|||||||
require 'gollum'
|
require 'gollum'
|
||||||
|
|
||||||
exec = {}
|
exec = {}
|
||||||
options = {}
|
options = { 'port' => 4567, 'bind' => '127.0.0.1' }
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = help
|
opts.banner = help
|
||||||
|
|
||||||
@@ -26,6 +26,10 @@ opts = OptionParser.new do |opts|
|
|||||||
options['port'] = port.to_i
|
options['port'] = port.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--host [HOST]", "Hostname or IP address to listen on (default 0.0.0.0).") do |host|
|
||||||
|
options['bind'] = host
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("--version", "Display current version.") do
|
opts.on("--version", "Display current version.") do
|
||||||
puts "Gollum " + Gollum::VERSION
|
puts "Gollum " + Gollum::VERSION
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
+5
-1
@@ -202,7 +202,9 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the String canonical name.
|
# Returns the String canonical name.
|
||||||
def self.cname(name)
|
def self.cname(name)
|
||||||
name.gsub(%r{[ /<>]}, '-')
|
name.respond_to?(:gsub) ?
|
||||||
|
name.gsub(%r{[ /<>]}, '-') :
|
||||||
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a format Symbol into an extension String.
|
# Convert a format Symbol into an extension String.
|
||||||
@@ -264,11 +266,13 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if the page could not be found.
|
# Returns a Gollum::Page or nil if the page could not be found.
|
||||||
def find_page_in_tree(map, name, checked_dir = nil)
|
def find_page_in_tree(map, name, checked_dir = nil)
|
||||||
|
return nil if name.to_s.empty?
|
||||||
if checked_dir = BlobEntry.normalize_dir(checked_dir)
|
if checked_dir = BlobEntry.normalize_dir(checked_dir)
|
||||||
checked_dir.downcase!
|
checked_dir.downcase!
|
||||||
end
|
end
|
||||||
|
|
||||||
map.each do |entry|
|
map.each do |entry|
|
||||||
|
next if entry.name.to_s.empty?
|
||||||
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
|
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
|
||||||
next unless page_match(name, entry.name)
|
next unless page_match(name, entry.name)
|
||||||
return entry.page(@wiki, @version)
|
return entry.page(@wiki, @version)
|
||||||
|
|||||||
+7
-3
@@ -221,14 +221,16 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns an Array of Gollum::Page instances.
|
# Returns an Array of Gollum::Page instances.
|
||||||
def pages(treeish = nil)
|
def pages(treeish = nil)
|
||||||
tree_list(treeish || 'master')
|
tree_list(treeish || 'master').sort! do |x, y|
|
||||||
|
x.title.downcase <=> y.title.downcase
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fill an array with a list of pages.
|
# Public: Returns the number of pages accessible from a commit
|
||||||
#
|
#
|
||||||
# ref - A String ref that is either a commit SHA or references one.
|
# ref - A String ref that is either a commit SHA or references one.
|
||||||
#
|
#
|
||||||
# Returns a flat Array of Gollum::Page instances.
|
# Returns a Fixnum
|
||||||
def size(ref = nil)
|
def size(ref = nil)
|
||||||
tree_map_for(ref || 'master').inject(0) do |num, entry|
|
tree_map_for(ref || 'master').inject(0) do |num, entry|
|
||||||
num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
|
num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
|
||||||
@@ -471,6 +473,8 @@ module Gollum
|
|||||||
@ref_map[ref] = real_sha if real_sha != ref
|
@ref_map[ref] = real_sha if real_sha != ref
|
||||||
@tree_map[real_sha] ||= parse_tree_for(real_sha)
|
@tree_map[real_sha] ||= parse_tree_for(real_sha)
|
||||||
end
|
end
|
||||||
|
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds the full listing of files and their blob SHA for a given commit
|
# Finds the full listing of files and their blob SHA for a given commit
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
x∙н[
|
||||||
|
б0@Q©Ё┼ы─▓╓yDэй$≥╘AшH:БЖМЭ=pА√╬╝MюзИ$┐(Ш≤≤UJ(ег╧tяq╤yv.EvVsUo╢ мфДШ■╢и3Q╛9Ф┌·1!#З░~Дя▄V·p*▐╜┴╤FВeеЖ╨■╬чюьД┌÷ЭdА╛ёжЙпcOХОPa╜╟В!m[@hУrH┐
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
60f12f4254f58801b9ee7db7bca5fa8aeefaa56b
|
308fdf72d89351bf53fa6eeb00884273047e07fa
|
||||||
|
|||||||
+44
-2
@@ -17,6 +17,12 @@ context "Markup" do
|
|||||||
assert @wiki.pages[0].formatted_data
|
assert @wiki.pages[0].formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Links
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
test "double page links no space" do
|
test "double page links no space" do
|
||||||
@wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)
|
@wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)
|
||||||
|
|
||||||
@@ -96,6 +102,12 @@ context "Markup" do
|
|||||||
assert_equal "<p>a <a href=\"http://example.com\">http://example.com</a> b</p>", page.formatted_data
|
assert_equal "<p>a <a href=\"http://example.com\">http://example.com</a> b</p>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Images
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
test "image with http url" do
|
test "image with http url" do
|
||||||
['http', 'https'].each do |scheme|
|
['http', 'https'].each do |scheme|
|
||||||
name = "Bilbo Baggins #{scheme}"
|
name = "Bilbo Baggins #{scheme}"
|
||||||
@@ -213,6 +225,12 @@ context "Markup" do
|
|||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# File links
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
test "file link with absolute path" do
|
test "file link with absolute path" do
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("alpha.jpg", "hi")
|
index.add("alpha.jpg", "hi")
|
||||||
@@ -244,6 +262,12 @@ context "Markup" do
|
|||||||
assert_equal %{<p>a <a href="http://example.com/alpha.jpg">Alpha</a> b</p>}, page.formatted_data
|
assert_equal %{<p>a <a href="http://example.com/alpha.jpg">Alpha</a> b</p>}, page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Code
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
test "code blocks" do
|
test "code blocks" do
|
||||||
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
||||||
output = "<p>a</p>\n\n<div class=\"highlight\"><pre>" +
|
output = "<p>a</p>\n\n<div class=\"highlight\"><pre>" +
|
||||||
@@ -292,6 +316,12 @@ context "Markup" do
|
|||||||
compare(content, output)
|
compare(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Various
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
test "escaped wiki link" do
|
test "escaped wiki link" do
|
||||||
content = "a '[[Foo]], b"
|
content = "a '[[Foo]], b"
|
||||||
output = "<p>a [[Foo]], b</p>"
|
output = "<p>a [[Foo]], b</p>"
|
||||||
@@ -313,18 +343,30 @@ context "Markup" do
|
|||||||
compare(content, output, 'org')
|
compare(content, output, 'org')
|
||||||
end
|
end
|
||||||
|
|
||||||
test "tex block syntax" do
|
#########################################################################
|
||||||
|
#
|
||||||
|
# TeX
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
|
test "TeX block syntax" do
|
||||||
content = 'a \[ a^2 \] b'
|
content = 'a \[ a^2 \] b'
|
||||||
output = "<p>a <script type=\"math/tex; mode=display\">a^2</script> b</p>"
|
output = "<p>a <script type=\"math/tex; mode=display\">a^2</script> b</p>"
|
||||||
compare(content, output, 'md')
|
compare(content, output, 'md')
|
||||||
end
|
end
|
||||||
|
|
||||||
test "tex inline syntax" do
|
test "TeX inline syntax" do
|
||||||
content = 'a \( a^2 \) b'
|
content = 'a \( a^2 \) b'
|
||||||
output = "<p>a <script type=\"math/tex\">a^2</script> b</p>"
|
output = "<p>a <script type=\"math/tex\">a^2</script> b</p>"
|
||||||
compare(content, output, 'md')
|
compare(content, output, 'md')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#
|
||||||
|
# Helpers
|
||||||
|
#
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
def compare(content, output, ext = "md", regexes = [])
|
def compare(content, output, ext = "md", regexes = [])
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.#{ext}", content)
|
index.add("Bilbo-Baggins.#{ext}", content)
|
||||||
|
|||||||
@@ -110,4 +110,9 @@ context "Page" do
|
|||||||
footer = @wiki.page("_Footer")
|
footer = @wiki.page("_Footer")
|
||||||
assert_nil footer.footer
|
assert_nil footer.footer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "cannot convert non string to human readable page title" do
|
||||||
|
assert_equal '', Gollum::Page.cname(nil)
|
||||||
|
assert_equal '', Gollum::Page.cname(3)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+8
-8
@@ -32,15 +32,15 @@ context "Wiki" do
|
|||||||
assert_equal commits, @wiki.log(:page => 2).map { |c| c.id }
|
assert_equal commits, @wiki.log(:page => 2).map { |c| c.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
test "list pages" do
|
test "list pages, sorted by title" do
|
||||||
pages = @wiki.pages
|
pages = @wiki.pages
|
||||||
assert_equal \
|
assert_equal \
|
||||||
%w(Bilbo-Baggins.md Eye-Of-Sauron.md Home.textile My-Precious.md),
|
%w(bilbo.md Bilbo-Baggins.md Eye-Of-Sauron.md My-Precious.md Home.textile),
|
||||||
pages.map { |p| p.filename }.sort
|
pages.map { |p| p.filename }
|
||||||
end
|
end
|
||||||
|
|
||||||
test "counts pages" do
|
test "counts pages" do
|
||||||
assert_equal 4, @wiki.size
|
assert_equal 5, @wiki.size
|
||||||
end
|
end
|
||||||
|
|
||||||
test "normalizes commit hash" do
|
test "normalizes commit hash" do
|
||||||
@@ -64,9 +64,9 @@ context "Wiki" do
|
|||||||
assert @wiki.ref_map.empty?
|
assert @wiki.ref_map.empty?
|
||||||
assert @wiki.tree_map.empty?
|
assert @wiki.tree_map.empty?
|
||||||
@wiki.tree_map_for 'master'
|
@wiki.tree_map_for 'master'
|
||||||
assert_equal({"master"=>"60f12f4254f58801b9ee7db7bca5fa8aeefaa56b"}, @wiki.ref_map)
|
assert_equal({"master"=>"308fdf72d89351bf53fa6eeb00884273047e07fa"}, @wiki.ref_map)
|
||||||
|
|
||||||
map = @wiki.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b']
|
map = @wiki.tree_map['308fdf72d89351bf53fa6eeb00884273047e07fa']
|
||||||
assert_equal 'Bilbo-Baggins.md', map[0].path
|
assert_equal 'Bilbo-Baggins.md', map[0].path
|
||||||
assert_equal '', map[0].dir
|
assert_equal '', map[0].dir
|
||||||
assert_equal map[0].path, map[0].name
|
assert_equal map[0].path, map[0].name
|
||||||
@@ -77,10 +77,10 @@ context "Wiki" do
|
|||||||
|
|
||||||
test "#tree_map_for only caches tree for commit" do
|
test "#tree_map_for only caches tree for commit" do
|
||||||
assert @wiki.tree_map.empty?
|
assert @wiki.tree_map.empty?
|
||||||
@wiki.tree_map_for '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
|
@wiki.tree_map_for '308fdf72d89351bf53fa6eeb00884273047e07fa'
|
||||||
assert @wiki.ref_map.empty?
|
assert @wiki.ref_map.empty?
|
||||||
|
|
||||||
entry = @wiki.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'][0]
|
entry = @wiki.tree_map['308fdf72d89351bf53fa6eeb00884273047e07fa'][0]
|
||||||
assert_equal 'Bilbo-Baggins.md', entry.path
|
assert_equal 'Bilbo-Baggins.md', entry.path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user