Finish nginx Lua Module scraper

pull/359/merge
Thibaut Courouble 9 years ago
parent acac755eb1
commit ac3aaea531

@ -1,7 +1,7 @@
[ [
[ [
"2016-02-28", "2016-02-28",
"New documentation: <a href=\"/codeigniter/\">CodeIgniter</a>" "New documentations: <a href=\"/codeigniter/\">CodeIgniter</a> and <a href=\"/nginx_lua_module/\">nginx Lua Module</a>"
], [ ], [
"2016-02-15", "2016-02-15",
"New documentations: <a href=\"/cakephp/\">CakePHP</a>, <a href=\"/chef/\">Chef</a> and <a href=\"/ramda/\">Ramda</a>" "New documentations: <a href=\"/cakephp/\">CakePHP</a>, <a href=\"/chef/\">Chef</a> and <a href=\"/ramda/\">Ramda</a>"

@ -284,6 +284,11 @@ credits = [
'2002-2016 Igor Sysoev<br>&copy; 2011-2016 Nginx, Inc.', '2002-2016 Igor Sysoev<br>&copy; 2011-2016 Nginx, Inc.',
'BSD', 'BSD',
'http://nginx.org/LICENSE' 'http://nginx.org/LICENSE'
], [
'nginx / Lua Module',
'2009-2016 Xiaozhe Wang (chaoslawful)<br>&copy; 2009-2016 Yichun "agentzh" Zhang (章亦春), CloudFlare Inc.',
'BSD',
'https://github.com/openresty/lua-nginx-module#copyright-and-license'
], [ ], [
'Node.js', 'Node.js',
'Joyent, Inc. and other Node contributors<br>Node.js is a trademark of Joyent, Inc.', 'Joyent, Inc. and other Node contributors<br>Node.js is a trademark of Joyent, Inc.',

@ -0,0 +1,6 @@
#= require views/pages/base
class app.views.GithubPage extends app.views.BasePage
prepare: ->
@highlightCode @findAll('pre.highlight-source-lua'), 'lua'
return

@ -1,8 +0,0 @@
#= require views/pages/base
# this may be used for all GitHub pages
class app.views.LuaNginxModulePage extends app.views.BasePage
prepare: ->
@highlightCode @findAll('div.highlight-source-lua pre'), 'lua'
return

@ -76,7 +76,8 @@
._icon-markdown:before { background-position: -1rem -5rem; @extend %darkIconFix !optional; } ._icon-markdown:before { background-position: -1rem -5rem; @extend %darkIconFix !optional; }
._icon-django:before { background-position: -2rem -5rem; } ._icon-django:before { background-position: -2rem -5rem; }
._icon-xpath:before { background-position: -3rem -5rem; } ._icon-xpath:before { background-position: -3rem -5rem; }
._icon-nginx:before { background-position: -4rem -5rem; } ._icon-nginx:before,
._icon-nginx_lua_module:before { background-position: -4rem -5rem; }
._icon-svg:before { background-position: -5rem -5rem; } ._icon-svg:before { background-position: -5rem -5rem; }
._icon-marionette:before { background-position: -6rem -5rem; } ._icon-marionette:before { background-position: -6rem -5rem; }
._icon-mongoose:before { background-position: -7rem -5rem; } ._icon-mongoose:before { background-position: -7rem -5rem; }

@ -17,6 +17,7 @@
} }
._cordova, ._cordova,
._github,
._grunt, ._grunt,
._less, ._less,
._lodash, ._lodash,

@ -0,0 +1,20 @@
module Docs
class Github
class CleanHtmlFilter < Filter
def call
css('.anchor').each do |node|
node.parent['id'] = node['href'].remove('#')
node.remove
end
css('.highlight > pre').each do |node|
node['class'] = node.parent['class']
node.content = node.content.strip_heredoc.gsub(' ', ' ')
node.parent.replace(node)
end
doc
end
end
end
end

@ -1,22 +0,0 @@
module Docs
class LuaNginxModule
class CleanHtmlFilter < Filter
def call
type = nil
doc.children.each do |node|
if node.name == 'h1'
section = node.content.strip
type = section.in?(['Directives', 'Nginx API for Lua']) ? section : nil
end
if type == nil || (node.name == 'ul' && node.previous_element.name == 'h1') || node.content.strip == 'Back to TOC'
node.remove()
elsif node.name == 'h2'
node["id"] = /^user-content-(.+)/.match(node.css('a.anchor').first["id"])[1]
end
end
doc
end
end
end
end

@ -1,17 +0,0 @@
module Docs
class LuaNginxModule
class EntriesFilter < Docs::EntriesFilter
def additional_entries
type = nil
doc.children.each_with_object [] do |node, entries|
if node.name == 'h1'
type = node.content.strip
elsif node.name == 'h2'
entries << [ node.content, node["id"], type ]
end
end
end
end
end
end

@ -0,0 +1,15 @@
module Docs
class NginxLuaModule
class CleanHtmlFilter < Filter
def call
css('a[href="#table-of-contents"]', 'a:contains("Back to TOC")').remove
css('h1, h2, h3').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
doc
end
end
end
end

@ -0,0 +1,20 @@
module Docs
class NginxLuaModule
class EntriesFilter < Docs::EntriesFilter
def additional_entries
entries = []
css('#directives + ul > li > a').each do |node|
entries << [node.content, node['href'].remove('#'), 'Directives']
end
css('#nginx-api-for-lua + ul > li > a').each do |node|
next if node.content == 'Introduction'
entries << [node.content, node['href'].remove('#'), 'Nginx API for Lua']
end
entries
end
end
end
end

@ -0,0 +1,8 @@
module Docs
class Github < UrlScraper
self.abstract = true
self.type = 'github'
html_filters.push 'github/clean_html'
end
end

@ -1,19 +0,0 @@
module Docs
class LuaNginxModule < UrlScraper
self.type = 'LuaNginxModule'
self.root_path = 'README.markdown'
html_filters.push 'lua_nginx_module/clean_html', 'lua_nginx_module/entries'
options[:container] = '#readme > article'
options[:attribution] = <<-HTML
Copyright (C) 2009-2015, by Xiaozhe Wang (chaoslawful) <a href="mailto:chaoslawful@gmail.com">chaoslawful@gmail.com</a>.<br>
Copyright (C) 2009-2015, by Yichun "agentzh" Zhang () <a href="mailto:agentzh@gmail.com">agentzh@gmail.com</a>, CloudFlare Inc.<br>
Licensed under the BSD License.
HTML
self.release = '0.10.0'
self.base_url = 'https://github.com/openresty/lua-nginx-module/tree/v0.10.0/'
end
end

@ -0,0 +1,19 @@
module Docs
class NginxLuaModule < Github
self.name = 'nginx / Lua Module'
self.slug = 'nginx_lua_module'
self.release = '0.10.0'
self.base_url = 'https://github.com/openresty/lua-nginx-module/tree/v0.10.0/'
html_filters.push 'nginx_lua_module/clean_html', 'nginx_lua_module/entries', 'title'
options[:root_title] = 'ngx_http_lua_module'
options[:container] = '#readme > article'
options[:attribution] = <<-HTML
&copy; 2009&ndash;2016 Xiaozhe Wang (chaoslawful)<br>
&copy; 2009&ndash;2016 Yichun "agentzh" Zhang (), CloudFlare Inc.<br>
Licensed under the BSD License.
HTML
end
end
Loading…
Cancel
Save