diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2019-05-21 02:23:50 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2019-05-21 02:23:50 +0300 |
commit | b09ee838e77695c5b577271666a490e2412b0afd (patch) | |
tree | 1d514109c5523ea169d90cecee8ee2e97a34ef88 /lib | |
parent | 09387629a7bab10f5b4085ea3a45b426e67c6de5 (diff) |
Add option to link to Web IDE to edit files
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers/edit_on_gitlab.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/helpers/edit_on_gitlab.rb b/lib/helpers/edit_on_gitlab.rb index 48b0010c..97fe1b51 100644 --- a/lib/helpers/edit_on_gitlab.rb +++ b/lib/helpers/edit_on_gitlab.rb @@ -1,6 +1,6 @@ module Nanoc::Helpers module EditOnGitLab - def edit_on_gitlab(item) + def edit_on_gitlab(item, editor: :simple) # Make an array out of the content's source path. content_filename_array = @item[:content_filename].split('/') # Remove "/content/" @@ -14,12 +14,15 @@ module Nanoc::Helpers if product == "omnibus" # omnibus-gitlab repo gitlab_url = "https://gitlab.com/gitlab-org/#{product}-gitlab/blob/master/doc/#{docs_content_filename}" + gitlab_ide_url = "https://gitlab.com/-/ide/project/gitlab-org/#{product}-gitlab/edit/master/-/doc/#{docs_content_filename}" elsif product == "runner" # gitlab-runner repo gitlab_url = "https://gitlab.com/gitlab-org/gitlab-#{product}/blob/master/docs/#{docs_content_filename}" + gitlab_ide_url = "https://gitlab.com/-/ide/project/gitlab-org/gitlab-#{product}/edit/master/-/docs/#{docs_content_filename}" elsif product == "charts" # GitLab Helm chart repo gitlab_url = "https://gitlab.com/#{product}/gitlab/blob/master/doc/#{docs_content_filename}" + gitlab_ide_url = "https://gitlab.com/-/ide/project/#{product}/gitlab/edit/master/-/doc/#{docs_content_filename}" elsif %w[ce ee].include?(product) # gitlab-ce and gitlab-ee repos if product == "ee" @@ -27,14 +30,24 @@ module Nanoc::Helpers product = "ce" if File.exists?(ce_file) end gitlab_url = "https://gitlab.com/gitlab-org/gitlab-#{product}/blob/master/doc/#{docs_content_filename}" + gitlab_ide_url = "https://gitlab.com/-/ide/project/gitlab-org/gitlab-#{product}/edit/master/-/doc/#{docs_content_filename}" elsif product == "debug" gitlab_url = "https://gitlab.com/debugging/#{product}/blob/master/content/#{docs_content_filename}" + gitlab_ide_url = "https://gitlab.com/-/ide/project/debugging/#{product}/edit/master/-/content/#{docs_content_filename}" else # gitlab-docs pages gitlab_url = "https://gitlab.com/gitlab-com/gitlab-docs/blob/master/#{@item[:content_filename]}" + gitlab_ide_url = "https://gitlab.com/-/ide/project/gitlab-com/gitlab-docs/edit/master/-/#{@item[:content_filename]}" end - result = gitlab_url + case editor + when :simple + gitlab_url + when :webide + gitlab_ide_url + else + raise "Unknown editor: #{editor}" + end end end end |