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

clean

parent b1cb1455
No related branches found
No related tags found
No related merge requests found
......@@ -4,16 +4,19 @@ class Admin::Communication::UnsplashController < Admin::Communication::Applicati
def index
if params[:query].blank?
@search = []
@total = 0
@total_pages = 0
else
@search = Unsplash::Search.search "/search/photos",
Unsplash::Photo,
{
query: params[:query],
page: (params[:page] || 1),
per_page: (params[:per_page] || 10),
orientation: (params[:orientation] || 'squarish'),
lang: (params[:lang] || 'en')
}
p = {
query: params[:query],
page: (params[:page] || 1),
per_page: (params[:per_page] || 10),
orientation: (params[:orientation] || 'squarish'),
lang: (params[:lang] || 'en')
}
@search = Unsplash::Search.search "/search/photos", Unsplash::Photo, p
@total = @search.total
@total_pages = @search.total_pages
end
end
end
......@@ -11,6 +11,8 @@ about_featured_image_alt = "##{about_identifier}_featured_image_alt"
about_featured_image_credit = "##{about_identifier}_featured_image_credit"
# fr, en...
lang = about&.language&.iso_code if about.respond_to? :language
# /admin/communication/unsplash.json?query=Page%20de%20test&per_page=12&page=1&lang=fr
path = admin_communication_unsplash_path(website_id: nil, format: :json)
%>
<div id="unsplash-app" v-cloak>
......@@ -91,7 +93,7 @@ lang = about&.language&.iso_code if about.respond_to? :language
return {
selected: {},
parameters: {
url: '<%= admin_communication_unsplash_path(format: :json) %>',
url: '<%= path %>',
per_page: 12,
lang: '<%= lang %>',
query: '<%= search || "" %>'
......@@ -132,7 +134,7 @@ lang = about&.language&.iso_code if about.respond_to? :language
}
}.bind(this);
xmlHttp.open( "GET", this.parameters.url + '&query=' + this.parameters.query + '&per_page=' + this.parameters.per_page + '&page=' + this.page + '&lang=' + this.parameters.lang, false );
xmlHttp.open( "GET", this.parameters.url + '?query=' + this.parameters.query + '&per_page=' + this.parameters.per_page + '&page=' + this.page + '&lang=' + this.parameters.lang, false );
xmlHttp.send( null );
},
select(image) {
......
json.total @search.total
json.total_pages @search.total_pages
json.total @total
json.total_pages @total_pages
json.results @search do |photo|
json.partial! 'admin/communication/unsplash/photo', photo: photo
end
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