From ae193f5194755a778e7fa8520cdfd1516f598f10 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 20 Jan 2024 22:17:49 +0100 Subject: [PATCH] Add htmx documentation --- assets/javascripts/news.json | 4 ++++ lib/docs/filters/htmx/clean_html.rb | 13 +++++++++++ lib/docs/filters/htmx/entries.rb | 31 ++++++++++++++++++++++++ lib/docs/scrapers/htmx.rb | 35 ++++++++++++++++++++++++++++ public/icons/docs/htmx/16.png | Bin 0 -> 817 bytes public/icons/docs/htmx/16@2x.png | Bin 0 -> 1607 bytes public/icons/docs/htmx/SOURCE | 1 + 7 files changed, 84 insertions(+) create mode 100644 lib/docs/filters/htmx/clean_html.rb create mode 100644 lib/docs/filters/htmx/entries.rb create mode 100644 lib/docs/scrapers/htmx.rb create mode 100644 public/icons/docs/htmx/16.png create mode 100644 public/icons/docs/htmx/16@2x.png create mode 100644 public/icons/docs/htmx/SOURCE diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 043a0401..b5340a3c 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2024-01-20", + "New documentation: htmx" + ], [ "2024-01-12", "New documentation: Hammerspoon" diff --git a/lib/docs/filters/htmx/clean_html.rb b/lib/docs/filters/htmx/clean_html.rb new file mode 100644 index 00000000..4c14c6aa --- /dev/null +++ b/lib/docs/filters/htmx/clean_html.rb @@ -0,0 +1,13 @@ +module Docs + class Htmx + class CleanHtmlFilter < Filter + def call + css('.zola-anchor').remove + doc.prepend_child("

htmx

