Change Page#name to Page#filename, and add extension-less Page#name
This commit is contained in:
@@ -9,7 +9,7 @@ module Gollum
|
|||||||
# Returns a new Gollum::Markup object, ready for rendering.
|
# Returns a new Gollum::Markup object, ready for rendering.
|
||||||
def initialize(page)
|
def initialize(page)
|
||||||
@wiki = page.wiki
|
@wiki = page.wiki
|
||||||
@name = page.name
|
@name = page.filename
|
||||||
@data = page.raw_data
|
@data = page.raw_data
|
||||||
@version = page.version.id
|
@version = page.version.id
|
||||||
@dir = ::File.dirname(page.path)
|
@dir = ::File.dirname(page.path)
|
||||||
@@ -267,8 +267,7 @@ module Gollum
|
|||||||
%{<a href="#{name}">#{name}</a>}
|
%{<a href="#{name}">#{name}</a>}
|
||||||
else
|
else
|
||||||
if page = @wiki.page(cname)
|
if page = @wiki.page(cname)
|
||||||
pname = page.name.split('.')[0..-2].join('.')
|
link = ::File.join(@wiki.base_path, Page.cname(page.name))
|
||||||
link = ::File.join(@wiki.base_path, Page.cname(pname))
|
|
||||||
presence = "present"
|
presence = "present"
|
||||||
else
|
else
|
||||||
link = ::File.join(@wiki.base_path, cname)
|
link = ::File.join(@wiki.base_path, cname)
|
||||||
|
|||||||
+7
-3
@@ -48,10 +48,14 @@ module Gollum
|
|||||||
# Public: The on-disk filename of the page including extension.
|
# Public: The on-disk filename of the page including extension.
|
||||||
#
|
#
|
||||||
# Returns the String name.
|
# Returns the String name.
|
||||||
def name
|
def filename
|
||||||
@blob && @blob.name
|
@blob && @blob.name
|
||||||
end
|
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
|
# 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
|
# 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
|
# first element is NOT an <h1> tag, the title will be constructed from the
|
||||||
@@ -79,7 +83,7 @@ module Gollum
|
|||||||
if !header.empty?
|
if !header.empty?
|
||||||
Sanitize.clean(header.to_html)
|
Sanitize.clean(header.to_html)
|
||||||
else
|
else
|
||||||
Sanitize.clean(self.name.split('.')[0..-2].join('.').gsub('-', ' '))
|
Sanitize.clean(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -152,7 +156,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the footer Page or nil if none exists.
|
# Returns the footer Page or nil if none exists.
|
||||||
def footer
|
def footer
|
||||||
return nil if page_match('_Footer', self.name)
|
return nil if page_match('_Footer', self.filename)
|
||||||
|
|
||||||
dirs = self.path.split('/')
|
dirs = self.path.split('/')
|
||||||
dirs.pop
|
dirs.pop
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ module Gollum
|
|||||||
else
|
else
|
||||||
map = delete_from_tree_map(map, page.path)
|
map = delete_from_tree_map(map, page.path)
|
||||||
dir = ::File.dirname(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)
|
map = add_to_tree_map(map, dir, name, format, data)
|
||||||
index = tree_map_to_index(map)
|
index = tree_map_to_index(map)
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-2
@@ -36,7 +36,7 @@ context "Wiki" do
|
|||||||
pages = @wiki.pages
|
pages = @wiki.pages
|
||||||
assert_equal \
|
assert_equal \
|
||||||
%w(Bilbo-Baggins.md Eye-Of-Sauron.md Home.textile My-<b>Precious.md),
|
%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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -50,7 +50,8 @@ context "Wiki page previewing" do
|
|||||||
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
||||||
assert_equal "# Bilbo", page.raw_data
|
assert_equal "# Bilbo", page.raw_data
|
||||||
assert_equal "<h1>Bilbo</h1>", page.formatted_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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user