Commit c68e3f77 authored by Marin Jankovski's avatar Marin Jankovski

Render images in help pages.

parent e4cd0c93
...@@ -5,8 +5,12 @@ class HelpController < ApplicationController ...@@ -5,8 +5,12 @@ class HelpController < ApplicationController
def show def show
@category = params[:category] @category = params[:category]
@file = params[:file] @file = params[:file]
format = params[:format] || 'md'
file_path = Rails.root.join('doc', @category, @file + ".#{format}")
if File.exists?(Rails.root.join('doc', @category, @file + '.md')) if %w(png jpg jpeg gif).include?(format)
send_file file_path, disposition: 'inline'
elsif File.exists?(file_path)
render 'show' render 'show'
else else
not_found! not_found!
......
...@@ -34,6 +34,7 @@ Gitlab::Application.routes.draw do ...@@ -34,6 +34,7 @@ Gitlab::Application.routes.draw do
get 'help' => 'help#index' get 'help' => 'help#index'
get 'help/:category/:file' => 'help#show', as: :help_page get 'help/:category/:file' => 'help#show', as: :help_page
get 'help/:category/*file' => 'help#show'
get 'help/shortcuts' get 'help/shortcuts'
# #
......
...@@ -8,7 +8,7 @@ class Spinach::Features::Help < Spinach::FeatureSteps ...@@ -8,7 +8,7 @@ class Spinach::Features::Help < Spinach::FeatureSteps
end end
step 'I visit the "Rake Tasks" help page' do step 'I visit the "Rake Tasks" help page' do
visit help_page_path("raketasks", "maintenance") visit help_page_path("raketasks", "maintenance.md")
end end
step 'I should see "Rake Tasks" page markdown rendered' do step 'I should see "Rake Tasks" page markdown rendered' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment