From 481f345382efd52a2e08aece050471862a4485cb Mon Sep 17 00:00:00 2001 From: JiangRu Date: Fri, 6 Feb 2015 17:04:39 +0800 Subject: [PATCH] add widget count --- app/controllers/galleries_controller.rb | 5 +++-- lib/gallery/engine.rb | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 6e173e7..1840757 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -36,6 +36,7 @@ class GalleriesController < ApplicationController def widget albums = Album.filter_by_widget_categories params = OrbitHelper.params + counts = OrbitHelper.widget_data_count images = [] total_images = 0 @@ -43,8 +44,8 @@ class GalleriesController < ApplicationController albums.each do |album| total_images = total_images + album.album_images.count end - total_images = total_images > 9 ? 9 : total_images - while images.count < total_images and images.count < AlbumImage.count + total_images = counts > 9 ? 9 : counts + while images.count < counts and images.count < AlbumImage.count albums.each do |album| img = album.album_images.sample if !images.include?(img) && img != nil diff --git a/lib/gallery/engine.rb b/lib/gallery/engine.rb index d0f6f28..53dc9f6 100644 --- a/lib/gallery/engine.rb +++ b/lib/gallery/engine.rb @@ -5,7 +5,8 @@ module Gallery module_label "gallery.gallery" base_url File.expand_path File.dirname(__FILE__) widget_methods ["widget"] - widget_settings [] + # widget_settings [] + widget_settings [{"data_count"=>10}] categorizable authorizable frontend_enabled