bcms_content_rotator 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1 @@
1
+ # Content Rotator Module for BrowserCMS
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ # filter_parameter_logging :password
10
+ end
@@ -0,0 +1,2 @@
1
+ class Cms::SlidesController < Cms::ContentBlockController
2
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,3 @@
1
+ class Slide < ActiveRecord::Base
2
+ acts_as_content_block
3
+ end
@@ -0,0 +1,23 @@
1
+ class ContentRotatorPortlet < Portlet
2
+
3
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
4
+ enable_template_editor true
5
+
6
+ def render
7
+
8
+ # Collect the list of slide_ids
9
+ @slide_ids = []
10
+ (1..5).each do |i|
11
+ s_id = self.send("slide_#{i}_id")
12
+ @slide_ids << s_id.to_i if (s_id && !s_id.empty?)
13
+ end
14
+
15
+ unsorted_slides = Slide.find(@slide_ids)
16
+
17
+ # Sort slides into explicit order based on slide_ids
18
+ @slides = []
19
+ @slide_ids.each do |id|
20
+ @slides << unsorted_slides.select{|item| item.id == id}.first
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ ##
2
+ # All methods from this helper will be available in the render.html.erb for ContentRotatorPortlet
3
+ module ContentRotatorPortletHelper
4
+
5
+ end
@@ -0,0 +1,4 @@
1
+ <%= f.cms_text_field :name %>
2
+ <%= f.cms_text_field :image_url %>
3
+ <%= f.cms_text_field :alt_text %>
4
+ <%= f.cms_text_editor :description %>
@@ -0,0 +1,4 @@
1
+ <p><b>Name:</b> <%= h @content_block.name %></p>
2
+ <p><b>Image Url:</b> <%= h @content_block.image_url %></p>
3
+ <p><b>Alt Text:</b> <%= h @content_block.alt_text %></p>
4
+ <p><b>Description:</b> <%= @content_block.description %></p>
@@ -0,0 +1,18 @@
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
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
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>
@@ -0,0 +1,10 @@
1
+ <% @slides = Slide.all %>
2
+ <%= f.cms_text_field :name %>
3
+ <%= f.cms_drop_down :slide_1_id, @slides.map{|c| [c.name, c.id.to_s]}, :label=>"Slide 1", :include_blank=>"[No slide selected]" %>
4
+ <%= f.cms_drop_down :slide_2_id, @slides.map{|c| [c.name, c.id.to_s]}, :label=>"Slide 2", :include_blank=>"[No slide selected]" %>
5
+ <%= f.cms_drop_down :slide_3_id, @slides.map{|c| [c.name, c.id.to_s]}, :label=>"Slide 3", :include_blank=>"[No slide selected]" %>
6
+ <%= f.cms_drop_down :slide_4_id, @slides.map{|c| [c.name, c.id.to_s]}, :label=>"Slide 4", :include_blank=>"[No slide selected]" %>
7
+ <%= f.cms_drop_down :slide_5_id, @slides.map{|c| [c.name, c.id.to_s]}, :label=>"Slide 5", :include_blank=>"[No slide selected]" %>
8
+ <%= f.cms_check_box :autorotate, :label => "Automatically rotate" %>
9
+ <%= f.cms_text_field :rotate_interval, :label => "Rotation delay", :instructions => "in seconds (has no effect if autorotate is off)" %>
10
+ <%= f.cms_template_editor :template %>
@@ -0,0 +1,64 @@
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ $(function() {
4
+ var slides = $('#slides div.slide'),
5
+ currentItem = 0,
6
+ rotateInterval = <%= @portlet.rotate_interval.to_i %> * 1000,
7
+ autorotate = <%= @portlet.autorotate %>,
8
+
9
+
10
+ runSlideShow = function() {
11
+ var item = $('#slides ul#controls li a:eq('+currentItem+')');
12
+ if (item.length) {
13
+ item.trigger('click', ['timer']);
14
+ currentItem++;
15
+ } else {
16
+ currentItem = 0;
17
+ }
18
+ },
19
+
20
+ selectSlide = function(e) {
21
+ if ($(this).parent().hasClass('on')) {
22
+ return false;
23
+ } else {
24
+ $('#slides ul#controls li').removeClass('on');
25
+ $(this).parent().addClass('on');
26
+ slides.hide();
27
+ slides.filter(this.hash).show();
28
+ return false;
29
+ }
30
+ };
31
+
32
+ slides.hide();
33
+ slides.filter(':first').show();
34
+ $('#slides #controls li').filter(':first').addClass('on');
35
+ $('#slides ul#controls li a').bind('click', {}, selectSlide).
36
+ each(function(i) { this.slideIndex=i; });
37
+
38
+ if (autorotate) {
39
+ setInterval(runSlideShow, (rotateInterval < 1000 ? 1000 : rotateInterval));
40
+ }
41
+ });
42
+ //]]>
43
+ </script>
44
+
45
+ <div id="slides">
46
+ <ul id="controls">
47
+ <% @slides.each_with_index do |slide, i| %>
48
+ <li><a href="#slide-<%= i %>"><%= h slide.name %></a></li>
49
+ <% end %>
50
+ </ul>
51
+ <% @slides.each_with_index do |slide, i| %>
52
+ <div id="slide-<%= i %>" class="slide">
53
+ <div class="info">
54
+ <div class="pad">
55
+ <h3><%= h slide.name %></h3>
56
+ <%= slide.description %>
57
+ </div>
58
+ </div>
59
+ <% unless slide.image_url.blank? %>
60
+ <%= image_tag slide.image_url, :alt => h(slide.alt_text) %>
61
+ <% end %>
62
+ </div>
63
+ <% end %>
64
+ </div>
@@ -0,0 +1,21 @@
1
+ class CreateSlides < ActiveRecord::Migration
2
+ def self.up
3
+ create_content_table :slides do |t|
4
+ t.string :name
5
+ t.string :image_url
6
+ t.string :alt_text
7
+ t.text :description
8
+ end
9
+
10
+
11
+ ContentType.create!(:name => "Slide", :group_name => "Content Rotator")
12
+ end
13
+
14
+ def self.down
15
+ ContentType.delete_all(['name = ?', 'Slide'])
16
+ CategoryType.all(:conditions => ['name = ?', 'Slide']).each(&:destroy)
17
+ #If you aren't creating a versioned table, be sure to comment this out.
18
+ drop_table :slide_versions
19
+ drop_table :slides
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module Cms::Routes
2
+ def routes_for_bcms_content_rotator
3
+ namespace(:cms) do |cms|
4
+ cms.content_blocks :slides
5
+ end
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require 'bcms_content_rotator/routes'
data/rails/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ gem_root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2
+ Cms.add_to_rails_paths gem_root
3
+ Cms.add_generator_paths gem_root, "db/migrate/[0-9]*_*.rb"
4
+ Cms.add_generator_paths gem_root, "public/bcms/content_rotator/**/*"
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bcms_content_rotator
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - BrowserMedia
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-17 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description:
23
+ email: github@browsermedia.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.markdown
30
+ files:
31
+ - app/controllers/application_controller.rb
32
+ - app/controllers/cms/slides_controller.rb
33
+ - app/helpers/application_helper.rb
34
+ - app/models/slide.rb
35
+ - app/portlets/content_rotator_portlet.rb
36
+ - app/portlets/helpers/content_rotator_portlet_helper.rb
37
+ - app/views/cms/slides/_form.html.erb
38
+ - app/views/cms/slides/render.html.erb
39
+ - app/views/layouts/templates/default.html.erb
40
+ - app/views/portlets/content_rotator/_form.html.erb
41
+ - app/views/portlets/content_rotator/render.html.erb
42
+ - db/migrate/20101111030324_create_slides.rb
43
+ - lib/bcms_content_rotator.rb
44
+ - lib/bcms_content_rotator/routes.rb
45
+ - rails/init.rb
46
+ - README.markdown
47
+ has_rdoc: true
48
+ homepage: http://www.browsercms.org
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirements: []
75
+
76
+ rubyforge_project: bcms_content_rotator
77
+ rubygems_version: 1.3.7
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: A Content Rotator Module for BrowserCMS
81
+ test_files: []
82
+