diff --git a/app/assets/stylesheets/gallery.css b/app/assets/stylesheets/gallery.css index c6dd415..40a34a7 100644 --- a/app/assets/stylesheets/gallery.css +++ b/app/assets/stylesheets/gallery.css @@ -143,6 +143,9 @@ /* Gallery Body */ +div.rgbody{ + margin-bottom::50px; +} .rgbody .gallery-info { padding: 0 5px; } diff --git a/app/controllers/admin/galleries_controller.rb b/app/controllers/admin/galleries_controller.rb index 627acf3..4fa6fb6 100644 --- a/app/controllers/admin/galleries_controller.rb +++ b/app/controllers/admin/galleries_controller.rb @@ -4,6 +4,24 @@ class Admin::GalleriesController < OrbitAdminController before_filter :setup_vars before_action :authenticate_user, :except => "imgs" before_action :log_user_action + find_tag = Tag.all.select{|value| value.name==I18n.t('gallery.not_show_desc')} + if find_tag.length==0 + module_app_id = ModuleApp.where(:key=>"gallery").first[:_id] + tags = ModuleApp.where(:key=>"gallery").first.tags + tag0 = Tag.new(is_default: false,module_app_ids: [module_app_id]) + tag1 = Tag.new(is_default: false,module_app_ids: [module_app_id]) + nowlocale = I18n.locale + I18n.available_locales.each do |locale| + I18n.locale = locale + tag0.name = I18n.t('gallery.show_desc') + tag1.name = I18n.t('gallery.not_show_desc') + end + I18n.locale = nowlocale + tag0.save + tag1.save + tags << tag0 + tags << tag1 + end def save_crop begin images = AlbumImage.all.select{|value| params[:id].include? value.id.to_s} diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 6bdb0b5..9f15dee 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -1,4 +1,22 @@ class GalleriesController < ApplicationController + find_tag = Tag.all.select{|value| value.name==I18n.t('gallery.not_show_desc')} + if find_tag.length==0 + module_app_id = ModuleApp.where(:key=>"gallery").first[:_id] + tags = ModuleApp.where(:key=>"gallery").first.tags + tag0 = Tag.new(is_default: false,module_app_ids: [module_app_id]) + tag1 = Tag.new(is_default: false,module_app_ids: [module_app_id]) + nowlocale = I18n.locale + I18n.available_locales.each do |locale| + I18n.locale = locale + tag0.name = I18n.t('gallery.show_desc') + tag1.name = I18n.t('gallery.not_show_desc') + end + I18n.locale = nowlocale + tag0.save + tag1.save + tags << tag0 + tags << tag1 + end def index albums = Album.filter_by_categories.filter_by_tags.asc(:order) galleries = albums.collect do |a| @@ -22,18 +40,20 @@ class GalleriesController < ApplicationController def show params = OrbitHelper.params album = Album.find_by_param(params[:uid]) + flag = show_desc? images = album.album_images.asc(:order).collect do |a| alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description) { "image-description" => a.description, "alt_title" => alt_text, - "link_to_show" => "/xhr/galleries/theater/" + a.id.to_s, - "thumb-src" => a.file.thumb.url + "link_to_show" => "/xhr/galleries/theater/" + a.id.to_s, + "thumb-src" => a.file.thumb.url } end { "images" => images, - "data" => {"album-title"=>album.name} + "data" => {"album-title"=>album.name, + "album-description" => (flag ? "

#{album.description}

" : "")} } end @@ -112,6 +132,21 @@ class GalleriesController < ApplicationController } render :json => {"data" => data}.to_json - end - + end + private + def show_desc? + tags = OrbitHelper.page_tags if tags.blank? + tags = [tags].flatten.uniq + flag = true + tag_temp = Tag.all.select{|value| tags.include? value.id.to_s} + tag_temp_length = 0 + tag_temp.each do |value| + if value.name==I18n.t('gallery.show_desc') + flag = true + elsif value.name==I18n.t('gallery.not_show_desc') + flag = false + end + end + flag + end end \ No newline at end of file diff --git a/app/models/album.rb b/app/models/album.rb index 8f738be..56e927e 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -24,5 +24,29 @@ class Album def self.find_by_param(input) self.find_by(uid: input) end - + def self.filter_by_tags(tags=[]) + tags = OrbitHelper.page_tags if tags.blank? + tags = [tags].flatten.uniq + if !(tags.include?("all")) + tag_temp = Tag.all.select{|value| tags.include? value.id.to_s} + tag_temp_length = 0 + tag_temp.each do |value| + if value.name==I18n.t('gallery.show_desc') || value.name==I18n.t('gallery.not_show_desc') + tag_temp_length+=1 + end + end + if tag_temp_length!=0 + if (tags.length - tag_temp_length) == 0 + tags = ['all'] + end + end + end + if tags.blank? || (tags.include?("all") rescue false) + self.all + else + tags + taggings = Tagging.where(:tag_id.in=>tags).map{|item| item.taggable_id} + self.where(:id.in=>taggings) + end + end end \ No newline at end of file diff --git a/app/views/admin/galleries/_album.html.erb b/app/views/admin/galleries/_album.html.erb index 8e9645f..7896261 100644 --- a/app/views/admin/galleries/_album.html.erb +++ b/app/views/admin/galleries/_album.html.erb @@ -16,7 +16,7 @@ <% if can_edit_or_delete?(album) %>
  • <%= link_to (content_tag(:i,"",:class=>"icon-trash danger")), admin_gallery_path(album.id), "data-confirm" => "Are you sure?", :method=>:delete %>
  • <% end %> -
  • <%= Category.find(album.category_id).title %>
  • +
  • <%= (Category.find(album.category_id).title rescue album.category_id) %>