bcms_content_rotator 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -2
- data/app/assets/javascripts/bcms_content_rotator.js +4 -0
- data/{public/bcms/content_rotator → app/assets/javascripts}/content_rotator.js +14 -7
- data/app/assets/stylesheets/bcms_content_rotator/application.css +13 -0
- data/app/controllers/bcms_content_rotator/slides_controller.rb +4 -0
- data/app/models/bcms_content_rotator/slide.rb +32 -0
- data/app/portlets/content_rotator_portlet.rb +2 -2
- data/app/views/{cms → bcms_content_rotator}/slides/_form.html.erb +2 -2
- data/app/views/{cms → bcms_content_rotator}/slides/render.html.erb +1 -1
- data/app/views/portlets/content_rotator/_form.html.erb +1 -1
- data/config/routes.rb +3 -0
- data/db/bcms_content_rotator.seeds.rb +3 -3
- data/db/migrate/20120522173257_v130.rb +9 -0
- data/lib/bcms_content_rotator.rb +4 -2
- data/lib/bcms_content_rotator/engine.rb +1 -0
- data/lib/bcms_content_rotator/version.rb +1 -1
- data/lib/generators/bcms_content_rotator/install/install_generator.rb +4 -3
- data/lib/tasks/bcms_content_rotator_tasks.rake +4 -0
- data/test/bcms_content_rotator_test.rb +7 -0
- data/test/functional/cms/slides_controller_test.rb +11 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/models/slide_test.rb +20 -0
- data/test/unit/portlets/content_rotator_portlet_test.rb +9 -0
- metadata +44 -20
- data/app/controllers/cms/slides_controller.rb +0 -2
- data/app/models/slide.rb +0 -28
- data/app/views/layouts/templates/default.html.erb +0 -18
- data/lib/bcms_content_rotator/routes.rb +0 -7
data/README.markdown
CHANGED
@@ -27,11 +27,11 @@ Follow the standard bcms module installation found here: http://guides.browsercm
|
|
27
27
|
$ rake db:migrate
|
28
28
|
$ rake db:seed:bcms_content_rotator
|
29
29
|
|
30
|
-
|
30
|
+
Next, add the content rotator javascript to your templates. The asset pipeline will automatically pull in the necessary dependencies like jquery.
|
31
31
|
|
32
32
|
<head>
|
33
33
|
...
|
34
|
-
<%= javascript_include_tag
|
34
|
+
<%= javascript_include_tag :bcms_content_rotator %>
|
35
35
|
<%= yield :html_head %>
|
36
36
|
</head>
|
37
37
|
|
@@ -1,18 +1,20 @@
|
|
1
|
-
|
1
|
+
var startslides;
|
2
2
|
$(function() {
|
3
3
|
var autorotate = $('#slides').data('autorotate'),
|
4
4
|
rotateInterval = $('#slides').data('rotate-interval') * 1000;
|
5
5
|
|
6
6
|
var slides = $('#slides div.slide'),
|
7
7
|
currentItem = 0,
|
8
|
+
numItems = $('#slides ul#controls li a').length,
|
8
9
|
runSlideShow = function() {
|
9
10
|
var item = $('#slides ul#controls li a:eq('+currentItem+')');
|
10
|
-
if (
|
11
|
-
item.trigger('click', ['timer']);
|
11
|
+
if (currentItem < numItems) {
|
12
12
|
currentItem++;
|
13
|
-
|
14
|
-
|
13
|
+
if (currentItem == numItems) {
|
14
|
+
currentItem = 0;
|
15
|
+
}
|
15
16
|
}
|
17
|
+
item.trigger('custom', ['timer']);
|
16
18
|
},
|
17
19
|
|
18
20
|
selectSlide = function(e) {
|
@@ -30,10 +32,15 @@ $(function() {
|
|
30
32
|
slides.hide();
|
31
33
|
slides.filter(':first').show();
|
32
34
|
$('#slides #controls li').filter(':first').addClass('on');
|
33
|
-
$('#slides ul#controls li a').bind('
|
35
|
+
$('#slides ul#controls li a').bind('custom', {}, selectSlide).
|
34
36
|
each(function(i) { this.slideIndex=i; });
|
37
|
+
$('#slides ul#controls li a').click(function() {
|
38
|
+
$(this).trigger('custom');
|
39
|
+
clearInterval(startslides);
|
40
|
+
return false;
|
41
|
+
});
|
35
42
|
|
36
43
|
if (autorotate) {
|
37
|
-
setInterval(runSlideShow, (rotateInterval < 1000 ? 1000 : rotateInterval));
|
44
|
+
startslides = setInterval(runSlideShow, (rotateInterval < 1000 ? 1000 : rotateInterval));
|
38
45
|
}
|
39
46
|
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BcmsContentRotator
|
2
|
+
class Slide < ActiveRecord::Base
|
3
|
+
acts_as_content_block
|
4
|
+
|
5
|
+
has_attachment :file
|
6
|
+
|
7
|
+
def set_attachment_file_path
|
8
|
+
if !attachment_file.blank?
|
9
|
+
attachment.file_path = "/slides/attachment/#{Time.now.to_s(:year_month_day)}/#{name.to_slug}.#{attachment_file.original_filename.split('.').last.to_s.downcase}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_attachment_section
|
14
|
+
if !attachment_file.blank?
|
15
|
+
attachment.section = Section.first(:conditions => {:name => 'Slide'})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def image_url
|
20
|
+
file.url
|
21
|
+
end
|
22
|
+
|
23
|
+
# The title of the link users click on the change slides.
|
24
|
+
def nav_title_or_name
|
25
|
+
navigation_title.blank? ? name : navigation_title
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_link?
|
29
|
+
!link_url.blank?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class ContentRotatorPortlet < Portlet
|
1
|
+
class ContentRotatorPortlet < Cms::Portlet
|
2
2
|
|
3
3
|
# Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
|
4
4
|
enable_template_editor true
|
@@ -12,7 +12,7 @@ class ContentRotatorPortlet < Portlet
|
|
12
12
|
@slide_ids << s_id.to_i if (s_id && !s_id.empty?)
|
13
13
|
end
|
14
14
|
|
15
|
-
unsorted_slides = Slide.find(@slide_ids)
|
15
|
+
unsorted_slides = BcmsContentRotator::Slide.find(@slide_ids)
|
16
16
|
|
17
17
|
# Sort slides into explicit order based on slide_ids
|
18
18
|
@slides = []
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= f.cms_text_field :name, :instructions=>"(Required) Title for this slide." %>
|
2
|
-
<%= f.cms_file_field :
|
3
|
-
<%= f.cms_text_field :alt_text, :instructions => "(Optional) Alt tag for each image. Displayed as tool tip when user
|
2
|
+
<%= f.cms_file_field :file, :label => "Image", :instructions => "(Required) Upload an image for the background of this slide." %>
|
3
|
+
<%= f.cms_text_field :alt_text, :instructions => "(Optional) Alt tag for each image. Displayed as tool tip when the user mouses over the slide." %>
|
4
4
|
<%= f.cms_text_field :link_url, :label=>"Link URL", :instructions=>"(Optional) Set a URL (i.e. http://...) to make the slide clickable. (If blank, images won't be be links.)" %>
|
5
5
|
<%= f.cms_text_field :navigation_title, :label=>"Nav Title", :instructions=>"(Optional) Title that users will click on to select a slide (If blank, 'name' will be used.)" %>
|
6
6
|
<%= f.cms_text_editor :description %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<p><b>Name:</b> <%= h @content_block.name %></p>
|
2
|
-
<p><b>Image:</b> <%= image_tag @content_block.
|
2
|
+
<p><b>Image:</b> <%= image_tag attachment_path_for(@content_block.file) %></p>
|
3
3
|
<p><b>Alt Text:</b> <%= h @content_block.alt_text %></p>
|
4
4
|
<p><b>Description:</b> <%= @content_block.description.html_safe %></p>
|
5
5
|
<p><b>Link Url:</b> <%= @content_block.link_url %>
|
data/config/routes.rb
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
ContentType.create!(:name => "Slide", :group_name => "Content Rotator")
|
2
|
-
unless Section.with_path('/slides').exists?
|
3
|
-
Section.create!(:name => "Slide", :parent => Section.
|
1
|
+
Cms::ContentType.create!(:name => "BcmsContentRotator::Slide", :group_name => "Content Rotator")
|
2
|
+
unless Cms::Section.with_path('/slides').exists?
|
3
|
+
Cms::Section.create!(:name => "Slide", :parent => Cms::Section.system.first, :path => '/slides', :allow_groups=>:all)
|
4
4
|
end
|
data/lib/bcms_content_rotator.rb
CHANGED
@@ -3,9 +3,10 @@ require 'cms/module_installation'
|
|
3
3
|
class BcmsContentRotator::InstallGenerator < Cms::ModuleInstallation
|
4
4
|
add_migrations_directory_to_source_root __FILE__
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def copy_migrations
|
7
|
+
rake 'bcms_content_rotator:install:migrations'
|
8
|
+
end
|
9
|
+
|
9
10
|
def add_seed_data_to_project
|
10
11
|
copy_file "../bcms_content_rotator.seeds.rb", "db/bcms_content_rotator.seeds.rb"
|
11
12
|
append_to_file "db/seeds.rb", "load File.expand_path('../bcms_content_rotator.seeds.rb', __FILE__)"
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../../test_helper')
|
2
|
+
|
3
|
+
module BcmsContentRotator
|
4
|
+
class SlideTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
test "should be able to create new block" do
|
7
|
+
assert Slide.create!
|
8
|
+
end
|
9
|
+
|
10
|
+
test "a Slide with a link_url should have a link" do
|
11
|
+
assert_equal true, Slide.new(:link_url=>"anything").has_link?
|
12
|
+
end
|
13
|
+
|
14
|
+
test "a Slide with no link_url shouldn't have a link" do
|
15
|
+
assert_equal false, Slide.new.has_link?
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_content_rotator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: browsercms
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - <
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.
|
21
|
+
version: 3.6.0
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.5.0.rc3
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
|
-
version_requirements:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.6.0
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 3.5.0.rc3
|
25
36
|
description:
|
26
37
|
email: github@browsermedia.com
|
27
38
|
executables: []
|
@@ -29,30 +40,38 @@ extensions: []
|
|
29
40
|
extra_rdoc_files:
|
30
41
|
- README.markdown
|
31
42
|
files:
|
32
|
-
- app/
|
33
|
-
- app/
|
43
|
+
- app/assets/javascripts/bcms_content_rotator.js
|
44
|
+
- app/assets/javascripts/content_rotator.js
|
45
|
+
- app/assets/stylesheets/bcms_content_rotator/application.css
|
46
|
+
- app/controllers/bcms_content_rotator/slides_controller.rb
|
47
|
+
- app/models/bcms_content_rotator/slide.rb
|
34
48
|
- app/portlets/content_rotator_portlet.rb
|
35
49
|
- app/portlets/helpers/content_rotator_portlet_helper.rb
|
36
|
-
- app/views/
|
37
|
-
- app/views/
|
38
|
-
- app/views/layouts/templates/default.html.erb
|
50
|
+
- app/views/bcms_content_rotator/slides/_form.html.erb
|
51
|
+
- app/views/bcms_content_rotator/slides/render.html.erb
|
39
52
|
- app/views/portlets/content_rotator/_form.html.erb
|
40
53
|
- app/views/portlets/content_rotator/render.html.erb
|
41
|
-
-
|
54
|
+
- config/routes.rb
|
42
55
|
- db/bcms_content_rotator.seeds.rb
|
43
|
-
-
|
56
|
+
- db/migrate/20101111030324_bcms_content_rotator120.rb
|
57
|
+
- db/migrate/20120522173257_v130.rb
|
44
58
|
- lib/bcms_content_rotator/engine.rb
|
45
|
-
- lib/bcms_content_rotator/routes.rb
|
46
59
|
- lib/bcms_content_rotator/version.rb
|
47
60
|
- lib/bcms_content_rotator.rb
|
48
61
|
- lib/generators/bcms_content_rotator/install/install_generator.rb
|
49
62
|
- lib/generators/bcms_content_rotator/install/USAGE
|
63
|
+
- lib/tasks/bcms_content_rotator_tasks.rake
|
50
64
|
- lib/tasks/install.rake
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
51
67
|
- COPYRIGHT.txt
|
52
68
|
- GPL.txt
|
53
|
-
- LICENSE.txt
|
54
|
-
- Gemfile
|
55
69
|
- README.markdown
|
70
|
+
- test/bcms_content_rotator_test.rb
|
71
|
+
- test/functional/cms/slides_controller_test.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
- test/unit/models/slide_test.rb
|
74
|
+
- test/unit/portlets/content_rotator_portlet_test.rb
|
56
75
|
homepage: https://github.com/browsermedia/bcms_content_rotator
|
57
76
|
licenses: []
|
58
77
|
post_install_message:
|
@@ -67,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
86
|
version: '0'
|
68
87
|
segments:
|
69
88
|
- 0
|
70
|
-
hash: -
|
89
|
+
hash: -3426288886057068608
|
71
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
91
|
none: false
|
73
92
|
requirements:
|
@@ -76,12 +95,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
95
|
version: '0'
|
77
96
|
segments:
|
78
97
|
- 0
|
79
|
-
hash: -
|
98
|
+
hash: -3426288886057068608
|
80
99
|
requirements: []
|
81
100
|
rubyforge_project: bcms_content_rotator
|
82
|
-
rubygems_version: 1.8.
|
101
|
+
rubygems_version: 1.8.24
|
83
102
|
signing_key:
|
84
103
|
specification_version: 3
|
85
104
|
summary: A BrowserCMS module for creating a Slideshow/Homepage rotator designed to
|
86
105
|
showcase site content using jQuery.
|
87
|
-
test_files:
|
106
|
+
test_files:
|
107
|
+
- test/bcms_content_rotator_test.rb
|
108
|
+
- test/functional/cms/slides_controller_test.rb
|
109
|
+
- test/test_helper.rb
|
110
|
+
- test/unit/models/slide_test.rb
|
111
|
+
- test/unit/portlets/content_rotator_portlet_test.rb
|
data/app/models/slide.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class Slide < ActiveRecord::Base
|
2
|
-
acts_as_content_block :belongs_to_attachment => true
|
3
|
-
|
4
|
-
def set_attachment_file_path
|
5
|
-
if !attachment_file.blank?
|
6
|
-
attachment.file_path = "/slides/attachment/#{Time.now.to_s(:year_month_day)}/#{name.to_slug}.#{attachment_file.original_filename.split('.').last.to_s.downcase}"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_attachment_section
|
11
|
-
if !attachment_file.blank?
|
12
|
-
attachment.section = Section.first(:conditions => {:name => 'Slide'})
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def image_url
|
17
|
-
attachment.file_path
|
18
|
-
end
|
19
|
-
|
20
|
-
# The title of the link users click on the change slides.
|
21
|
-
def nav_title_or_name
|
22
|
-
navigation_title.blank? ? name : navigation_title
|
23
|
-
end
|
24
|
-
|
25
|
-
def has_link?
|
26
|
-
!link_url.blank?
|
27
|
-
end
|
28
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
5
|
-
<%= javascript_include_tag 'jquery', :bcms_content_rotator %>
|
6
|
-
<title><%= page_title %></title>
|
7
|
-
<%= yield :html_head %>
|
8
|
-
</head>
|
9
|
-
<body style="margin: 0; padding: 0; text-align: center;">
|
10
|
-
<%= cms_toolbar %>
|
11
|
-
<div id="wrapper" style="width: 700px; margin: 0 auto; text-align: left; padding: 30px">
|
12
|
-
Breadcrumbs: <%= render_breadcrumbs %>
|
13
|
-
Main Menu: <%= render_menu %>
|
14
|
-
<h1><%= page_title %></h1>
|
15
|
-
<%= container :main %>
|
16
|
-
</div>
|
17
|
-
</body>
|
18
|
-
</html>
|