diff --git a/.travis.yml b/.travis.yml
index 18e4b577..01437ec0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,10 @@
rvm:
- - 2.0.0
- 2.1.0
- 2.1.1
- - 2.2.2
+ - 2.2.1
- 2.3.0
- - jruby-19mode
+ - 2.4.0
+ - jruby-9.1.8.0
before_install:
- sudo apt-get update
- sudo apt-get install libicu-dev
diff --git a/README.md b/README.md
index cd9a1efd..27fec06f 100644
--- a/README.md
+++ b/README.md
@@ -150,6 +150,7 @@ Gollum comes with the following command line options:
| --mathjax | none | Enables MathJax (renders mathematical equations). By default, uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.5 |
| --irb | none | Launch Gollum in "console mode", with a [predefined API](https://github.com/gollum/gollum-lib/). |
| --h1-title | none | Tell Gollum to use the first `
` as page title. |
+| --no-display-metadata | none | Do not render metadata tables in pages. |
| --show-all | none | Tell Gollum to also show files in the file view. By default, only valid pages are shown. |
| --collapse-tree | none | Tell Gollum to collapse the file tree, when the file view is opened. By default, the tree is expanded. |
| --user-icons | [MODE] | Tell Gollum to use specific user icons for history view. Can be set to `gravatar`, `identicon` or `none`. Default: `none`. |
diff --git a/bin/gollum b/bin/gollum
index d8b130bb..a3aa6bc1 100755
--- a/bin/gollum
+++ b/bin/gollum
@@ -131,6 +131,9 @@ MSG
opts.on("--h1-title", "Use the first '' as page title.") do
wiki_options[:h1_title] = true
end
+ opts.on("--no-display-metadata", "Do not render metadata tables in pages.") do
+ wiki_options[:display_metadata] = false
+ end
opts.on("--show-all", "Also show files in the file view. By default, only valid pages are shown.") do
wiki_options[:show_all] = true
end
diff --git a/gollum.gemspec b/gollum.gemspec
index f9618080..ed271c39 100644
--- a/gollum.gemspec
+++ b/gollum.gemspec
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ['--charset=UTF-8']
s.extra_rdoc_files = %w[README.md LICENSE]
- s.add_dependency 'gollum-lib', '~> 4.0', '>= 4.0.1'
+ s.add_dependency 'gollum-lib', '~> 5.0.a'
s.add_dependency 'kramdown', '~> 1.9.0'
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4'
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
diff --git a/lib/gollum/public/gollum/css/template.css b/lib/gollum/public/gollum/css/template.css
index 6bde233e..ff170265 100644
--- a/lib/gollum/public/gollum/css/template.css
+++ b/lib/gollum/public/gollum/css/template.css
@@ -385,7 +385,9 @@ a:active, a:hover {
}
.markdown-body table tr th,
-.markdown-body table tr td {
+.markdown-body table tr td,
+.markdown-body table tr td table,
+.markdown-body table tr th table {
border: 1px solid #ccc;
text-align: none;
margin: 0;
diff --git a/lib/gollum/templates/page.mustache b/lib/gollum/templates/page.mustache
index f23aec2a..b00f1205 100644
--- a/lib/gollum/templates/page.mustache
+++ b/lib/gollum/templates/page.mustache
@@ -69,6 +69,7 @@ Mousetrap.bind(['e'], function( e ) {
{{/has_header}}
+ {{{rendered_metadata}}}
{{{content}}}
diff --git a/lib/gollum/views/page.rb b/lib/gollum/views/page.rb
index 3e7c243c..0fa879df 100644
--- a/lib/gollum/views/page.rb
+++ b/lib/gollum/views/page.rb
@@ -130,13 +130,21 @@ module Precious
# Access to embedded metadata.
#
- # Examples
- #
- # {{#metadata}}{{name}}{{/metadata}}
- #
# Returns Hash.
def metadata
@page.metadata
+ end
+
+ # Access to embedded metadata.
+ #
+ # Examples
+ #
+ # {{#rendered_metadata}}{{name}}{{/rendered_metadata}}
+ #
+ # Returns HTML table.
+ def rendered_metadata
+ return '' unless page.display_metadata? && !metadata.empty?
+ @rendered_metadata ||= table(metadata)
end
private
@@ -184,6 +192,26 @@ module Precious
# .inner_html will cause href escaping on UTF-8
doc.css("div#gollum-root").children.to_xml(@@to_xml)
end
+
+ def table(data)
+ return data.to_s if data.empty?
+ result = "\n"
+ keys = data.respond_to?(:keys) && data.respond_to?(:values) ? data.keys : nil
+ if keys
+ data = data.values
+ result << "\n"
+ keys.each do |heading|
+ result << "| #{CGI.escapeHTML(heading)} | \n"
+ end
+ result << "
\n"
+ end
+ result << "\n"
+ data.each do |value|
+ result << "| " << (value.respond_to?(:each) ? table(value) : CGI.escapeHTML(value.to_s)) << " | \n"
+ end
+ result << "
\n
\n"
+ end
+
end
end
end
diff --git a/test/test_app.rb b/test/test_app.rb
index 5a0da233..da912de7 100644
--- a/test/test_app.rb
+++ b/test/test_app.rb
@@ -636,11 +636,11 @@ context "Frontend with lotr" do
body = last_response.body
- assert body.include?("Bilbo Baggins"), "/pages should include the page 'Bilbo Baggins'"
+ assert body.include?("Bilbo-Baggins"), "/pages should include the page 'Bilbo Baggins'"
assert body.include?("Gondor"), "/pages should include the folder 'Gondor'"
assert !body.include?("Boromir"), "/pages should NOT include the page 'Boromir'"
assert body.include?("Mordor"), "/pages should include the folder 'Mordor'"
- assert !body.include?("Eye Of Sauron"), "/pages should NOT include the page 'Eye Of Sauron'"
+ assert !body.include?("Eye-Of-Sauron"), "/pages should NOT include the page 'Eye Of Sauron'"
assert !body.match(/(Zamin).+(roast\-mutton)/m), "/pages should be sorted alphabetically"
end
@@ -650,8 +650,8 @@ context "Frontend with lotr" do
body = last_response.body
- assert !body.include?("Bilbo Baggins"), "/pages/Mordor/ should NOT include the page 'Bilbo Baggins'"
- assert body.include?("Eye Of Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
+ assert !body.include?("Bilbo-Baggins"), "/pages/Mordor/ should NOT include the page 'Bilbo Baggins'"
+ assert body.include?("Eye-Of-Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
end
test "symbolic link pages" do
diff --git a/test/test_page_view.rb b/test/test_page_view.rb
index c4da61d4..af069896 100644
--- a/test/test_page_view.rb
+++ b/test/test_page_view.rb
@@ -29,6 +29,28 @@ context "Precious::Views::Page" do
assert_equal '1 & 2', actual
end
+ test "metadata is rendered into a table" do
+ title = 'metadata test'
+ @wiki.write_page(title, :markdown, "---\nsome: metadata\nhere: for you\n---\n# Some markdown\nIn this doc")
+ page = @wiki.page(title)
+
+ @view = Precious::Views::Page.new
+ @view.instance_variable_set :@page, page
+
+ assert_equal @view.rendered_metadata, <<-EOS
+
+
+| some |
+here |
+
+
+| metadata |
+for you |
+
+
+EOS
+ end
+
test "h1 title can be disabled" do
title = 'H1'
@wiki.write_page(title, :markdown, '# 1 & 2 ' + "\n # 3", commit_details)