diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2023-03-07 22:58:55 +0300 |
---|---|---|
committer | Sarah German <sgerman@gitlab.com> | 2023-03-07 22:58:55 +0300 |
commit | feb110fc5634df3c6ac7858770df142734c72c3f (patch) | |
tree | 44abde8ca97058332b15e96fc0d2f4895c036982 /lib | |
parent | 7846dd526e31550f845e8e66452d11be822c8689 (diff) |
Remove any Omnibus-related code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/navigation.rb | 31 | ||||
-rw-r--r-- | lib/gitlab/navigation/section.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/symlinks_converter.rb | 39 | ||||
-rw-r--r-- | lib/helpers/generic.rb | 7 |
4 files changed, 0 insertions, 84 deletions
diff --git a/lib/gitlab/navigation.rb b/lib/gitlab/navigation.rb index fd490588..a00dc600 100644 --- a/lib/gitlab/navigation.rb +++ b/lib/gitlab/navigation.rb @@ -1,19 +1,14 @@ # frozen_string_literal: true -require_relative '../helpers/generic' require_relative '../helpers/icons_helper' module Gitlab class Navigation - include Nanoc::Helpers::Generic include Nanoc::Helpers::IconsHelper def initialize(items, item) @items = items @item = item - - disable_inactive_sections! - omnibus_only_items! end def nav_items @@ -40,36 +35,10 @@ module Gitlab attr_reader :items, :item - def disable_inactive_sections! - return unless omnibus? - - children.each do |section| - section.disable! unless has_active_element?([section]) - end - end - - # Remove sections and categories menu items missing in Omnibus - def omnibus_only_items! - return unless omnibus? - - children.filter! do |section| - if allowed_link?(section.url) - section.children.filter! { |category| allowed_link?(category.url) } - true - end - end - end - def allowed_link?(link) link.start_with?('ee/', 'http') end - def has_active_element?(collection) - return false unless collection - - collection.any? { |element| show_element?(element) || has_active_element?(element.children) } - end - def dir @dir ||= item.identifier.to_s[%r{(?<=/)[^/]+}] end diff --git a/lib/gitlab/navigation/section.rb b/lib/gitlab/navigation/section.rb index 40ae04a7..dc470cb9 100644 --- a/lib/gitlab/navigation/section.rb +++ b/lib/gitlab/navigation/section.rb @@ -5,13 +5,6 @@ module Gitlab class Section def initialize(section) @section = section - @enabled = true - end - - attr_reader :enabled - - def disable! - @enabled = false end def title diff --git a/lib/gitlab/symlinks_converter.rb b/lib/gitlab/symlinks_converter.rb deleted file mode 100644 index 043a5042..00000000 --- a/lib/gitlab/symlinks_converter.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - class SymlinksConverter - include Nanoc::Helpers::Generic - EXTENSIONS = %w[png jpg gif svg].freeze - - def initialize(config, items) - @config = config - @items = items - end - - def self.run(config, items) - new(config, items).run - end - - def run - return unless omnibus? - - items.each do |item| - id = item.identifier - - next unless id.to_s.start_with?('/ee/') - next unless EXTENSIONS.include?(id.ext) - - file_path = File.join(config.fetch(:content_dir), id.to_s) - real_path = Pathname.new(file_path).realpath.to_s - symlink = File.join(config.output_dir, id.to_s) - - # Replace a file with a symlink - File.delete(symlink) && File.symlink(real_path, symlink) if File.exist?(symlink) - end - end - - private - - attr_reader :config, :items - end -end diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb index cfcb8112..f0ef3f44 100644 --- a/lib/helpers/generic.rb +++ b/lib/helpers/generic.rb @@ -20,13 +20,6 @@ module Nanoc::Helpers end # - # Used when bundling gitlab-docs with Omnibus - # - def omnibus? - ENV['NANOC_ENV'] == 'omnibus' - end - - # # Find the current branch. If CI_COMMIT_BRANCH is not defined, that means # we're working locally, and Git is used to find the branch. # |