Skip to content

Commit

Permalink
Fix #539
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Nov 11, 2012
1 parent 44edb8c commit f699b82
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gollum/frontend/views/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Page < Layout
DEFAULT_AUTHOR = 'you'

def title
@page.url_path.gsub("-", " ")
@page.url_path_title
end

def page_header
Expand Down
21 changes: 21 additions & 0 deletions lib/gollum/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/test_wiki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f699b82

Please sign in to comment.