diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /app/controllers/help_controller.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'app/controllers/help_controller.rb')
-rw-r--r-- | app/controllers/help_controller.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 1508531828d..9635e476510 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -12,8 +12,7 @@ class HelpController < ApplicationController YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m.freeze def index - # Remove YAML frontmatter so that it doesn't look weird - @help_index = File.read(path_to_doc('index.md')).sub(YAML_FRONT_MATTER_REGEXP, '') + @help_index = get_markdown_without_frontmatter(path_to_doc('index.md')) # Prefix Markdown links with `help/` unless they are external links. # '//' not necessarily part of URL, e.g., mailto:mail@example.com @@ -59,8 +58,25 @@ class HelpController < ApplicationController @instance_configuration = InstanceConfiguration.new end + def drawers + @clean_path = Rack::Utils.clean_path_info(params[:markdown_file]) + @path = path_to_doc("#{@clean_path}.md") + + if File.exist?(@path) + render :drawers, formats: :html, layout: false + else + head :not_found + end + end + private + # Remove YAML frontmatter so that it doesn't look weird + helper_method :get_markdown_without_frontmatter + def get_markdown_without_frontmatter(path) + File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '') + end + def redirect_to_documentation_website? Gitlab::UrlSanitizer.valid_web?(documentation_url) end @@ -100,8 +116,7 @@ class HelpController < ApplicationController path = path_to_doc("#{@path}.md") if File.exist?(path) - # Remove YAML frontmatter so that it doesn't look weird - @markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '') + @markdown = get_markdown_without_frontmatter(path) render :show, formats: :html else |