Skip to content
Browse files

First commit for spree_multi_slideshow.

  • Loading branch information...
0 parents commit 0489bd6bd68df642fc5b3a156e2af41066d5f32c @damianogiacomello committed Jan 16, 2012
Showing with 1,022 additions and 0 deletions.
  1. +10 −0 .gitignore
  2. +1 −0 .rspec
  3. +17 −0 Gemfile
  4. +228 −0 Gemfile.lock
  5. +26 −0 LICENSE
  6. +20 −0 README.md
  7. +31 −0 Rakefile
  8. +11 −0 Versionfile
  9. +1 −0 app/assets/javascripts/admin/spree_multi_slideshow.js
  10. +231 −0 app/assets/javascripts/store/spree_multi_slideshow.js
  11. +3 −0 app/assets/stylesheets/admin/spree_multi_slideshow.css
  12. +73 −0 app/assets/stylesheets/store/spree_multi_slideshow.css
  13. +7 −0 app/controllers/spree/admin/slideshow_types_controller.rb
  14. +5 −0 app/controllers/spree/slides_controller.rb
  15. +5 −0 app/controllers/spree/slideshow_types_controller.rb
  16. +7 −0 app/helpers/spree/admin/slideshow_types_helper.rb
  17. +5 −0 app/helpers/spree/slides_helper.rb
  18. +27 −0 app/helpers/spree/slideshow_types_helper.rb
  19. +14 −0 app/models/spree/slide.rb
  20. +10 −0 app/models/spree/slideshow_type.rb
  21. +4 −0 app/overrides/slideshow_type_admin_tab.rb
  22. +8 −0 app/views/spree/admin/slideshow_types/_form.html.erb
  23. +10 −0 app/views/spree/admin/slideshow_types/edit.html.erb
  24. +34 −0 app/views/spree/admin/slideshow_types/index.html.erb
  25. +10 −0 app/views/spree/admin/slideshow_types/new.html.erb
  26. +32 −0 config/locales/en.yml
  27. +32 −0 config/locales/it.yml
  28. +14 −0 config/routes.rb
  29. +13 −0 db/migrate/20120116081431_create_slideshow_types.rb
  30. +16 −0 db/migrate/20120116083546_create_slides.rb
  31. +29 −0 lib/generators/spree_multi_slideshow/install/install_generator.rb
  32. +2 −0 lib/spree_multi_slideshow.rb
  33. +24 −0 lib/spree_multi_slideshow/engine.rb
  34. +7 −0 script/rails
  35. +31 −0 spec/spec_helper.rb
  36. +24 −0 spree_multi_slideshow.gemspec