") if root_page? + css('div:contains("NEWS:")').remove + css('h2:contains("sponsors"), #sponsor-table').remove + doc + end + end + end +end diff --git a/lib/docs/filters/htmx/entries.rb b/lib/docs/filters/htmx/entries.rb new file mode 100644 index 00000000..fc5053c6 --- /dev/null +++ b/lib/docs/filters/htmx/entries.rb @@ -0,0 +1,31 @@ +module Docs + class Htmx + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').content + end + + def get_type + if slug.start_with?('attributes') + 'Attributes' + elsif slug.start_with?('headers') + 'Headers' + elsif slug.start_with?('events') + 'Events' + elsif slug.start_with?('extensions') + 'Extensions' + else + get_name + end + end + + def additional_entries + css('h3[id]:has(code)').each_with_object [] do |node, entries| + name = node.at_css('code').content + id = node['id'] + entries << [name, id] + end + end + end + end +end diff --git a/lib/docs/scrapers/htmx.rb b/lib/docs/scrapers/htmx.rb new file mode 100644 index 00000000..6e6f638e --- /dev/null +++ b/lib/docs/scrapers/htmx.rb @@ -0,0 +1,35 @@ +module Docs + class Htmx < UrlScraper + self.name = 'htmx' + self.type = 'simple' + self.slug = 'htmx' + self.links = { + home: 'https://htmx.org/', + code: 'https://github.com/bigskysoftware/htmx' + } + self.release = '1.9.10' + self.base_url = "https://htmx.org/" + self.initial_paths = %w(reference/) + + html_filters.push 'htmx/entries', 'htmx/clean_html' + + options[:trailing_slash] = true + options[:container] = '.content' + options[:download_images] = false + options[:skip_patterns] = [ + /\Aessays/, + /\Aexamples/, + /\Amigration-guide/, + /\Aposts/, + ] + + # https://github.com/bigskysoftware/htmx/blob/master/LICENSE + options[:attribution] = <<-HTML + Licensed under the Zero-Clause BSD + HTML + + def get_latest_version(opts) + get_npm_version('htmx.org', opts) + end + end +end diff --git a/public/icons/docs/htmx/16.png b/public/icons/docs/htmx/16.png new file mode 100644 index 0000000000000000000000000000000000000000..8f98938fa6de1fd60eda87610df8925a6ec35370 GIT binary patch literal 817 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=Ijcz0ZMQdctjR6Fz_7)VaDV6D^h@h>?NMQuIw)uMMMR- zQj{DXGcYhF1^9%xDk>@}DJdx{D}x9XRb?dwMOiT=B}Ek#6=f9_H63$3mwZ(XJr!k; zw3?cly1Kfmnud~`s8K+tZQ&IS4GmRQRe5=NK|w(s9UVPAJ)lXdDoWPbC-i-q^fVPT zwR98|6r`o4?d|R7%$f7;+qb;@0&!6RUCRK+%E!{G=8g5$U%q^uIB}x6xw)L2+?Ow3 zwrtrF7Z<0iXP_)EZW1!lI_t2ClDxjYL27F1-o1Oje*N0r-Mw__(%-*-uU@@6ARs_f zQ^O|jtdU=ns)B^Jj&68(_|~mk|NQwgdGcgWPtTPrSN{I}CoelyLD$2v;*p-2n}nE9 zb4%;bpFii#o9F20sHv$bDk^GjVP&kRY7{)#Dr29zs-mi@nuUdhv9Ym;h={hfwvLXj zin5}*rk-8deIuV*b!90nEiFw=EiDZ-9YY&qzb0)1OAU2ZElqU|6&Xzpb)XDTUQ1hB zOI!Eb%Pd7;1T64$aSW-r#d^?I&xMhp;b1;Teyf7Z(gK!N;WwNmSE`M-9$~a-naAAG zq`FD_wfa2C)H4yGqQ_QU`_n6$9eUNuK2+`g)|vNtBc^yZm;bJiEUQg1l4Mx3?Oxb7 zKE{NPuS#|@Gx+scM35I_EzGc^^Gpy5lC*!-l@%H&^=ku58@jYvQ@N+?B zs#yrL&T1p+RkDv4?Q1)=X4R@yzt|@ws?`*}Sp!O1swJ)wB`Jv|saDBFsX&Us$iT=% z*T7KM$RNbX(8|!%%EVOLz`)ADVBWd2b5Jzo=BH$)Rbpx|GJ|N45J|HFYS4h&P?DLO hT3nKtTY#>|%*xOJqQ^7yoIOwvgQu&X%Q~loCIIAO1B(Cv literal 0 HcmV?d00001 diff --git a/public/icons/docs/htmx/16@2x.png b/public/icons/docs/htmx/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..9f2fcf87d7988977276bb46a3feb6a1f064ee7c1 GIT binary patch literal 1607 zcmZXSc~DbV6viKRm+LYnvR(yVpV-!)H+=xs+Vg4AO{A3ox1_x4?@~G1OS;r02q!30BJb@ zxTaTKT_z(oW~HlR3;^KRJRLT-(oQE4qP3T+>gwuT zTwD+o;o0ynrX=%yM&i3>3 zgSa4!@}(P_{Sz-i5F8K?P*70N+1c6E)s>&0FA|A(Jf54ITXl7HZ*T9uefu;T4T4}0 zhvp$)t;p zmv4Q<^HM<|6Gl)5gP~9;ii(N`1_s8)#g(%AMn=w`KcASG$mjE6h>PIDMVoK= zt^Wq%vSH%IQB*7zo6Y9&@$t&a%HrbU=H_M;<-r`9ATU9Z`9!2K!5nvt$Ct@uPoF-0 z_wHR=TU$;}j+d7gj^ld0zOk{9>Q2L8mL#THmi`bI2f`4$ySw|`xpQ%Gaj~(np`oEH zCY>knU8KL`yY4K^Wrc->frJ|%h9D?Kk@d4EBm)6y7!T*+e3;AdjXNPryN`<%C=8;+ zk77Io262&Gnf=Un?P&yJp%7E3N|B}A69%R5_(I%6%;SqN48>4{hvU$w(wXqFO+sjh zDxyC%>>A%YTJ)1O0+2pmy!33Xj+fe#f!8L3NFX0_;joJCcn5#xh3%C{`gEB zZPMP@GxLOl6WQrZOqB5phZ#4zFZPmy?;rEN{Db$SRr=pZo3tMsqV|-JKFOwpHC32K zDz|XlW~STZL^zD==3vWjkc9843oN^056}I5 zzL7xeR`?KzJ+t_R$ujRJJ4_bFrB0CP6hA@{rKfq zV-^pk#a6essKs1!Amu^cof6?NE{Yi92iHuTC#KBV>hhNDia6*f~R zRstux=3N_lxA}3%PJ!zAuD&dkWue-p(rLwxi`6f8EN~cfB&kQrJp-Y6cVF2Wu0QCx z!t@;dZV)Jcw%vtZUQxUMq|GoXeQ-g#VW#=lLvgOhm#3xpJ<6|-Pp$ryl~`(JPxhhb#TO&f>J}wG>1gtb z!6Or61}2hoJiR2=_d&-pqOXa64%Oa21f$jMRyK>wLw+^E+XjO+F3|79dn;on0nlYMps189Q7RrQPG G^Zo?aid*ae literal 0 HcmV?d00001 diff --git a/public/icons/docs/htmx/SOURCE b/public/icons/docs/htmx/SOURCE new file mode 100644 index 00000000..bfba7d6d --- /dev/null +++ b/public/icons/docs/htmx/SOURCE @@ -0,0 +1 @@ +https://github.com/bigskysoftware/htmx/blob/v1.9.10/www/static/img/htmx_logo.2.png