diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 79edd81b..0e348f9d 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -842,6 +842,11 @@ credits = [ '2004-2017 Fabien Potencier', 'MIT', 'https://symfony.com/doc/current/contributing/code/license.html' + ], [ + 'TailwindCSS', + 'Adam Wathan', + 'MIT', + 'https://raw.githubusercontent.com/tailwindlabs/tailwindcss/master/LICENSE' ], [ 'Tcl/Tk', 'The Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, and other parties', diff --git a/lib/docs/filters/tailwindcss/clean_html.rb b/lib/docs/filters/tailwindcss/clean_html.rb new file mode 100644 index 00000000..fda174a2 --- /dev/null +++ b/lib/docs/filters/tailwindcss/clean_html.rb @@ -0,0 +1,77 @@ +module Docs + class Tailwindcss + class CleanHtmlFilter < Filter + def call + clean_up + + # Remove code highlighting + css('pre').each do |node| + node.content = node.content + node['data-language'] = 'php' + end + + doc + end + + def clean_up + @doc = doc.at_css('#content-wrapper') + + css('.location').remove + + # Replace .header with

+ css('.page-header > h1').each do |node| + node.content = 'Tailwind' if root_page? + node.parent.before(node).remove + end + + css('.container-fluid').each do |node| + node.name = 'table' + node.css('.row').each { |n| n.name = 'tr' } + node.css('div[class^="col"]').each { |n| n.name = 'td' } + end + + css('> div').each do |node| + node.before(node.children).remove + end + + # Remove + css('a > abbr').each do |node| + node.parent['title'] = node['title'] + node.before(node.children).remove + end + + # Clean up headings + css('h1 > a', '.content', 'h3 > code', 'h3 strong', 'abbr').each do |node| + node.before(node.children).remove + end + + # Remove empty + css('td').each do |node| + node.remove if node.content =~ /\A\s+\z/ + end + + # @doc = at_css('.docs_body') + + # Clean up headings + css('h2 > a').each do |node| + node.before(node.children).remove + end + + css('p > a[name]').each do |node| + node.parent.next_element['id'] = node['name'] + end + + css('blockquote').each do |node| + node['class'] = 'tip' if node.inner_html.include?('{tip}') + node.inner_html = node.inner_html.remove(/\{(tip|note)\}\s?/) + end + + css('blockquote').each do |node| + if node.inner_html.include?('You\'re browsing the documentation for an old version of Laravel.') + node.remove + end + end + end + end + end +end diff --git a/lib/docs/filters/tailwindcss/entries.rb b/lib/docs/filters/tailwindcss/entries.rb new file mode 100644 index 00000000..2fc2af2b --- /dev/null +++ b/lib/docs/filters/tailwindcss/entries.rb @@ -0,0 +1,51 @@ +module Docs + class Tailwindcss + class EntriesFilter < Docs::EntriesFilter + # def get_name + # if api_page? + # name = at_css('h1').content.strip.remove('Illuminate\\') + # name << " (#{type})" unless name.start_with?(self.type) + # name + # else + # at_css('h1').content + # end + # end + + def get_type + # /customizing-colors rediects to /colors, hence making css + # selector below not to match the href + if result[:path] == 'customizing-colors' + selector = "#sidebar a[href='#{result[:path]}']" + else + selector = "#sidebar a[href='#{result[:path]}']" + end + + check = at_css(selector).parent.parent.parent.css('h5').inner_text + check + end + + # def additional_entries + # return [] if root_page? || !api_page? + # base_name = self.name.remove(/\(.+\)/).strip + + # css('h3[id^="method_"]').each_with_object [] do |node, entries| + # next if node.at_css('.location').content.start_with?('in') + + # name = node['id'].remove('method_') + # name.prepend "#{base_name}::" + # name << '()' + + # entries << [name, node['id']] + # end + # end + + # def api_page? + # subpath.start_with?('/api') + # end + + # def include_default_entry? + # true + # end + end + end +end diff --git a/lib/docs/scrapers/tailwindcss.rb b/lib/docs/scrapers/tailwindcss.rb new file mode 100644 index 00000000..d13dfe24 --- /dev/null +++ b/lib/docs/scrapers/tailwindcss.rb @@ -0,0 +1,31 @@ +module Docs + class Tailwindcss < UrlScraper + self.name = 'Tailwind CSS' + self.type = 'tailwindcss' + self.slug = 'tailwindcss' + self.base_url = 'https://tailwindcss.com/docs' + self.root_path = '/installation' + self.release = '8.5' + + html_filters.push 'tailwindcss/entries', 'tailwindcss/clean_html' + + # options[:container] = 'body'; + + options[:skip_patterns] = [ + %r{\/guides\/.*}, + %r{\/colors\z} + ] + + #Obtainable from https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE + options[:attribution] = <<-HTML + MIT License
+ Copyright (c) Adam Wathan
+ Copyright (c) Jonathan Reinink
+ HTML + + def get_latest_version(opts) + doc = fetch_doc('https://tailwindcss.com/docs/installation', opts) + doc.at_css('select option[value=v2]').inner_text + end + end +end diff --git a/public/icons/docs/tailwindcss/16.png b/public/icons/docs/tailwindcss/16.png new file mode 100644 index 00000000..697450ec Binary files /dev/null and b/public/icons/docs/tailwindcss/16.png differ diff --git a/public/icons/docs/tailwindcss/16@2x.png b/public/icons/docs/tailwindcss/16@2x.png new file mode 100644 index 00000000..d84c40ff Binary files /dev/null and b/public/icons/docs/tailwindcss/16@2x.png differ