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
path: root/lib
diff options
context:
space:
mode:
authorEvan Read <eread@gitlab.com>2022-10-18 16:29:56 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2022-10-18 16:29:56 +0300
commitfa5d47fd2172e3ef8e4551272e8fa2cd818f4972 (patch)
tree2adbd44b21730bc9a76aaf4e7fecb9fdc2db4740 /lib
parent92f10a633d1328d885817f676ceff792b5261eea (diff)
Automatically enable new RuboCop cops
Diffstat (limited to 'lib')
-rw-r--r--lib/filters/tabs.rb1
-rw-r--r--lib/helpers/algolia_rank.rb85
-rw-r--r--lib/helpers/generic.rb1
-rw-r--r--lib/helpers/versions.rb1
4 files changed, 43 insertions, 45 deletions
diff --git a/lib/filters/tabs.rb b/lib/filters/tabs.rb
index 08385383..6caa5504 100644
--- a/lib/filters/tabs.rb
+++ b/lib/filters/tabs.rb
@@ -18,5 +18,4 @@ class TabsFilter < Nanoc::Filter
def generateWrapper(content)
%(<div class="js-tabs">#{content}</div>)
end
-
end
diff --git a/lib/helpers/algolia_rank.rb b/lib/helpers/algolia_rank.rb
index 3e14f0d7..03bcc7bf 100644
--- a/lib/helpers/algolia_rank.rb
+++ b/lib/helpers/algolia_rank.rb
@@ -1,50 +1,51 @@
# frozen_string_literal: true
module Nanoc::Helpers
- module AlgoliaRank
- ###
- # Add a URL pattern and weight to CUSTOM_PAGERANKS to modify Algolia search results.
- #
- # Weights greater than DEFAULT_PAGERANK will boost a page in search results,
- # and weights below DEFAULT_PAGERANK will lower its ranking.
- #
- # The weight value appears in the "docsearch:pageRank" metatag
- # on each page that contains the URL pattern.
- #
- # For example, the "/runner/development/reviewing-gitlab-runner.html" page
- # will match "/runner/development" in CUSTOM_PAGERANKS and receive a weight of "20".
- #
- # @see https://docsearch.algolia.com/docs/record-extractor/#boost-search-results-with-pagerank
- ##
- DEFAULT_PAGERANK = 100
- CUSTOM_PAGERANKS = {
- "/ee/api" => 50,
- "/ee/development" => 20,
- "/omnibus/development" => 20,
- "/runner/development" => 20,
- "/charts/development" => 20,
- }
+ module AlgoliaRank
+ ###
+ # Add a URL pattern and weight to CUSTOM_PAGERANKS to modify Algolia search results.
+ #
+ # Weights greater than DEFAULT_PAGERANK will boost a page in search results,
+ # and weights below DEFAULT_PAGERANK will lower its ranking.
+ #
+ # The weight value appears in the "docsearch:pageRank" metatag
+ # on each page that contains the URL pattern.
+ #
+ # For example, the "/runner/development/reviewing-gitlab-runner.html" page
+ # will match "/runner/development" in CUSTOM_PAGERANKS and receive a weight of "20".
+ #
+ # @see https://docsearch.algolia.com/docs/record-extractor/#boost-search-results-with-pagerank
+ ##
+ DEFAULT_PAGERANK = 100
+ CUSTOM_PAGERANKS = {
+ "/ee/api" => 50,
+ "/ee/development" => 20,
+ "/omnibus/development" => 20,
+ "/runner/development" => 20,
+ "/charts/development" => 20
+ }.freeze
- def algolia_rank(item)
- if result = CUSTOM_PAGERANKS.keys.find {|k| item.identifier.to_s.include? k}
- return CUSTOM_PAGERANKS[result]
- else
- return DEFAULT_PAGERANK
- end
- end
+ def algolia_rank(item)
+ if result = CUSTOM_PAGERANKS.keys.find { |k| item.identifier.to_s.include? k }
+ return CUSTOM_PAGERANKS[result]
+ else
+ return DEFAULT_PAGERANK
+ end
+ end
+
+ ###
+ # Calculate the navigation level of a given page.
+ # We use this on Algolia to increase relevance of higher-level pages.
+ ###
+ def algolia_level(item)
+ path = item.identifier.to_s
+ level = path.scan("/").count
- ###
- # Calculate the navigation level of a given page.
- # We use this on Algolia to increase relevance of higher-level pages.
- ###
- def algolia_level(item)
- path = item.identifier.to_s
- level = path.scan("/").count
- if path.include? "index.md"
- level -= 1
- end
- return level
- end
+ if path.include? "index.md"
+ level -= 1
+ end
+ return level
end
+ end
end
diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb
index cb6e8c12..1f7a091c 100644
--- a/lib/helpers/generic.rb
+++ b/lib/helpers/generic.rb
@@ -53,6 +53,5 @@ module Nanoc::Helpers
def show_banner?
@items['/_data/banner.yaml'][:show_banner]
end
-
end
end
diff --git a/lib/helpers/versions.rb b/lib/helpers/versions.rb
index 954ea6ca..70fa6a67 100644
--- a/lib/helpers/versions.rb
+++ b/lib/helpers/versions.rb
@@ -32,6 +32,5 @@ module Nanoc::Helpers
def stable_version?(version)
version.match?(STABLE_VERSIONS_REGEX)
end
-
end
end