gallery versioning added.. and also the models changed for gallery now more R4 compatible. urls for gallery working fine now..
This commit is contained in:
parent
16b695200a
commit
91d5ab6352
|
@ -238,7 +238,7 @@ class ApplicationController < ActionController::Base
|
||||||
redirect_to ret
|
redirect_to ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_sorted_and_filtered(object_class, query = nil, objects = nil)
|
def get_sorted_and_filtered(object_class, query = nil, objects = nil, pagination = true)
|
||||||
if params[:filter] || params[:sort] || params[:new_filter]
|
if params[:filter] || params[:sort] || params[:new_filter]
|
||||||
@filter = params[:filter]
|
@filter = params[:filter]
|
||||||
new_filter = params[:new_filter]
|
new_filter = params[:new_filter]
|
||||||
|
@ -345,7 +345,12 @@ class ApplicationController < ActionController::Base
|
||||||
if (!user_signed_in? && object_class == "bulletin")
|
if (!user_signed_in? && object_class == "bulletin")
|
||||||
objects = get_bulletins_for_open_backend(objects)
|
objects = get_bulletins_for_open_backend(objects)
|
||||||
end
|
end
|
||||||
Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
|
|
||||||
|
if pagination
|
||||||
|
Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
|
||||||
|
else
|
||||||
|
filter_authorized_objects(objects)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_bulletins_for_open_backend(objects)
|
def get_bulletins_for_open_backend(objects)
|
||||||
|
|
|
@ -99,7 +99,7 @@ class DefaultWidgetController< OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_filter_data
|
def get_filter_data
|
||||||
model = eval(@default_widget["query"])
|
model = @default_widget["query"].classify.constantize
|
||||||
if params[:filter_category_id].is_a? Array
|
if params[:filter_category_id].is_a? Array
|
||||||
data = model.where(:category_id.in => params[:filter_category_id])
|
data = model.where(:category_id.in => params[:filter_category_id])
|
||||||
elsif params[:filter_category_id].is_a? String
|
elsif params[:filter_category_id].is_a? String
|
||||||
|
|
|
@ -96,6 +96,7 @@ class PagesController < ApplicationController
|
||||||
options << "#{options.blank? ? '?' : '&'}preview=#{params[:preview]}" unless params[:preview].blank?
|
options << "#{options.blank? ? '?' : '&'}preview=#{params[:preview]}" unless params[:preview].blank?
|
||||||
options << "#{options.blank? ? '?' : '&'}controller_action=#{params[:controller_action]}" unless params[:controller_action].blank?
|
options << "#{options.blank? ? '?' : '&'}controller_action=#{params[:controller_action]}" unless params[:controller_action].blank?
|
||||||
options << "#{options.blank? ? '?' : '&'}clicked_field_name=#{params[:clicked_field_name]}" unless params[:clicked_field_name].blank?
|
options << "#{options.blank? ? '?' : '&'}clicked_field_name=#{params[:clicked_field_name]}" unless params[:clicked_field_name].blank?
|
||||||
|
options << "#{options.blank? ? '?' : '&'}image_id=#{params[:image_id]}" unless params[:image_id].blank?
|
||||||
redirect_to(url + options) unless save_from_no_lang_for_page
|
redirect_to(url + options) unless save_from_no_lang_for_page
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -187,12 +188,9 @@ class PagesController < ApplicationController
|
||||||
@item = Item.where(:category => category_ids).first
|
@item = Item.where(:category => category_ids).first
|
||||||
else
|
else
|
||||||
if params[:action] && params[:action] == "show_from_link"
|
if params[:action] && params[:action] == "show_from_link"
|
||||||
default_widget = module_app.get_default_widget
|
model = params[:app_action].classify.constantize
|
||||||
if !default_widget.blank?
|
|
||||||
model = eval(params[:app_action].classify.constantize)
|
|
||||||
item = model.find(params[:id])
|
item = model.find(params[:id])
|
||||||
@item = Item.where(:category => [item.category_id.to_s]).first
|
@item = Item.where(:category => [item.category_id.to_s]).first
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace :gallery do
|
||||||
|
task :migrate_albums => :environment do
|
||||||
|
@albums = GalleryAlbum.all
|
||||||
|
@albums.each do |album|
|
||||||
|
newalbum = Album.new
|
||||||
|
newalbum.name = album.name
|
||||||
|
newalbum.description = album.description
|
||||||
|
newalbum.cover = album.cover
|
||||||
|
newalbum.cover_path = album.cover_path
|
||||||
|
newalbum.tag_names = album.tag_names
|
||||||
|
newalbum.category_id = album.category_id
|
||||||
|
newalbum.save!
|
||||||
|
@images = album.gallery_images
|
||||||
|
@images.each do |image|
|
||||||
|
img = newalbum.album_images.new
|
||||||
|
img.title = image.title
|
||||||
|
img.description = image.description
|
||||||
|
img.file = image.file
|
||||||
|
img.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -228,8 +228,8 @@ var galleryAPI = function(){
|
||||||
next = imagecount + 1;
|
next = imagecount + 1;
|
||||||
prev = imagecount - 1;
|
prev = imagecount - 1;
|
||||||
}
|
}
|
||||||
$(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.url});
|
$(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.theater.url});
|
||||||
$(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.url});
|
$(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.theater.url});
|
||||||
};
|
};
|
||||||
if(imageArray.length > 1)
|
if(imageArray.length > 1)
|
||||||
updateNavigation();
|
updateNavigation();
|
||||||
|
|
|
@ -19,7 +19,7 @@ var galleryAPI = function(){
|
||||||
if(photo_id){
|
if(photo_id){
|
||||||
var params = rcom.getUrlVars();
|
var params = rcom.getUrlVars();
|
||||||
var url = window.location.href.split("?")[0];
|
var url = window.location.href.split("?")[0];
|
||||||
params["id"] = photo_id;
|
params["image_id"] = photo_id;
|
||||||
for(i=0;i<params.length;i++){
|
for(i=0;i<params.length;i++){
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
url+="?"+params[i]+"="+params[params[i]];
|
url+="?"+params[i]+"="+params[params[i]];
|
||||||
|
@ -34,7 +34,7 @@ var galleryAPI = function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadTheater = function(id){
|
this.loadTheater = function(albumid,id){
|
||||||
var imageArray;
|
var imageArray;
|
||||||
var imagecount = 0;
|
var imagecount = 0;
|
||||||
// var picHeight = 0;
|
// var picHeight = 0;
|
||||||
|
@ -163,7 +163,6 @@ var galleryAPI = function(){
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
$img.attr({"src":dom.attr("data-content")}).css("height","auto").load(function(){
|
$img.attr({"src":dom.attr("data-content")}).css("height","auto").load(function(){
|
||||||
console.log(dom.attr("data-content"));
|
|
||||||
g.loadcomplete();
|
g.loadcomplete();
|
||||||
$img.fadeIn(200);
|
$img.fadeIn(200);
|
||||||
});;
|
});;
|
||||||
|
@ -174,9 +173,8 @@ var galleryAPI = function(){
|
||||||
$slidelist.stop().animate({'height':'0px'}, 300);
|
$slidelist.stop().animate({'height':'0px'}, 300);
|
||||||
$slidelist.find("ul").hide();
|
$slidelist.find("ul").hide();
|
||||||
if(rcom.getInternetExplorerVersion() == -1){
|
if(rcom.getInternetExplorerVersion() == -1){
|
||||||
|
|
||||||
if(pageurl!=window.location){
|
if(pageurl!=window.location){
|
||||||
pageurl = window.location.pathname+"?id="+pageurl+"&controller_action=theater";
|
pageurl = window.location.pathname+"?id="+albumid+"&controller_action=theater&image_id="+pageurl;
|
||||||
window.history.pushState({path:pageurl},'',pageurl);
|
window.history.pushState({path:pageurl},'',pageurl);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -205,8 +203,8 @@ var galleryAPI = function(){
|
||||||
next = imagecount + 1;
|
next = imagecount + 1;
|
||||||
prev = imagecount - 1;
|
prev = imagecount - 1;
|
||||||
}
|
}
|
||||||
$(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.url});
|
$(".navN").attr({"href":imageArray[next]._id,"data-content":imageArray[next].file.theater.url});
|
||||||
$(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.url});
|
$(".navP").attr({"href":imageArray[prev]._id,"data-content":imageArray[prev].file.theater.url});
|
||||||
};
|
};
|
||||||
if(imageArray.length > 1)
|
if(imageArray.length > 1)
|
||||||
updateNavigation();
|
updateNavigation();
|
||||||
|
|
|
@ -14,6 +14,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
@tags = get_tags
|
@tags = get_tags
|
||||||
category_ids = @categories.collect{|t| t.id}
|
category_ids = @categories.collect{|t| t.id}
|
||||||
@albums = get_sorted_and_filtered("album", :category_id.in => category_ids)
|
@albums = get_sorted_and_filtered("album", :category_id.in => category_ids)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def theater
|
def theater
|
||||||
@image = AlbumImage.find(params[:id])
|
@image = AlbumImage.find(params[:image_id])
|
||||||
@albumid = @image.album_id
|
@albumid = @image.album_id
|
||||||
@album = Album.find(@albumid)
|
@album = Album.find(@albumid)
|
||||||
@images = @album.album_images.all
|
@images = @album.album_images.all
|
||||||
|
|
|
@ -24,18 +24,18 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
|
||||||
if !@randoms.include?r
|
if !@randoms.include?r
|
||||||
@randoms << r
|
@randoms << r
|
||||||
image = @album_images[r]
|
image = @album_images[r]
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url}
|
||||||
@images << values
|
@images << values
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif @album_images.count == @total
|
elsif @album_images.count == @total
|
||||||
@album_images.each do |image|
|
@album_images.each do |image|
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url}
|
||||||
@images << values
|
@images << values
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@album_images.each do |image|
|
@album_images.each do |image|
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url}
|
||||||
@images << values
|
@images << values
|
||||||
end
|
end
|
||||||
until @images.count == @total do
|
until @images.count == @total do
|
||||||
|
|
|
@ -53,6 +53,10 @@ class GalleryUploader < CarrierWave::Uploader::Base
|
||||||
process :resize_to_fill => [200, 200]
|
process :resize_to_fill => [200, 200]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
version :theater do
|
||||||
|
process :resize_to_limit => [1920, 1080]
|
||||||
|
end
|
||||||
|
|
||||||
# Add a white list of extensions which are allowed to be uploaded.
|
# Add a white list of extensions which are allowed to be uploaded.
|
||||||
# For images you might use something like this:
|
# For images you might use something like this:
|
||||||
# def extension_white_list
|
# def extension_white_list
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div id="imgholder">
|
<div id="imgholder">
|
||||||
<div class="rslide" style="position:relative; width:100%;">
|
<div class="rslide" style="position:relative; width:100%;">
|
||||||
<div class="rslideinside"><div id="loading" style="display:none;"></div>
|
<div class="rslideinside"><div id="loading" style="display:none;"></div>
|
||||||
<div class="comp" id='main_pic' data-content='<%= @image.album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.url %>" alt="" /></a></div>
|
<div class="comp" id='main_pic' data-content='<%= @image.album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.theater.url %>" alt="" /></a></div>
|
||||||
<div class="rslidenav">
|
<div class="rslidenav">
|
||||||
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
|
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
|
||||||
<a href="" class="navN" title="下一張" onclick="return false;">Next</a>
|
<a href="" class="navN" title="下一張" onclick="return false;">Next</a>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<div class="slidelist">
|
<div class="slidelist">
|
||||||
<ul id='galleryimagelist' style="display:none;">
|
<ul id='galleryimagelist' style="display:none;">
|
||||||
<% @images.each_with_index do |image,i| %>
|
<% @images.each_with_index do |image,i| %>
|
||||||
<li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" onload="gallery.loadcomplete();" /></a></li>
|
<li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.theater.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" onload="gallery.loadcomplete();" /></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,34 +30,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if is_admin? %>
|
|
||||||
<!-- #TODO or 類別屬於他 -->
|
|
||||||
<!-- tag part -->
|
|
||||||
<div id="tag_panel" class="my_scroll">
|
|
||||||
<div class="scrollbar">
|
|
||||||
<div class="track">
|
|
||||||
<div class="thumb">
|
|
||||||
<div class="end"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<%
|
|
||||||
@locales = Array.new
|
|
||||||
@site_valid_locales.each do |locale|
|
|
||||||
@locales << locale
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
|
|
||||||
<%# if @authenticated %>
|
|
||||||
<div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"> <div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
|
|
||||||
<%# end %>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%end%>
|
|
||||||
|
|
||||||
<!-- tag end -->
|
|
||||||
<div class="form-actions form-fixed pagination-right rghead">
|
<div class="form-actions form-fixed pagination-right rghead">
|
||||||
<div class="rgfn">
|
<div class="rgfn">
|
||||||
<%= link_to (content_tag(:i,I18n.t("gallery.back_to_photos"),:class=>"icon-arrow-left icon-black")),"",:class=>"bt-back btn pull-left btn-primary",:title=>I18n.t("gallery.back_to_photos")%>
|
<%= link_to (content_tag(:i,I18n.t("gallery.back_to_photos"),:class=>"icon-arrow-left icon-black")),"",:class=>"bt-back btn pull-left btn-primary",:title=>I18n.t("gallery.back_to_photos")%>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class='rgphoto'>
|
<div class='rgphoto'>
|
||||||
<a title='<%= image.description %>' href='<%= theater_panel_gallery_front_end_album_path(image) %>'>
|
<a title='<%= image.description %>' href='<%= theater_panel_gallery_front_end_album_path(@album,:image_id=>image) %>'>
|
||||||
<img src='<%= image.file.thumb.url %>'/>
|
<img src='<%= image.file.thumb.url %>'/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
|
@ -6,7 +6,7 @@
|
||||||
<div id="imgholder">
|
<div id="imgholder">
|
||||||
<div class="rslide" style="position:relative; width:100%;">
|
<div class="rslide" style="position:relative; width:100%;">
|
||||||
<div class="rslideinside"><div id="loading" style="display:none;"></div>
|
<div class="rslideinside"><div id="loading" style="display:none;"></div>
|
||||||
<div class="comp" id='main_pic' data-content='<%= @image.album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.url %>" alt="" /></a></div>
|
<div class="comp" id='main_pic' data-content='<%= @image.album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.theater.url %>" alt="" /></a></div>
|
||||||
<div class="rslidenav">
|
<div class="rslidenav">
|
||||||
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
|
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
|
||||||
<a href="" class="navN" title="下一張" onclick="return false;">Next</a>
|
<a href="" class="navN" title="下一張" onclick="return false;">Next</a>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<div class="slidelist">
|
<div class="slidelist">
|
||||||
<ul id='galleryimagelist' style="display:none;">
|
<ul id='galleryimagelist' style="display:none;">
|
||||||
<% @images.each_with_index do |image,i| %>
|
<% @images.each_with_index do |image,i| %>
|
||||||
<li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" /></a></li>
|
<li for="<%= i %>"><a href="<%= image.id %>" class="list_element" data-content="<%= image.file.theater.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" /></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
var gallery = new galleryAPI();
|
var gallery = new galleryAPI();
|
||||||
gallery.initialize();
|
gallery.initialize();
|
||||||
gallery.loadArea = "theater";
|
gallery.loadArea = "theater";
|
||||||
gallery.loadTheater("<%= params[:id] %>");
|
gallery.loadTheater("<%= params[:id] %>","<%= params[:image_id] %>");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue