Parcourir la source

Merge pull request #2134 from freeCodeCamp/htmx

Add htmx documentation
Simon Legner il y a 1 an
Parent
commit
ef799d1114

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
+  [
+    "2024-01-20",
+    "New documentation: <a href=\"/htmx/\">htmx</a>"
+  ],
   [
     "2024-01-12",
     "New documentation: <a href=\"/hammerspoon/\">Hammerspoon</a>"

+ 13 - 0
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("<h1>htmx</h1>") if root_page?
+        css('div:contains("NEWS:")').remove
+        css('h2:contains("sponsors"), #sponsor-table').remove
+        doc
+      end
+    end
+  end
+end

+ 31 - 0
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

+ 35 - 0
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

BIN
public/icons/docs/htmx/16.png


BIN
public/icons/docs/htmx/16@2x.png


+ 1 - 0
public/icons/docs/htmx/SOURCE

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