bridgetown-builder 1.2.0 → 1.3.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4f3b5e5443d455e70f7a05b0e89ee387b152c059924e6cff045bcf0eb285729
4
- data.tar.gz: 73b68f3525fac4a9640ceea765dbd4e63b313486a0b83843c5a03d572de2ac1b
3
+ metadata.gz: c38840e8a6fa31ce496039296a54f2c103c75dd503b46a36084362a8f0093c58
4
+ data.tar.gz: a84fd459c7175de01869185dfafada9ccdb52d2aa50ee2940903836eab939ddd
5
5
  SHA512:
6
- metadata.gz: 8fb5357911e9ebf372de1a8f3b0469d598863c7ea1f108c7594efc7b6b71055468f18d49dc8aea4beed6a7c03038a1f6a5e8ecfab9a31c8838102c47fdd125ad
7
- data.tar.gz: 5a677fb81f1142013dc178df1e4efdd6c08f6089b88e44e2400908ce5134d6a572b83ec438bb0c37cb430630534aa2c187d79e12e85347a5a4ab33278cc59964
6
+ metadata.gz: 25c3e036d3751fbf753080806040a72fe817f2e3be1bec149bfde0c5b272e13b308fcf6978359231029b4c37de0729c2376a8e912d3c7b419fd516135e48f6c9
7
+ data.tar.gz: c4f34a421f95bf817b8f475a1fb39880cc53a2746cd4a5bc47787ff51757ce559e13294b87e741ac491f0cf6f6d60acaec8242f70b3a3f86ccf561a010ff5a28
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "faraday_middleware/redirect_limit_reached"
4
- require "faraday_middleware/response/follow_redirects"
5
- require "faraday_middleware/response/parse_json"
3
+ require "faraday/follow_redirects"
6
4
 
7
5
  module Bridgetown
8
6
  module Builders
9
7
  module DSL
10
8
  module HTTP
11
- def get(url, headers: {}, parse_json: true)
9
+ def get(url, headers: {}, parse_json: true, **params)
12
10
  body = begin
13
- connection(parse_json: parse_json).get(url, headers: headers).body
11
+ connection(parse_json: parse_json).get(url, params, headers).body
14
12
  rescue Faraday::ParsingError
15
13
  Bridgetown.logger.error(
16
14
  "Faraday::ParsingError",
@@ -25,12 +23,14 @@ module Bridgetown
25
23
  headers["Content-Type"] = "application/json" if parse_json
26
24
 
27
25
  Faraday.new(headers: headers) do |faraday|
28
- faraday.use FaradayMiddleware::FollowRedirects
26
+ faraday.response :follow_redirects
27
+
29
28
  if parse_json
30
- faraday.use FaradayMiddleware::ParseJson, parser_options: {
29
+ faraday.response :json, parser_options: {
31
30
  object_class: HashWithDotAccess::Hash,
32
31
  }
33
32
  end
33
+
34
34
  yield faraday if block_given?
35
35
  end
36
36
  end
@@ -28,7 +28,11 @@ module Bridgetown
28
28
  #
29
29
  # @return [String] transformed HTML
30
30
  def self.call(resource, inspectors)
31
- doc = Nokogiri.HTML5(resource.output)
31
+ doc = if resource.site.config.html_inspector_parser == "nokolexbor"
32
+ Nokolexbor::HTML(resource.output)
33
+ else
34
+ Nokogiri.HTML5(resource.output)
35
+ end
32
36
 
33
37
  inspectors.each do |block|
34
38
  block.call(doc, resource)
@@ -73,9 +77,16 @@ module Bridgetown
73
77
  Bridgetown::Utils::RequireGems.require_with_graceful_fail "nokogiri"
74
78
  end
75
79
 
76
- return if Nokogiri::XML::Node <= QuerySelection
80
+ Nokogiri::XML::Node.include QuerySelection unless Nokogiri::XML::Node <= QuerySelection
81
+ end
82
+
83
+ # Require the Nokolexbor gem if necessary and add the `QuerySelection` mixin
84
+ def setup_nokolexbor
85
+ unless defined?(Nokolexbor)
86
+ Bridgetown::Utils::RequireGems.require_with_graceful_fail "nokolexbor"
87
+ end
77
88
 
78
- Nokogiri::XML::Node.include QuerySelection
89
+ Nokolexbor::Node.include QuerySelection unless Nokolexbor::Node <= QuerySelection
79
90
  end
80
91
 
81
92
  # Shorthand for `HTML.call`
@@ -91,12 +102,17 @@ module Bridgetown
91
102
 
92
103
  # Set up an inspector to review or manipulate HTML resources
93
104
  # @yield the block to be called after the resource has been rendered
94
- # @yieldparam [Nokogiri::HTML5::Document] the Nokogiri document
105
+ # @yieldparam [Nokogiri::HTML5::Document, Nokolexbor::Document]
106
+ # the Nokogiri or Nokolexbor document
95
107
  def inspect_html(&block)
96
108
  unless @_html_inspectors
97
109
  @_html_inspectors = []
98
110
 
99
- Inspectors.setup_nokogiri
111
+ if site.config.html_inspector_parser == "nokolexbor"
112
+ Inspectors.setup_nokolexbor
113
+ else
114
+ Inspectors.setup_nokogiri
115
+ end
100
116
 
101
117
  hook :resources, :post_render do |resource|
102
118
  next unless HTML.can_run?(resource, @_html_inspectors)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-25 00:00:00.000000000 Z
11
+ date: 2023-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.3.0.beta2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 1.3.0.beta2
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []
@@ -62,9 +62,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - ">"
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: 1.3.1
68
68
  requirements: []
69
69
  rubygems_version: 3.1.4
70
70
  signing_key: