Compare commits

..
14 Commits
45 changed files with 9542 additions and 174 deletions

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 KiB

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB

+1 -1
View File
@@ -4,7 +4,7 @@
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file. // the compiled file.
// //
//= require jquery //= require mobile/jquery-1.7.1
//= require lib/jquery.preload.min.js //= require lib/jquery.preload.min.js
//= require cycle2 //= require cycle2
//= require mobile/jquery.mu.image.resize //= require mobile/jquery.mu.image.resize
File diff suppressed because it is too large. Load diff
@@ -24,10 +24,10 @@ $('#index').live('pageinit',function(){
}); });
$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)}); $(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
$(this).find(".newpic img").muImageResize({width: 280, height: 200}); $(this).find(".newpic img").muImageResize({width: 280, height: 200});
$('.slideshow').cycle({ // $('.slideshow').cycle({
fx: $effect, // fx: $effect,
timeout: $timeout // timeout: $timeout
}); // });
$(".newlist").css({ $(".newlist").css({
"width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30, "width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30,
}) })
@@ -113,10 +113,10 @@ $(window).bind("orientationchange", function(){
}); });
$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)}); $(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
$('.slideshow').cycle({ // $('.slideshow').cycle({
fx: $effect, // fx: $effect,
timeout: $timeout // timeout: $timeout
}); // });
$(".newlist").css({ $(".newlist").css({
"width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30, "width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30,
@@ -171,12 +171,20 @@ div[data-role="page"] {
float: left; float: left;
width: 280px; width: 280px;
min-height: 490px; min-height: 490px;
max-height: 490px; /*max-height: 490px;*/
background-color: #FFFFFF; background-color: #FFFFFF;
padding: 10px; padding: 10px;
margin: 0 10px 10px 0; margin: 0 10px 10px 0;
box-shadow: 0px 3px 5px rgba(0,0,0,.1); box-shadow: 0px 3px 5px rgba(0,0,0,.1);
} }
.content .orbit-cycle-slideshow {
height: 300px;
overflow: hidden;
}
.content .orbit-cycle-slideshow img {
width: 100%;
height: auto;
}
#index .content .newpic { #index .content .newpic {
width: 280px; width: 280px;
height: 200px; height: 200px;
@@ -318,13 +326,22 @@ div[id^="dialog"] .content {
margin-bottom: 5px; margin-bottom: 5px;
} }
@media(min-width:320px){ @media(min-width:320px){
.content .orbit-cycle-slideshow {
height: 130px;
}
} }
@media(min-width: 480px){ @media(min-width: 480px){
.content .orbit-cycle-slideshow {
height: 170px;
}
.content .newitem { .content .newitem {
width: 440px; width: 440px;
} }
} }
@media(min-width:600px) { @media(min-width:600px) {
.content .orbit-cycle-slideshow {
height: 200px;
}
.main-menu ul { .main-menu ul {
width: 420px; width: 420px;
} }
@@ -333,6 +350,9 @@ div[id^="dialog"] .content {
} }
} }
@media(min-width:768px) { @media(min-width:768px) {
.content .orbit-cycle-slideshow {
height: 250px;
}
.main-menu ul { .main-menu ul {
width: 480px; width: 480px;
} }
@@ -344,6 +364,9 @@ div[id^="dialog"] .content {
} }
} }
@media(min-width:800px) { @media(min-width:800px) {
.content .orbit-cycle-slideshow {
height: 330px;
}
.main-menu ul { .main-menu ul {
width: 480px; width: 480px;
} }
@@ -352,6 +375,9 @@ div[id^="dialog"] .content {
} }
} }
@media(min-width:961px) { @media(min-width:961px) {
.content .orbit-cycle-slideshow {
height: 380px;
}
.main-menu ul { .main-menu ul {
width: 480px; width: 480px;
} }
+13 -2
View File
@@ -23,6 +23,13 @@ class ApplicationController < ActionController::Base
end end
end end
def check_mobile_api_openness
if !Site.first.mobile_api_openness_on
redirect_to '/users/sign_in' if not (authenticate_user! and is_member? )
end
end
def site_restart def site_restart
Resque.enqueue(RestartServer) Resque.enqueue(RestartServer)
end end
@@ -238,7 +245,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]
@@ -346,7 +353,11 @@ class ApplicationController < ActionController::Base
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)
+1 -1
View File
@@ -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
+1 -1
View File
@@ -7,7 +7,7 @@ class MobileController < ApplicationController
def index def index
date_now = Time.now date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page(params[:page_main]).per(15) @bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page(params[:page_main]).per(15)
@ad_banner = AdBanner.where(title: "Banner")[0] @ad_banner = AdBanner.find(:all, :conditions => {:title => /Home/i})[0]
end end
def announcement def announcement
+11 -4
View File
@@ -2,6 +2,7 @@ class PagesController < ApplicationController
include ApplicationHelper include ApplicationHelper
before_filter :get_item, :only => [:index_from_link, :show_from_link] before_filter :get_item, :only => [:index_from_link, :show_from_link]
before_filter :check_frontend_open, :only => [:index,:show] before_filter :check_frontend_open, :only => [:index,:show]
before_filter :get_last_update_date, :only => [:index,:show]
# caches_page :index # caches_page :index
def index def index
@@ -96,6 +97,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,10 +189,11 @@ 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 rescue nil
model = eval(default_widget["query"]) if !model.nil?
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 if !module_app.has_category.blank?
end
end end
end end
@@ -214,4 +217,8 @@ class PagesController < ApplicationController
return false return false
end end
end end
def get_last_update_date
@last_update_date = t(:total_visitors)+' : '+ Impression.count.to_s+' | '+t(:update_at)+' : '+Bulletin.order_by(:updated_at.desc).limit(1).first[:updated_at].to_s
end
end end
+1
View File
@@ -14,6 +14,7 @@ class Site
field :frontend_open, :type => Boolean, :default => true field :frontend_open, :type => Boolean, :default => true
field :backend_openness_on, :type => Boolean, :default => false field :backend_openness_on, :type => Boolean, :default => false
field :mobile_api_openness_on, :type => Boolean, :default => false
field :desktop_closed, :type => Boolean, :default => false field :desktop_closed, :type => Boolean, :default => false
field :sitemap_menu_in_header, :type => Boolean, :default => false field :sitemap_menu_in_header, :type => Boolean, :default => false
field :enable_terms_of_use, :type => Boolean, :default => false field :enable_terms_of_use, :type => Boolean, :default => false
+15
View File
@@ -132,6 +132,21 @@
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted"><%= I18n.t('site.mobile_version')%></label>
<div class="controls">
<%= f.check_box :mobile_on , :class=>"toggle-check", :data=> { disabled: true } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= I18n.t('site.mobile_api_openness_on') %></label>
<div class="controls">
<%= f.check_box :mobile_api_openness_on , :class=>"toggle-check", :data=> { disabled: true } %>
<span class="help-block">Make API available for Mobile Apps</span>
</div>
</div>
</div> </div>
<!-- Language --> <!-- Language -->
+1
View File
@@ -41,5 +41,6 @@
} }
</style> </style>
<% end %> <% end %>
<div id='last_update_date_wrap' style='display:none;'><div id='last_update_date'><%= @last_update_date %></div></div>
</body> </body>
</html> </html>
+3 -5
View File
@@ -3,9 +3,7 @@
<% end %> <% end %>
<ul> <ul>
<li>總機電話:<a href="tel:+886229393091">02-29393091</a></li> <li>電話:<a href="tel:+886492563489">0492563489</a></li>
<li>傳真:02-29379611</li> <li>傳真:0492568302</li>
<li>緊急重大事件通聯窗口:校內分機 66119、66110</li> <li>地址:南投縣草屯鎮中正路568號</li>
<li>總值日室:<a href="tel:+88229387132">02-29387132</a></li>
<li>駐警衛室:<a href="tel:+88229387129">02-29387129</a></li>
</ul> </ul>
+1 -1
View File
@@ -5,6 +5,6 @@
<div id='map_canvas'></div> <div id='map_canvas'></div>
<script type='text/javascript'> <script type='text/javascript'>
var $map_center = "24.987449, 121.576117" var $map_center = "23.979724,120.696806"
var $map_zoom = 17 var $map_zoom = 17
</script> </script>
+2 -1
View File
@@ -386,6 +386,7 @@ en:
thumbnail: Thumbnail thumbnail: Thumbnail
site: site:
backend_openness_on: Backend Openness backend_openness_on: Backend Openness
mobile_api_openness_on: Mobile API Openness
default_image: Site default image default_image: Site default image
description: Site description description: Site description
description_help: Description Guide description_help: Description Guide
@@ -399,7 +400,7 @@ en:
keywords: Site keywords keywords: Site keywords
keywords_help: Keyword Guide keywords_help: Keyword Guide
language: Site language language: Site language
mobile_version: Mobile version mobile_version: Enable Mobile Web
openness: Openness openness: Openness
search: Site Search search: Site Search
search_help: Please Enter the search argument for Google search. search_help: Please Enter the search argument for Google search.
+1
View File
@@ -389,6 +389,7 @@ zh_tw:
frontend_closed: 前台關閉? frontend_closed: 前台關閉?
frontend_open: 開啟前台 frontend_open: 開啟前台
backend_openness_on: 開啟開放式後台(訪客可遊覽) backend_openness_on: 開啟開放式後台(訪客可遊覽)
mobile_api_openness_on: 開啟手機API
enable_personal_desktop: 開啟個人桌面 enable_personal_desktop: 開啟個人桌面
default_image: 預設圖像 default_image: 預設圖像
description: 網站描述 description: 網站描述
+3
View File
@@ -3,15 +3,18 @@ production:
hostname: localhost hostname: localhost
port: 8982 port: 8982
log_level: WARNING log_level: WARNING
solr_home: solr
development: development:
solr: solr:
hostname: localhost hostname: localhost
port: 8982 port: 8982
log_level: INFO log_level: INFO
solr_home: solr
test: test:
solr: solr:
hostname: localhost hostname: localhost
port: 8981 port: 8981
log_level: WARNING log_level: WARNING
solr_home: solr
+23
View File
@@ -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
+1 -1
View File
@@ -122,7 +122,7 @@ namespace :migrate do
a.widgets = {} a.widgets = {}
a.widgets[:widget1] = [] a.widgets[:widget1] = []
a.widget_options_fields_i18n = {"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal", "album_id"=>"gallery.album"}} a.widget_options_fields_i18n = {"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal", "album_id"=>"gallery.album"}}
a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name}}} a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"Album.all", "value"=>:id, "label"=>:name}}}
a.save a.save
end end
+1 -1
View File
@@ -5,7 +5,7 @@ namespace :new_ui do
%w(ask ask_question ask_category), %w(ask ask_question ask_category),
%w(asset asset), %w(asset asset),
%w(faq qa), %w(faq qa),
%w(gallery gallery_album gallery_category), %w(gallery album gallery_category),
%w(location location), %w(location location),
%w(personal_book writing_book), %w(personal_book writing_book),
%w(personal_conference writing_conference), %w(personal_conference writing_conference),
@@ -12,7 +12,9 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<%if user_signed_in? && is_manager?%>
<div class="modal-footer"> <div class="modal-footer">
<%= link_to t(:delete_), panel_calendar_new_back_end_event_path(@event),:class => "btn bt-del", :method => :delete, :remote => true %> <%= link_to t(:delete_), panel_calendar_new_back_end_event_path(@event),:class => "btn bt-del", :method => :delete, :remote => true %>
<%= link_to t(:edit), edit_panel_calendar_new_back_end_event_path(@event),:class => "btn btn-primary",:id=>"edit_event_btn" ,:remote => true %> <%= link_to t(:edit), edit_panel_calendar_new_back_end_event_path(@event),:class => "btn btn-primary",:id=>"edit_event_btn" ,:remote => true %>
</div> </div>
<% end %>
@@ -48,18 +48,7 @@
<div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div> <div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div>
<div id="event_create_space" class="modal" style="right: 8px; bottom: 50px; left: auto; top: auto; width: 400px; margin: 0;display:none;"></div> <div id="event_create_space" class="modal" style="right: 8px; bottom: 50px; left: auto; top: auto; width: 400px; margin: 0;display:none;"></div>
<div id="calendar-loading">Loading...</div> <div id="calendar-loading">Loading...</div>
<div class="form-actions form-fixed">
<div class="row-fluid">
<div class="span8">
</div>
<%if is_manager?%>
<div class="span4">
<%= link_to "Add", new_panel_calendar_new_back_end_event_path, :class => "btn btn-primary pull-right", :id=>"create_event_btn", :ref=>"add-btn" %>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
var calendar = new Calendar("#calendar"); var calendar = new Calendar("#calendar");
</script> </script>
<%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();
@@ -8,7 +8,7 @@ var galleryAPI = function(){
g = this; g = this;
this.urlVars = rcom.getUrlVars(); this.urlVars = rcom.getUrlVars();
this.albumArea = $("#orbit_gallery"); this.albumArea = $("#orbit_gallery");
this.loadArea = null; this.loadArea = "theater";
this.tagList = $(".taglist ul"); this.tagList = $(".taglist ul");
this.loading = $("#loading"); this.loading = $("#loading");
// this.authenticated = false; // this.authenticated = false;
@@ -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();
@@ -6,32 +6,32 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
def show def show
@tags = get_tags @tags = get_tags
@image = GalleryImage.find(params[:id]) @image = AlbumImage.find(params[:id])
@albumid = @image.gallery_album_id @albumid = @image.album_id
@album = GalleryAlbum.find(@albumid) @album = Album.find(@albumid)
@images = @album.gallery_images.all @images = @album.album_images.all
end end
def destroy def destroy
images = params['images'] images = params['images']
images.each do |image| images.each do |image|
img = GalleryImage.find(image) img = AlbumImage.find(image)
img.delete img.delete
end end
if params['delete_cover'] == "true" if params['delete_cover'] == "true"
album = GalleryAlbum.find(params['id']) album = Album.find(params['id'])
album.update_attributes(:cover=>"default",:cover_path => nil) album.update_attributes(:cover=>"default",:cover_path => nil)
end end
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
end end
def update_image def update_image
image = GalleryImage.find(params[:image_id]) image = AlbumImage.find(params[:image_id])
image.update_attributes(params[:gallery_image]) image.update_attributes(params[:album_image])
image.save image.save
@album = GalleryAlbum.find(image.gallery_album_id.to_s) @album = Album.find(image.album_id.to_s)
@images = @album.gallery_images @images = @album.album_images
@image_content = [] @image_content = []
@images.each do |image| @images.each do |image|
@image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids} @image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids}
@@ -42,11 +42,11 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
def delete_photos def delete_photos
images = params['images'] images = params['images']
images.each do |image| images.each do |image|
img = GalleryImage.find(image) img = AlbumImage.find(image)
img.delete img.delete
end end
if params['delete_cover'] == "true" if params['delete_cover'] == "true"
album = GalleryAlbum.find(params['album_id']) album = Album.find(params['album_id'])
album.update_attributes(:cover=>"default",:cover_path => nil) album.update_attributes(:cover=>"default",:cover_path => nil)
end end
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
@@ -57,13 +57,13 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController
tags = params[:tag_ids] tags = params[:tag_ids]
i = nil i = nil
images.each do |image| images.each do |image|
img = GalleryImage.find(image) img = AlbumImage.find(image)
img.tagged_ids = tags img.tagged_ids = tags
img.save img.save
i = img i = img
end end
@album = GalleryAlbum.find(i.gallery_album_id.to_s) @album = Album.find(i.album_id.to_s)
@images = @album.gallery_images @images = @album.album_images
@image_content = [] @image_content = []
@images.each do |image| @images.each do |image|
@image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids} @image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids}
@@ -1,5 +1,5 @@
class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
open_for_visitor :only => [:index, :show] open_for_visitor :only => [:index, :show, :get_album_json, :get_imgs_json, :imgs]
open_for_manager :except => [:index,:show,:update] open_for_manager :except => [:index,:show,:update]
open_for_sub_manager :except => [:index, :show] open_for_sub_manager :except => [:index, :show]
@@ -13,12 +13,13 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
@categories = get_categories_for_index @categories = get_categories_for_index
@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("gallery_album", :category_id.in => category_ids) @albums = get_sorted_and_filtered("album", :category_id.in => category_ids)
end end
def show def show
@album = GalleryAlbum.find(params[:id]) @album = Album.find(params[:id])
@images = @album.gallery_images @images = @album.album_images
@image_content = [] @image_content = []
@images.each do |image| @images.each do |image|
@image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids} @image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids}
@@ -33,12 +34,12 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
def new def new
@categories = get_categories_for_index @categories = get_categories_for_index
@tags = get_tags @tags = get_tags
@album = GalleryAlbum.new @album = Album.new
end end
def create def create
album = GalleryAlbum.new(params[:gallery_album]) album = Album.new(params[:album])
album.save! album.save!
redirect_to panel_gallery_back_end_albums_path redirect_to panel_gallery_back_end_albums_path
end end
@@ -46,38 +47,38 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
def destroy def destroy
album = GalleryAlbum.find(params[:id]) album = Album.find(params[:id])
album.destroy album.destroy
redirect_to panel_gallery_back_end_albums_path redirect_to panel_gallery_back_end_albums_path
end end
def edit def edit
@album = GalleryAlbum.find(params[:id]) @album = Album.find(params[:id])
@tags = get_tags @tags = get_tags
end end
def set_cover def set_cover
if params[:set_cover] == "true" if params[:set_cover] == "true"
album = GalleryAlbum.find(params[:album_id]) album = Album.find(params[:album_id])
image = GalleryImage.find(params[:image_id]) image = AlbumImage.find(params[:image_id])
album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:image_id]}) album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:image_id]})
else else
album = GalleryAlbum.find(params[:album_id]) album = Album.find(params[:album_id])
album.update_attributes({:cover_path => nil, :cover=>"default"}) album.update_attributes({:cover_path => nil, :cover=>"default"})
end end
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
end end
def get_album_json def get_album_json
albums = GalleryAlbum.all albums = Album.all
output = Array.new output = Array.new
albums.each do |album| albums.each do |album|
tag_names = Array.new tag_names = Array.new
album.tag_ids.each do |tag| album.tag_ids.each do |tag|
tag_names << GalleryTag.find(tag)[I18n.locale] tag_names << get_tags.include?(tag)
end end
if album.cover_path if album.cover_path
cover_path = album.cover_path cover_path = album.cover_path
@@ -96,15 +97,15 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
end end
def get_imgs_json def get_imgs_json
album = GalleryAlbum.find(params[:album_id]) album = Album.find(params[:album_id])
images = album.gallery_images.all images = album.album_images.all
output = Array.new output = Array.new
images.each do |image| images.each do |image|
tags = Array.new tags = Array.new
image.tag_ids.each do |tag| image.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale] tags << get_tags.include?(tag)
end end
output << { output << {
@@ -119,21 +120,21 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
end end
def imgs def imgs
@album = GalleryAlbum.find(params[:album_id]) @album = Album.find(params[:album_id])
@tag_names = Array.new @tag_names = Array.new
@images = @album.gallery_images.all @images = @album.album_images.all
@output = Array.new @output = Array.new
@images.each do |values| @images.each do |values|
tags = Array.new tags = Array.new
values.tag_ids.each do |tag| values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale] tags << get_tags.include?(tag)
end end
@output << { _id: values.id, @output << { _id: values.id,
theater_link: panel_gallery_back_end_album_image_path(values), theater_link: panel_gallery_back_end_album_image_path(values),
description: values.description, description: values.description,
title: values.title, title: values.title,
file: values.file.as_json[:file], file: values.file.as_json[:file],
gallery_album_id: values.gallery_album_id, gallery_album_id: values.album_id,
tag_ids: values.tag_ids, tag_ids: values.tag_ids,
tag_names: tags} tag_names: tags}
end end
@@ -143,11 +144,11 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
def upload_image def upload_image
@album = GalleryAlbum.find(params[:album_id]) @album = Album.find(params[:album_id])
@files = params['files'] @files = params['files']
a = Array.new a = Array.new
@files.each do |file| @files.each do |file|
@image = @album.gallery_images.new @image = @album.album_images.new
@image.file = file @image.file = file
@image.save! @image.save!
a << {"thumbnail_url"=>@image.file.thumb.url,"url"=>panel_gallery_back_end_album_image_path(@image)} a << {"thumbnail_url"=>@image.file.thumb.url,"url"=>panel_gallery_back_end_album_image_path(@image)}
@@ -157,21 +158,21 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
def new_images def new_images
if params[:last_image_id] != "" if params[:last_image_id] != ""
@lastimage = GalleryImage.find(params[:last_image_id]) @lastimage = AlbumImage.find(params[:last_image_id])
@album = GalleryAlbum.find(params[:album_id]) @album = Album.find(params[:album_id])
@newimages = @album.gallery_images.where(:created_at.gt => @lastimage.created_at) @newimages = @album.album_images.where(:created_at.gt => @lastimage.created_at)
else else
@album = GalleryAlbum.find(params[:album_id]) @album = Album.find(params[:album_id])
@newimages = @album.gallery_images @newimages = @album.album_images
end end
render :layout=>false render :layout=>false
end end
def images_tags def images_tags
album = GalleryAlbum.find(params[:album_id]) album = Album.find(params[:album_id])
tags = Array.new tags = Array.new
images = album.gallery_images.all images = album.album_images.all
images.each do |image| images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids} tags << {"id"=>image.id, "tags" => image.tag_ids}
end end
@@ -179,10 +180,10 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
end end
def update def update
@album = GalleryAlbum.find(params[:id]) @album = Album.find(params[:id])
tagsToDestroy = [] tagsToDestroy = []
tagsToAdd = [] tagsToAdd = []
new_tags = params[:gallery_album][:tag_ids] new_tags = params[:album][:tag_ids]
old_tags = @album.tagged_ids old_tags = @album.tagged_ids
old_tags.each do |tag| old_tags.each do |tag|
if !new_tags.include?(tag) if !new_tags.include?(tag)
@@ -197,14 +198,14 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
end end
end end
update_children_image_tag(tagsToDestroy,tagsToAdd) update_children_image_tag(tagsToDestroy,tagsToAdd)
@album.update_attributes(params[:gallery_album]) @album.update_attributes(params[:album])
redirect_to panel_gallery_back_end_album_path(@album) redirect_to panel_gallery_back_end_album_path(@album)
end end
def update_children_image_tag(tagsToDestroy,tagsToAdd) def update_children_image_tag(tagsToDestroy,tagsToAdd)
# tagsToDestroy will contain all tag ids which have to be deleted from the galley_images # tagsToDestroy will contain all tag ids which have to be deleted from the galley_images
# tagsToAdd will contain all tag ids which ve to be added in tall gallery_images # tagsToAdd will contain all tag ids which ve to be added in tall album_images
@images = GalleryImage.all @images = AlbumImage.all
@images.each do |image| @images.each do |image|
image.tagged_ids.concat(tagsToAdd) image.tagged_ids.concat(tagsToAdd)
tagsToDestroy.each do |tag| tagsToDestroy.each do |tag|
@@ -1,16 +1,16 @@
class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
def index def index
@albums = GalleryAlbum.where(:category_id.in => params[:category_id]) @albums = Album.where(:category_id.in => params[:category_id])
end end
def show def show
@album = GalleryAlbum.find(params[:id]) @album = Album.find(params[:id])
@images = @album.gallery_images @images = @album.album_images
end end
def imgs def imgs
@album = GalleryAlbum.find(params[:id]) @album = Album.find(params[:id])
@images = @album.gallery_images.all @images = @album.album_images.all
@output = Array.new @output = Array.new
@images.each do |values| @images.each do |values|
tags = Tag.find(values.tagged_ids).map{|t| t.name} tags = Tag.find(values.tagged_ids).map{|t| t.name}
@@ -19,7 +19,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
:description => values.description, :description => values.description,
:title => values.title, :title => values.title,
:file => values.file.as_json[:file], :file => values.file.as_json[:file],
:gallery_album_id => values.gallery_album_id, :gallery_album_id => values.album_id,
:tag_ids => values.tag_ids, :tag_ids => values.tag_ids,
:tag_names => tags} :tag_names => tags}
end end
@@ -27,9 +27,9 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
end end
def images_tags def images_tags
album = GalleryAlbum.find(params[:album_id]) album = Album.find(params[:album_id])
tags = Array.new tags = Array.new
images = album.gallery_images.all images = album.album_images.all
images.each do |image| images.each do |image|
tags << {"id"=>image.id, "tags" => image.tag_ids} tags << {"id"=>image.id, "tags" => image.tag_ids}
end end
@@ -37,10 +37,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
end end
def theater def theater
@image = GalleryImage.find(params[:id]) @image = AlbumImage.find(params[:image_id])
@albumid = @image.gallery_album_id @albumid = @image.album_id
@album = GalleryAlbum.find(@albumid) @album = Album.find(@albumid)
@images = @album.gallery_images.all @images = @album.album_images.all
tags = @album.tagged_ids tags = @album.tagged_ids
@tagnames = Tag.find(tags).map{|t| t.name} @tagnames = Tag.find(tags).map{|t| t.name}
@back_link = panel_gallery_front_end_album_path(@albumid) @back_link = panel_gallery_front_end_album_path(@albumid)
@@ -6,8 +6,8 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
vertical = @part.widget_options['vertical'].to_i rescue 0 vertical = @part.widget_options['vertical'].to_i rescue 0
horizontal = @part.widget_options['horizontal'].to_i rescue 0 horizontal = @part.widget_options['horizontal'].to_i rescue 0
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil @album = Album.find(@part.widget_options['album_id']) rescue nil
@album_images = @album.gallery_images if @album @album_images = @album.album_images if @album
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6 @settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
@@ -16,27 +16,34 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
@rnd = Random.new @rnd = Random.new
@images = [] @images = []
if @album_images.count > @total if !@album_images.nil?
@randoms = [] if @album_images.count > @total
until @randoms.count == @total do @randoms = []
r = @rnd.rand(0...@album_images.count) until @randoms.count == @total do
if !@randoms.include?r r = @rnd.rand(0...@album_images.count)
@randoms << r if !@randoms.include?r
image = @album_images[r] @randoms << r
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} image = @album_images[r]
values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url}
@images << values
end
end
elsif @album_images.count == @total
@album_images.each do |image|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url}
@images << values
end
else
@album_images.each do |image|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url}
@images << values
end
until @images.count == @total do
values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"}
@images << values @images << values
end end
end end
elsif @album_images.count == @total
@album_images.each do |image|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
else else
@album_images.each do |image|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
until @images.count == @total do until @images.count == @total do
values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"}
@images << values @images << values
@@ -1,4 +1,4 @@
class GalleryAlbum class Album
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
@@ -12,7 +12,7 @@ class GalleryAlbum
field :tag_names field :tag_names
# has_and_belongs_to_many :tags, :class_name => "GalleryTag" # has_and_belongs_to_many :tags, :class_name => "GalleryTag"
has_many :gallery_images, :autosave => true, :dependent => :destroy has_many :album_images, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :gallery_images, :allow_destroy => true accepts_nested_attributes_for :album_images, :allow_destroy => true
end end
@@ -1,4 +1,4 @@
class GalleryImage class AlbumImage
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitTag::Taggable include OrbitTag::Taggable
@@ -10,6 +10,6 @@ class GalleryImage
# has_and_belongs_to_many :tags, :class_name => "GalleryTag" # has_and_belongs_to_many :tags, :class_name => "GalleryTag"
belongs_to :gallery_album belongs_to :album
end end
@@ -9,7 +9,7 @@ class GalleryCategory
field :name, localize: true field :name, localize: true
has_many :gallery_albums, :autosave => true, :dependent => :destroy has_many :albums, :autosave => true, :dependent => :destroy
def title def title
name name
@@ -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.gallery_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")%>
@@ -50,7 +50,7 @@
<div class="controls" data-toggle="buttons-checkbox"> <div class="controls" data-toggle="buttons-checkbox">
<%@tags.each do |tag|%> <%@tags.each do |tag|%>
<label class="checkbox inline btn <%= 'active' if @album.tag_ids.include?(tag.id) %>"> <label class="checkbox inline btn <%= 'active' if @album.tag_ids.include?(tag.id) %>">
<%= check_box_tag 'gallery_album[tag_ids][]', tag.id, @album.tag_ids.include?(tag.id)%> <%= check_box_tag 'album[tag_ids][]', tag.id, @album.tag_ids.include?(tag.id)%>
<%= tag.name %> <%= tag.name %>
</label> </label>
<%end %> <%end %>
@@ -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.gallery_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>
@@ -57,8 +57,7 @@
galleryAPI.prototype.locale = "<%= I18n.locale %>"; galleryAPI.prototype.locale = "<%= I18n.locale %>";
var gallery = new galleryAPI(); var gallery = new galleryAPI();
gallery.initialize(); gallery.initialize();
gallery.loadArea = "theater"; gallery.loadTheater("<%= params[:id] %>","<%= params[:image_id] %>");
gallery.loadTheater("<%= params[:id] %>");
</script> </script>
@@ -19,7 +19,7 @@
<div class="albumname_edit"> <div class="albumname_edit">
<label for=""><%= t("gallery.album_name") %></label> <label for=""><%= t("gallery.album_name") %></label>
<div class="inputui rginput rgih26 w380"><input type="text" name="gallery_album[name_translations][<%= locale %>]" value="<%= @album_name[locale] %>" class="txtchange" /></div> <div class="inputui rginput rgih26 w380"><input type="text" name="album[name_translations][<%= locale %>]" value="<%= @album_name[locale] %>" class="txtchange" /></div>
</div> </div>
<div class='description_loader'> <div class='description_loader'>
@@ -7,7 +7,7 @@
</div> --> </div> -->
<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.gallery_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.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>
+2 -2
View File
@@ -26,7 +26,7 @@ module Gallery
# image :image # image :image
# end # end
categories_query 'GalleryCategory.all' # categories_query 'GalleryCategory.all'
# tags_query 'GalleryTag.all' # tags_query 'GalleryTag.all'
#* customize_widget "albums","gallery.widget.albums",:fields=>[],:style=>[],:options=>{"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name}}} #* customize_widget "albums","gallery.widget.albums",:fields=>[],:style=>[],:options=>{"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name}}}
@@ -37,7 +37,7 @@ module Gallery
style ["1","2"] style ["1","2"]
options "vertical",:i18n => "gallery.widget_option.vertical",:options_item=>[1, 2] options "vertical",:i18n => "gallery.widget_option.vertical",:options_item=>[1, 2]
options "horizontal",:i18n => "gallery.widget_option.horizontal",:options_item=>[1, 2,3,4,5,6] options "horizontal",:i18n => "gallery.widget_option.horizontal",:options_item=>[1, 2,3,4,5,6]
options "album_id",:i18n =>"gallery.album",:options_item => {"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name} options "album_id",:i18n =>"gallery.album",:options_item => {"query"=>"Album.all", "value"=>:id, "label"=>:name}
end end
end end
@@ -1,5 +1,6 @@
class Panel::Location::BackEnd::LocationsController < OrbitBackendController class Panel::Location::BackEnd::LocationsController < OrbitBackendController
include AdminHelper include AdminHelper
open_for_visitor :only => [:get_location_categories, :get_categorywise_locations]
def index def index
@locations = LocationInfo.all @locations = LocationInfo.all
@@ -89,4 +90,43 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
render :json => JSON.pretty_generate(@data) render :json => JSON.pretty_generate(@data)
end end
def get_location_categories
check_mobile_api_openness
location_categories = get_categories_for_index
@data = Array.new
location_categories.each do |category|
I18n.locale = :en
name_en = category.title
I18n.locale = :zh_tw
name_zh_tw = category.title
category_id = category.id.to_s
@data << { name_en: name_en, name_zh_tw: name_zh_tw, category_id: category_id, location_link: "http://#{request.host_with_port}"+"/#{panel_location_back_end_locations_get_categorywise_locations_path}"+"?category_id=#{category_id}"}
end
render :json => JSON.pretty_generate(@data)
end
def get_categorywise_locations
check_mobile_api_openness
location_infos = LocationInfo.where(:category_id => params[:category_id])
@data = Array.new
location_infos.each do |location|
picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}"
thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}"
@data << { id: location.id.to_s,
name: location.name,
pic_url: picurl,
thumb_url: thumburl,
longitude: location.longitude,
latitude: location.latitude,
description: location.description }
end
render :json => JSON.pretty_generate(@data)
end
end end
+3
View File
@@ -3,6 +3,9 @@ Rails.application.routes.draw do
namespace :location do namespace :location do
namespace :back_end do namespace :back_end do
match 'location_categories/list' => "location_categories#list" match 'location_categories/list' => "location_categories#list"
match "locations/get_locations" => "locations#get_locations"
match "locations/get_categorywise_locations" => "locations#get_categorywise_locations"
match "locations/get_location_categories" => "locations#get_location_categories"
resources :location_categories resources :location_categories
match "locations/get_locations" => "locations#get_locations" match "locations/get_locations" => "locations#get_locations"
match "locations/get_categories" => "locations#get_categories" match "locations/get_categories" => "locations#get_categories"