Class: HelpController

Inherits:
ApplicationController show all
Defined in:
app/controllers/help_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Instance Method Details

#indexObject


6
7
8
9
10
11
12
# File 'app/controllers/help_controller.rb', line 6

def index
  @help_index = File.read(Rails.root.join('doc', 'README.md'))

  # Prefix Markdown links with `help/` unless they already have been
  # See http://rubular.com/r/nwwhzH6Z8X
  @help_index.gsub!(/(\]\()(?!help\/)([^\)\(]+)(\))/, '\1help/\2\3')
end

#shortcutsObject


50
51
# File 'app/controllers/help_controller.rb', line 50

def shortcuts
end

#showObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/help_controller.rb', line 14

def show
  @category = clean_path_info(path_params[:category])
  @file = path_params[:file]

  respond_to do |format|
    format.any(:markdown, :md, :html) do
      # Note: We are purposefully NOT using `Rails.root.join`
      path = File.join(Rails.root, 'doc', @category, "#{@file}.md")

      if File.exist?(path)
        @markdown = File.read(path)

        render 'show.html.haml'
      else
        # Force template to Haml
        render 'errors/not_found.html.haml', layout: 'errors', status: 404
      end
    end

    # Allow access to images in the doc folder
    format.any(:png, :gif, :jpeg) do
      # Note: We are purposefully NOT using `Rails.root.join`
      path = File.join(Rails.root, 'doc', @category, "#{@file}.#{params[:format]}")

      if File.exist?(path)
        send_file(path, disposition: 'inline')
      else
        head :not_found
      end
    end

    # Any other format we don't recognize, just respond 404
    format.any { head :not_found }
  end
end

#uiObject


53
54
55
# File 'app/controllers/help_controller.rb', line 53

def ui
  @user = User.new(id: 0, name: 'John Doe', username: '@johndoe')
end