Skip to content
Snippets Groups Projects
Commit faab5eca authored by Arnaud Levy's avatar Arnaud Levy
Browse files

async route /admin/communication/unsplash?search=ocean

parent dde1089a
No related branches found
No related tags found
No related merge requests found
class Admin::Communication::UnsplashController < Admin::Communication::ApplicationController
layout false
def index
@search = params[:search]
@photos = @search ? Unsplash::Photo.search(@search, 1, 18, :squarish)
: []
end
end
<% unless image.attached? %>
<% if !image.attached? && text.present? %>
<p>Voulez-vous utiliser une de ces images Unsplash ?</p>
<div class="row">
<% Unsplash::Photo.search(text, 1, 4, :squarish).each do |photo| %>
<div class="col-6">
<%= render 'admin/application/unsplash/photo', photo: photo %>
<%= render 'admin/communication/unsplash/photo', photo: photo %>
</div>
<% end %>
</div>
......@@ -31,7 +31,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form class="row">
<div class="row">
<div class="col-lg-9">
<input type="text"
name="search"
......@@ -45,12 +45,14 @@
Chercher
</button>
</div>
</form>
</div>
<div class="row">
<% Unsplash::Photo.search(text, 1, 18, :squarish).each do |photo| %>
<div class="col-6 col-lg-2">
<%= render 'admin/application/unsplash/photo', photo: photo %>
</div>
<% if text %>
<% Unsplash::Photo.search(text, 1, 18, :squarish).each do |photo| %>
<div class="col-6 col-lg-2">
<%= render 'admin/communication/unsplash/photo', photo: photo %>
</div>
<% end %>
<% end %>
</div>
</div>
......
<% @photos.each do |photo| %>
<div class="col-6 col-lg-2">
<%= render 'admin/communication/unsplash/photo', photo: photo %>
</div>
<% end %>
......@@ -52,11 +52,9 @@
label: false,
input_html: { accept: '.jpg,.jpeg,.png,.svg' },
preview: true
%>
<%= f.input :featured_image_alt %>
</div>
<div class="card-body">
<%= render 'admin/application/unsplash/selector',
%>
<%= f.input :featured_image_alt %>
<%= render 'admin/communication/unsplash/selector',
image: post.featured_image,
text: post.image_keywords %>
</div>
......
namespace :communication do
get 'unsplash' => 'unsplash#index'
resources :websites do
get 'home' => 'website/home#edit'
patch 'home' => 'website/home#update'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment