From 5f3d97d7c2721d9abfa7049153acca9679cd25d2 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 20 Oct 2014 20:25:58 +0800 Subject: [PATCH] removed unknown authorization error for gallery frontend --- .../javascripts/galleryAPI_frontend.js.erb | 12 ++++++------ app/controllers/admin/galleries_controller.rb | 3 ++- app/controllers/galleries_controller.rb | 17 +++++++++++++++++ app/views/galleries/theater.html.erb | 5 ++++- config/routes.rb | 1 + 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/galleryAPI_frontend.js.erb b/app/assets/javascripts/galleryAPI_frontend.js.erb index 55faba6..5201279 100644 --- a/app/assets/javascripts/galleryAPI_frontend.js.erb +++ b/app/assets/javascripts/galleryAPI_frontend.js.erb @@ -231,15 +231,15 @@ var galleryAPI = function(){ updateNavigation(); } - var preparestage = function(albumid){ - $.getJSON("/admin/galleries/"+albumid+"/imgs", function(album){ - imageArray = eval(album.images); - $.each(album.images,function(i,image){ + var preparestage = function(images){ + // $.getJSON("/galleries/imgs?id=" + albumid, function(album){ + imageArray = images; + $.each(images,function(i,image){ if(image._id == id) imagecount = i; }) bindHandlers(); - }) + // }) } // if(rcom.getInternetExplorerVersion()!=-1){ // var url_constructor = window.location.href.split("/"); @@ -258,7 +258,7 @@ var galleryAPI = function(){ var albumid = $("#main_pic").attr("data-content"); g.albumArea.css("margin-bottom","0"); // picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight()); - preparestage(albumid); + preparestage(json_image_data); } this.loadcomplete = function(){ diff --git a/app/controllers/admin/galleries_controller.rb b/app/controllers/admin/galleries_controller.rb index 57d7ba2..e74890f 100644 --- a/app/controllers/admin/galleries_controller.rb +++ b/app/controllers/admin/galleries_controller.rb @@ -125,7 +125,8 @@ class Admin::GalleriesController < OrbitAdminController end def imgs - @album = Album.find(params[:gallery_id]) + @album = Album.find(params[:id]) + debugger @tag_names = Array.new @images = @album.album_images.all @output = Array.new diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 9c27f5f..6e173e7 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -65,6 +65,22 @@ class GalleriesController < ApplicationController } end + def imgs(album_id) + album = Album.find(album_id) + tag_names = Array.new + images = album.album_images.all + output = Array.new + images.each do |values| + output << { _id: values.id.to_s, + description: values.description, + title: values.title, + file: values.file.as_json[:file], + gallery_album_id: values.album_id, + tags: values.tags} + end + return output + end + def theater params = OrbitHelper.params image = AlbumImage.find(params[:uid]) @@ -75,6 +91,7 @@ class GalleriesController < ApplicationController "album" => album, "images" => images, "image" => image, + "wall_images" => imgs(albumid), "back_to_albums" => OrbitHelper.url_to_show(album.to_param) } end diff --git a/app/views/galleries/theater.html.erb b/app/views/galleries/theater.html.erb index abd77f4..a075902 100644 --- a/app/views/galleries/theater.html.erb +++ b/app/views/galleries/theater.html.erb @@ -3,8 +3,11 @@ @album = data["album"] @image = data["image"] @back_link = data["back_to_albums"] + @wall_images = data["wall_images"] %> - + <%= stylesheet_link_tag "gallery_frontend" %>