Merge branch 'master' into special-chars-in-page-names

This commit is contained in:
rick
2010-09-30 14:02:39 -07:00
11 changed files with 82 additions and 18 deletions
+3
View File
@@ -9,6 +9,8 @@
* Support a `:gollum_path` Sinatra setting for `Precious::App`
* Add Wiki#size to efficiently count pages without loading them.
* 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
* Increase minimum Sanitize version requirement to 1.1.0.
1.0.x versions of Sanitize require Hpricot instead of Nokogiri
@@ -19,6 +21,7 @@
anonymous info.
* Prevent `Gollum::Wiki#write_page` from clobbering existing pages.
* Handle duplicate page errors in frontend.
* Fix bugs trying to retrieve pages with invalid names.
# 1.0.1 / 2010-08-12
+6 -2
View File
@@ -8,7 +8,7 @@ Gollum is a multi-format Wiki Engine/API/Frontend.
Basic Command Line Usage:
gollum [OPTIONS] [PATH]
PATH The path to the Gollum repository.
PATH The path to the Gollum repository (default .).
Options:
HELP
@@ -18,7 +18,7 @@ require 'rubygems'
require 'gollum'
exec = {}
options = {}
options = { 'port' => 4567, 'bind' => '127.0.0.1' }
opts = OptionParser.new do |opts|
opts.banner = help
@@ -26,6 +26,10 @@ opts = OptionParser.new do |opts|
options['port'] = port.to_i
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
puts "Gollum " + Gollum::VERSION
exit 0
+5 -1
View File
@@ -202,7 +202,9 @@ module Gollum
#
# Returns the String canonical name.
def self.cname(name)
name.gsub(%r{[ /<>]}, '-')
name.respond_to?(:gsub) ?
name.gsub(%r{[ /<>]}, '-') :
''
end
# 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.
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)
checked_dir.downcase!
end
map.each do |entry|
next if entry.name.to_s.empty?
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
next unless page_match(name, entry.name)
return entry.page(@wiki, @version)
+7 -3
View File
@@ -221,14 +221,16 @@ module Gollum
#
# Returns an Array of Gollum::Page instances.
def pages(treeish = nil)
tree_list(treeish || 'master')
tree_list(treeish || 'master').sort! do |x, y|
x.title.downcase <=> y.title.downcase
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.
#
# Returns a flat Array of Gollum::Page instances.
# Returns a Fixnum
def size(ref = nil)
tree_map_for(ref || 'master').inject(0) do |num, entry|
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
@tree_map[real_sha] ||= parse_tree_for(real_sha)
end
rescue Grit::GitRuby::Repository::NoSuchShaFound
[]
end
# 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┐
+1 -1
View File
@@ -1 +1 @@
60f12f4254f58801b9ee7db7bca5fa8aeefaa56b
308fdf72d89351bf53fa6eeb00884273047e07fa
+45 -3
View File
@@ -17,6 +17,12 @@ context "Markup" do
assert @wiki.pages[0].formatted_data
end
#########################################################################
#
# Links
#
#########################################################################
test "double page links no space" do
@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
end
#########################################################################
#
# Images
#
#########################################################################
test "image with http url" do
['http', 'https'].each do |scheme|
name = "Bilbo Baggins #{scheme}"
@@ -213,6 +225,12 @@ context "Markup" do
relative_image(content, output)
end
#########################################################################
#
# File links
#
#########################################################################
test "file link with absolute path" do
index = @wiki.repo.index
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
end
#########################################################################
#
# Code
#
#########################################################################
test "code blocks" do
content = "a\n\n```ruby\nx = 1\n```\n\nb"
output = "<p>a</p>\n\n<div class=\"highlight\"><pre>" +
@@ -292,6 +316,12 @@ context "Markup" do
compare(content, output)
end
#########################################################################
#
# Various
#
#########################################################################
test "escaped wiki link" do
content = "a '[[Foo]], b"
output = "<p>a [[Foo]], b</p>"
@@ -313,18 +343,30 @@ context "Markup" do
compare(content, output, 'org')
end
test "tex block syntax" do
#########################################################################
#
# TeX
#
#########################################################################
test "TeX block syntax" do
content = 'a \[ a^2 \] b'
output = "<p>a <script type=\"math/tex; mode=display\">a^2</script> b</p>"
compare(content, output, 'md')
end
test "tex inline syntax" do
test "TeX inline syntax" do
content = 'a \( a^2 \) b'
output = "<p>a <script type=\"math/tex\">a^2</script> b</p>"
compare(content, output, 'md')
end
#########################################################################
#
# Helpers
#
#########################################################################
def compare(content, output, ext = "md", regexes = [])
index = @wiki.repo.index
index.add("Bilbo-Baggins.#{ext}", content)
@@ -350,4 +392,4 @@ context "Markup" do
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
end
end
end
+5
View File
@@ -110,4 +110,9 @@ context "Page" do
footer = @wiki.page("_Footer")
assert_nil footer.footer
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
+8 -8
View File
@@ -32,15 +32,15 @@ context "Wiki" do
assert_equal commits, @wiki.log(:page => 2).map { |c| c.id }
end
test "list pages" do
test "list pages, sorted by title" do
pages = @wiki.pages
assert_equal \
%w(Bilbo-Baggins.md Eye-Of-Sauron.md Home.textile My-Precious.md),
pages.map { |p| p.filename }.sort
%w(bilbo.md Bilbo-Baggins.md Eye-Of-Sauron.md My-Precious.md Home.textile),
pages.map { |p| p.filename }
end
test "counts pages" do
assert_equal 4, @wiki.size
assert_equal 5, @wiki.size
end
test "normalizes commit hash" do
@@ -64,9 +64,9 @@ context "Wiki" do
assert @wiki.ref_map.empty?
assert @wiki.tree_map.empty?
@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 '', map[0].dir
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
assert @wiki.tree_map.empty?
@wiki.tree_map_for '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
@wiki.tree_map_for '308fdf72d89351bf53fa6eeb00884273047e07fa'
assert @wiki.ref_map.empty?
entry = @wiki.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'][0]
entry = @wiki.tree_map['308fdf72d89351bf53fa6eeb00884273047e07fa'][0]
assert_equal 'Bilbo-Baggins.md', entry.path
end
end