From f4144738976538045cd2ff148162b4325c31b0e2 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 23 May 2014 14:04:26 +0800 Subject: [PATCH] added widget and engine settings --- app/controllers/galleries_controller.rb | 35 +++++++++++++++++++++---- lib/gallery/engine.rb | 5 ++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 424ec43..4226d35 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -19,15 +19,40 @@ class GalleriesController < ApplicationController album = Album.find_by_param(params[:uid]) images = album.album_images.collect do |a| { - "link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater", - "thumb-src" => a.file.thumb.url + "link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater", + "thumb-src" => a.file.thumb.url } - end + end + { + "images" => images, + "data" => {"album-title"=>album.name} + } + end + + def widget + albums = Album.filter_by_widget_categories + params = OrbitHelper.params + + images = [] + while images.count < 9 + albums.each do |album| + img = album.album_images.sample + if !images.include?(img) && img != nil + images << img + end + end + end + images = images.collect do |a| + { + "link_to_show" => "/" + I18n.locale.to_s + params[:url] + "/-" + a.id.to_s + "?method=theater", + "thumb-src" => a.file.thumb.url + } + end { "images" => images, - "data" => {"album-title"=>album.name} + "extras" => {"widget-title"=>"Gallery"} } - end + end def theater params = OrbitHelper.params diff --git a/lib/gallery/engine.rb b/lib/gallery/engine.rb index b5dc163..3b668cb 100644 --- a/lib/gallery/engine.rb +++ b/lib/gallery/engine.rb @@ -4,10 +4,11 @@ module Gallery OrbitApp.registration "Gallery", :type => "ModuleApp" do module_label "gallery.gallery" base_url File.expand_path File.dirname(__FILE__) - + widget_methods ["widget"] + widget_settings [{"data_count"=>10}] categorizable authorizable - frontend_enabled + frontend_enabled side_bar do head_label_i18n 'gallery.gallery', icon_class: "icons-pictures"