10 .gitignore
@@ -0,0 +1,10 @@
+\#*
+*~
+.#*
+.DS_Store
+.idea
+.project
+tmp
+nbproject
+*.swp
+spec/dummy
1 .rspec
@@ -0,0 +1 @@
+--colour
17 Gemfile
@@ -0,0 +1,17 @@
+source 'http://rubygems.org'
+
+gem 'sqlite3'
+
+gem 'spree', '0.70.3'
+gem "paperclip", ">= 2.4.1"
+
+group :test do
+ gem 'rspec-rails', '= 2.6.1'
+ gem 'database_cleaner', '= 0.6.7'
+ gem 'nokogiri'
+ gem 'capybara', '1.0.1'
+ gem 'faker'
+ gem 'factory_girl'
+end
+
+gemspec
228 Gemfile.lock
@@ -0,0 +1,228 @@
+PATH
+ remote: .
+ specs:
+ spree_multi_slideshow (0.70.3)
+ paperclip (>= 2.4.1)
+ spree_core (>= 0.70.3)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
+ mail (~> 2.3.0)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemerchant (1.17.0)
+ activesupport (>= 2.3.11)
+ braintree (>= 2.0.0)
+ builder (>= 2.0.0)
+ json (>= 1.5.1)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ acts_as_list (0.1.4)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.1)
+ braintree (2.13.2)
+ builder (>= 2.0.0)
+ builder (3.0.0)
+ cancan (1.6.5)
+ capybara (1.0.1)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.0)
+ ffi (~> 1.0.6)
+ cocaine (0.2.1)
+ database_cleaner (0.6.7)
+ deface (0.7.2)
+ nokogiri (~> 1.5.0)
+ rails (>= 3.0.9)
+ devise (1.4.7)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.0.3)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ factory_girl (1.3.3)
+ faker (1.0.0)
+ i18n (~> 0.4)
+ ffi (1.0.11)
+ highline (1.6.2)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.19)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.5)
+ kaminari (0.13.0)
+ actionpack (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ railties (>= 3.0.0)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ meta_search (1.1.1)
+ actionpack (~> 3.1.0)
+ activerecord (~> 3.1.0)
+ activesupport (~> 3.1.0)
+ polyamorous (~> 0.5.0)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ nested_set (1.6.8)
+ activerecord (>= 3.0.0)
+ railties (>= 3.0.0)
+ nokogiri (1.5.0)
+ orm_adapter (0.0.5)
+ paperclip (2.4.1)
+ activerecord (>= 2.3.0)
+ activesupport (>= 2.3.2)
+ cocaine (>= 0.0.2)
+ mime-types
+ polyamorous (0.5.0)
+ activerecord (~> 3.0)
+ polyglot (0.3.3)
+ rack (1.3.6)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
+ bundler (~> 1.0)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rd_find_by_param (0.1.1)
+ activerecord (~> 3.0)
+ activesupport (~> 3.0)
+ rd_resource_controller (1.0.1)
+ rdoc (3.12)
+ json (~> 1.4)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
+ rubyzip (0.9.5)
+ selenium-webdriver (2.16.0)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0.9)
+ multi_json (~> 1.0.4)
+ rubyzip
+ spree (0.70.3)
+ spree_api (= 0.70.3)
+ spree_auth (= 0.70.3)
+ spree_core (= 0.70.3)
+ spree_dash (= 0.70.3)
+ spree_promo (= 0.70.3)
+ spree_sample (= 0.70.3)
+ spree_api (0.70.3)
+ spree_auth (= 0.70.3)
+ spree_core (= 0.70.3)
+ spree_auth (0.70.3)
+ cancan (= 1.6.5)
+ devise (= 1.4.7)
+ spree_core (= 0.70.3)
+ spree_core (0.70.3)
+ activemerchant (= 1.17.0)
+ acts_as_list (= 0.1.4)
+ deface (>= 0.7.0)
+ faker (= 1.0.0)
+ highline (= 1.6.2)
+ jquery-rails (>= 1.0.14)
+ kaminari (>= 0.12.4)
+ meta_search (= 1.1.1)
+ nested_set (= 1.6.8)
+ paperclip (= 2.4.1)
+ rails (<= 3.1.3, >= 3.1.1)
+ rd_find_by_param (= 0.1.1)
+ rd_resource_controller
+ state_machine (= 1.0.1)
+ stringex (= 1.0.3)
+ spree_dash (0.70.3)
+ spree_core (= 0.70.3)
+ spree_promo (0.70.3)
+ spree_auth (= 0.70.3)
+ spree_core (= 0.70.3)
+ spree_sample (0.70.3)
+ spree_core (= 0.70.3)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.5)
+ state_machine (1.0.1)
+ stringex (1.0.3)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+ warden (1.0.6)
+ rack (>= 1.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara (= 1.0.1)
+ database_cleaner (= 0.6.7)
+ factory_girl
+ faker
+ nokogiri
+ paperclip (>= 2.4.1)
+ rspec-rails (= 2.6.1)
+ spree (= 0.70.3)
+ spree_multi_slideshow!
+ sqlite3
26 LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2012 [name of plugin creator]
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name Spree nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 README.md
@@ -0,0 +1,20 @@
+SpreeMultiSlideshow
+===================
+
+Introduction goes here.
+
+
+Example
+=======
+
+Example goes here.
+
+Testing
+-------
+
+Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
+
+ $ bundle exec rake test app
+ $ bundle exec rspec spec
+
+Copyright (c) 2012 [name of extension creator], released under the New BSD License
31 Rakefile
@@ -0,0 +1,31 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rubygems/package_task'
+require 'rspec/core/rake_task'
+require 'cucumber/rake/task'
+require 'spree_core/testing_support/common_rake'
+
+RSpec::Core::RakeTask.new
+Cucumber::Rake::Task.new
+
+task :default => [:spec, :cucumber ]
+
+spec = eval(File.read('spree_multi_slideshow.gemspec'))
+
+Gem::PackageTask.new(spec) do |p|
+ p.gem_spec = spec
+end
+
+desc "Release to gemcutter"
+task :release => :package do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
+end
+
+desc "Generates a dummy app for testing"
+task :test_app do
+ ENV['LIB_NAME'] = 'spree_multi_slideshow'
+ Rake::Task['common:test_app'].invoke
+end
11 Versionfile
@@ -0,0 +1,11 @@
+# This file is used to designate compatibilty with different versions of Spree
+# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
+
+# Examples
+#
+# "0.70.x" => { :branch => "master"}
+# "0.60.x" => { :branch => "0-60-stable" }
+# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
+
+"0.70.x" => { :branch => "master"}
+
1 app/assets/javascripts/admin/spree_multi_slideshow.js
@@ -0,0 +1 @@
+//= require admin/spree_core
231 app/assets/javascripts/store/spree_multi_slideshow.js
@@ -0,0 +1,231 @@
+//= require store/spree_core
+
+// page init
+jQuery(function($) {
+ initGalleries();
+});
+
+// galleries init
+function initGalleries(){
+ // main banner slideshow
+ jQuery('div.gallery').fadeGallery({
+ autoRotation: true,
+ switchTime: 5000, //ms
+ duration: 800 //ms
+ });
+};
+
+// slideshow plugin
+jQuery.fn.fadeGallery = function(_options){
+ var _options = jQuery.extend({
+ slideElements:'div.frame > ul > li',
+ pagerGener: false,
+ pagerHold: false,
+ pagerLinks:'ul.nav-list li',
+ btnNext:'a.next',
+ btnPrev:'a.prev',
+ btnPlayPause:'a.play-pause',
+ btnPlay:'a.play',
+ btnPause:'a.pause',
+ pausedClass:'paused',
+ disabledClass: 'disabled',
+ playClass:'playing',
+ activeClass:'active',
+ currentNum:false,
+ allNum:false,
+ startSlide:null,
+ noCircle:false,
+ caption:'ul.caption > li',
+ pauseOnHover:false,
+ autoRotation:false,
+ autoHeight:false,
+ onChange:false,
+ switchTime:3000,
+ duration:650,
+ event:'click'
+ },_options);
+
+ return this.each(function(){
+ // gallery options
+ var _this = jQuery(this);
+ var _slides = jQuery(_options.slideElements, _this);
+ var _btnPrev = jQuery(_options.btnPrev, _this);
+ var _btnNext = jQuery(_options.btnNext, _this);
+ var _btnPlayPause = jQuery(_options.btnPlayPause, _this);
+ var _btnPause = jQuery(_options.btnPause, _this);
+ var _btnPlay = jQuery(_options.btnPlay, _this);
+ var _pauseOnHover = _options.pauseOnHover;
+ var _autoRotation = _options.autoRotation;
+ var _activeClass = _options.activeClass;
+ var _disabledClass = _options.disabledClass;
+ var _pausedClass = _options.pausedClass;
+ var _playClass = _options.playClass;
+ var _autoHeight = _options.autoHeight;
+ var _duration = _options.duration;
+ var _switchTime = _options.switchTime;
+ var _controlEvent = _options.event;
+ var _currentNum = (_options.currentNum ? jQuery(_options.currentNum, _this) : false);
+ var _allNum = (_options.allNum ? jQuery(_options.allNum, _this) : false);
+ var _startSlide = _options.startSlide;
+ var _noCycle = _options.noCircle;
+ var _onChange = _options.onChange;
+ var _pagerGener = _options.pagerGener;
+ var _pagerHold = jQuery(_options.pagerHold,_this);
+ var _caption = jQuery(_options.caption,_this);
+ var _paging = '';
+ if(_pagerGener){
+ for(var i=0; i< _slides.length; i++){
+ _paging += '<li><a href="#">'+(i+1)+'</a></li>';
+ }
+ _pagerHold.html('<ul>'+_paging+'</ul>');
+ }
+ var _pagerLinks = jQuery(_options.pagerLinks, _this);
+ // gallery init
+ var _hover = false;
+ var _prevIndex = 0;
+ var _currentIndex = 0;
+ var _slideCount = _slides.length;
+ var _timer;
+ if(_slideCount < 2) return;
+
+ _prevIndex = _slides.index(_slides.filter('.'+_activeClass));
+ if(_prevIndex < 0) _prevIndex = _currentIndex = 0;
+ else _currentIndex = _prevIndex;
+ if(_startSlide != null) {
+ if(_startSlide == 'random') _prevIndex = _currentIndex = Math.floor(Math.random()*_slideCount);
+ else _prevIndex = _currentIndex = parseInt(_startSlide);
+ }
+ _slides.hide().eq(_currentIndex).show();
+ _caption.hide().eq(_currentIndex).show();
+ if(_autoRotation) _this.removeClass(_pausedClass).addClass(_playClass);
+ else _this.removeClass(_playClass).addClass(_pausedClass);
+
+ // gallery control
+ if(_btnPrev.length) {
+ _btnPrev.bind(_controlEvent,function(){
+ prevSlide();
+ return false;
+ });
+ }
+ if(_btnNext.length) {
+ _btnNext.bind(_controlEvent,function(){
+ nextSlide();
+ return false;
+ });
+ }
+ if(_pagerLinks.length) {
+ _pagerLinks.each(function(_ind){
+ jQuery(this).bind(_controlEvent,function(){
+ if(_currentIndex != _ind) {
+ _prevIndex = _currentIndex;
+ _currentIndex = _ind;
+ switchSlide();
+ }
+ return false;
+ });
+ });
+ }
+
+ // play pause section
+ if(_btnPlayPause.length) {
+ _btnPlayPause.bind(_controlEvent,function(){
+ if(_this.hasClass(_pausedClass)) {
+ _this.removeClass(_pausedClass).addClass(_playClass);
+ _autoRotation = true;
+ autoSlide();
+ } else {
+ _autoRotation = false;
+ if(_timer) clearTimeout(_timer);
+ _this.removeClass(_playClass).addClass(_pausedClass);
+ }
+ return false;
+ });
+ }
+ if(_btnPlay.length) {
+ _btnPlay.bind(_controlEvent,function(){
+ _this.removeClass(_pausedClass).addClass(_playClass);
+ _autoRotation = true;
+ autoSlide();
+ return false;
+ });
+ }
+ if(_btnPause.length) {
+ _btnPause.bind(_controlEvent,function(){
+ _autoRotation = false;
+ if(_timer) clearTimeout(_timer);
+ _this.removeClass(_playClass).addClass(_pausedClass);
+ return false;
+ });
+ }
+ // gallery animation
+ function prevSlide() {
+ _prevIndex = _currentIndex;
+ if(_currentIndex > 0) _currentIndex--;
+ else {
+ if(_noCycle) return;
+ else _currentIndex = _slideCount-1;
+ }
+ switchSlide();
+ }
+ function nextSlide() {
+ _prevIndex = _currentIndex;
+ if(_currentIndex < _slideCount-1) _currentIndex++;
+ else {
+ if(_noCycle) return;
+ else _currentIndex = 0;
+ }
+ switchSlide();
+ }
+ function refreshStatus() {
+ if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentIndex).addClass(_activeClass);
+ if(_currentNum) _currentNum.text(_currentIndex+1);
+ if(_allNum) _allNum.text(_slideCount);
+ _slides.eq(_prevIndex).removeClass(_activeClass);
+ _slides.eq(_currentIndex).addClass(_activeClass);
+ if(_noCycle) {
+ if(_btnPrev.length) {
+ if(_currentIndex == 0) _btnPrev.addClass(_disabledClass);
+ else _btnPrev.removeClass(_disabledClass);
+ }
+ if(_btnNext.length) {
+ if(_currentIndex == _slideCount-1) _btnNext.addClass(_disabledClass);
+ else _btnNext.removeClass(_disabledClass);
+ }
+ }
+ if(typeof _onChange === 'function') {
+ _onChange(_this, _currentIndex);
+ }
+ }
+ function switchSlide() {
+ _slides.eq(_prevIndex).stop().animate({opacity:0},{duration: _duration, queue: false,complete:function(){
+ jQuery(this).css({display:'none'});
+ }})
+ _slides.eq(_currentIndex).stop().css({display:'block',opacity:0}).animate({opacity:1},{duration: _duration, queue: false,complete:function(){
+ jQuery(this).css({opacity:''});
+ }})
+ _caption.eq(_prevIndex).fadeOut();
+ _caption.eq(_currentIndex).fadeIn();
+ if(_autoHeight) _slides.eq(_currentIndex).parent().animate({height:_slides.eq(_currentIndex).outerHeight(true)},{duration:_duration,queue:false});
+ refreshStatus();
+ autoSlide();
+ }
+
+ // autoslide function
+ function autoSlide() {
+ if(!_autoRotation || _hover) return;
+ if(_timer) clearTimeout(_timer);
+ _timer = setTimeout(nextSlide,_switchTime+_duration);
+ }
+ if(_pauseOnHover) {
+ _this.hover(function(){
+ _hover = true;
+ if(_timer) clearTimeout(_timer);
+ },function(){
+ _hover = false;
+ autoSlide();
+ });
+ }
+ refreshStatus();
+ autoSlide();
+ });
+};
3 app/assets/stylesheets/admin/spree_multi_slideshow.css
@@ -0,0 +1,3 @@
+/*
+ *= require admin/spree_core
+*/
73 app/assets/stylesheets/store/spree_multi_slideshow.css
@@ -0,0 +1,73 @@
+/*
+ *= require store/spree_core
+*/
+
+.gallery{
+ width: 900px;
+ height:276px;
+ padding:15px 0 0;
+ overflow: hidden;
+ z-index:0;
+ color:#fff;
+ background:url(../images/bg-gallery.png) no-repeat 20px 0;
+ margin-bottom:-2px;
+}
+.gallery .frame{
+ width:900px;
+ overflow:hidden;
+ position:relative;
+ height:251px;
+}
+.gallery .frame ul{
+ position:absolute;
+ overflow:hidden;
+ margin:0;
+ padding:0;
+ list-style:none;
+ width:900px;
+ height:251px;
+}
+.gallery .frame li{
+ width:900px;
+ height:251px;
+ position:absolute;
+ top:0;
+ left:0;
+ background:#f1f1f1;
+}
+.gallery .frame li.active{z-index:2;}
+.gallery img{
+ display:block;
+}
+.gallery .prev,
+.gallery .next{
+ position:absolute;
+ top:160px;
+ left:47px;
+ background:url(../images/sprite01.png) no-repeat;
+ width:39px;
+ height:39px;
+ text-indent:-9999px;
+ overflow:hidden;
+ z-index:3;
+}
+.gallery .next{
+ right:56px;
+ left:auto;
+ background-position: 0 -43px;
+}
+.gallery .text-holder{
+ background:url(../images/bg-text02.png) no-repeat;
+ width: 234px;
+ height:98px;
+ padding:45px 0 0 50px;
+ position:absolute;
+ right:1px;
+ bottom:1px;
+ font:bold 33px/40px 'Candrb', Arial, Helvetica, sans-serif;
+ text-align:center;
+}
+.gallery .text-holder strong span{
+ font-size:52px;
+ display:block;
+}
7 app/controllers/spree/admin/slideshow_types_controller.rb
@@ -0,0 +1,7 @@
+module Spree
+ module Admin
+ class SlideshowTypesController < BaseController
+
+ end
+ end
+end
5 app/controllers/spree/slides_controller.rb
@@ -0,0 +1,5 @@
+module Spree
+ class SlidesController < BaseController
+
+ end
+end
5 app/controllers/spree/slideshow_types_controller.rb
@@ -0,0 +1,5 @@
+module Spree
+ class SlideshowTypesController < BaseController
+
+ end
+end
7 app/helpers/spree/admin/slideshow_types_helper.rb
@@ -0,0 +1,7 @@
+module Spree
+ module Admin
+ module Admin::SlideshowTypesHelper
+
+ end
+ end
+end
5 app/helpers/spree/slides_helper.rb
@@ -0,0 +1,5 @@
+module Spree
+ module SlidesHelper
+
+ end
+end
27 app/helpers/spree/slideshow_types_helper.rb
@@ -0,0 +1,27 @@
+module Spree
+ module SlideshowTypesHelper
+
+ def insert_slideshow(params={})
+ @content_for_head_added ||= false
+ if not @content_for_head_added
+ content_for(:head) { stylesheet_link_tag 'spree_multi_slideshow.css' }
+ content_for(:head) { javascript_include_tag 'spree_multi_slideshow.js' }
+ @content_for_head_added = true
+ end
+ content_tag :div, link_to("prev", "#", :class => "prev") + content_tag(:div, content_tag(:ul, slide_images(params)), :class => "frame") + link_to("next", "#", :class => "next"), :class => "gallery playing"
+ end
+
+ def slide_images(params)
+ max = params[:max]||5
+ group = params[:category]||""
+ slides = SlideshowType.enable.slide
+ slides = slides.sort_by { |slide| slide.position }
+
+ slides.map do |slide|
+ content_tag(:li, link_to(image_tag(slide.image.url(:slide)), slide.url, { :title => slide.title }) + content_tag(:div, content_tag(:strong, raw(slide.title)), :class => "text-holder"))
+ end.join
+
+ end
+
+ end
+end
14 app/models/spree/slide.rb
@@ -0,0 +1,14 @@
+class Spree::Slide < ActiveRecord::Base
+ belongs_to :slideable, :polymorphic => true
+
+ validate :no_image_errors
+ has_attached_file :image,
+ :url => "/assets/slides/:id/:style_:basename.:extension",
+ :path => ":rails_root/public/assets/slides/:id/:style_:basename.:extension",
+ :default_url => "/missing/:style.jpg",
+ :styles => {:thumbnail => "-gravity center 100x50#", :small => "150x100#", :slide => "" },
+ :convert_options => {:thumbnail => "-gravity Center", :slide => "-gravity Center"}
+
+ #process_in_background :image UTILE MA OCCORRE ATTIVARE ANCHE LA GEMMA DELAYED-PAPERCLIP
+
+end
10 app/models/spree/slideshow_type.rb
@@ -0,0 +1,10 @@
+class Spree::SlideshowType < ActiveRecord::Base
+
+ has_many :slide, :as => :slideable
+
+ validates :name, :slide_number, :width, :presence => true
+ validates_numericality_of :slide_number, :only_integer => true
+
+ scope :enable, :conditions => ["enabled = ?", true]
+
+end
4 app/overrides/slideshow_type_admin_tab.rb
@@ -0,0 +1,4 @@
+Deface::Override.new(:virtual_path => "layouts/admin",
+ :name => "slideshow_type_admin_tab",
+ :insert_bottom => "[data-hook='admin_tabs']",
+ :text => "<%= tab(:slideshow_types) %>")
8 app/views/spree/admin/slideshow_types/_form.html.erb
@@ -0,0 +1,8 @@
+<%= f.inputs do %>
+ <%= f.input :name %>
+ <%= f.input :title %>
+ <%= f.input :width %>
+ <%= f.input :slide_number %>
+ <%= f.input :enable_navigation %>
+ <%= f.input :enabled %>
+<% end %>
10 app/views/spree/admin/slideshow_types/edit.html.erb
@@ -0,0 +1,10 @@
+<h1><%= t("slideshow_type.new_page") %></h1>
+<%= render "shared/error_messages", :target => @slideshow_type %>
+
+<%= semantic_form_for([:admin, @slideshow_type]) do |f| %>
+ <%= render :partial => "form", :locals => { :f => f } %>
+ <p class="form-buttons">
+ <%= button t("actions.create"), nil, 'submit' %>
+ <%= t("or") %> <%= link_to t("actions.cancel"), admin_slideshow_types_path %>
+ </p>
+<% end %>
34 app/views/spree/admin/slideshow_types/index.html.erb
@@ -0,0 +1,34 @@
+<div class='toolbar'>
+ <ul class='actions'>
+ <li id="new_product_link">
+ <%= button_link_to t("slideshow_type.new_page"), new_object_url, {:icon => 'add'} %>
+ </li>
+ </ul>
+ <br class='clear' />
+</div>
+
+<h1><%=t("slideshow_type.slideshow") %></h1>
+
+<table class="index">
+ <tr>
+ <th><%= Spree::SlideshowType.human_attribute_name(:name) %></th>
+ <th><%= Spree::SlideshowType.human_attribute_name(:enabled) %></th>
+ <th><%= t("action") %></th>
+ </tr>
+ <tbody>
+ <% @slideshow_type.each do |slideshow_type| %>
+ <tr class="<%= cycle('even', 'odd') %>" id="<%= dom_id slideshow_type %>">
+ <td>
+ <%= slideshow_type.name %>
+ </td>
+ <td>
+ <%= icon('tick') if slideshow_type.enable %>
+ </td>
+ <td>
+ <%= link_to_edit slideshow_type %> &nbsp;
+ <%= link_to_delete slideshow_type %>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
10 app/views/spree/admin/slideshow_types/new.html.erb
@@ -0,0 +1,10 @@
+<h1><%= t("slideshow_type.new_page") %></h1>
+<%= render "shared/error_messages", :target => @slideshow_type %>
+
+<%= semantic_form_for([:admin, @slideshow_type]) do |f| %>
+ <%= render :partial => "form", :locals => { :f => f } %>
+ <p class="form-buttons">
+ <%= button t("actions.create"), nil, 'submit' %>
+ <%= t("or") %> <%= link_to t("actions.cancel"), admin_slideshow_types_path %>
+ </p>
+<% end %>
32 config/locales/en.yml
@@ -0,0 +1,32 @@
+---
+it:
+ activerecord:
+ attributes:
+ slideshow_type:
+ name: Name
+ enabled: Enable?
+ width: Width
+ title: Title
+ slide_number: Slide Number
+ enable_navigation: Next and Prev enable?
+ slide:
+ category: Category
+ position: Position
+ models:
+ slideshow_type:
+ one: Slideshow
+ many: Slideshows
+ slide:
+ one: Slide
+ many: Slides
+
+ slideshow_type: Slideshow
+ slideshow_types: Slideshows
+ slide: Slide
+ slides: Slides
+ slideshow_type:
+ slideshow: Slideshow
+ slideshow_desc: Manage slideshow and slide.
+ new_page: New page
+ editing_page: Editing page
+ confirm_delete: Are you sure ?
32 config/locales/it.yml
@@ -0,0 +1,32 @@
+---
+it:
+ activerecord:
+ attributes:
+ slideshow_type:
+ name: Nome
+ enabled: Attivo?
+ width: Larghezza
+ title: Titolo
+ slide_number: Numero Slide
+ enable_navigation: Tasti navigazione attivi?
+ slide:
+ category: Categoria
+ position: Posizione
+ models:
+ slideshow_type:
+ one: Slideshow
+ many: Slideshows
+ slide:
+ one: Slide
+ many: Slides
+
+ slideshow_type: Slideshow
+ slideshow_types: Slideshows
+ slide: Slide
+ slides: Slides
+ slideshow_type:
+ slideshow: Slideshow
+ slideshow_desc: Gestione slideshow e slide.
+ new_page: Nuova pagina
+ editing_page: Modifica pagina
+ confirm_delete: Sei sicuro?
14 config/routes.rb
@@ -0,0 +1,14 @@
+Rails.application.routes.draw do
+
+ namespace :admin do
+ resources :slideshow_types do
+ resources :slides
+ end
+ end
+
+ resources :slides
+
+ resources :slideshow_types
+
+ # Add your extension routes here
+end
13 db/migrate/20120116081431_create_slideshow_types.rb
@@ -0,0 +1,13 @@
+class CreateSlideshowTypes < ActiveRecord::Migration
+ def change
+ create_table :slideshow_types do |t|
+ t.string :name
+ t.boolean :enabled, :default => 0
+ t.integer :width, :default => 500
+ t.integer :slide_number, :default => 4
+ t.boolean :enable_navigation, :default => 1
+
+ t.timestamps
+ end
+ end
+end
16 db/migrate/20120116083546_create_slides.rb
@@ -0,0 +1,16 @@
+class CreateSlides < ActiveRecord::Migration
+ def change
+ create_table :slides do |t|
+ t.string :category, :title, :url
+
+ t.string :image_content_type, :image_file_name
+ t.integer :image_size, :position
+ t.string :type, :limit => 75
+ t.integer :image_width, :image_height
+
+ t.references :slideable, :polymorphic => true
+
+ t.timestamps
+ end
+ end
+end
29 lib/generators/spree_multi_slideshow/install/install_generator.rb
@@ -0,0 +1,29 @@
+module SpreeMultiSlideshow
+ module Generators
+ class InstallGenerator < Rails::Generators::Base
+
+ def add_javascripts
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_multi_slideshow\n"
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_multi_slideshow\n"
+ end
+
+ def add_stylesheets
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_multi_slideshow\n", :before => /\*\//, :verbose => true
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_multi_slideshow\n", :before => /\*\//, :verbose => true
+ end
+
+ def add_migrations
+ run 'bundle exec rake railties:install:migrations FROM=spree_multi_slideshow'
+ end
+
+ def run_migrations
+ res = ask "Would you like to run the migrations now? [Y/n]"
+ if res == "" || res.downcase == "y"
+ run 'bundle exec rake db:migrate'
+ else
+ puts "Skiping rake db:migrate, don't forget to run it!"
+ end
+ end
+ end
+ end
+end
2 lib/spree_multi_slideshow.rb
@@ -0,0 +1,2 @@
+require 'spree_core'
+require 'spree_multi_slideshow/engine'
24 lib/spree_multi_slideshow/engine.rb
@@ -0,0 +1,24 @@
+module SpreeMultiSlideshow
+ class Engine < Rails::Engine
+ engine_name 'spree_multi_slideshow'
+
+ config.autoload_paths += %W(#{config.root}/lib)
+
+ # use rspec for tests
+ config.generators do |g|
+ g.test_framework :rspec
+ end
+
+ def self.activate
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
+ Rails.application.config.cache_classes ? require(c) : load(c)
+ end
+
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
+ Rails.application.config.cache_classes ? require(c) : load(c)
+ end
+ end
+
+ config.to_prepare &method(:activate).to_proc
+ end
+end
7 script/rails
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+
+ENGINE_PATH = File.expand_path('../..', __FILE__)
+load File.expand_path('../../spec/dummy/script/rails', __FILE__)
+
31 spec/spec_helper.rb
@@ -0,0 +1,31 @@
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+
+
+require File.expand_path("../dummy/config/environment.rb", __FILE__)
+
+
+require 'rspec/rails'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+end
24 spree_multi_slideshow.gemspec
@@ -0,0 +1,24 @@
+# encoding: UTF-8
+Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = 'spree_multi_slideshow'
+ s.version = '0.70.3'
+ s.summary = 'Add gem summary here'
+ s.description = 'Add (optional) gem description here'
+ s.required_ruby_version = '>= 1.8.7'
+
+ s.author = 'Damiano Giacomello'
+ s.email = 'damiano.giacomello@diginess.it'
+ # s.homepage = 'http://www.rubyonrails.org'
+ # s.rubyforge_project = 'actionmailer'
+
+ #s.files = `git ls-files`.split("\n")
+ #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.require_path = 'lib'
+ s.requirements << 'none'
+
+ s.add_dependency 'spree_core', '>= 0.70.3'
+ s.add_dependency 'paperclip', '>= 2.4.1'
+ s.add_development_dependency 'rspec-rails'
+end
+

0 comments on commit 0489bd6

Please sign in to comment.
Something went wrong with that request. Please try again.