Permalink
Browse files

Fix #579

  • Loading branch information...
1 parent f699b82 commit 470a7b8f52324fdc9007b1d3febbfc3500d19768 @bootstraponline bootstraponline committed Nov 11, 2012
Showing with 12 additions and 1 deletion.
  1. +3 −0 bin/gollum
  2. +2 −0 lib/gollum/frontend/app.rb
  3. +2 −1 lib/gollum/frontend/views/page.rb
  4. +5 −0 lib/gollum/wiki.rb
View
@@ -80,6 +80,9 @@ opts = OptionParser.new do |opts|
opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
wiki_options[:collapse_tree] = true
end
+ opts.on("--h1-title", "Sets page title to value of first h1") do
+ wiki_options[:h1_title] = true
+ end
end
# Read command line options into `options` hash
@@ -239,6 +239,7 @@ def wiki_new
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@css = wiki.css
+ @h1_title = wiki.h1_title
@editable = false
mustache :page
end
@@ -362,6 +363,7 @@ def show_page_or_file(fullpath)
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@css = wiki.css
+ @h1_title = wiki.h1_title
mustache :page
elsif file = wiki.file(fullpath)
content_type file.mime_type
@@ -8,7 +8,8 @@ class Page < Layout
DEFAULT_AUTHOR = 'you'
def title
- @page.url_path_title
+ h1 = @h1_title ? page_header_from_content(@content) : false
+ h1 || @page.url_path_title
end
def page_header
View
@@ -141,6 +141,10 @@ def history_sanitization
# Defaults to false
attr_reader :css
+ # Sets page title to value of first h1
+ # Defaults to false
+ attr_reader :h1_title
+
# Public: Initialize a new Gollum Repo.
#
# path - The String path to the Git repository that holds the Gollum
@@ -196,6 +200,7 @@ def initialize(path, options = {})
@show_all = options.fetch :show_all, false
@collapse_tree = options.fetch :collapse_tree, false
@css = options.fetch :css, false
+ @h1_title = options.fetch :h1_title, false
end
# Public: check whether the wiki's git repo exists on the filesystem.

0 comments on commit 470a7b8

Please sign in to comment.