diff --git a/app/controllers/admin/communication/unsplash_controller.rb b/app/controllers/admin/communication/unsplash_controller.rb index d84f4a5914b06777efd842559ccf2127e4d8919b..062610f231abd62ec1bca0ce7ad4613edf6981dd 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 454d292b992a11ae7e36b8c56889ffcde58a4187..0000000000000000000000000000000000000000 --- 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 1adb90b3cb3d20d8291defa3fb4fec7bcfc9851a..0000000000000000000000000000000000000000 --- 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 c22e78b8f0f6b05bbd609df3c5bb3591179cc651..97c3014261aa30866d073aef765e1ed6afcb09aa 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