Showing the changes to lib/docs (3 of 8 files). Show all
Unified · Split
| @@ -0,0 +1,34 @@ | |||
| 1 | module Docs | ||
| 2 | class Liquid | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | root_page? ? root : other | ||
| 6 | end | ||
| 7 | |||
| 8 | def root | ||
| 9 | doc = at_css('.home-banner') | ||
| 10 | |||
| 11 | css('.btn-row').remove | ||
| 12 | |||
| 13 | doc | ||
| 14 | end | ||
| 15 | |||
| 16 | def other | ||
| 17 | doc = at_css('.content__area > .content') | ||
| 18 | |||
| 19 | css('button.menu-button').remove | ||
| 20 | |||
| 21 | css('code').each do |node| | ||
| 22 | node.remove_attribute('class') | ||
| 23 | node.content = node.content | ||
| 24 | end | ||
| 25 | |||
| 26 | css('pre', '.highlighter-rouge').each do |node| | ||
| 27 | node.remove_attribute('class') | ||
| 28 | end | ||
| 29 | |||
| 30 | doc | ||
| 31 | end | ||
| 32 | end | ||
| 33 | end | ||
| 34 | end | ||
| @@ -0,0 +1,28 @@ | |||
| 1 | module Docs | ||
| 2 | class Liquid | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | def get_name | ||
| 5 | at_css('h1').content | ||
| 6 | end | ||
| 7 | |||
| 8 | def get_type | ||
| 9 | if not root_page? | ||
| 10 | slug.split('/').first.capitalize | ||
| 11 | end | ||
| 12 | end | ||
| 13 | |||
| 14 | def additional_entries | ||
| 15 | entries = [] | ||
| 16 | |||
| 17 | if get_type == 'Tags' | ||
| 18 | css('h2').each do |node| | ||
| 19 | entries << [node.content, node['id']] | ||
| 20 | end | ||
| 21 | end | ||
| 22 | |||
| 23 | entries | ||
| 24 | end | ||
| 25 | |||
| 26 | end | ||
| 27 | end | ||
| 28 | end | ||
| @@ -0,0 +1,19 @@ | |||
| 1 | module Docs | ||
| 2 | class Liquid < UrlScraper | ||
| 3 | self.name = 'Liquid' | ||
| 4 | self.type = 'liquid' | ||
| 5 | self.base_url = "https://shopify.github.io/liquid/" | ||
| 6 | self.links = { | ||
| 7 | home: 'http://liquidmarkup.org/', | ||
| 8 | code: 'https://github.com/shopify/liquid' | ||
| 9 | } | ||
| 10 | |||
| 11 | html_filters.push 'liquid/entries', 'liquid/clean_html' | ||
| 12 | |||
| 13 | options[:attribution] = <<-HTML | ||
| 14 | © 2005, 2006 Tobias Luetke<br> | ||
| 15 | Licensed under the MIT License. | ||
| 16 | HTML | ||
| 17 | |||
| 18 | end | ||
| 19 | end | ||