Add SVG documentation

pull/129/head
Thibaut 10 years ago
parent 78beda8974
commit 5335c81535

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

@ -108,7 +108,7 @@ credits = [
'Apache',
'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
], [
'CSS<br>DOM<br>HTML<br>JavaScript<br>XPath',
'CSS<br>DOM<br>HTML<br>JavaScript<br>SVG<br>XPath',
'2005-2014 Mozilla Developer Network and individual contributors',
'CC BY-SA',
'http://creativecommons.org/licenses/by-sa/2.5/'

@ -33,7 +33,10 @@ newsItem = (date, news) ->
result
app.news = [
[ 1413590400000, # October 18, 2014
[ 1413676800000, # October 19, 2014
""" New <a href="/svg/">SVG</a> documentation """,
], [
1413590400000, # October 18, 2014
""" New <a href="/nginx/">nginx</a> documentation """,
], [
1413158400000, # October 13, 2014

@ -4,7 +4,7 @@
width: 1rem;
height: 1rem;
background-image: image-url('icons.png');
background-size: 5rem 11rem;
background-size: 5rem 12rem;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@ -66,3 +66,4 @@
._icon-django:before { background-position: -2rem -10rem; }
._icon-xpath:before { background-position: -3rem -10rem; }
._icon-nginx:before { background-position: -4rem -10rem; }
._icon-svg:before { background-position: 0 -11rem; }

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

@ -0,0 +1 @@
http://www.w3.org/2009/08/svg-logos.html
Loading…
Cancel
Save