bidi2pdf-rails 0.0.1.pre.alpha → 0.1.1
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/.idea/bidi2pdf-rails.iml +68 -84
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +54 -0
- data/README.md +118 -28
- data/Rakefile +2 -0
- data/cliff.toml +126 -0
- data/lib/bidi2pdf_rails/browser_console_log_subscriber.rb +24 -0
- data/lib/bidi2pdf_rails/chromedriver_manager_singleton.rb +11 -11
- data/lib/bidi2pdf_rails/config.rb +137 -0
- data/lib/bidi2pdf_rails/configurable.rb +106 -0
- data/lib/bidi2pdf_rails/main_log_subscriber.rb +33 -0
- data/lib/bidi2pdf_rails/network_log_subscriber.rb +20 -0
- data/lib/bidi2pdf_rails/railtie.rb +13 -45
- data/lib/bidi2pdf_rails/services/html_renderer.rb +33 -0
- data/lib/bidi2pdf_rails/services/html_to_pdf_converter.rb +37 -0
- data/lib/bidi2pdf_rails/services/pdf_browser_session.rb +38 -0
- data/lib/bidi2pdf_rails/services/pdf_injection.rb +31 -0
- data/lib/bidi2pdf_rails/services/pdf_renderer.rb +94 -0
- data/lib/bidi2pdf_rails/services/url_to_pdf_converter.rb +91 -0
- data/lib/bidi2pdf_rails/version.rb +1 -1
- data/lib/bidi2pdf_rails.rb +41 -58
- data/lib/generators/bidi2pdf_rails/USAGE +12 -4
- data/lib/generators/bidi2pdf_rails/initializer_generator.rb +136 -30
- data/lib/generators/bidi2pdf_rails/templates/bidi2pdf_rails.rb.tt +25 -79
- data/spec/acceptance/user_can_download_report_pdf_spec.rb +133 -0
- data/spec/acceptance/user_can_generate_pdf_from_protected_remote_url_spec.rb +173 -0
- data/spec/acceptance/user_can_inject_css_before_pdf_printing_spec.rb +132 -0
- data/spec/acceptance/user_can_inject_js_before_pdf_printing_spec.rb +158 -0
- data/spec/dummy/app/assets/javascripts/simple.js +12 -0
- data/spec/dummy/app/assets/stylesheets/simple.css +3 -0
- data/spec/dummy/app/controllers/reports_controller.rb +47 -0
- data/spec/dummy/app/controllers/secure_controller.rb +52 -0
- data/spec/dummy/app/views/layouts/simple.html.erb +17 -0
- data/spec/dummy/app/views/reports/simple.html.erb +6 -0
- data/spec/dummy/app/views/secure/show.html.erb +10 -0
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/initializers/bidi2pdf_rails.rb +72 -54
- data/spec/dummy/config/initializers/cors.rb +1 -1
- data/spec/dummy/config/routes.rb +14 -0
- data/spec/dummy/log/development.log +18331 -158
- data/spec/dummy/log/test.log +87874 -0
- data/spec/dummy/tmp/pids/server.pid +1 -1
- data/spec/integration/generators/bidi2pdf_rails/initializer_generator_spec.rb +64 -0
- data/spec/rails_helper.rb +8 -1
- data/spec/spec_helper.rb +47 -5
- data/spec/support/default_dirs_helper.rb +32 -0
- data/spec/support/pdf_helper.rb +12 -0
- data/spec/support/render_setting_helpers.rb +47 -0
- data/spec/support/request_server_bootstrap.rb +44 -0
- data/spec/{bidi2pdf_rails → unit/bidi2pdf_rails}/bidi2pdf_rails_spec.rb +1 -1
- data/spec/unit/bidi2pdf_rails/configurable/base_nested_config_spec.rb +133 -0
- data/tasks/changelog.rake +29 -0
- data/tasks/coverage.rake +23 -0
- metadata +108 -27
- data/lib/bidi2pdf_rails/log_subscriber.rb +0 -13
- data/spec/dummy/spec/helpers/reports_helper_spec.rb +0 -15
- data/spec/dummy/spec/requests/reports_spec.rb +0 -10
- data/spec/dummy/spec/views/reports/show.html.erb_spec.rb +0 -5
- data/spec/generator/bidie2pdf_rails_initializer_generator_spec.rb +0 -5
- data/spec/generator/initializer_generator_spec.rb +0 -5
- data/spec/requests/reports_spec.rb +0 -17
@@ -0,0 +1,158 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails_helper"
|
4
|
+
require "net/http"
|
5
|
+
require "rack/handler/puma"
|
6
|
+
require "socket"
|
7
|
+
require "base64"
|
8
|
+
|
9
|
+
RSpec.feature "As a user, I want to inject js into a website before printing a PDF", :pdf, type: :request do
|
10
|
+
before(:all) do
|
11
|
+
# Bidi2pdfRails.config.general_options.headless = false
|
12
|
+
Bidi2pdfRails::ChromedriverManagerSingleton.initialize_manager force: true
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
Bidi2pdfRails::ChromedriverManagerSingleton.shutdown
|
17
|
+
end
|
18
|
+
|
19
|
+
scenario "Using raw CSS" do
|
20
|
+
# Controller setup:
|
21
|
+
#
|
22
|
+
# You can configure basic auth in two ways:
|
23
|
+
#
|
24
|
+
# 1. In an initializer (global config):
|
25
|
+
#
|
26
|
+
# Bidi2pdfRails.configure do |config|
|
27
|
+
# config.pdf_settings.custom_js = <<~JS
|
28
|
+
# // insert styles into the page with javascript
|
29
|
+
# document.head.insertAdjacentHTML('beforeend', `
|
30
|
+
# <style>
|
31
|
+
# p {
|
32
|
+
# page-break-after: always;
|
33
|
+
# }
|
34
|
+
# </style>
|
35
|
+
# `);
|
36
|
+
# document.body.insertAdjacentHTML('beforeend', `
|
37
|
+
# <p>7</p>
|
38
|
+
# <p>8</p>
|
39
|
+
# `);
|
40
|
+
# JS
|
41
|
+
#
|
42
|
+
# 2. Inline within controller action:
|
43
|
+
# js = <<~JS
|
44
|
+
# // insert styles into the page with javascript
|
45
|
+
# document.head.insertAdjacentHTML('beforeend', `
|
46
|
+
# <style>
|
47
|
+
# p {
|
48
|
+
# page-break-after: always;
|
49
|
+
# }
|
50
|
+
# </style>
|
51
|
+
# `);
|
52
|
+
# document.body.insertAdjacentHTML('beforeend', `
|
53
|
+
# <p>7</p>
|
54
|
+
# <p>8</p>
|
55
|
+
# `);
|
56
|
+
# JS
|
57
|
+
# render pdf: 'inject-js-raw',
|
58
|
+
# custom_js: js,
|
59
|
+
# layout: 'simple',
|
60
|
+
# template: 'reports/simple',
|
61
|
+
# wait_for_page_loaded: false,
|
62
|
+
# print_options: { page: { format: :A4 } }
|
63
|
+
#
|
64
|
+
|
65
|
+
when_ "I request a PDF from a page and inject raw js" do
|
66
|
+
before do
|
67
|
+
with_pdf_settings :custom_js, <<-JS
|
68
|
+
// insert styles into the page with javascript
|
69
|
+
document.head.insertAdjacentHTML('beforeend', `
|
70
|
+
<style>
|
71
|
+
p {
|
72
|
+
page-break-after: always;
|
73
|
+
}
|
74
|
+
</style>
|
75
|
+
`);
|
76
|
+
document.body.insertAdjacentHTML('beforeend', `
|
77
|
+
<p>7</p>
|
78
|
+
<p>8</p>
|
79
|
+
`);
|
80
|
+
JS
|
81
|
+
|
82
|
+
@response = get_pdf_response "/inject/raw-js"
|
83
|
+
end
|
84
|
+
|
85
|
+
then_ "I receive a successful HTTP response" do
|
86
|
+
expect(@response.code).to eq("200")
|
87
|
+
end
|
88
|
+
|
89
|
+
and_ "I receive a PDF file in response" do
|
90
|
+
expect(@response['Content-Type']).to eq("application/pdf")
|
91
|
+
end
|
92
|
+
|
93
|
+
and_ "the PDF contains the expected number of pages" do
|
94
|
+
expected_page_count = 8
|
95
|
+
expect(@response.body).to have_pdf_page_count(expected_page_count)
|
96
|
+
end
|
97
|
+
|
98
|
+
and_ "the disposition header is set to attachment" do
|
99
|
+
expect(@response['Content-Disposition']).to start_with('inline; filename="inject-raw-js.pdf"')
|
100
|
+
end
|
101
|
+
|
102
|
+
and_ 'the last page contains the expected content ("6")' do
|
103
|
+
expect(@response.body).to contains_pdf_text("6").at_page(6)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
scenario "Using an external javascript file" do
|
109
|
+
# Controller setup:
|
110
|
+
#
|
111
|
+
# You can configure cookies in two ways:
|
112
|
+
#
|
113
|
+
# 1. In an initializer (global config):
|
114
|
+
#
|
115
|
+
# Bidi2pdfRails.configure do |config|
|
116
|
+
# config.pdf_settings.custom_js_url = ->(controller) { controller.view_context.asset_url 'javascripts/simple.js' }
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# 2. Inline within controller action:
|
120
|
+
#
|
121
|
+
# render pdf: 'inject-js-url',
|
122
|
+
# custom_js_url: view_context.asset_url('javascripts/simple.js'),
|
123
|
+
# layout: 'simple',
|
124
|
+
# template: 'reports/simple',
|
125
|
+
# wait_for_page_loaded: false,
|
126
|
+
# print_options: { page: { format: :A4 } }
|
127
|
+
#
|
128
|
+
|
129
|
+
when_ "I request a PDF from a page and inject an external stylesheet" do
|
130
|
+
before do
|
131
|
+
with_pdf_settings :custom_js_url, ->(controller) { controller.view_context.asset_url 'javascripts/simple.js' }
|
132
|
+
|
133
|
+
@response = get_pdf_response "/inject/url-js"
|
134
|
+
end
|
135
|
+
|
136
|
+
then_ "I receive a successful HTTP response" do
|
137
|
+
expect(@response.code).to eq("200")
|
138
|
+
end
|
139
|
+
|
140
|
+
and_ "I receive a PDF file in response" do
|
141
|
+
expect(@response['Content-Type']).to eq("application/pdf")
|
142
|
+
end
|
143
|
+
|
144
|
+
and_ "the PDF contains the expected number of pages" do
|
145
|
+
expected_page_count = 8
|
146
|
+
expect(@response.body).to have_pdf_page_count(expected_page_count)
|
147
|
+
end
|
148
|
+
|
149
|
+
and_ "the disposition header is set to attachment" do
|
150
|
+
expect(@response['Content-Disposition']).to start_with('inline; filename="inject-url-js.pdf"')
|
151
|
+
end
|
152
|
+
|
153
|
+
and_ 'the last page contains the expected content ("6")' do
|
154
|
+
expect(@response.body).to contains_pdf_text(6).at_page(6)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -5,4 +5,51 @@ class ReportsController < ApplicationController
|
|
5
5
|
format.pdf { render pdf: 'my-report', layout: 'pdf' }
|
6
6
|
end
|
7
7
|
end
|
8
|
+
|
9
|
+
def convert_remote_url
|
10
|
+
render pdf: 'convert-remote-url', url: "http://example.com", wait_for_page_loaded: false, print_options: { page: { format: :A4 } }
|
11
|
+
end
|
12
|
+
|
13
|
+
def inline_html
|
14
|
+
html = <<~HTML
|
15
|
+
<html>
|
16
|
+
<head>
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<h1>PDF Rendering Sample</h1>
|
20
|
+
<p style="page-break-after: always;">Page break</p>
|
21
|
+
<p>Content Page 2</p>
|
22
|
+
</body>
|
23
|
+
</html>
|
24
|
+
HTML
|
25
|
+
render pdf: 'inline-html', inline: html, wait_for_page_loaded: false, print_options: { page: { format: :A4 } }
|
26
|
+
end
|
27
|
+
|
28
|
+
def inject
|
29
|
+
render pdf: "inject-#{params[:kind]}", layout: 'simple', template: 'reports/simple', wait_for_page_loaded: false, print_options: { page: { format: :A4 } }
|
30
|
+
end
|
31
|
+
|
32
|
+
def convert_remote_url_basic_auth
|
33
|
+
render pdf: 'convert-remote-url-basic-auth',
|
34
|
+
url: basic_auth_endpoint_url(only_path: false),
|
35
|
+
wait_for_page_loaded: false
|
36
|
+
end
|
37
|
+
|
38
|
+
def convert_remote_url_cookie
|
39
|
+
render pdf: 'convert-remote-url-cookie',
|
40
|
+
url: cookie_endpoint_url(only_path: false),
|
41
|
+
wait_for_page_loaded: false
|
42
|
+
end
|
43
|
+
|
44
|
+
def convert_remote_url_header
|
45
|
+
render pdf: 'convert-remote-url-cookie',
|
46
|
+
url: api_endpoint_url(only_path: false),
|
47
|
+
wait_for_page_loaded: false
|
48
|
+
end
|
49
|
+
|
50
|
+
def convert_remote_url_error
|
51
|
+
render pdf: 'convert-remote-url-cookie',
|
52
|
+
url: "https://httpstat.us/#{params[:code]}",
|
53
|
+
wait_for_page_loaded: false
|
54
|
+
end
|
8
55
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# app/controllers/secure_controller.rb
|
2
|
+
class SecureController < ApplicationController
|
3
|
+
# Basic Auth protection for the first action
|
4
|
+
http_basic_authenticate_with name: "admin", password: "secret", only: :basic_auth_endpoint
|
5
|
+
|
6
|
+
before_action :authenticate_with_api_key, only: :api_endpoint
|
7
|
+
before_action :authenticate_with_cookie, only: :cookie_endpoint
|
8
|
+
|
9
|
+
def basic_auth_endpoint
|
10
|
+
@auth_method = "HTTP Basic Authentication"
|
11
|
+
@auth_description = "This endpoint requires username and password authentication."
|
12
|
+
@auth_details = "Credentials: username: <code>admin</code>, password: <code>secret</code>"
|
13
|
+
|
14
|
+
render :show, layout: 'simple'
|
15
|
+
end
|
16
|
+
|
17
|
+
def api_endpoint
|
18
|
+
@auth_method = "API Key Authentication"
|
19
|
+
@auth_description = "This endpoint requires an API key in the header."
|
20
|
+
@auth_details = "Required header: <code>X-API-Key: your-secret-api-key</code>"
|
21
|
+
|
22
|
+
render :show, layout: 'simple'
|
23
|
+
end
|
24
|
+
|
25
|
+
def cookie_endpoint
|
26
|
+
@auth_method = "Cookie Authentication"
|
27
|
+
@auth_description = "This endpoint requires an authentication cookie."
|
28
|
+
@auth_details = "Required cookie: <code>auth_token</code> with value <code>valid-authentication-token</code>"
|
29
|
+
|
30
|
+
render :show, layout: 'simple'
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def authenticate_with_api_key
|
36
|
+
api_key = request.headers["X-API-Key"]
|
37
|
+
valid_key = "your-secret-api-key"
|
38
|
+
|
39
|
+
if api_key.blank? || api_key != valid_key
|
40
|
+
render html: "<h1>Unauthorized</h1><p>Invalid or missing API key</p>".html_safe, status: :unauthorized
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def authenticate_with_cookie
|
45
|
+
auth_token = cookies.signed[:auth_token]
|
46
|
+
valid_token = "valid-authentication-token"
|
47
|
+
|
48
|
+
if auth_token.blank? || auth_token != valid_token
|
49
|
+
render html: "<h1>Unauthorized</h1><p>Invalid or missing API key</p>".html_safe, status: :unauthorized
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= content_for(:title) || "Dummy" %></title>
|
5
|
+
<%= csp_meta_tag %>
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
7
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
<%= csp_meta_tag %>
|
10
|
+
|
11
|
+
<%= yield :head %>
|
12
|
+
</head>
|
13
|
+
|
14
|
+
<body>
|
15
|
+
<%= yield %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# app/views/secure/show.html.erb
|
2
|
+
<h1>Protected Resource</h1>
|
3
|
+
<p>This page is secured with: <strong><%= @auth_method %></strong></p>
|
4
|
+
<p><%= @auth_description %></p>
|
5
|
+
|
6
|
+
<div class="auth-details">
|
7
|
+
<%= @auth_details %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<p>When authenticated, you can access this content.</p>
|
@@ -46,7 +46,7 @@ Rails.application.configure do
|
|
46
46
|
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
47
47
|
|
48
48
|
# Prepend all log lines with the following tags.
|
49
|
-
config.log_tags = [
|
49
|
+
config.log_tags = [:request_id]
|
50
50
|
|
51
51
|
# "info" includes generic and useful information about system operation, but avoids logging too much
|
52
52
|
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
@@ -3,62 +3,80 @@
|
|
3
3
|
Bidi2pdfRails.configure do |config|
|
4
4
|
overrides = Rails.application.config.x.bidi2pdf_rails
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
config.
|
11
|
-
|
12
|
-
#
|
13
|
-
config.
|
14
|
-
config.
|
15
|
-
|
16
|
-
#
|
17
|
-
# config.
|
18
|
-
config.
|
19
|
-
# config.
|
20
|
-
# config.chrome_session_args = [
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
# config.
|
27
|
-
# config.
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
# config.
|
35
|
-
# config.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# PDF
|
40
|
-
#
|
41
|
-
|
42
|
-
#
|
43
|
-
# config.
|
44
|
-
# config.
|
45
|
-
# config.
|
46
|
-
# config.
|
47
|
-
|
6
|
+
#
|
7
|
+
# General Options
|
8
|
+
#
|
9
|
+
|
10
|
+
# config.general_options.logger = Rails.logger # The logger
|
11
|
+
|
12
|
+
# Allowed values: "none", "low", "medium", "high"
|
13
|
+
config.general_options.verbosity = "medium" # How verbose to be
|
14
|
+
# config.general_options.headless = !Rails.env.development? # Run Chrome in headless mode
|
15
|
+
# config.general_options.wait_for_network_idle = true # Wait for network idle
|
16
|
+
config.general_options.wait_for_page_loaded = true # Wait for page loaded
|
17
|
+
# config.general_options.wait_for_page_check_script = nil # Wait for page check script
|
18
|
+
# config.general_options.notification_service = -> { ActiveSupport::Notifications } # Notification service
|
19
|
+
# config.general_options.default_timeout = 10 # Default timeout for various Bidi commands
|
20
|
+
# config.general_options.chrome_session_args = ["--disable-gpu", "--disable-popup-blocking", "--disable-hang-monitor"] # Chrome session arguments
|
21
|
+
|
22
|
+
#
|
23
|
+
# Chromedriver Settings (when chromedriver run within your app)
|
24
|
+
#
|
25
|
+
|
26
|
+
# config.chromedriver_settings.install_dir = nil # Chromedriver install directory
|
27
|
+
# config.chromedriver_settings.port = 0 # Chromedriver port
|
28
|
+
|
29
|
+
#
|
30
|
+
# Proxy Settings
|
31
|
+
#
|
32
|
+
|
33
|
+
# config.proxy_settings.addr = nil # Proxy address (e.g., 127.0.0.1)
|
34
|
+
# config.proxy_settings.port = nil # Proxy port (e.g., 8080)
|
35
|
+
# config.proxy_settings.user = nil # Proxy user
|
36
|
+
# config.proxy_settings.pass = -> { Rails.application.credentials.dig('bidi2pdf_rails', 'proxy_pass') } # Proxy password
|
37
|
+
|
38
|
+
#
|
39
|
+
# PDF Settings
|
40
|
+
#
|
41
|
+
|
42
|
+
# Allowed values: "portrait", "landscape"
|
43
|
+
# config.pdf_settings.orientation = "portrait" # PDF orientation (portrait/landscape)
|
44
|
+
# config.pdf_settings.margins = false # Configure PDF margins?
|
45
|
+
# config.pdf_settings.margin_top = 2.5 # PDF margin top (cm)
|
46
|
+
# config.pdf_settings.margin_bottom = 2 # PDF margin bottom (cm)
|
47
|
+
# config.pdf_settings.margin_left = 2 # PDF margin left (cm)
|
48
|
+
# config.pdf_settings.margin_right = 2 # PDF margin right (cm)
|
49
|
+
|
50
|
+
# Allowed values: "letter", "legal", "tabloid", "ledger", "a0", "a1", "a2", "a3", "a4", "a5", "a6"
|
51
|
+
# config.pdf_settings.page_format = nil # PDF page format (e.g., A4)
|
52
|
+
# config.pdf_settings.page_width = 21.0 # PDF page width (cm, not needed when format is specified)
|
53
|
+
# config.pdf_settings.page_height = 29.7 # PDF page height (cm, not needed when format is specified)
|
54
|
+
# config.pdf_settings.print_background = true # Print background graphics?
|
55
|
+
# config.pdf_settings.scale = 1.0 # PDF scale (e.g., 1.0)
|
56
|
+
# config.pdf_settings.shrink_to_fit = false # Shrink to fit?
|
57
|
+
# config.pdf_settings.custom_js = nil # Raw JavaScript code to inject before PDF generation (without <script> tags)
|
58
|
+
# config.pdf_settings.custom_css = nil # Raw CSS styles to inject before PDF generation (without <style> tags)
|
59
|
+
# config.pdf_settings.custom_js_url = nil # URL to JavaScript file to load before PDF generation (takes precedence over custom_js)
|
60
|
+
# config.pdf_settings.custom_css_url = nil # URL to CSS file to load before PDF generation (takes precedence over custom_css)
|
61
|
+
|
62
|
+
#
|
63
|
+
# Remote URL Settings
|
64
|
+
#
|
65
|
+
|
66
|
+
# config.render_remote_settings.browser_url = nil # Remote browser URL (e.g. http://localhost:3001/sesion)
|
67
|
+
# config.render_remote_settings.basic_auth_user = nil # Basic auth user
|
68
|
+
# config.render_remote_settings.basic_auth_pass = -> { Rails.application.credentials.dig('bidi2pdf_rails', 'basic_auth_pass') } # Basic auth password
|
69
|
+
# config.render_remote_settings.headers = {"X-API-INFO" => "my info"} # Headers to be send when allong an url
|
70
|
+
# config.render_remote_settings.cookies = {"session_id" => "my session"} # Cookies to be send when alling an url
|
71
|
+
end
|
48
72
|
|
49
|
-
|
50
|
-
|
51
|
-
#
|
73
|
+
Rails.application.config.after_initialize do
|
74
|
+
Bidi2pdfRails::MainLogSubscriber.attach_to "bidi2pdf", inherit_all: true # needed for imported methods
|
75
|
+
Bidi2pdfRails::MainLogSubscriber.attach_to "bidi2pdf_rails", inherit_all: true # needed for imported methods
|
52
76
|
|
53
|
-
|
54
|
-
# "X-API-KEY" => "topsecret"
|
55
|
-
# }
|
77
|
+
Bidi2pdfRails::BrowserConsoleLogSubscriber.attach_to "bidi2pdf"
|
56
78
|
|
57
|
-
|
58
|
-
# username: "admin",
|
59
|
-
# password: "secret"
|
60
|
-
# }
|
79
|
+
Bidi2pdfRails::MainLogSubscriber.silence /network_event_.*\.bidi2pdf/
|
61
80
|
|
62
|
-
|
63
|
-
# config.install_dir = Rails.root.join("tmp", "bidi2pdf").to_s
|
81
|
+
Bidi2pdfRails::NetworkLogSubscriber.attach_to "bidi2pdf"
|
64
82
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
get "reports/:id" => "reports#show", as: :report
|
3
3
|
|
4
|
+
get "convert-remote-url" => "reports#convert_remote_url", as: :print_remote
|
5
|
+
get "inline-html" => "reports#inline_html", as: :print_inline
|
6
|
+
get "convert-remote-url-basic-auth" => "reports#convert_remote_url_basic_auth", as: :print_remote_basic_auth
|
7
|
+
get "convert-remote-url-cookie" => "reports#convert_remote_url_cookie", as: :print_remote_url_cookie
|
8
|
+
get "convert-remote-url-header" => "reports#convert_remote_url_header", as: :print_remote_url_header
|
9
|
+
get "convert-remote-url-error/:code" => "reports#convert_remote_url_error", as: :print_error
|
10
|
+
get "inject/:kind" => "reports#inject",
|
11
|
+
constraints: { kind: /(raw-css|raw-js|url-css|url-js)/ },
|
12
|
+
as: :inject_css
|
13
|
+
|
14
|
+
get 'basic-auth', to: 'secure#basic_auth_endpoint', as: :basic_auth_endpoint
|
15
|
+
get 'header-auth', to: 'secure#api_endpoint', as: :api_endpoint
|
16
|
+
get 'cookie-auth', to: 'secure#cookie_endpoint', as: :cookie_endpoint
|
17
|
+
|
4
18
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
5
19
|
|
6
20
|
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|