diff --git a/bin/gollum b/bin/gollum index 2ea1aa17..b35f37d8 100755 --- a/bin/gollum +++ b/bin/gollum @@ -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 diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index ba68923a..73e22630 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -239,6 +239,7 @@ module Precious @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 @@ module Precious @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 diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index 4b4b738d..522b5ac1 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -8,7 +8,8 @@ module Precious 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 diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 553e3c6b..b33e0e9b 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -141,6 +141,10 @@ module Gollum # 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 @@ module Gollum @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.