This commit is contained in:
bootstraponline
2012-11-11 14:14:00 -07:00
parent 44edb8c7da
commit f699b82a9f
3 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ module Precious
DEFAULT_AUTHOR = 'you'
def title
@page.url_path.gsub("-", " ")
@page.url_path_title
end
def page_header
+21
View File
@@ -168,6 +168,27 @@ module Gollum
path
end
# Public: Defines title for page.rb
#
# Returns the String title
def url_path_title
metadata_title || url_path.gsub("-", " ")
end
# Public: Metadata title
#
# Set with <!-- --- title: New Title --> in page content
#
# Returns the String title or nil if not defined
def metadata_title
if metadata
title = metadata['title']
return title unless title.nil?
end
nil
end
# Public: The url_path, but CGI escaped.
#
# Returns the String url_path
+8
View File
@@ -198,6 +198,14 @@ context "Wiki page writing" do
assert_equal cd[:email], @wiki.repo.commits.first.author.email
end
test "page title override with metadata" do
@wiki.write_page("Gollum", :markdown, "<!-- --- title: Over -->", commit_details)
page = @wiki.page("Gollum")
assert_equal 'Over', page.url_path_title
end
test "update page with format change" do
@wiki.write_page("Gollum", :markdown, "# Gollum", commit_details)