From ae8cd642e0c0e475fe0ce3f6d483aa2683ed6fb7 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 6 May 2022 15:56:59 +0200 Subject: [PATCH] total --- .../admin/communication/unsplash_controller.rb | 4 ++-- app/views/admin/communication/unsplash/_photo.html.erb | 9 --------- app/views/admin/communication/unsplash/index.html.erb | 5 ----- .../admin/communication/unsplash/index.json.jbuilder | 3 ++- 4 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 app/views/admin/communication/unsplash/_photo.html.erb delete mode 100644 app/views/admin/communication/unsplash/index.html.erb diff --git a/app/controllers/admin/communication/unsplash_controller.rb b/app/controllers/admin/communication/unsplash_controller.rb index d84f4a591..062610f23 100644 --- a/app/controllers/admin/communication/unsplash_controller.rb +++ b/app/controllers/admin/communication/unsplash_controller.rb @@ -3,9 +3,9 @@ class Admin::Communication::UnsplashController < Admin::Communication::Applicati def index if params[:query].blank? - @photos = [] + @search = [] else - @photos = Unsplash::Search.search "/search/photos", + @search = Unsplash::Search.search "/search/photos", Unsplash::Photo, { query: params[:query], diff --git a/app/views/admin/communication/unsplash/_photo.html.erb b/app/views/admin/communication/unsplash/_photo.html.erb deleted file mode 100644 index 454d292b9..000000000 --- a/app/views/admin/communication/unsplash/_photo.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%= image_tag photo['urls']['thumb'], - class: 'img-fluid img-thumbnail mb-3', - data: { - unsplash: photo['id'], - filename: "#{photo['id']}.jpg", - preview: photo['urls']['regular'], - alt: photo['alt_description'], - credit: "Photo by <a href=\"https://unsplash.com/@#{ photo['user']['username'] }?utm_source=#{ Unsplash.configuration.utm_source }&utm_medium=referral\"> #{ photo['user']['name'] }</a> on <a href=\"https://unsplash.com/?utm_source=#{ Unsplash.configuration.utm_source }&utm_medium=referral\">Unsplash</a>" - } %> diff --git a/app/views/admin/communication/unsplash/index.html.erb b/app/views/admin/communication/unsplash/index.html.erb deleted file mode 100644 index 1adb90b3c..000000000 --- a/app/views/admin/communication/unsplash/index.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% @photos.each do |photo| %> - <div class="col-6 col-lg-2"> - <%= render 'admin/communication/unsplash/photo', photo: photo %> - </div> -<% end %> diff --git a/app/views/admin/communication/unsplash/index.json.jbuilder b/app/views/admin/communication/unsplash/index.json.jbuilder index c22e78b8f..97c301426 100644 --- a/app/views/admin/communication/unsplash/index.json.jbuilder +++ b/app/views/admin/communication/unsplash/index.json.jbuilder @@ -1,3 +1,4 @@ -json.array! @photos do |photo| +json.total = @search.total +json.results @search do |photo| json.partial! 'admin/communication/unsplash/photo', photo: photo end -- GitLab