diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-04 15:23:32 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-04 15:23:32 +0300 |
commit | 45ca39e81bf857cdb58b1a184b8fab0e56c200f7 (patch) | |
tree | f6df41eab9f5f66ee4ff86196634bb331d9aff84 /app/controllers | |
parent | 124e7d5efc53cfacf6fb579328245e0619c73c9d (diff) | |
parent | 9925051ece7bd8758cda9179340b734f6f5c522f (diff) |
Merge remote-tracking branch 'github.com/master'
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/help_controller.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index c4d620d87b1..fbd9e67e6df 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -3,17 +3,35 @@ class HelpController < ApplicationController end def show - @category = params[:category] - @file = params[:file] + @filepath = params[:filepath] + @format = params[:format] - if File.exists?(Rails.root.join('doc', @category, @file + '.md')) - render 'show' + respond_to do |format| + format.md { render_doc } + format.all { send_file_data } + end + end + + def shortcuts + end + + private + + def render_doc + if File.exists?(Rails.root.join('doc', @filepath + '.md')) + render 'show.html.haml' else not_found! end end - def shortcuts + def send_file_data + path = Rails.root.join('doc', "#{@filepath}.#{@format}") + if File.exists?(path) + send_file(path, disposition: 'inline') + else + head :not_found + end end def ui |