mirror of https://github.com/freeCodeCamp/devdocs
parent
5d966ea058
commit
451ba37ef7
@ -1,37 +0,0 @@
|
||||
module Docs
|
||||
class Docker
|
||||
class CleanHtmlOldFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
doc.inner_html = "<h1>Docker Documentation</h1>"
|
||||
return doc
|
||||
end
|
||||
|
||||
@doc = at_css('#DocumentationText')
|
||||
|
||||
at_css('h2').name = 'h1' unless at_css('h1')
|
||||
|
||||
css('.anchorLink', '.reading-time', 'hr', '> div[style*="margin-top"]:last-child').remove
|
||||
|
||||
css('h1 + h1').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
node['data-language'] = node.parent['class'][/language-(\w+)/, 1] if node.parent['class']
|
||||
end
|
||||
|
||||
css('div.highlighter-rouge').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('code.highlighter-rouge').each do |node|
|
||||
node.content = node.content.gsub(/\s+/, ' ').strip
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,22 +0,0 @@
|
||||
module Docs
|
||||
class Docker
|
||||
class CleanHtmlVeryOldFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
doc.inner_html = "<h1>Docker Documentation</h1>"
|
||||
return doc
|
||||
end
|
||||
|
||||
@doc = at_css('#content')
|
||||
|
||||
at_css('h2').name = 'h1' unless at_css('h1')
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,75 +0,0 @@
|
||||
module Docs
|
||||
class Docker
|
||||
class EntriesOldFilter < Docs::EntriesFilter
|
||||
NAME_BY_SUBPATH = {
|
||||
'engine/' => 'Engine',
|
||||
'compose/' => 'Compose',
|
||||
'machine/' => 'Machine'
|
||||
}
|
||||
|
||||
def get_name
|
||||
return NAME_BY_SUBPATH[subpath] if NAME_BY_SUBPATH[subpath]
|
||||
return at_css('h1').content unless nav_link
|
||||
|
||||
name = nav_link.content.strip
|
||||
name.capitalize! if name == 'exoscale'
|
||||
name.remove! ' (base command)'
|
||||
|
||||
if name =~ /\A[a-z\-\s]+\z/
|
||||
name.prepend 'docker-compose ' if subpath =~ /compose\/reference\/./
|
||||
name.prepend 'docker-machine ' if subpath =~ /machine\/reference\/./
|
||||
else
|
||||
name << " (#{product})" if name !~ /#{product}/i
|
||||
end
|
||||
|
||||
name
|
||||
end
|
||||
|
||||
TYPE_BY_SUBPATH = {
|
||||
'engine/' => 'Engine',
|
||||
'compose/' => 'Compose',
|
||||
'machine/' => 'Machine'
|
||||
}
|
||||
|
||||
def get_type
|
||||
return TYPE_BY_SUBPATH[subpath] if TYPE_BY_SUBPATH[subpath]
|
||||
return 'Engine: CLI' if subpath.start_with?('engine/reference/commandline/')
|
||||
return 'Engine: Admin Guide' if subpath.start_with?('engine/admin/')
|
||||
return 'Engine: Security' if subpath.start_with?('engine/security/')
|
||||
return 'Engine: Extend' if subpath.start_with?('engine/extend/')
|
||||
return 'Engine: Get Started' if subpath.start_with?('engine/getstarted')
|
||||
return 'Engine: Tutorials' if subpath.start_with?('engine/tutorials/')
|
||||
return product if !nav_link && subpath =~ /\A\w+\/[\w\-]+\/\z/
|
||||
|
||||
leaves = nav_link.ancestors('li.leaf').reverse
|
||||
return product if leaves.length <= 2
|
||||
|
||||
type = leaves[0..1].map { |node| node.at_css('> a').content.strip }.join(': ')
|
||||
type.remove! %r{\ADocker }
|
||||
type.remove! ' Engine'
|
||||
type.sub! %r{Command[\-\s]line reference}i, 'CLI'
|
||||
type.sub! 'CLI reference', 'CLI'
|
||||
type
|
||||
end
|
||||
|
||||
def nav_link
|
||||
return @nav_link if defined?(@nav_link)
|
||||
@nav_link = at_css('.currentPage')
|
||||
|
||||
unless @nav_link
|
||||
link = at_css('#DocumentationText li a')
|
||||
return unless link
|
||||
link = at_css(".docsidebarnav_section a[href='#{link['href']}']")
|
||||
return unless link
|
||||
@nav_link = link.ancestors('.menu-closed').first.at_css('a')
|
||||
end
|
||||
|
||||
@nav_link
|
||||
end
|
||||
|
||||
def product
|
||||
@product ||= subpath.split('/').first.capitalize
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,56 +0,0 @@
|
||||
module Docs
|
||||
class Docker
|
||||
class EntriesVeryOldFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = nav_link ? nav_link.content.strip : at_css('#content h1').content.strip
|
||||
name.capitalize! if name == 'exoscale'
|
||||
|
||||
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
|
||||
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
unless nav_link
|
||||
return 'Engine: User guide' if subpath.start_with?('engine/userguide')
|
||||
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
|
||||
end
|
Loading…
Reference in new issue