diff options
author | Robert Speicher <robert@gitlab.com> | 2017-09-21 17:35:09 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-09-21 17:35:09 +0000 |
commit | 6c0473ef6fa8255167eb26c288ac50af537cefbc (patch) | |
tree | 60e00bd2fdaeaeab2c31c2354f4855ed824cdece | |
parent | 3ce3614089b16f670ac91524302280c906dd4815 (diff) | |
parent | 52ddf8e64db81458d2e87bbfb6071ae3d15c01ad (diff) | |
download | gitlab-ce-6c0473ef6fa8255167eb26c288ac50af537cefbc.tar.gz |
Merge branch 'hide-frontmatter-help-page' into 'master'
Do not show YAML frontmatter for doc pages under /help
See merge request gitlab-org/gitlab-ce!14345
-rw-r--r-- | app/controllers/help_controller.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 87c0f8905ff..572915a4930 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -3,8 +3,13 @@ class HelpController < ApplicationController layout 'help' + # Taken from Jekyll + # https://github.com/jekyll/jekyll/blob/3.5-stable/lib/jekyll/document.rb#L13 + YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m + def index - @help_index = File.read(Rails.root.join('doc', 'README.md')) + # Remove YAML frontmatter so that it doesn't look weird + @help_index = File.read(Rails.root.join('doc', 'README.md')).sub(YAML_FRONT_MATTER_REGEXP, '') # Prefix Markdown links with `help/` unless they are external links # See http://rubular.com/r/X3baHTbPO2 @@ -22,7 +27,8 @@ class HelpController < ApplicationController path = File.join(Rails.root, 'doc', "#{@path}.md") if File.exist?(path) - @markdown = File.read(path) + # Remove YAML frontmatter so that it doesn't look weird + @markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '') render 'show.html.haml' else |