modified gallery json format but it have some bugs...
This commit is contained in:
		
							parent
							
								
									ad429af58c
								
							
						
					
					
						commit
						96622b168f
					
				| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
 | 
					class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
 | 
				
			||||||
  include AdminHelper
 | 
					  include AdminHelper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_filter :force_order_for_user, :except => [:index,:get_album_json]
 | 
					  before_filter :force_order_for_user, :except => [:index,:get_album_json,:get_img_json]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def index
 | 
					  def index
 | 
				
			||||||
    if is_manager? || is_admin? || is_sub_manager?
 | 
					    if is_manager? || is_admin? || is_sub_manager?
 | 
				
			||||||
| 
						 | 
					@ -119,9 +119,27 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    albums.each do |album|
 | 
					    albums.each do |album|
 | 
				
			||||||
      tag_names = Array.new
 | 
					      tag_names = Array.new
 | 
				
			||||||
      all_image = Array.new
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      album.tag_ids.each do |tag|
 | 
				
			||||||
 | 
					        tag_names << GalleryTag.find(tag)[I18n.locale]
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      output << {
 | 
				
			||||||
 | 
					        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}"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    render :json=>JSON.pretty_generate(output)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def get_img_json
 | 
				
			||||||
 | 
					    album = GalleryAlbum.find(params[:album_id])
 | 
				
			||||||
    images = album.gallery_images.all
 | 
					    images = album.gallery_images.all
 | 
				
			||||||
 | 
					    output = Array.new
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    images.each do |image|
 | 
					    images.each do |image|
 | 
				
			||||||
      tags = Array.new
 | 
					      tags = Array.new
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,19 +155,6 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
 | 
				
			||||||
                      image_tag_names: tags}
 | 
					                      image_tag_names: tags}
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      album.tag_ids.each do |tag|
 | 
					 | 
				
			||||||
        tag_names << GalleryTag.find(tag)[I18n.locale]
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
      output << {
 | 
					 | 
				
			||||||
                  album_cover_file: "http://#{request.host_with_port}#{album.cover_path}",
 | 
					 | 
				
			||||||
                  album_name: album.name,
 | 
					 | 
				
			||||||
                  album_tag_names: tag_names,
 | 
					 | 
				
			||||||
                  images: all_image
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #render :json=>{:images => @output,
 | 
					 | 
				
			||||||
    #               :tag_names  => @tag_names}.to_json
 | 
					 | 
				
			||||||
    render :json=>JSON.pretty_generate(output)
 | 
					    render :json=>JSON.pretty_generate(output)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,11 +6,14 @@ Rails.application.routes.draw do
 | 
				
			||||||
        match "upload_image" => "albums#upload_image"
 | 
					        match "upload_image" => "albums#upload_image"
 | 
				
			||||||
        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"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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_img_json/:album_id" => "album_images#get_img_json"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          collection do
 | 
					          collection do
 | 
				
			||||||
            get "get_album_json"
 | 
					            get "get_album_json"
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in New Issue