Merge branch 'master' of github.com:github/gollum
This commit is contained in:
@@ -2,3 +2,4 @@ coverage
|
|||||||
pkg
|
pkg
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.bundle
|
.bundle
|
||||||
|
Gemfile.lock
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
PATH
|
|
||||||
remote: .
|
|
||||||
specs:
|
|
||||||
gollum (1.1.0)
|
|
||||||
albino (~> 1.0)
|
|
||||||
github-markup (>= 0.4.0, < 1.0.0)
|
|
||||||
grit (~> 2.3)
|
|
||||||
mustache (>= 0.11.2, < 1.0.0)
|
|
||||||
nokogiri (~> 1.4)
|
|
||||||
sanitize (~> 1.1)
|
|
||||||
sinatra (~> 1.0)
|
|
||||||
|
|
||||||
GEM
|
|
||||||
remote: http://rubygems.org/
|
|
||||||
specs:
|
|
||||||
RedCloth (4.2.3)
|
|
||||||
albino (1.0)
|
|
||||||
diff-lcs (1.1.2)
|
|
||||||
github-markup (0.5.0)
|
|
||||||
grit (2.3.0)
|
|
||||||
diff-lcs (~> 1.1)
|
|
||||||
mime-types (~> 1.15)
|
|
||||||
mime-types (1.16)
|
|
||||||
mocha (0.9.9)
|
|
||||||
rake
|
|
||||||
mustache (0.11.2)
|
|
||||||
nokogiri (1.4.3.1)
|
|
||||||
org-ruby (0.5.3)
|
|
||||||
rubypants (>= 0.2.0)
|
|
||||||
rack (1.2.1)
|
|
||||||
rake (0.8.7)
|
|
||||||
rdiscount (1.6.5)
|
|
||||||
rubypants (0.2.0)
|
|
||||||
sanitize (1.2.1)
|
|
||||||
nokogiri (~> 1.4.1)
|
|
||||||
shoulda (2.11.3)
|
|
||||||
sinatra (1.1.0)
|
|
||||||
rack (~> 1.1)
|
|
||||||
tilt (~> 1.1)
|
|
||||||
tilt (1.1)
|
|
||||||
|
|
||||||
PLATFORMS
|
|
||||||
ruby
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
RedCloth
|
|
||||||
albino (~> 1.0)
|
|
||||||
github-markup (>= 0.4.0, < 1.0.0)
|
|
||||||
gollum!
|
|
||||||
grit (~> 2.3)
|
|
||||||
mocha
|
|
||||||
mustache (>= 0.11.2, < 1.0.0)
|
|
||||||
nokogiri (~> 1.4)
|
|
||||||
org-ruby
|
|
||||||
rdiscount
|
|
||||||
sanitize (~> 1.1)
|
|
||||||
shoulda
|
|
||||||
sinatra (~> 1.0)
|
|
||||||
@@ -32,7 +32,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns an unbaked Grit::Blob instance.
|
# Returns an unbaked Grit::Blob instance.
|
||||||
def blob(repo)
|
def blob(repo)
|
||||||
@blob ||= Grit::Blob.create(repo,
|
@blob ||= Grit::Blob.create(repo,
|
||||||
:id => @sha, :name => name, :size => @size)
|
:id => @sha, :name => name, :size => @size)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,19 +53,21 @@ module Gollum
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Normalizes a given directory name for searching through tree paths.
|
# Normalizes a given directory name for searching through tree paths.
|
||||||
# Ensures that a directory begins with a slash, or
|
# Ensures that a directory begins with a slash, or
|
||||||
#
|
#
|
||||||
# normalize_dir("") # => ""
|
# normalize_dir("") # => ""
|
||||||
# normalize_dir(".") # => ""
|
# normalize_dir(".") # => ""
|
||||||
# normalize_dir("foo") # => "/foo"
|
# normalize_dir("foo") # => "/foo"
|
||||||
# normalize_dir("/foo/") # => "/foo"
|
# normalize_dir("/foo/") # => "/foo"
|
||||||
# normalize_dir("/") # => ""
|
# normalize_dir("/") # => ""
|
||||||
|
# normalize_dir("c:/") # => ""
|
||||||
#
|
#
|
||||||
# dir - String directory name.
|
# dir - String directory name.
|
||||||
#
|
#
|
||||||
# Returns a normalized String directory name, or nil if no directory
|
# Returns a normalized String directory name, or nil if no directory
|
||||||
# is given.
|
# is given.
|
||||||
def self.normalize_dir(dir)
|
def self.normalize_dir(dir)
|
||||||
|
return '' if dir =~ /^.:\/$/
|
||||||
if dir
|
if dir
|
||||||
dir = ::File.expand_path(dir, '/')
|
dir = ::File.expand_path(dir, '/')
|
||||||
dir = '' if dir == '/'
|
dir = '' if dir == '/'
|
||||||
|
|||||||
+27
-23
@@ -4,15 +4,16 @@ module Gollum
|
|||||||
|
|
||||||
Wiki.page_class = self
|
Wiki.page_class = self
|
||||||
|
|
||||||
VALID_PAGE_RE = /^(.+)\.(md|mkdn?|mdown|markdown|textile|rdoc|org|creole|re?st(\.txt)?|asciidoc|pod)$/i
|
VALID_PAGE_RE = /^(.+)\.(md|mkdn?|mdown|markdown|textile|rdoc|org|creole|re?st(\.txt)?|asciidoc|pod|(media)?wiki)$/i
|
||||||
FORMAT_NAMES = { :markdown => "Markdown",
|
FORMAT_NAMES = { :markdown => "Markdown",
|
||||||
:textile => "Textile",
|
:textile => "Textile",
|
||||||
:rdoc => "RDoc",
|
:rdoc => "RDoc",
|
||||||
:org => "Org-mode",
|
:org => "Org-mode",
|
||||||
:creole => "Creole",
|
:creole => "Creole",
|
||||||
:rest => "reStructuredText",
|
:rest => "reStructuredText",
|
||||||
:asciidoc => "AsciiDoc",
|
:asciidoc => "AsciiDoc",
|
||||||
:pod => "Pod" }
|
:mediawiki => "MediaWiki",
|
||||||
|
:pod => "Pod" }
|
||||||
|
|
||||||
# Sets a Boolean determing whether this page is a historical version.
|
# Sets a Boolean determing whether this page is a historical version.
|
||||||
#
|
#
|
||||||
@@ -65,7 +66,7 @@ module Gollum
|
|||||||
@blob && @blob.name
|
@blob && @blob.name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: The canonical page name without extension, and dashes converted
|
# Public: The canonical page name without extension, and dashes converted
|
||||||
# to spaces.
|
# to spaces.
|
||||||
#
|
#
|
||||||
# Returns the String name.
|
# Returns the String name.
|
||||||
@@ -161,6 +162,8 @@ module Gollum
|
|||||||
:pod
|
:pod
|
||||||
when /\.(\d)$/i
|
when /\.(\d)$/i
|
||||||
:roff
|
:roff
|
||||||
|
when /\.(media)?wiki$/i
|
||||||
|
:mediawiki
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
@@ -176,7 +179,7 @@ module Gollum
|
|||||||
# options - The options Hash:
|
# options - The options Hash:
|
||||||
# :page - The Integer page number (default: 1).
|
# :page - The Integer page number (default: 1).
|
||||||
# :per_page - The Integer max count of items to return.
|
# :per_page - The Integer max count of items to return.
|
||||||
# :follow - Follow's a file across renames, but falls back
|
# :follow - Follow's a file across renames, but falls back
|
||||||
# to a slower Grit native call. (default: false)
|
# to a slower Grit native call. (default: false)
|
||||||
#
|
#
|
||||||
# Returns an Array of Grit::Commit.
|
# Returns an Array of Grit::Commit.
|
||||||
@@ -206,7 +209,7 @@ module Gollum
|
|||||||
@sidebar ||= find_sub_page(:sidebar)
|
@sidebar ||= find_sub_page(:sidebar)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gets a Boolean determining whether this page is a historical version.
|
# Gets a Boolean determining whether this page is a historical version.
|
||||||
# Historical pages are pulled using exact SHA hashes and format all links
|
# Historical pages are pulled using exact SHA hashes and format all links
|
||||||
# with rel="nofollow"
|
# with rel="nofollow"
|
||||||
#
|
#
|
||||||
@@ -244,14 +247,15 @@ module Gollum
|
|||||||
# Returns the String extension (no leading period).
|
# Returns the String extension (no leading period).
|
||||||
def self.format_to_ext(format)
|
def self.format_to_ext(format)
|
||||||
case format
|
case format
|
||||||
when :markdown then 'md'
|
when :markdown then 'md'
|
||||||
when :textile then 'textile'
|
when :textile then 'textile'
|
||||||
when :rdoc then 'rdoc'
|
when :rdoc then 'rdoc'
|
||||||
when :org then 'org'
|
when :org then 'org'
|
||||||
when :creole then 'creole'
|
when :creole then 'creole'
|
||||||
when :rest then 'rest'
|
when :rest then 'rest'
|
||||||
when :asciidoc then 'asciidoc'
|
when :asciidoc then 'asciidoc'
|
||||||
when :pod then 'pod'
|
when :pod then 'pod'
|
||||||
|
when :mediawiki then 'mediawiki'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -280,7 +284,7 @@ module Gollum
|
|||||||
def find(name, version)
|
def find(name, version)
|
||||||
map = @wiki.tree_map_for(version.to_s)
|
map = @wiki.tree_map_for(version.to_s)
|
||||||
if page = find_page_in_tree(map, name)
|
if page = find_page_in_tree(map, name)
|
||||||
page.version = version.is_a?(Grit::Commit) ?
|
page.version = version.is_a?(Grit::Commit) ?
|
||||||
version : @wiki.commit_for(version)
|
version : @wiki.commit_for(version)
|
||||||
page.historical = page.version.to_s == version.to_s
|
page.historical = page.version.to_s == version.to_s
|
||||||
page
|
page
|
||||||
@@ -293,7 +297,7 @@ module Gollum
|
|||||||
# map - The Array tree map from Wiki#tree_map.
|
# map - The Array tree map from Wiki#tree_map.
|
||||||
# name - The canonical String page name.
|
# name - The canonical String page name.
|
||||||
# checked_dir - Optional String of the directory a matching page needs
|
# checked_dir - Optional String of the directory a matching page needs
|
||||||
# to be in. The string should
|
# to be in. The string should
|
||||||
#
|
#
|
||||||
# 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)
|
||||||
@@ -352,7 +356,7 @@ module Gollum
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads a sub page. Sub page nanes (footers) are prefixed with
|
# Loads a sub page. Sub page nanes (footers) are prefixed with
|
||||||
# an underscore to distinguish them from other Pages.
|
# an underscore to distinguish them from other Pages.
|
||||||
#
|
#
|
||||||
# name - String page name.
|
# name - String page name.
|
||||||
|
|||||||
+6
-5
@@ -22,11 +22,12 @@ def testpath(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cloned_testpath(path)
|
def cloned_testpath(path)
|
||||||
path = testpath(path)
|
repo = File.expand_path(testpath(path))
|
||||||
cloned = path.chomp('.git')
|
path = File.dirname(repo)
|
||||||
FileUtils.rm_rf cloned
|
cloned = File.join(path, self.class.name)
|
||||||
Dir.chdir(File.expand_path(File.dirname(path))) do
|
FileUtils.rm_rf(cloned)
|
||||||
%x{git clone #{File.basename(path)}}
|
Dir.chdir(path) do
|
||||||
|
%x{git clone #{File.basename(repo)} #{self.class.name}}
|
||||||
end
|
end
|
||||||
cloned
|
cloned
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -134,4 +134,13 @@ context "Page" do
|
|||||||
assert_equal '', Gollum::Page.cname(nil)
|
assert_equal '', Gollum::Page.cname(nil)
|
||||||
assert_equal '', Gollum::Page.cname(3)
|
assert_equal '', Gollum::Page.cname(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "normalize_dir" do
|
||||||
|
assert_equal "", Gollum::BlobEntry.normalize_dir("")
|
||||||
|
assert_equal "", Gollum::BlobEntry.normalize_dir(".")
|
||||||
|
assert_equal "", Gollum::BlobEntry.normalize_dir("/")
|
||||||
|
assert_equal "", Gollum::BlobEntry.normalize_dir("c:/")
|
||||||
|
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("foo")
|
||||||
|
assert_equal "/foo", Gollum::BlobEntry.normalize_dir("/foo")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -8,7 +8,7 @@ context "Page Reverting" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm_rf @path
|
FileUtils.rm_rf(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "reverts single commit" do
|
test "reverts single commit" do
|
||||||
|
|||||||
Reference in New Issue
Block a user