grover 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/grover/configuration.rb +1 -3
- data/lib/grover/middleware.rb +6 -12
- data/lib/grover/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1062c1738a1216a3c8fb5907b1abcb5abee7ef4e
|
4
|
+
data.tar.gz: 7a6aea69f2eaa43d30f0c126f0baea36c3b70470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3824873485392bc39b03509cd88f296555aaea0984eaff8158be31bee78fc282d790d86cb988bf05eac1035a866d0306131fd31dd4d67fdca0157e3e241e3721
|
7
|
+
data.tar.gz: 7f2ce9086e1206c2464232f80893b7098272737cb74398299514b6c8ed2f817e4485706965f73f858ac0f5e13c10b58653d84b1d574042b76225da0a954d08bd
|
data/lib/grover/configuration.rb
CHANGED
data/lib/grover/middleware.rb
CHANGED
@@ -15,9 +15,9 @@ class Grover
|
|
15
15
|
|
16
16
|
def call(env)
|
17
17
|
@request = Rack::Request.new(env)
|
18
|
-
@render_pdf =
|
18
|
+
@render_pdf = pdf_request?
|
19
19
|
|
20
|
-
configure_env_for_pdf_request(env) if
|
20
|
+
configure_env_for_pdf_request(env) if rendering_pdf?
|
21
21
|
status, headers, response = @app.call(env)
|
22
22
|
|
23
23
|
if rendering_pdf? && html_content?(headers)
|
@@ -37,7 +37,7 @@ class Grover
|
|
37
37
|
@render_pdf
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def pdf_request?
|
41
41
|
!@request.path.match(PDF_REGEX).nil?
|
42
42
|
end
|
43
43
|
|
@@ -59,7 +59,7 @@ class Grover
|
|
59
59
|
body = body.join if body.is_a?(Array)
|
60
60
|
|
61
61
|
body = HTMLPreprocessor.process body, root_url, protocol
|
62
|
-
Grover.new(body, display_url: request_url
|
62
|
+
Grover.new(body, display_url: request_url)
|
63
63
|
end
|
64
64
|
|
65
65
|
def add_cover_content(grover)
|
@@ -88,10 +88,7 @@ class Grover
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def configure_env_for_pdf_request(env)
|
91
|
-
|
92
|
-
|
93
|
-
env['PATH_INFO'] = path_without_extension
|
94
|
-
env['REQUEST_URI'] = path_without_extension
|
91
|
+
env['PATH_INFO'] = env['REQUEST_URI'] = path_without_extension
|
95
92
|
env['HTTP_ACCEPT'] = concat(env['HTTP_ACCEPT'], Rack::Mime.mime_type('.html'))
|
96
93
|
env['Rack-Middleware-Grover'] = 'true'
|
97
94
|
end
|
@@ -109,10 +106,7 @@ class Grover
|
|
109
106
|
end
|
110
107
|
|
111
108
|
def path_without_extension
|
112
|
-
|
113
|
-
|
114
|
-
path = @request.path.sub(PDF_REGEX, '')
|
115
|
-
@path_without_extension = path.sub(@request.script_name, '')
|
109
|
+
@request.path.sub(PDF_REGEX, '').sub(@request.script_name, '')
|
116
110
|
end
|
117
111
|
|
118
112
|
def request_url
|
data/lib/grover/version.rb
CHANGED