Skip to content

Commit ae193f5

Browse files
committed
Add htmx documentation
1 parent c6a468f commit ae193f5

File tree

7 files changed

+84
-0
lines changed

7 files changed

+84
-0
lines changed

assets/javascripts/news.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

817 Bytes
Loading
1.57 KB
Loading

public/icons/docs/htmx/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/bigskysoftware/htmx/blob/v1.9.10/www/static/img/htmx_logo.2.png

0 commit comments

Comments
 (0)