Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md11
-rw-r--r--layouts/archives.html1
-rw-r--r--layouts/footer.html1
-rw-r--r--lib/helpers/edit_on_gitlab.rb17
4 files changed, 28 insertions, 2 deletions
diff --git a/README.md b/README.md
index 80ca533d..84e906a2 100644
--- a/README.md
+++ b/README.md
@@ -346,6 +346,17 @@ The links pointing to the files should be similar to:
Nanoc will then build and render those links correctly according with what's
defined in [`Rules`](/Rules).
+## Linking to source files
+
+A helper called [`edit_on_gitlab`](/lib/helpers/edit_on_gitlab.rb) can be used
+to link to a page's source file. We can link to both the simple editor and the
+web IDE. Here's how you can use it in a Nanoc layout:
+
+- Default editor: `<a href="<%= edit_on_gitlab(@item, editor: :simple) %>">Simple editor</a>`
+- Web IDE: `<a href="<%= edit_on_gitlab(@item, editor: :webide) %>">Web IDE</a>`
+
+If you don't specify `editor:`, the simple one is used by default.
+
## Review Apps for documentation merge requests
If you are contributing to GitLab docs read how to [create a Review App with each
diff --git a/layouts/archives.html b/layouts/archives.html
index e8ed67c2..e0403ef6 100644
--- a/layouts/archives.html
+++ b/layouts/archives.html
@@ -15,6 +15,7 @@
<%# Show Edit button only in production and on master branch (hide archives) %>
<div class="edit-on">
<a class="btn btn-tanuki btn-default" href="<%= edit_on_gitlab(@item) %>">Edit this page</a>
+ <a class="btn btn-tanuki btn-default" href="<%= edit_on_gitlab(@item, editor: :webide) %>">Web IDE</a>
</div>
<% end %>
<% if @item[:last_updated] %>
diff --git a/layouts/footer.html b/layouts/footer.html
index decb1ffe..a8c80a15 100644
--- a/layouts/footer.html
+++ b/layouts/footer.html
@@ -9,6 +9,7 @@
<div class="edit-on">
<i class="fa fa-code-fork" aria-hidden="true"></i>
<a href="<%= edit_on_gitlab(@item) %>">Edit this page</a>
+ (<a href="<%= edit_on_gitlab(@item, editor: :webide) %>">Web IDE</a>)
</div>
<% end %>
</div>
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