mirror of https://github.com/freeCodeCamp/devdocs
parent
78beda8974
commit
5335c81535
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
@ -0,0 +1,32 @@
|
||||
module Docs
|
||||
class Svg
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
doc.inner_html = doc.at_css('#Documentation + dl').to_html
|
||||
end
|
||||
|
||||
def other
|
||||
css('.prevnext').remove
|
||||
|
||||
if at_css('p').content.include?("\u{00AB}")
|
||||
at_css('p').remove
|
||||
end
|
||||
|
||||
if slug == 'Attribute' || slug == 'Element'
|
||||
at_css('h2').name = 'h1'
|
||||
end
|
||||
|
||||
css('#SVG_Attributes + div[style]').each do |node|
|
||||
node.remove_attribute('style')
|
||||
node['class'] = 'index'
|
||||
css('h3').each { |n| n.name = 'span' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,47 @@
|
||||
module Docs
|
||||
class Svg
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = super
|
||||
name.remove!('Element.').try(:downcase!)
|
||||
name.remove!('Attribute.').try(:downcase!)
|
||||
name.remove!('Tutorial.')
|
||||
name.gsub!('_', '')
|
||||
|
||||
if name.in?(%w(Element Attribute Content\ type))
|
||||
"#{name}s"
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
def get_type
|
||||
if slug.start_with?('Element')
|
||||
'Elements'
|
||||
elsif slug.start_with?('Attribute')
|
||||
'Attributes'
|
||||
elsif slug.start_with?('Tutorial')
|
||||
'Tutorial'
|
||||
elsif slug == 'Content_type'
|
||||
'Content types'
|
||||
else
|
||||
'Miscellaneous'
|
||||
end
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] unless slug == 'Content_type'
|
||||
entries = []
|
||||
|
||||
css('h2[id]').each do |node|
|
||||
dl = node.next_element
|
||||
next unless dl.name == 'dl'
|
||||
name = dl.at_css('dt').content.remove(/[<>]/)
|
||||
entries << [name, node['id']]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
module Docs
|
||||
class Svg < Mdn
|
||||
self.name = 'SVG'
|
||||
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/SVG'
|
||||
|
||||
html_filters.push 'svg/clean_html', 'svg/entries', 'title'
|
||||
|
||||
options[:root_title] = 'SVG'
|
||||
|
||||
options[:title] = ->(filter) do
|
||||
if filter.slug.starts_with?('Element/')
|
||||
"<#{filter.default_title}>"
|
||||
elsif filter.slug != 'Attribute' && filter.slug != 'Element'
|
||||
filter.default_title
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
options[:skip] = %w(
|
||||
/Compatibility_sources
|
||||
/FAQ
|
||||
/SVG_animation_with_SMIL
|
||||
/SVG_as_an_Image)
|
||||
|
||||
options[:fix_urls] = ->(url) do
|
||||
url.sub! 'https://developer.mozilla.org/en-US/Web/SVG', Svg.base_url
|
||||
url.sub! 'https://developer.mozilla.org/en-US/docs/SVG', Svg.base_url
|
||||
url.sub! 'https://developer.mozilla.org/en/SVG', Svg.base_url
|
||||
url
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 331 B |
After Width: | Height: | Size: 726 B |
@ -0,0 +1 @@
|
||||
http://www.w3.org/2009/08/svg-logos.html
|
Loading…
Reference in new issue