albums api with get albums and images within the album
This commit is contained in:
parent
17597668a4
commit
2490668d06
|
@ -4,8 +4,9 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
# before_filter :force_order_for_user, :except => [:index,:get_album_json,:get_imgs_json]
|
# before_filter :force_order_for_user, :except => [:index,:get_album_json,:get_imgs_json]
|
||||||
|
|
||||||
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_imgs_json,:get_albums,:imgs]
|
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_imgs_json,:get_albums,:imgs]
|
||||||
before_filter :force_order_for_user,:except => [:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs]
|
before_filter :force_order_for_user,:except => [:index,:show,:get_album_json,:get_albums,:imgs,:get_image_json]
|
||||||
before_filter :for_app_sub_manager,:except => [:index,:show,:get_album_json,:get_imgs_json,:get_albums,:imgs]
|
before_filter :for_app_sub_manager,:except => [:index,:show,:get_album_json,:get_albums,:imgs,:get_image_json]
|
||||||
|
|
||||||
# before_filter lambda
|
# before_filter lambda
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -126,17 +127,18 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
|
album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
|
||||||
album_name: album.name,
|
album_name: album.name,
|
||||||
album_tag_names: tag_names,
|
album_tag_names: tag_names,
|
||||||
album_link:"http://#{request.host_with_port}#{panel_gallery_back_end_album_get_imgs_json_path(album)}"
|
album_link:"http://#{request.host_with_port}/panel/gallery/back_end/albums/get_image_json?album_id=#{album.id}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
render :json=>JSON.pretty_generate(output)
|
render :json=>JSON.pretty_generate(output)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_imgs_json
|
def get_image_json
|
||||||
album = GalleryAlbum.find(params[:album_id])
|
album = GalleryAlbum.where(:_id => params[:album_id])
|
||||||
images = album.gallery_images.all
|
if album.first.present?
|
||||||
output = Array.new
|
images = album.first.gallery_images.all
|
||||||
|
output = Array.new
|
||||||
|
|
||||||
images.each do |image|
|
images.each do |image|
|
||||||
tags = Tag.find(image.tagged_ids).map{|t| t.name}
|
tags = Tag.find(image.tagged_ids).map{|t| t.name}
|
||||||
|
@ -150,6 +152,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :json=>JSON.pretty_generate(output)
|
render :json=>JSON.pretty_generate(output)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def imgs
|
def imgs
|
||||||
|
|
|
@ -8,12 +8,13 @@ Rails.application.routes.draw do
|
||||||
match "save_tags" => "tags#save_tags"
|
match "save_tags" => "tags#save_tags"
|
||||||
match "albums/save_tags" => "tags#save_tags"
|
match "albums/save_tags" => "tags#save_tags"
|
||||||
|
|
||||||
|
match "albums/get_image_json" => "albums#get_image_json"
|
||||||
|
|
||||||
resources :albums do
|
resources :albums do
|
||||||
match "set_cover" => "albums#set_cover"
|
match "set_cover" => "albums#set_cover"
|
||||||
match "imgs" => "albums#imgs"
|
match "imgs" => "albums#imgs"
|
||||||
match "upload_panel" => "albums#upload_panel"
|
match "upload_panel" => "albums#upload_panel"
|
||||||
match "images_tags" => "albums#images_tags"
|
match "images_tags" => "albums#images_tags"
|
||||||
match "get_imgs_json" => "albums#get_imgs_json"
|
|
||||||
|
|
||||||
collection do
|
collection do
|
||||||
get "get_album_json"
|
get "get_album_json"
|
||||||
|
|
Loading…
Reference in New Issue