|
|
@@ -2,20 +2,56 @@ module Docs
|
|
|
class Docker
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
def get_name
|
|
|
- title = at_css('h1').content
|
|
|
+ name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip
|
|
|
+ name.capitalize! if name == 'exoscale'
|
|
|
|
|
|
- title = title.split(' — ').first
|
|
|
- title = title.split(' - ').first
|
|
|
+ if name =~ /\A[a-z\-\s]+\z/
|
|
|
+ name.prepend 'docker ' if subpath =~ /engine\/reference\/commandline\/./
|
|
|
+ name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
|
|
|
+ name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
|
|
|
+ name.prepend 'swarm ' if subpath =~ /swarm\/reference\/./ && name != 'swarm'
|
|
|
+ else
|
|
|
+ name << " (#{product})" if name !~ /#{product}/i
|
|
|
+ end
|
|
|
|
|
|
- title
|
|
|
+ name
|
|
|
end
|
|
|
|
|
|
def get_type
|
|
|
- if slug.count('/') == 1 or slug.count('/') == 2
|
|
|
- slug.split('/').first.capitalize
|
|
|
- else
|
|
|
- slug.split('/')[0...-1].map(&:capitalize).join('/').gsub(/\-|\_/, ' ')
|
|
|
+ unless nav_link
|
|
|
+ return 'Engine: User guide' if subpath.start_with?('engine/userguide')
|
|
|
+ return 'Engine: Secure' if subpath.start_with?('engine/security')
|
|
|
+ return 'Engine' if subpath == 'engine/'
|
|
|
+ end
|
|
|
+
|
|
|
+ type = nav_link.ancestors('article').to_a.reverse.to_a[0..1].map do |node|
|
|
|
+ node.at_css('> button').content.strip
|
|
|
+ end.join(': ')
|
|
|
+
|
|
|
+ type.remove! %r{\ADocker }
|
|
|
+ type.remove! %r{ Engine}
|
|
|
+ type.sub! %r{Command[\-\s]line reference}i, 'CLI'
|
|
|
+ type = 'Engine: Reference' if type == 'Engine: reference'
|
|
|
+ type
|
|
|
+ end
|
|
|
+
|
|
|
+ def nav_link
|
|
|
+ return @nav_link if defined?(@nav_link)
|
|
|
+ @nav_link = at_css('#multiple .active')
|
|
|
+
|
|
|
+ unless @nav_link
|
|
|
+ link = at_css('#content li a')
|
|
|
+ return unless link
|
|
|
+ link = at_css("#multiple a[href='#{link['href']}']")
|
|
|
+ return unless link
|
|
|
+ @nav_link = link.ancestors('article').first.at_css('button')
|
|
|
end
|
|
|
+
|
|
|
+ @nav_link
|
|
|
+ end
|
|
|
+
|
|
|
+ def product
|
|
|
+ @product ||= subpath.split('/').first.capitalize
|
|
|
end
|
|
|
end
|
|
|
end
|