From cd07247e5f44fc983a18b945ebb7d9ae5240eb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=B6hm?= Date: Fri, 9 Aug 2024 12:35:58 +0200 Subject: [PATCH] Added pdf preview --- Gemfile | 2 +- Gemfile.lock | 14 ++++++++++++++ app/views/jobs/_job_tr.html.erb | 5 +++++ app/views/jobs/index.html.erb | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 169cbfd..4a873a6 100644 --- a/Gemfile +++ b/Gemfile @@ -45,7 +45,7 @@ gem 'tzinfo-data', platforms: %i[windows jruby] gem 'bootsnap', require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] -# gem "image_processing", "~> 1.2" +gem "image_processing", "~> 1.2" group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem diff --git a/Gemfile.lock b/Gemfile.lock index 0772e33..07c3dd2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,11 +105,20 @@ GEM erubi (1.13.0) faker (3.4.2) i18n (>= 1.8.11, < 2) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) globalid (1.2.1) activesupport (>= 6.1) hashery (2.1.2) i18n (1.14.5) concurrent-ruby (~> 1.0) + image_processing (1.13.0) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) importmap-rails (2.0.1) actionpack (>= 6.0.0) activesupport (>= 6.0.0) @@ -135,6 +144,7 @@ GEM net-smtp marcel (1.0.4) matrix (0.4.2) + mini_magick (4.13.2) mini_mime (1.1.5) minitest (5.24.1) msgpack (1.7.2) @@ -223,6 +233,9 @@ GEM rexml (3.3.4) strscan ruby-rc4 (0.1.5) + ruby-vips (2.2.2) + ffi (~> 1.12) + logger rubyzip (2.3.2) selenium-webdriver (4.23.0) base64 (~> 0.2) @@ -296,6 +309,7 @@ DEPENDENCIES capybara debug faker (~> 3.4) + image_processing (~> 1.2) importmap-rails inline_svg (~> 1.9) jbuilder diff --git a/app/views/jobs/_job_tr.html.erb b/app/views/jobs/_job_tr.html.erb index e14e24d..dae3f3d 100644 --- a/app/views/jobs/_job_tr.html.erb +++ b/app/views/jobs/_job_tr.html.erb @@ -3,6 +3,11 @@ <%= job.id %> <%= job.fullname %> + + <% if job.pdf.attached? %> + <%= image_tag job.pdf.preview(resize_to_limit: [100, 100]) %> + <% end %> + <% if job.pdf.attached? %> <%#= link_to job.pdf.filename, rails_blob_path(job.pdf, disposition: "attachment") %> diff --git a/app/views/jobs/index.html.erb b/app/views/jobs/index.html.erb index 25bed62..d241af6 100644 --- a/app/views/jobs/index.html.erb +++ b/app/views/jobs/index.html.erb @@ -12,7 +12,7 @@ ID Auftraggeber - PDF + PDF A0 A1 A2