فهرست منبع

Finish Liquid scraper

Thibaut Courouble 8 سال پیش
والد
کامیت
22461b057d

BIN
assets/images/docs.png


BIN
assets/images/docs@2x.png


+ 3 - 0
assets/javascripts/news.json

@@ -1,5 +1,8 @@
 [
   [
+    "2017-05-14",
+    "New documentation: <a href=\"/liquid/\">Liquid</a>"
+  ], [
     "2017-04-30",
     "New documentation: <a href=\"/openjdk/\">OpenJDK</a>"
   ], [

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -323,6 +323,11 @@ credits = [
     '2009-2016 The Core Less Team',
     'CC BY',
     'https://creativecommons.org/licenses/by/3.0/'
+  ], [
+    'Liquid',
+    '2005, 2006 Tobias Luetke',
+    'MIT',
+    'https://raw.githubusercontent.com/Shopify/liquid/master/LICENSE'
   ], [
     'Lo-Dash',
     '2012-2016 The Dojo Foundation',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -43,6 +43,7 @@
 %icon-clipboard-white       { background-position: -1rem -2rem; }
 %icon-close-white           { background-position: -2rem -2rem; }
 
+._icon-liquid:before        { background-position: -1rem 0; }
 ._icon-openjdk:before       { background-position: -2rem 0; }
 ._icon-codeceptjs:before    { background-position: -3rem 0; }
 ._icon-codeception:before   { background-position: -4rem 0; }

+ 1 - 14
assets/stylesheets/pages/_liquid.scss

@@ -1,18 +1,5 @@
 ._liquid {
   @extend %simple;
 
-  .code-label {
-    @extend %block-label, %label-green;
-    border-bottom-left-radius: 0;
-    border-bottom-right-radius: 0;
-    margin-left: 0;
-    margin-right: 0;
-    margin-bottom: -1px;
-  }
-
-  .code-label ~ div > pre {
-    margin-top: 0;
-    border-top-left-radius: 0;
-    border-top-right-radius: 0;
-  }
+  p.code-label { @extend %pre-heading; }
 }

+ 6 - 19
lib/docs/filters/liquid/clean_html.rb

@@ -2,29 +2,16 @@ module Docs
   class Liquid
     class CleanHtmlFilter < Filter
       def call
-        root_page? ? root : other
-      end
-
-      def root
-        doc = at_css('.home-banner')
-
-        css('.btn-row').remove
-
-        doc
-      end
-
-      def other
-        doc = at_css('.content__area > .content')
+        @doc = at_css('.content__area > .content')
 
-        css('button.menu-button').remove
+        css('.home-banner', '.menu-button', '#used-by', '#used-by ~ *').remove
 
-        css('code').each do |node|
-          node.remove_attribute('class')
-          node.content = node.content
+        css('.highlighter-rouge').each do |node|
+          node.before(node.children).remove
         end
 
-        css('pre', '.highlighter-rouge').each do |node|
-          node.remove_attribute('class')
+        css('pre').each do |node|
+          node.content = node.content.strip
         end
 
         doc

+ 4 - 11
lib/docs/filters/liquid/entries.rb

@@ -6,23 +6,16 @@ module Docs
       end
 
       def get_type
-        if not root_page?
-          slug.split('/').first.capitalize
-        end
+        slug.split('/').first.capitalize
       end
 
       def additional_entries
-        entries = []
+        return [] unless type == 'Tags'
 
-        if get_type == 'Tags'
-          css('h2').each do |node|
-            entries << [node.content, node['id']]
-          end
+        css('h2').map do |node|
+          [node.content, node['id']]
         end
-
-        entries
       end
-
     end
   end
 end

+ 8 - 5
lib/docs/scrapers/liquid.rb

@@ -2,18 +2,21 @@ module Docs
   class Liquid < UrlScraper
     self.name = 'Liquid'
     self.type = 'liquid'
-    self.base_url = "https://shopify.github.io/liquid/"
+    self.base_url = 'https://shopify.github.io/liquid/'
+    self.release = '4.0.0'
     self.links = {
-      home: 'http://liquidmarkup.org/',
-      code: 'https://github.com/shopify/liquid'
+      home: 'https://shopify.github.io/liquid/',
+      code: 'https://github.com/Shopify/liquid'
     }
 
-    html_filters.push 'liquid/entries', 'liquid/clean_html'
+    html_filters.push 'liquid/entries', 'liquid/clean_html', 'title'
+
+    options[:title] = false
+    options[:root_title] = 'Liquid'
 
     options[:attribution] = <<-HTML
       &copy; 2005, 2006 Tobias Luetke<br>
       Licensed under the MIT License.
     HTML
-
   end
 end

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


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


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

@@ -1 +0,0 @@
-https://shopify.github.io/liquid/images/icons/water-drop-64x.png

BIN
public/icons/docs/liquid/water-drop-64x.png