summaryrefslogtreecommitdiff
path: root/app/controllers/help_controller.rb
diff options
context:
space:
mode:
authorSullivan SENECHAL <soullivaneuh@gmail.com>2014-10-07 14:06:05 +0200
committerSullivan SENECHAL <sullivan@nexylan.com>2015-04-03 11:56:50 +0200
commitd365004e684e98459061fcd5fbaf9bea880934a8 (patch)
tree0a2961445ed5b23e97ed2c7f676bf6bf76a09e78 /app/controllers/help_controller.rb
parent0d0042d27481d31027a10edb2ba3a184bff5075a (diff)
downloadgitlab-ce-d365004e684e98459061fcd5fbaf9bea880934a8.tar.gz
Fix and improve help rendering
Diffstat (limited to 'app/controllers/help_controller.rb')
-rw-r--r--app/controllers/help_controller.rb28
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