mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
feat: varnish chedckout
This commit is contained in:
parent
5e0b4e2ccd
commit
8e5c9bbc56
5 changed files with 101 additions and 0 deletions
60
lib/docs/filters/varnish/entries.rb
Executable file
60
lib/docs/filters/varnish/entries.rb
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
module Docs
|
||||||
|
class Varnish
|
||||||
|
class EntriesFilter < Docs::EntriesFilter
|
||||||
|
TYPE_BY_SLUG = {}
|
||||||
|
|
||||||
|
def call
|
||||||
|
if root_page?
|
||||||
|
css('.section').each do |node|
|
||||||
|
type = node.at_css('h2').content[0..-2]
|
||||||
|
node.css('li > a').each do |n|
|
||||||
|
s = n['href'].split('/')[-2]
|
||||||
|
TYPE_BY_SLUG[s] = type
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_name
|
||||||
|
at_css('h1').content[0..-2]
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_type
|
||||||
|
case slug
|
||||||
|
when /installation/
|
||||||
|
'Installation'
|
||||||
|
when /users-guide/
|
||||||
|
'Users Guide'
|
||||||
|
when /tutorial/
|
||||||
|
'Tutorial'
|
||||||
|
when /reference/
|
||||||
|
'Reference Manual'
|
||||||
|
when /dev-guide/
|
||||||
|
'Dev Guide'
|
||||||
|
else
|
||||||
|
TYPE_BY_SLUG[slug.split('/').first] || 'Other'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_default_entry?
|
||||||
|
slug != 'reference/'
|
||||||
|
end
|
||||||
|
|
||||||
|
def additional_entries
|
||||||
|
entries = []
|
||||||
|
|
||||||
|
css('dl.class > dt[id]').each do |node|
|
||||||
|
name = node['id'].split('.').last
|
||||||
|
id = node['id']
|
||||||
|
type = node['id'].split('.')[0..-2].join('.')
|
||||||
|
entries << [name, id, type]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
entries
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
40
lib/docs/scrapers/varnish.rb
Normal file
40
lib/docs/scrapers/varnish.rb
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
module Docs
|
||||||
|
class Varnish < UrlScraper
|
||||||
|
self.name = 'Varnish'
|
||||||
|
self.type = 'sphinx'
|
||||||
|
|
||||||
|
self.root_path = 'index.html'
|
||||||
|
self.links = {
|
||||||
|
home: 'https://varnish-cache.org/',
|
||||||
|
code: 'https://github.com/varnishcache/varnish-cache'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
html_filters.push 'varnish/entries', 'sphinx/clean_html'
|
||||||
|
|
||||||
|
options[:container] = '.body > section'
|
||||||
|
|
||||||
|
|
||||||
|
options[:skip] = %w(genindex.html search.html)
|
||||||
|
|
||||||
|
options[:skip_patterns] = [/phk/, /glossary/, /whats-new/]
|
||||||
|
|
||||||
|
|
||||||
|
options[:attribution] = <<-HTML
|
||||||
|
Copyright © 2006 Verdens Gang AS<br>
|
||||||
|
Copyright © 2006–2020 Varnish Software AS<br>
|
||||||
|
Licensed under the BSD-2-Clause License.
|
||||||
|
HTML
|
||||||
|
|
||||||
|
version do
|
||||||
|
self.release = '7.3.0'
|
||||||
|
self.base_url = 'https://varnish-cache.org/docs/7.3/'
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_latest_version(opts)
|
||||||
|
contents = get_github_file_contents('varnishcache', 'varnish-cache', 'doc/changes.rst', opts)
|
||||||
|
contents.scan(/Varnish\s+Cache\s+([0-9.]+)/)[0][0]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
BIN
public/icons/docs/varnish/16.png
Normal file
BIN
public/icons/docs/varnish/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
public/icons/docs/varnish/16@2x.png
Normal file
BIN
public/icons/docs/varnish/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 859 B |
1
public/icons/docs/varnish/SOURCE
Normal file
1
public/icons/docs/varnish/SOURCE
Normal file
|
@ -0,0 +1 @@
|
||||||
|
https://www.varnish-software.com/branding/
|
Loading…
Reference in a new issue