Change Page#name to Page#filename, and add extension-less Page#name

This commit is contained in:
rick
2010-08-02 15:32:05 -07:00
parent ed576a88ce
commit f0b22390fb
4 changed files with 13 additions and 9 deletions
+2 -3
View File
@@ -9,7 +9,7 @@ module Gollum
# Returns a new Gollum::Markup object, ready for rendering.
def initialize(page)
@wiki = page.wiki
@name = page.name
@name = page.filename
@data = page.raw_data
@version = page.version.id
@dir = ::File.dirname(page.path)
@@ -267,8 +267,7 @@ module Gollum
%{<a href="#{name}">#{name}</a>}
else
if page = @wiki.page(cname)
pname = page.name.split('.')[0..-2].join('.')
link = ::File.join(@wiki.base_path, Page.cname(pname))
link = ::File.join(@wiki.base_path, Page.cname(page.name))
presence = "present"
else
link = ::File.join(@wiki.base_path, cname)
+7 -3
View File
@@ -48,10 +48,14 @@ module Gollum
# Public: The on-disk filename of the page including extension.
#
# Returns the String name.
def name
def filename
@blob && @blob.name
end
def name
filename.split('.')[0..-2].join('.').gsub('-', ' ')
end
# Public: If the first element of a formatted page is an <h1> tag it can
# be considered the title of the page and used in the display. If the
# first element is NOT an <h1> tag, the title will be constructed from the
@@ -79,7 +83,7 @@ module Gollum
if !header.empty?
Sanitize.clean(header.to_html)
else
Sanitize.clean(self.name.split('.')[0..-2].join('.').gsub('-', ' '))
Sanitize.clean(name)
end
end
@@ -152,7 +156,7 @@ module Gollum
#
# Returns the footer Page or nil if none exists.
def footer
return nil if page_match('_Footer', self.name)
return nil if page_match('_Footer', self.filename)
dirs = self.path.split('/')
dirs.pop
+1 -1
View File
@@ -154,7 +154,7 @@ module Gollum
else
map = delete_from_tree_map(map, page.path)
dir = ::File.dirname(page.path)
name = page.name.split('.')[0..-2].join('.')
name = page.name
map = add_to_tree_map(map, dir, name, format, data)
index = tree_map_to_index(map)
end
+3 -2
View File
@@ -36,7 +36,7 @@ context "Wiki" do
pages = @wiki.pages
assert_equal \
%w(Bilbo-Baggins.md Eye-Of-Sauron.md Home.textile My-<b>Precious.md),
pages.map { |p| p.name }.sort
pages.map { |p| p.filename }.sort
end
end
@@ -50,7 +50,8 @@ context "Wiki page previewing" do
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
assert_equal "# Bilbo", page.raw_data
assert_equal "<h1>Bilbo</h1>", page.formatted_data
assert_equal "Test.md", page.name
assert_equal "Test.md", page.filename
assert_equal "Test", page.name
end
end