Commit 3358afa7 authored by Connor Shea's avatar Connor Shea

Update the help_page_path route to accept paths directly instead of using parameters.

parent 61f0e894
...@@ -12,13 +12,12 @@ class HelpController < ApplicationController ...@@ -12,13 +12,12 @@ class HelpController < ApplicationController
end end
def show def show
@category = clean_path_info(path_params[:category]) @path = path_params[:path]
@file = path_params[:file]
respond_to do |format| respond_to do |format|
format.any(:markdown, :md, :html) do format.any(:markdown, :md, :html) do
# Note: We are purposefully NOT using `Rails.root.join` # Note: We are purposefully NOT using `Rails.root.join`
path = File.join(Rails.root, 'doc', @category, "#{@file}.md") path = File.join(Rails.root, 'doc', "#{@path}.md")
if File.exist?(path) if File.exist?(path)
@markdown = File.read(path) @markdown = File.read(path)
...@@ -33,7 +32,7 @@ class HelpController < ApplicationController ...@@ -33,7 +32,7 @@ class HelpController < ApplicationController
# Allow access to images in the doc folder # Allow access to images in the doc folder
format.any(:png, :gif, :jpeg) do format.any(:png, :gif, :jpeg) do
# Note: We are purposefully NOT using `Rails.root.join` # Note: We are purposefully NOT using `Rails.root.join`
path = File.join(Rails.root, 'doc', @category, "#{@file}.#{params[:format]}") path = File.join(Rails.root, 'doc', "#{@path}.#{params[:format]}")
if File.exist?(path) if File.exist?(path)
send_file(path, disposition: 'inline') send_file(path, disposition: 'inline')
...@@ -57,8 +56,7 @@ class HelpController < ApplicationController ...@@ -57,8 +56,7 @@ class HelpController < ApplicationController
private private
def path_params def path_params
params.require(:category) params.require(:path)
params.require(:file)
params params
end end
......
...@@ -43,15 +43,15 @@ module SearchHelper ...@@ -43,15 +43,15 @@ module SearchHelper
# Autocomplete results for internal help pages # Autocomplete results for internal help pages
def help_autocomplete def help_autocomplete
[ [
{ category: "Help", label: "API Help", url: help_page_path("api", "README") }, { category: "Help", label: "API Help", url: help_page_path("api/README") },
{ category: "Help", label: "Markdown Help", url: help_page_path("markdown", "markdown") }, { category: "Help", label: "Markdown Help", url: help_page_path("markdown/markdown") },
{ category: "Help", label: "Permissions Help", url: help_page_path("permissions", "permissions") }, { category: "Help", label: "Permissions Help", url: help_page_path("permissions/permissions") },
{ category: "Help", label: "Public Access Help", url: help_page_path("public_access", "public_access") }, { category: "Help", label: "Public Access Help", url: help_page_path("public_access/public_access") },
{ category: "Help", label: "Rake Tasks Help", url: help_page_path("raketasks", "README") }, { category: "Help", label: "Rake Tasks Help", url: help_page_path("raketasks/README") },
{ category: "Help", label: "SSH Keys Help", url: help_page_path("ssh", "README") }, { category: "Help", label: "SSH Keys Help", url: help_page_path("ssh/README") },
{ category: "Help", label: "System Hooks Help", url: help_page_path("system_hooks", "system_hooks") }, { category: "Help", label: "System Hooks Help", url: help_page_path("system_hooks/system_hooks") },
{ category: "Help", label: "Webhooks Help", url: help_page_path("web_hooks", "web_hooks") }, { category: "Help", label: "Webhooks Help", url: help_page_path("web_hooks/web_hooks") },
{ category: "Help", label: "Workflow Help", url: help_page_path("workflow", "README") }, { category: "Help", label: "Workflow Help", url: help_page_path("workflow/README") },
] ]
end end
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
.col-sm-10 .col-sm-10
= f.text_area :description, class: "form-control", rows: 10 = f.text_area :description, class: "form-control", rows: 10
.hint .hint
Description parsed with #{link_to "GitLab Flavored Markdown", help_page_path('markdown', 'markdown'), target: '_blank'}. Description parsed with #{link_to "GitLab Flavored Markdown", help_page_path('markdown/markdown'), target: '_blank'}.
.form-group .form-group
= f.label :logo, class: 'control-label' = f.label :logo, class: 'control-label'
.col-sm-10 .col-sm-10
......
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
= source = source
%span.help-block#import-sources-help %span.help-block#import-sources-help
Enabled sources for code import during project creation. OmniAuth must be configured for GitHub Enabled sources for code import during project creation. OmniAuth must be configured for GitHub
= link_to "(?)", help_page_path("integration", "github") = link_to "(?)", help_page_path("integration/github")
, Bitbucket , Bitbucket
= link_to "(?)", help_page_path("integration", "bitbucket") = link_to "(?)", help_page_path("integration/bitbucket")
and GitLab.com and GitLab.com
= link_to "(?)", help_page_path("integration", "gitlab") = link_to "(?)", help_page_path("integration/gitlab")
.form-group .form-group
%label.control-label.col-sm-2 Enabled Git access protocols %label.control-label.col-sm-2 Enabled Git access protocols
.col-sm-10 .col-sm-10
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
.col-sm-10 .col-sm-10
%p.light %p.light
Paste a machine public key here. Read more about how to generate it Paste a machine public key here. Read more about how to generate it
= link_to "here", help_page_path("ssh", "README") = link_to "here", help_page_path("ssh/README")
= f.text_area :key, class: "form-control thin_area", rows: 5 = f.text_area :key, class: "form-control thin_area", rows: 5
.form-actions .form-actions
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
.panel-body.form-holder .panel-body.form-holder
%p.light %p.light
Read more about project permissions Read more about project permissions
%strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink" %strong= link_to "here", help_page_path("permissions/permissions"), class: "vlink"
= form_tag members_update_admin_group_path(@group), id: "new_project_member", class: "bulk_import", method: :put do = form_tag members_update_admin_group_path(@group), id: "new_project_member", class: "bulk_import", method: :put do
%div %div
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
System hooks System hooks
%p.light %p.light
#{link_to "System hooks ", help_page_path("system_hooks", "system_hooks"), class: "vlink"} can be #{link_to "System hooks ", help_page_path("system_hooks/system_hooks"), class: "vlink"} can be
used for binding events when GitLab creates a User or Project. used for binding events when GitLab creates a User or Project.
%hr %hr
......
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
- else - else
passed. passed.
= link_to icon('question-circle'), help_page_path('administration', 'repository_checks') = link_to icon('question-circle'), help_page_path('administration/repository_checks')
.form-group .form-group
= f.submit 'Trigger repository check', class: 'btn btn-primary' = f.submit 'Trigger repository check', class: 'btn btn-primary'
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
%h3 Access Denied %h3 Access Denied
%hr %hr
%p You are not allowed to access this page. %p You are not allowed to access this page.
%p Read more about project permissions #{link_to "here", help_page_path("permissions", "permissions"), class: "vlink"} %p Read more about project permissions #{link_to "here", help_page_path("permissions/permissions"), class: "vlink"}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
= select_tag :access_level, options_for_select(GroupMember.access_level_roles, @group_member.access_level), class: "project-access-select select2" = select_tag :access_level, options_for_select(GroupMember.access_level_roles, @group_member.access_level), class: "project-access-select select2"
.help-block .help-block
Read more about role permissions Read more about role permissions
%strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink" %strong= link_to "here", help_page_path("permissions/permissions"), class: "vlink"
.form-actions .form-actions
= f.submit 'Add users to group', class: "btn btn-create" = f.submit 'Add users to group', class: "btn btn-create"
- page_title @file.humanize, *@category.split("/").reverse.map(&:humanize) - page_title @path.split("/").reverse.map(&:humanize)
.documentation.wiki .documentation.wiki
= markdown @markdown.gsub('$your_email', current_user.try(:email) || "email@example.com") = markdown @markdown.gsub('$your_email', current_user.try(:email) || "email@example.com")
...@@ -549,4 +549,4 @@ ...@@ -549,4 +549,4 @@
%li wiki page %li wiki page
%li help page %li help page
You can check how markdown rendered at #{link_to 'Markdown help page', help_page_path("markdown", "markdown")}. You can check how markdown rendered at #{link_to 'Markdown help page', help_page_path("markdown/markdown")}.
...@@ -38,6 +38,6 @@ ...@@ -38,6 +38,6 @@
As an administrator you may like to configure As an administrator you may like to configure
- else - else
Consider asking your GitLab administrator to configure Consider asking your GitLab administrator to configure
= link_to 'GitHub integration', help_page_path("integration", "github") = link_to 'GitHub integration', help_page_path("integration/github")
which will allow login via GitHub and allow importing projects without which will allow login via GitHub and allow importing projects without
generating a Personal Access Token. generating a Personal Access Token.
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
Add an SSH key Add an SSH key
%p.profile-settings-content %p.profile-settings-content
Before you can add an SSH key you need to Before you can add an SSH key you need to
= link_to "generate it.", help_page_path("ssh", "README") = link_to "generate it.", help_page_path("ssh/README")
= render 'form' = render 'form'
%hr %hr
%h5 %h5
......
...@@ -43,12 +43,12 @@ ...@@ -43,12 +43,12 @@
.form-group .form-group
= f.label :dashboard, class: 'label-light' do = f.label :dashboard, class: 'label-light' do
Default Dashboard Default Dashboard
= link_to('(?)', help_page_path('profile', 'preferences') + '#default-dashboard', target: '_blank') = link_to('(?)', help_page_path('profile/preferences') + '#default-dashboard', target: '_blank')
= f.select :dashboard, dashboard_choices, {}, class: 'form-control' = f.select :dashboard, dashboard_choices, {}, class: 'form-control'
.form-group .form-group
= f.label :project_view, class: 'label-light' do = f.label :project_view, class: 'label-light' do
Project view Project view
= link_to('(?)', help_page_path('profile', 'preferences') + '#default-project-view', target: '_blank') = link_to('(?)', help_page_path('profile/preferences') + '#default-project-view', target: '_blank')
= f.select :project_view, project_view_choices, {}, class: 'form-control' = f.select :project_view, project_view_choices, {}, class: 'form-control'
.help-block .help-block
Choose what content you want to see on a project's home page. Choose what content you want to see on a project's home page.
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
- else - else
%p %p
Download the Google Authenticator application from App Store or Google Play Store and scan this code. Download the Google Authenticator application from App Store or Google Play Store and scan this code.
More information is available in the #{link_to('documentation', help_page_path('profile', 'two_factor_authentication'))}. More information is available in the #{link_to('documentation', help_page_path('profile/two_factor_authentication'))}.
.row.append-bottom-10 .row.append-bottom-10
.col-md-3 .col-md-3
= raw @qr_code = raw @qr_code
......
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
as administrator you need to configure as administrator you need to configure
- else - else
ask your GitLab administrator to configure ask your GitLab administrator to configure
== #{link_to 'OAuth integration', help_page_path("integration", "bitbucket")}. == #{link_to 'OAuth integration', help_page_path("integration/bitbucket")}.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- unless @repository.gitlab_ci_yml - unless @repository.gitlab_ci_yml
.form-group .form-group
%p Builds need to be configured before you can begin using Continuous Integration. %p Builds need to be configured before you can begin using Continuous Integration.
= link_to 'Get started with Builds', help_page_path('ci', 'quick_start', 'README'), class: 'btn btn-info' = link_to 'Get started with Builds', help_page_path('ci/quick_start/README'), class: 'btn btn-info'
.form-group .form-group
%p Get recent application code using the following command: %p Get recent application code using the following command:
.radio .radio
......
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
as administrator you need to configure as administrator you need to configure
- else - else
ask your GitLab administrator to configure ask your GitLab administrator to configure
== #{link_to 'OAuth integration', help_page_path("integration", "gitlab")}. == #{link_to 'OAuth integration', help_page_path("integration/gitlab")}.
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
%strong Only allow merge requests to be merged if the build succeeds %strong Only allow merge requests to be merged if the build succeeds
.help-block .help-block
Builds need to be configured to enable this feature. Builds need to be configured to enable this feature.
= link_to icon('question-circle'), help_page_path('workflow', 'merge_requests', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds') = link_to icon('question-circle'), help_page_path('workflow/merge_requests', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds')
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post
- unless @repository.gitlab_ci_yml - unless @repository.gitlab_ci_yml
= link_to 'Get started with Builds', help_page_path('ci/quick_start', 'README'), class: 'btn btn-info' = link_to 'Get started with Builds', help_page_path('ci/quick_start/README'), class: 'btn btn-info'
= link_to ci_lint_path, class: 'btn btn-default' do = link_to ci_lint_path, class: 'btn btn-default' do
%span CI Lint %span CI Lint
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
.form-group .form-group
%p.light.append-bottom-0 %p.light.append-bottom-0
Paste a machine public key here. Read more about how to generate it Paste a machine public key here. Read more about how to generate it
= link_to "here", help_page_path("ssh", "README") = link_to "here", help_page_path("ssh/README")
= f.submit "Add key", class: "btn-create btn" = f.submit "Add key", class: "btn-create btn"
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
.form-group.project-visibility-level-holder .form-group.project-visibility-level-holder
= f.label :visibility_level, class: 'label-light' do = f.label :visibility_level, class: 'label-light' do
Visibility Level Visibility Level
= link_to "(?)", help_page_path("public_access", "public_access") = link_to "(?)", help_page_path("public_access/public_access")
- if can_change_visibility_level?(@project, current_user) - if can_change_visibility_level?(@project, current_user)
= render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: @project.visibility_level, form_model: @project) = render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: @project.visibility_level, form_model: @project)
- else - else
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
Environments are places where code gets deployed, such as staging or production. Environments are places where code gets deployed, such as staging or production.
%br %br
= succeed "." do = succeed "." do
= link_to "Read more about environments", help_page_path("ci", "environments") = link_to "Read more about environments", help_page_path("ci/environments")
- if can?(current_user, :create_environment, @project) - if can?(current_user, :create_environment, @project)
= link_to new_namespace_project_environment_path(@project.namespace, @project), class: 'btn btn-create' do = link_to new_namespace_project_environment_path(@project.namespace, @project), class: 'btn btn-create' do
New environment New environment
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
%p %p
Environments allow you to track deployments of your application Environments allow you to track deployments of your application
= succeed "." do = succeed "." do
= link_to "Read more about environments", help_page_path("ci", "environments") = link_to "Read more about environments", help_page_path("ci/environments")
= render 'form' = render 'form'
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
Define environments in the deploy stage(s) in Define environments in the deploy stage(s) in
%code .gitlab-ci.yml %code .gitlab-ci.yml
to track deployments here. to track deployments here.
= link_to "Read more", help_page_path("ci", "environments"), class: "btn btn-success" = link_to "Read more", help_page_path("ci/environments"), class: "btn btn-success"
- else - else
.table-holder .table-holder
%table.table.environments %table.table.environments
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
.form-group.project-visibility-level-holder .form-group.project-visibility-level-holder
= f.label :visibility_level, class: 'label-light' do = f.label :visibility_level, class: 'label-light' do
Visibility Level Visibility Level
= link_to "(?)", help_page_path("public_access", "public_access") = link_to "(?)", help_page_path("public_access/public_access")
= render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: @project.visibility_level, form_model: @project) = render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: @project.visibility_level, form_model: @project)
= f.submit 'Create project', class: "btn btn-create project-submit", tabindex: 4 = f.submit 'Create project', class: "btn btn-create project-submit", tabindex: 4
......
.comment-toolbar.clearfix .comment-toolbar.clearfix
.toolbar-text .toolbar-text
Styling with Styling with
= link_to 'Markdown', help_page_path('markdown', 'markdown'), target: '_blank', tabindex: -1 = link_to 'Markdown', help_page_path('markdown/markdown'), target: '_blank', tabindex: -1
is supported is supported
%button.toolbar-button.markdown-selector{ type: 'button', tabindex: '-1' } %button.toolbar-button.markdown-selector{ type: 'button', tabindex: '-1' }
= icon('file-image-o', class: 'toolbar-button-icon') = icon('file-image-o', class: 'toolbar-button-icon')
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
New pipeline New pipeline
- unless @repository.gitlab_ci_yml - unless @repository.gitlab_ci_yml
= link_to 'Get started with Pipelines', help_page_path('ci/quick_start', 'README'), class: 'btn btn-info' = link_to 'Get started with Pipelines', help_page_path('ci/quick_start/README'), class: 'btn btn-info'
= link_to ci_lint_path, class: 'btn btn-default' do = link_to ci_lint_path, class: 'btn btn-default' do
%span CI Lint %span CI Lint
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
= select_tag :access_level, options_for_select(ProjectMember.access_level_roles, @project_member.access_level), class: "project-access-select select2" = select_tag :access_level, options_for_select(ProjectMember.access_level_roles, @project_member.access_level), class: "project-access-select select2"
.help-block .help-block
Read more about role permissions Read more about role permissions
%strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink" %strong= link_to "here", help_page_path("permissions/permissions"), class: "vlink"
.form-actions .form-actions
= f.submit 'Add users to project', class: "btn btn-create" = f.submit 'Add users to project', class: "btn btn-create"
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
%p.prepend-top-20 %p.prepend-top-20
Protected branches are designed to: Protected branches are designed to:
%ul %ul
%li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"} %li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions/permissions"), class: "vlink"}
%li prevent anyone from force pushing to the branch %li prevent anyone from force pushing to the branch
%li prevent anyone from deleting the branch %li prevent anyone from deleting the branch
%p.append-bottom-0 Read more about #{link_to "project permissions", help_page_path("permissions", "permissions"), class: "underlined-link"} %p.append-bottom-0 Read more about #{link_to "project permissions", help_page_path("permissions/permissions"), class: "underlined-link"}
.col-lg-9 .col-lg-9
%h5.prepend-top-0 %h5.prepend-top-0
Protect a branch Protect a branch
......
.form-group.project-visibility-level-holder .form-group.project-visibility-level-holder
= f.label :visibility_level, class: 'control-label' do = f.label :visibility_level, class: 'control-label' do
Visibility Level Visibility Level
= link_to "(?)", help_page_path("public_access", "public_access") = link_to "(?)", help_page_path("public_access/public_access")
.col-sm-10 .col-sm-10
- if can_change_visibility_level - if can_change_visibility_level
= render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: visibility_level, form_model: form_model) = render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: visibility_level, form_model: form_model)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
%h4.prepend-top-0 %h4.prepend-top-0
= page_title = page_title
%p %p
#{link_to "Webhooks", help_page_path("web_hooks", "web_hooks")} can be #{link_to "Webhooks", help_page_path("web_hooks/web_hooks")} can be
used for binding events when something is happening within the project. used for binding events when something is happening within the project.
.col-lg-9.append-bottom-default .col-lg-9.append-bottom-default
= form_for hook, as: :hook, url: polymorphic_path(url_components + [:hooks]) do |f| = form_for hook, as: :hook, url: polymorphic_path(url_components + [:hooks]) do |f|
......
...@@ -89,9 +89,9 @@ Rails.application.routes.draw do ...@@ -89,9 +89,9 @@ Rails.application.routes.draw do
mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\/(info\/lfs|gitlab-lfs)/.match(request.path_info) }, via: [:get, :post, :put] mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\/(info\/lfs|gitlab-lfs)/.match(request.path_info) }, via: [:get, :post, :put]
# Help # Help
get 'help' => 'help#index' get 'help' => 'help#index'
get 'help/:category/:file' => 'help#show', as: :help_page, constraints: { category: /.*/, file: /[^\/\.]+/ } get 'help/*path' => 'help#show', as: :help_page
get 'help/:category/:subcategory/:file' => 'help#show', as: :deep_help_page, constraints: { category: /.*/, subcategory: /.*/, file: /[^\/\.]+/ }
get 'help/shortcuts' get 'help/shortcuts'
get 'help/ui' => 'help#ui' get 'help/ui' => 'help#ui'
......
...@@ -8,7 +8,7 @@ class Spinach::Features::DashboardHelp < Spinach::FeatureSteps ...@@ -8,7 +8,7 @@ class Spinach::Features::DashboardHelp < 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")
end end
step 'I should see "Rake Tasks" page markdown rendered' do step 'I should see "Rake Tasks" page markdown rendered' do
......
...@@ -6,7 +6,7 @@ describe 'Help Pages', feature: true do ...@@ -6,7 +6,7 @@ describe 'Help Pages', feature: true do
login_as :user login_as :user
end end
it 'replace the variable $your_email with the email of the user' do it 'replace the variable $your_email with the email of the user' do
visit help_page_path('ssh', 'README') visit help_page_path('ssh/README')
expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"") expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
end end
end end
......
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