diff --git a/Dockerfile b/Dockerfile index 7b9745aba..2f3531282 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,19 +3,9 @@ FROM ruby:2.4 # Cleanup expired Let's Encrypt CA (Sept 30, 2021) RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f -RUN \ - apt-get update && \ - apt-get install -y \ - cron \ - # wkhtmltopdf dependencies \ - xfonts-75dpi \ - xfonts-base \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# wkhtmltopdf -RUN curl -L https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb --output wkhtmltopdf.deb && \ - dpkg -i wkhtmltopdf.deb && \ - rm -f wkhtmltopdf.deb +RUN apt-get update && \ + apt-get install -y cron && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Create a user for the web app. RUN addgroup --gid 9999 app && \ diff --git a/Dockerfile-dev b/Dockerfile-dev index ca7aef1b1..cc4afcccb 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,5 +1,12 @@ FROM ruby:2.4 +# Cleanup expired Let's Encrypt CA (Sept 30, 2021) +RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f + +RUN apt-get update && \ + apt-get install -y cron default-mysql-client && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + # ENV POIROT_STDOUT true # ENV POIROT_SUPPRESS_RAILS_LOG true # ENV NNDD_VERSION "cdx-0.11-pre7" @@ -8,36 +15,3 @@ FROM ruby:2.4 # RUN \ # mkdir -p /app/public/ && \ # curl -L https://github.com/instedd/notifiable-diseases/releases/download/$NNDD_VERSION/nndd.tar.gz | tar -xzv -C /app/public/ - -ENV LOCAL_SHARE "/usr/local/share" - -# Cleanup expired Let's Encrypt CA (Sept 30, 2021) -RUN sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf && update-ca-certificates -f - -RUN \ - apt-get update && \ - apt-get install -y \ - build-essential \ - chrpath \ - cron \ - libssl-dev \ - libxft-dev \ - libfreetype6 \ - libfreetype6-dev \ - libfontconfig1 \ - libfontconfig1-dev \ - # wkhtmltopdf dependencies \ - xfonts-75dpi \ - xfonts-base \ - imagemagick \ - ghostscript \ - libgs-dev \ - default-mysql-client \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -ARG TARGETARCH - -# wkhtmltopdf -RUN curl -L https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_${TARGETARCH}.deb --output wkhtmltopdf.deb && \ - dpkg -i wkhtmltopdf.deb && \ - rm -f wkhtmltopdf.deb diff --git a/Gemfile b/Gemfile index c329177b9..c7452a85e 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,8 @@ gem 'csv_builder', '~> 2.1' gem 'haml-rails', '~> 0.9' gem 'jbuilder', '~> 2.5' gem 'view_components', git: 'https://github.com/manastech/rails-view_components.git', branch: 'master' -gem 'wicked_pdf', '~> 2.1' +gem 'prawn' +gem 'prawn-svg' # Authentication # gem 'bcrypt-ruby', '~> 3.1.2' diff --git a/Gemfile.lock b/Gemfile.lock index 770628389..755563a90 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -375,6 +375,14 @@ GEM parallel paranoia (2.4.3) activerecord (>= 4.0, < 6.2) + pdf-core (0.7.0) + prawn (2.2.2) + pdf-core (~> 0.7.0) + ttfunk (~> 1.5) + prawn-svg (0.32.0) + css_parser (~> 1.6) + prawn (>= 0.11.1, < 3) + rexml (~> 3.2) premailer (1.12.1) addressable css_parser (>= 1.6.0) @@ -544,6 +552,7 @@ GEM tilt (2.0.11) timecop (0.9.6) trollop (2.9.10) + ttfunk (1.6.2.1) turbolinks (2.5.4) coffee-rails tzinfo (1.2.10) @@ -570,8 +579,6 @@ GEM websocket-extensions (0.1.5) whenever (1.0.0) chronic (>= 0.6.3) - wicked_pdf (2.6.3) - activesupport xpath (3.2.0) nokogiri (~> 1.8) @@ -629,6 +636,8 @@ DEPENDENCIES parallel_tests (~> 3.5.1) paranoia (< 2.5.0) poirot_rails! + prawn + prawn-svg premailer-rails (< 1.10) pry-byebug (< 3.10.0) pry-rescue @@ -666,7 +675,6 @@ DEPENDENCIES web-console (< 4.0) webmock (~> 2.3.1) whenever (~> 1.0) - wicked_pdf (~> 2.1) BUNDLED WITH 1.17.3 diff --git a/app/assets/fonts/Roboto/LICENSE.txt b/app/assets/fonts/Roboto/LICENSE.txt new file mode 100644 index 000000000..75b52484e --- /dev/null +++ b/app/assets/fonts/Roboto/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/app/assets/fonts/Roboto/RobotoMono-Bold.ttf b/app/assets/fonts/Roboto/RobotoMono-Bold.ttf new file mode 100644 index 000000000..8eff26c1e Binary files /dev/null and b/app/assets/fonts/Roboto/RobotoMono-Bold.ttf differ diff --git a/app/assets/fonts/Roboto/RobotoMono-Regular.ttf b/app/assets/fonts/Roboto/RobotoMono-Regular.ttf new file mode 100644 index 000000000..d9371a1bd Binary files /dev/null and b/app/assets/fonts/Roboto/RobotoMono-Regular.ttf differ diff --git a/app/assets/stylesheets/_barcode_card.scss b/app/assets/stylesheets/_barcode_card.scss index dfedee380..55c9b9a7a 100644 --- a/app/assets/stylesheets/_barcode_card.scss +++ b/app/assets/stylesheets/_barcode_card.scss @@ -66,60 +66,6 @@ } } -// Print Barcode style - -.barcode-card-print { - page-break-after: always; - break-after: page; - - height: 100%; - width: 100%; - - font-family: 'Roboto Mono', monospace; - - background: $white; - margin: 1px; - padding: 3px; - - .barcode { - margin: auto; // center barcode - margin-top: 0; - margin-bottom: 0; - width: 40%; - } - - .code { - font-size: 9px; - margin: -1px; - padding: 0 1px; - - .uuid { - margin: 0px; - text-align: center; - } - } - - .logo { - @include flexbox(); - flex-direction: row; - align-items: center; - - font-size: 7px; - padding: 0 1px; - margin-top: 1px; - width: 100%; - - .label { - margin-left: 3px; - } - - img { - width: 15px; - height: auto; - } - } -} - // INVENTORY .inventory-button { diff --git a/app/assets/stylesheets/pdf.scss b/app/assets/stylesheets/pdf.scss deleted file mode 100644 index 60300b248..000000000 --- a/app/assets/stylesheets/pdf.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; -@import "mixins"; -@import "reset"; -@import "layout"; -@import "barcode_card"; diff --git a/app/controllers/boxes_controller.rb b/app/controllers/boxes_controller.rb index 24f253c04..a3e749853 100644 --- a/app/controllers/boxes_controller.rb +++ b/app/controllers/boxes_controller.rb @@ -38,17 +38,10 @@ def inventory def print return unless authorize_resource(@box, READ_BOX) - render pdf: "cdx_box_#{@box.uuid}", - template: "boxes/print.pdf", - layout: "layouts/pdf.html", - locals: { - box: @box, - samples: @box.samples.preload(:batch, :sample_identifiers).map { |s| SamplePresenter.new(s, request.format) }, - }, - margin: { top: 0, bottom: 0, left: 0, right: 0 }, - page_width: "1in", - page_height: "1in", - show_as_html: params.key?("debug") + send_data BoxLabelPdf.render(@box, @box.samples.preload(:batch, :sample_identifiers)), + filename: "cdx_box_#{@box.uuid}", + type: "application/pdf", + disposition: "inline" end def new diff --git a/app/controllers/samples_controller.rb b/app/controllers/samples_controller.rb index 6a10d6e48..88446ab66 100644 --- a/app/controllers/samples_controller.rb +++ b/app/controllers/samples_controller.rb @@ -121,31 +121,23 @@ def create end def print - @sample = Sample.find(params[:id]) - return unless authorize_resource(@sample, READ_SAMPLE) - - render pdf: "cdx_sample_#{@sample.uuid}", - template: "samples/barcode.pdf", - layout: "layouts/pdf.html", - locals: { :sample => SamplePresenter.new(@sample, request.format) }, - margin: { top: 0, bottom: 0, left: 0, right: 0 }, - page_width: "1in", - page_height: "1in", - show_as_html: params.key?("debug") + sample = Sample.find(params[:id]) + return unless authorize_resource(sample, READ_SAMPLE) + + send_data SampleLabelPdf.render(sample), + filename: "cdx_sample_#{sample.uuid}.pdf", + type: "application/pdf", + disposition: "inline" end def bulk_print samples = Sample.where(id: params[:sample_ids]) return unless authorize_resources(samples, READ_SAMPLE) - render pdf: "cdx_samples_#{samples.size}_#{DateTime.now.strftime("%Y%m%d-%H%M")}", - template: "samples/bulk_print.pdf", - layout: "layouts/pdf.html", - locals: { samples: samples.preload(:sample_identifiers).map { |s| SamplePresenter.new(s, request.format) } }, - margin: { top: 0, bottom: 0, left: 0, right: 0 }, - page_width: "1in", - page_height: "1in", - show_as_html: params.key?("debug") + send_data SamplesLabelPdf.render(samples.preload(:box, :sample_identifiers)), + filename: "cdx_samples_#{samples.size}_#{DateTime.now.strftime("%Y%m%d-%H%M")}", + type: "application/pdf", + disposition: "inline" end def edit diff --git a/app/documents/base_pdf.rb b/app/documents/base_pdf.rb new file mode 100644 index 000000000..94aacffbd --- /dev/null +++ b/app/documents/base_pdf.rb @@ -0,0 +1,20 @@ +class BasePdf + include Prawn::View + + def self.render(*args) + view = new(*args) + view.setup + view.template + view.render + end + + def assets_path + @assets_path ||= Rails.root.join("app/assets") + end + + def setup + end + + def template + end +end diff --git a/app/documents/box_label_pdf.rb b/app/documents/box_label_pdf.rb new file mode 100644 index 000000000..a79d1c1d9 --- /dev/null +++ b/app/documents/box_label_pdf.rb @@ -0,0 +1,24 @@ +class BoxLabelPdf < SamplesLabelPdf + def initialize(box, samples) + @box = box + super(samples) + end + + def template + render_uuid(@box.uuid) + render_box_details + render_cdx_logo + + start_new_page + super + end + + protected + + def render_box_details + text_lines [ + @box.institution.name.truncate(22), + "#{@box.purpose} (#{@samples.size} samples)", + ] + end +end diff --git a/app/documents/label_pdf.rb b/app/documents/label_pdf.rb new file mode 100644 index 000000000..6a0b7cc01 --- /dev/null +++ b/app/documents/label_pdf.rb @@ -0,0 +1,65 @@ +class LabelPdf < BasePdf + def document + @document ||= Prawn::Document.new( + top_margin: 1.8, + left_margin: 2.4, + right_margin: 2, + bottom_margin: 0, + page_size: [72, 72], # 1in == 72pt + print_scaling: :none + ) + end + + def setup + font_families.update("RobotoMono" => { + normal: assets_path.join("fonts/Roboto/RobotoMono-Regular.ttf"), + bold: assets_path.join("fonts/Roboto/RobotoMono-Bold.ttf"), + }) + font "RobotoMono" + font_size 5.3 + default_leading 0 + end + + protected + + def render_uuid(uuid) + svg qrcode_svg(uuid), width: 27.4, height: 27.4, position: :center, enable_web_requests: false + move_down 1.6 + text_line uuid, align: :center, leading: 0.2 + move_up 0.6 + end + + def qrcode_svg(value) + barcode = Barby::QrCode.new(value, level: :m) + outputter = Barby::SvgOutputter.new(barcode) + outputter.xdim = 2 + outputter.margin = 0 + outputter.to_svg + end + + def render_sample_details(sample) + text_lines [ + "I.N. #{sample.isolate_name}".truncate(22), + "I.M. #{sample.inactivation_method}".truncate(22), + "P.D. #{sample.date_produced.strftime("%m/%d/%Y")}", + ], leading: -0.5 + end + + def render_cdx_logo + bounding_box [0.6, 7], width: bounds.right do + image assets_path.join("images/cdx-logo-bw.png"), width: 8.9, height: 4.1 + move_up 4.5 + text "https://cdx.io", indent_paragraphs: 10.8, character_spacing: -0.07, size: 4.1 + end + end + + def text_lines(lines, leading: -0.5, **options) + lines.each_with_index do |line, index| + text_line line, leading: leading, **options + end + end + + def text_line(line, **options) + text line, character_spacing: -0.2, **options + end +end diff --git a/app/documents/sample_label_pdf.rb b/app/documents/sample_label_pdf.rb new file mode 100644 index 000000000..72949aca9 --- /dev/null +++ b/app/documents/sample_label_pdf.rb @@ -0,0 +1,11 @@ +class SampleLabelPdf < LabelPdf + def initialize(sample) + @sample = SamplePresenter.new(sample, Mime::Type.lookup("application/pdf")) + end + + def template + render_uuid(@sample.uuid) + render_sample_details(@sample) + render_cdx_logo + end +end diff --git a/app/documents/samples_label_pdf.rb b/app/documents/samples_label_pdf.rb new file mode 100644 index 000000000..f5190d630 --- /dev/null +++ b/app/documents/samples_label_pdf.rb @@ -0,0 +1,15 @@ +class SamplesLabelPdf < LabelPdf + def initialize(samples) + format = Mime::Type.lookup("application/pdf") + @samples = samples.map { |sample| SamplePresenter.new(sample, format) } + end + + def template + @samples.each_with_index do |sample, index| + start_new_page unless index == 0 + render_uuid(sample.uuid) + render_sample_details(sample) + render_cdx_logo + end + end +end diff --git a/app/helpers/barcode_helper.rb b/app/helpers/barcode_helper.rb index 777dff50f..3ab899621 100644 --- a/app/helpers/barcode_helper.rb +++ b/app/helpers/barcode_helper.rb @@ -14,7 +14,7 @@ def barcode(code) def image_barcode(code) barcode = Barby::Code93.new(code) - file = Tempfile.new(['barcode', '.png']) + file = Tempfile.new(['barcode', '.png'], encoding: "BINARY") outputter = Barby::PngOutputter.new(barcode) outputter.xdim = 2 file.write outputter.to_png diff --git a/app/views/boxes/barcode.pdf.haml b/app/views/boxes/barcode.pdf.haml deleted file mode 100644 index 0b467bddc..000000000 --- a/app/views/boxes/barcode.pdf.haml +++ /dev/null @@ -1,14 +0,0 @@ -.barcode-card-print - .barcode-content - .barcode - = image_tag barcode_img_data_url(box.uuid) - .code - .uuid - #{box.uuid} - .code - #{(box.institution.name).truncate(22)} - .code - #{box.purpose} (#{box.samples.count} samples) - .logo - = image_tag wicked_pdf_asset_base64('cdx-logo-bw.png') - .label https://cdx.io diff --git a/app/views/boxes/print.pdf.haml b/app/views/boxes/print.pdf.haml deleted file mode 100644 index 1f8324638..000000000 --- a/app/views/boxes/print.pdf.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render template: "boxes/barcode", locals: { box: box } - -- samples.each do |sample| - = render template: "samples/barcode", locals: { sample: sample } diff --git a/app/views/layouts/pdf.html.haml b/app/views/layouts/pdf.html.haml deleted file mode 100644 index 89de282c6..000000000 --- a/app/views/layouts/pdf.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -!!! -%html - %head - %title Connected Diagnostics Platform - = stylesheet_link_tag wicked_pdf_asset_base64("pdf") - = wicked_pdf_stylesheet_link_tag "https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap" - %body - = yield diff --git a/app/views/samples/barcode.pdf.haml b/app/views/samples/barcode.pdf.haml deleted file mode 100644 index a5c5e848c..000000000 --- a/app/views/samples/barcode.pdf.haml +++ /dev/null @@ -1,18 +0,0 @@ -.barcode-card-print - .barcode-content - -# .title - -# = sample.institution - .barcode - = image_tag barcode_img_data_url(sample.uuid) - .code - .uuid - #{sample.uuid} - .code - I.N. #{sample.isolate_name} - .code - I.M. #{sample.inactivation_method} - .code - P.D. #{sample.date_produced_description} - .logo - = image_tag wicked_pdf_asset_base64('cdx-logo-bw.png') - .label https://cdx.io diff --git a/app/views/samples/bulk_print.pdf.haml b/app/views/samples/bulk_print.pdf.haml deleted file mode 100644 index 731036c25..000000000 --- a/app/views/samples/bulk_print.pdf.haml +++ /dev/null @@ -1,2 +0,0 @@ -- samples.each do |sample| - = render template: "samples/barcode.pdf", locals: { sample: sample } diff --git a/config/application.rb b/config/application.rb index c6b234bd4..b6c52ec0e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,7 +28,7 @@ class Application < Rails::Application g.assets = false end config.autoload_paths << Rails.root.join("features", "support", "page_objects") - config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths += %W(#{config.root}/documents #{config.root}/lib) config.assets.precompile += %w( mailer.css ) diff --git a/config/initializers/wicked_pdf.rb b/config/initializers/wicked_pdf.rb deleted file mode 100644 index e7a2d3302..000000000 --- a/config/initializers/wicked_pdf.rb +++ /dev/null @@ -1,27 +0,0 @@ -# WickedPDF Global Configuration -# -# Use this to set up shared configuration options for your entire application. -# Any of the configuration options shown here can also be applied to single -# models by passing arguments to the `render :pdf` call. -# -# To learn more, check out the README: -# -# https://github.com/mileszs/wicked_pdf/blob/master/README.md - -WickedPdf.config = { - # Path to the wkhtmltopdf executable: This usually isn't needed if using - # one of the wkhtmltopdf-binary family of gems. - exe_path: '/usr/local/bin/wkhtmltopdf', - # or - # exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf') - - # Layout file to be used for all PDFs - # (but can be overridden in `render :pdf` calls) - # layout: 'pdf.html', - - # Using wkhtmltopdf without an X server can be achieved by enabling the - # 'use_xvfb' flag. This will wrap all wkhtmltopdf commands around the - # 'xvfb-run' command, in order to simulate an X server. - # - # use_xvfb: true, -}