History

Add htmx documentation

Simon Legner committed 2 years ago

Commit ae193f51 parent c6a468f7 files · +82 −-2Browse files

Unified · Split

7 files
  1. assets/javascripts/news.json +4 −0
  2. lib/docs/filters/htmx/clean_html.rb +13 −0
  3. lib/docs/filters/htmx/entries.rb +31 −0
  4. lib/docs/scrapers/htmx.rb +35 −0
  5. public/icons/docs/htmx/16.png +0 −0
  6. public/icons/docs/htmx/16@2x.png +0 −0
  7. public/icons/docs/htmx/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
11 [
2+ [
3+ "2024-01-20",
4+ "New documentation: <a href=\"/htmx/\">htmx</a>"
5+ ],
26 [
37 "2024-01-12",
48 "New documentation: <a href=\"/hammerspoon/\">Hammerspoon</a>"
lib/docs/filters/htmx/clean_html.rb+13−0
@@ -0,0 +1,13 @@
1+module Docs
2+ class Htmx
3+ class CleanHtmlFilter < Filter
4+ def call
5+ css('.zola-anchor').remove
6+ doc.prepend_child("<h1>htmx</h1>") if root_page?
7+ css('div:contains("NEWS:")').remove
8+ css('h2:contains("sponsors"), #sponsor-table').remove
9+ doc
10+ end
11+ end
12+ end
13+end
lib/docs/filters/htmx/entries.rb+31−0
@@ -0,0 +1,31 @@
1+module Docs
2+ class Htmx
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ at_css('h1').content
6+ end
7+
8+ def get_type
9+ if slug.start_with?('attributes')
10+ 'Attributes'
11+ elsif slug.start_with?('headers')
12+ 'Headers'
13+ elsif slug.start_with?('events')
14+ 'Events'
15+ elsif slug.start_with?('extensions')
16+ 'Extensions'
17+ else
18+ get_name
19+ end
20+ end
21+
22+ def additional_entries
23+ css('h3[id]:has(code)').each_with_object [] do |node, entries|
24+ name = node.at_css('code').content
25+ id = node['id']
26+ entries << [name, id]
27+ end
28+ end
29+ end
30+ end
31+end
lib/docs/scrapers/htmx.rb+35−0
@@ -0,0 +1,35 @@
1+module Docs
2+ class Htmx < UrlScraper
3+ self.name = 'htmx'
4+ self.type = 'simple'
5+ self.slug = 'htmx'
6+ self.links = {
7+ home: 'https://htmx.org/',
8+ code: 'https://github.com/bigskysoftware/htmx'
9+ }
10+ self.release = '1.9.10'
11+ self.base_url = "https://htmx.org/"
12+ self.initial_paths = %w(reference/)
13+
14+ html_filters.push 'htmx/entries', 'htmx/clean_html'
15+
16+ options[:trailing_slash] = true
17+ options[:container] = '.content'
18+ options[:download_images] = false
19+ options[:skip_patterns] = [
20+ /\Aessays/,
21+ /\Aexamples/,
22+ /\Amigration-guide/,
23+ /\Aposts/,
24+ ]
25+
26+ # https://github.com/bigskysoftware/htmx/blob/master/LICENSE
27+ options[:attribution] = <<-HTML
28+ Licensed under the Zero-Clause BSD
29+ HTML
30+
31+ def get_latest_version(opts)
32+ get_npm_version('htmx.org', opts)
33+ end
34+ end
35+end
public/icons/docs/htmx/16.png+0−0

Binary file not shown.

public/icons/docs/htmx/16@2x.png+0−0

Binary file not shown.

public/icons/docs/htmx/SOURCE+1−0
@@ -0,0 +1 @@
1+https://github.com/bigskysoftware/htmx/blob/v1.9.10/www/static/img/htmx_logo.2.png