mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
4641978716
* New styles * Fundamental styles for home page * Legal pages * Community page, downloads page, tutorials page * Docs page * Content toggle and github badge * Add code - highlighter * Copy button * Sliding content animation * fix particle animatino on downloads page * Scroll-to-top button * docs sidebar links * innocent comments on resources * Fancy code animation * Small update to diamond * whatever slider * Slider styles * initial selection if no sliders are there * add netifly config Signed-off-by: Christoph Hartmann <chris@lollyrock.com> * inspec for provisioners * fix incorrect text on aws ssm * fix layout javascript post-rebase * resource grouping in docs * introduce groups in docs/resources * fix minor spelling issues and move download button in new features section Signed-off-by: Christoph Hartmann <chris@lollyrock.com> * pass linting Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
50 lines
1.3 KiB
Ruby
50 lines
1.3 KiB
Ruby
# encoding: utf-8
|
|
# helper methods for source/layouts/sidebar.slim
|
|
module SidebarHelpers
|
|
SIDEBAR_LAYOUTS = %w{docs}.freeze
|
|
|
|
def sidebar_data(sidebar_layout)
|
|
unless SIDEBAR_LAYOUTS.include?(sidebar_layout)
|
|
raise "'#{sidebar_layout}' is not a valid sidebar layout type."
|
|
end
|
|
|
|
data.public_send(:"#{sidebar_layout}_sidebar").sidebar_links.dup
|
|
end
|
|
|
|
def link_classes(current_url, item_link)
|
|
't-purple' if same_link?(current_url, item_link.link)
|
|
end
|
|
|
|
def print_sub_links?(current_url, item_link)
|
|
return false unless sub_links?(item_link)
|
|
|
|
same_link?(item_link.link, current_url) ||
|
|
active_child?(current_url, item_link)
|
|
end
|
|
|
|
def same_link?(one, two)
|
|
# fix comparing '.html' to empty suffix links
|
|
if !one.end_with?('.html') && two.end_with?('.html')
|
|
two = two.sub(/\.html$/, '')
|
|
end
|
|
strip_trailing_slash(one) == strip_trailing_slash(two)
|
|
end
|
|
|
|
def strip_trailing_slash(str)
|
|
str.end_with?('/') ? str[0..-2] : str
|
|
end
|
|
|
|
def active_child?(current_url, item_link)
|
|
return false unless sub_links?(item_link)
|
|
|
|
sub_link_urls(item_link).include?(strip_trailing_slash(current_url))
|
|
end
|
|
|
|
def sub_links?(item_link)
|
|
item_link.respond_to?(:sub_links) && item_link.sub_links.count > 0
|
|
end
|
|
|
|
def sub_link_urls(item)
|
|
item.sub_links.collect { |sub| strip_trailing_slash(sub.link) }
|
|
end
|
|
end
|