Permalink
Browse files

Fix #539

  • Loading branch information...
1 parent 44edb8c commit f699b82a9f135b5d8d609b1d271819e6d6880bbd @bootstraponline bootstraponline committed Nov 11, 2012
Showing with 30 additions and 1 deletion.
  1. +1 −1 lib/gollum/frontend/views/page.rb
  2. +21 −0 lib/gollum/page.rb
  3. +8 −0 test/test_wiki.rb
@@ -8,7 +8,7 @@ class Page < Layout
DEFAULT_AUTHOR = 'you'
def title
- @page.url_path.gsub("-", " ")
+ @page.url_path_title
end
def page_header
View
@@ -168,6 +168,27 @@ def url_path
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
View
@@ -198,6 +198,14 @@
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)

0 comments on commit f699b82

Please sign in to comment.