From 8e5c9bbc5604be55f19df98208db4c439b8dd53a Mon Sep 17 00:00:00 2001 From: Terry Cai Date: Fri, 6 Oct 2023 18:12:43 +0800 Subject: [PATCH] feat: varnish chedckout --- lib/docs/filters/varnish/entries.rb | 60 ++++++++++++++++++++++++++++ lib/docs/scrapers/varnish.rb | 40 +++++++++++++++++++ public/icons/docs/varnish/16.png | Bin 0 -> 1428 bytes public/icons/docs/varnish/16@2x.png | Bin 0 -> 859 bytes public/icons/docs/varnish/SOURCE | 1 + 5 files changed, 101 insertions(+) create mode 100755 lib/docs/filters/varnish/entries.rb create mode 100644 lib/docs/scrapers/varnish.rb create mode 100644 public/icons/docs/varnish/16.png create mode 100644 public/icons/docs/varnish/16@2x.png create mode 100644 public/icons/docs/varnish/SOURCE diff --git a/lib/docs/filters/varnish/entries.rb b/lib/docs/filters/varnish/entries.rb new file mode 100755 index 00000000..34c2be89 --- /dev/null +++ b/lib/docs/filters/varnish/entries.rb @@ -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 diff --git a/lib/docs/scrapers/varnish.rb b/lib/docs/scrapers/varnish.rb new file mode 100644 index 00000000..13564955 --- /dev/null +++ b/lib/docs/scrapers/varnish.rb @@ -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
+ Copyright © 2006–2020 Varnish Software AS
+ 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 diff --git a/public/icons/docs/varnish/16.png b/public/icons/docs/varnish/16.png new file mode 100644 index 0000000000000000000000000000000000000000..49c7e76e6dae555af006cc10dc501ac02e73ac8c GIT binary patch literal 1428 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m{l`FB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuk#6rQ`QqR!L z#K720N5ROz&{E&PLf_C>*TB%qz|6|jTmcG{fVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8fo2%#8yV>WRp=I1=9MH?=;jqG!%T2VElw`VEGWs$&r<-In3$Ab zT4JjNbScCOxdm`z^NOLt1Pn0!io^naLp=kKmtYEgeeo;J&4sHjE(uCSxEHIz#UYgi zsro^w#rdU0$-sz9QwCX8VC7ttnpl!w6q28x0}I7~jQo=P;*9(P1tXx76f}GjlQZ)` zBAQ?=zP?tTdBr7(dC94sF1AWQL-aB;Q>+XPObty<-7HNU&D{(QU7akPj7*$d&5Yb! zoGcAZ-5go(3=B-Ho-U3d z6}NgO#d-uMN*u4ZzI~(pWzm^qU5i-ec5%7}#g=Mq5{zA=qGIHvv_e5?q0_F9YU^LQ zbtx&fws2{^c%3AE_st@nlWi%JT7+7JRzA#W-#qv2oO`nDR=1AHRp{M&Ui;tv-t+%9 z5^atqQcDwV$XxjPN#MHLu^0bxI_4~Te%mwa_Jr?mR8~*b5HnMkdC46ZZ0=#TlbI*b zrNG~D4f4z%186JN_O1(dS5v| zy2{LxDEqF{cgoXnxAdM}MKe3E@3Pbpp73L?z$5jFzv4&U?B8G@Z2bCi;M|4Zs(0*l zKC~lC=bFW-L-Eh{I|rQeRo(6JUP&NhYtgSv?t_QrPH{v|^L=}Y|IMKbJ1_F|TOH%v z7Wtw=LddN$^4HHskM}*9MH_2RTj%nJ3%-+ASt=9H_!OqjdN`6h1KQ s{8`5sd2Xilu^*rF>S}$(nEwbTFt}e^@BjNW8@QnKboFyt=akR{03|{jssI20 literal 0 HcmV?d00001 diff --git a/public/icons/docs/varnish/16@2x.png b/public/icons/docs/varnish/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..442b11dcb35eeb9f5bbafe04f0f94da528a7567e GIT binary patch literal 859 zcmV-h1El&+6otR@&)>9GQf#eh6%?eRU~R^UrEyiQR9p#Nh(%XI78RsoGC?~TF8N*#RQM?m+3UkCOAYwMg!fJx9H z#3;kL`SuVPm;}xDU>^Z;4Omga1OYdl7Nwt7Hc3n4?3Tcz#MSqzX{ltRVY-}5{t}5;QMs(^$Ut7uiuFB6C1!! zV($d5B7KQ;iemPf?D^6j98Lh6n~1&uyaalik(}!*Fi={L!(klW10Mh%#NinBQw)q( zk@Yu7A2v}7Mj9iEk5&g?PC$MT{7g+>--N^SD0A($!?}5g-bB#{i+Q~s63|KPeu~`} zYBy^LMB9K3b)4LW!&142vwtJKjPxwhcfdb2HuIn<(5pmIA0s`#)_<2vg_>Tx(fXR= zxrCybW!A;)EH9ouN(f^p>?DLc!CQepk%_j1DRRA3L-Ynm8zZsA__k%=Q2P002ovPDHLkV1g8zi9`SZ literal 0 HcmV?d00001 diff --git a/public/icons/docs/varnish/SOURCE b/public/icons/docs/varnish/SOURCE new file mode 100644 index 00000000..ebc3b9fc --- /dev/null +++ b/public/icons/docs/varnish/SOURCE @@ -0,0 +1 @@ +https://www.varnish-software.com/branding/