diff options
author | Connor Shea <connor.james.shea@gmail.com> | 2016-11-23 02:15:38 +0300 |
---|---|---|
committer | Connor Shea <connor.james.shea@gmail.com> | 2016-11-23 02:15:38 +0300 |
commit | 322df5ff8342bf4ed13b0833a3e126d1140f4ac9 (patch) | |
tree | a5c28c79913a0665a17cc5bde9eeb808cec1e6d0 /lib | |
parent | be91e30adaabd1312395d1a03d4ac02e960a83bb (diff) |
Make Edit on GitLab a helper.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers/edit_on_gitlab.rb | 27 | ||||
-rw-r--r-- | lib/helpers_.rb | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/helpers/edit_on_gitlab.rb b/lib/helpers/edit_on_gitlab.rb new file mode 100644 index 00000000..df623290 --- /dev/null +++ b/lib/helpers/edit_on_gitlab.rb @@ -0,0 +1,27 @@ +module Nanoc::Helpers + module EditOnGitLab + def edit_on_gitlab(item) + # Make an array out of the content's source path. + content_filename_array = @item[:content_filename].split('/') + # Remove "/content/" + content_filename_array.shift + # Get the product name. + product = content_filename_array.shift + # This should be the path from the doc/ directory for a given file. + content_filename = content_filename_array.join("/") + + if product == "omnibus" + # omnibus-gitlab repo + gitlab_url = "https://gitlab.com/gitlab-org/#{product}-gitlab/blob/master/doc/#{content_filename}" + elsif product == "runner" + # gitlab-runner repo + gitlab_url = "https://gitlab.com/gitlab-org/gitlab-ci-multi-#{product}/blob/master/docs/#{content_filename}" + else + # gitlab-ce and gitlab-ee repos + gitlab_url = "https://gitlab.com/gitlab-org/gitlab-#{product}/blob/master/doc/#{content_filename}" + end + + result = "<a href='#{gitlab_url}'>Improve this documentation on GitLab.com</a>" + end + end +end diff --git a/lib/helpers_.rb b/lib/helpers_.rb index 589df4b7..3dbaab87 100644 --- a/lib/helpers_.rb +++ b/lib/helpers_.rb @@ -2,6 +2,7 @@ include Nanoc::Helpers::LinkTo include Nanoc::Helpers::XMLSitemap include Nanoc::Helpers::Rendering include Nanoc::Helpers::ChildParentBetter +include Nanoc::Helpers::EditOnGitLab require 'redcarpet' require 'rouge' |