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_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 :for_app_sub_manager,: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_albums,:imgs,:get_image_json]
|
||||
|
||||
# before_filter lambda
|
||||
|
||||
def index
|
||||
|
@ -126,17 +127,18 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
|||
album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
|
||||
album_name: album.name,
|
||||
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
|
||||
|
||||
render :json=>JSON.pretty_generate(output)
|
||||
end
|
||||
|
||||
def get_imgs_json
|
||||
album = GalleryAlbum.find(params[:album_id])
|
||||
images = album.gallery_images.all
|
||||
output = Array.new
|
||||
def get_image_json
|
||||
album = GalleryAlbum.where(:_id => params[:album_id])
|
||||
if album.first.present?
|
||||
images = album.first.gallery_images.all
|
||||
output = Array.new
|
||||
|
||||
images.each do |image|
|
||||
tags = Tag.find(image.tagged_ids).map{|t| t.name}
|
||||
|
@ -150,6 +152,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
|||
end
|
||||
|
||||
render :json=>JSON.pretty_generate(output)
|
||||
end
|
||||
end
|
||||
|
||||
def imgs
|
||||
|
|
|
@ -7,13 +7,14 @@ Rails.application.routes.draw do
|
|||
match "upload_image" => "albums#upload_image"
|
||||
match "save_tags" => "tags#save_tags"
|
||||
match "albums/save_tags" => "tags#save_tags"
|
||||
|
||||
match "albums/get_image_json" => "albums#get_image_json"
|
||||
|
||||
resources :albums do
|
||||
match "set_cover" => "albums#set_cover"
|
||||
match "imgs" => "albums#imgs"
|
||||
match "upload_panel" => "albums#upload_panel"
|
||||
match "images_tags" => "albums#images_tags"
|
||||
match "get_imgs_json" => "albums#get_imgs_json"
|
||||
|
||||
collection do
|
||||
get "get_album_json"
|
||||
|
|
Loading…
Reference in New Issue