bcms_person 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,9 @@
1
+ == BrowserCMS Person extension
2
+
3
+ This BrowserCMS 3.1 (or greater) extension allows you to create and group lists of people together in an attractive format.
4
+
5
+ == Requirements
6
+
7
+ * bcms_thumbnail - which should be installed and activated before you attempt to use this extension. bcms_thumbnail requires the ImageMagick command-line utilities (identify and mogrify for example).
8
+
9
+
@@ -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::PeopleController < Cms::ContentBlockController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Cms::PersonCategoriesController < 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,25 @@
1
+ class Person < ActiveRecord::Base
2
+ acts_as_content_block
3
+ belongs_to_attachment
4
+ belongs_to :person_category
5
+
6
+ validates_presence_of :first_name, :last_name
7
+
8
+ def set_attachment_file_path
9
+ # The default behavior is use /attachments/file.txt for the attachment path,
10
+ # assuming file.txt was the name of the file the user uploaded
11
+ # You should override this with your own strategy for setting the attachment path
12
+ super
13
+ end
14
+
15
+ def set_attachment_section
16
+ # The default behavior is to put all attachments in the root section
17
+ # Override this method if you would like to change that
18
+ super
19
+ end
20
+
21
+ def display_name
22
+ "#{self.first_name} #{self.last_name}"
23
+ end
24
+
25
+ end
@@ -0,0 +1,9 @@
1
+ class PersonCategory < ActiveRecord::Base
2
+ acts_as_content_block
3
+ acts_as_list
4
+
5
+ has_many :people
6
+
7
+ validates_presence_of :name
8
+
9
+ end
@@ -0,0 +1,5 @@
1
+ ##
2
+ # All methods from this helper will be available in the render.html.erb for PersonListByCategoryPortlet
3
+ module PersonListByCategoryPortletHelper
4
+
5
+ end
@@ -0,0 +1,13 @@
1
+ class PersonListByCategoryPortlet < Portlet
2
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
3
+ enable_template_editor false
4
+
5
+ def render
6
+ if self.person_category_id.blank?
7
+ @people = Person.find(:all, :order => (self.sort_order.blank?) ? 'first_name, last_name' : self.sort_order)
8
+ else
9
+ @person_category = PersonCategory.find(self.person_category_id.to_i)
10
+ @people = Person.find(:all, :conditions => ['person_category_id = ?', self.person_category_id], :order => (self.sort_order.blank?) ? 'first_name, last_name' : self.sort_order)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ <%= f.cms_text_field :name, :label => 'Full Name', :instructions => 'This is just to identify the person in the backend.' %>
2
+ <%= f.cms_text_field :first_name, :instructions => 'Required' %>
3
+ <%= f.cms_text_field :middle_name %>
4
+ <%= f.cms_text_field :last_name, :instructions => 'Required' %>
5
+ <%= f.cms_drop_down :person_category_id, PersonCategory.all(:order => "name").map{|c| [c.name, c.id]}, :prompt => "- Select one -", :label => "Person Category", :instructions => 'Please select what type of person this is. You can add more categories under "Person -> Person Category" in the admin interface.' %>
6
+ <%= f.cms_text_field :job_title %>
7
+ <%= f.cms_text_field :phone %>
8
+ <%= f.cms_text_field :office %>
9
+ <%= f.cms_text_editor :summary, :instructions => 'Used in compact listings - should probably be 2 to 3 sentences.' %>
10
+ <%= f.cms_text_editor :description, :instructions => 'The full description of this person. If you enter content here, we\'ll create a toggle that allows visitors to switch between the summary and full description content. Requires jQuery.' %>
11
+ <%= f.cms_file_field :attachment_file, :label => "Photo", :instructions => 'Upload a cropped jpg, png, or gif of any reasonable size - we\'ll scale it automatically.' %>
12
+ <%= f.cms_date_picker :start_date %>
13
+ <%= f.cms_date_picker :end_date %>
14
+ <%= f.cms_check_box :sticky, :instructions => 'This person should always be at the top of lists.' %>
15
+
@@ -0,0 +1,30 @@
1
+ <div class="person person-<%= @content_block.id %>">
2
+ <div class="person-photo">
3
+ <% unless @content_block.attachment.blank? %>
4
+ <%= image_tag(thumbnail(@content_block,'100'), :alt => @content_block.display_name, :class => 'thumbnail-photo') %>
5
+ <% end %>
6
+ </div>
7
+
8
+ <div class="person-meta">
9
+ <%= (@content_block.phone.blank?) ? '' : %Q|<div class="phone"><span>Phone:</span> #{@content_block.phone}</div>| %>
10
+ <%= (@content_block.office.blank?) ? '' : %Q|<div class="office"><span>Office:</span> #{@content_block.office}</div>| %>
11
+ <%= (@content_block.start_date.blank?) ? '' : %Q|<div class="start_date"><span>From:</span> #{@content_block.start_date.month}/#{content_block.start_date.year}</div>| %>
12
+ <%= (@content_block.end_date.blank?) ? '' : %Q|<div class="end_date"><span>To:</span> #{@content_block.start_date.month}/#{content_block.start_date.year}</div>| %>
13
+ </div>
14
+
15
+ <div class="person-content">
16
+ <h2 class="person-name"><%= h @content_block.display_name %><a name="<%= @content_block.display_name.gsub(/[^a-z\d]/i,'-').downcase %>"></a></h2>
17
+ <%= (@content_block.job_title.blank?) ? '' : "<h3 class=\"person-job-title\">#{h @content_block.job_title}</h3>" %>
18
+ <div class="summary" id="person-<%= @content_block.id %>-summary"><%= @content_block.summary %></div>
19
+ <% if ! @content_block.description.blank? %>
20
+ <div class="description" style="display: none;" id="person-<%= @content_block.id %>-description">
21
+ <% unless @content_block.attachment.blank? %>
22
+ <%= image_tag(thumbnail(@content_block,'200'), :alt => @content_block.display_name, :class=>'full-photo') %>
23
+ <% end %>
24
+ <%= @content_block.description %>
25
+ </div>
26
+ <div class="person-details-toggle"><a href="#" id="person-<%= @content_block.id %>-toggle" class="person-toggle">more &raquo;</a></div>
27
+ <% end %>
28
+ </div>
29
+ <div class="clear"></div>
30
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= f.cms_text_field :name %>
2
+ <%= f.cms_text_field :description %>
3
+ <%= f.cms_text_field :position, :instructions => 'Sets the order of this category in lists.' %>
@@ -0,0 +1,3 @@
1
+
2
+ <p><b>Name:</b> <%= @content_block.name %></p>
3
+ <p><b>Description:</b> <%= @content_block.description %></p>
@@ -0,0 +1,14 @@
1
+ <%= f.cms_text_field :name %>
2
+ <%= f.cms_text_editor :description, :instructions => 'Appears below the title and above the list of people' %>
3
+ <%= f.cms_drop_down :person_category_id, PersonCategory.all(:order => "name").map{|c| [c.name, c.id.to_s]}, :prompt => "- All people -", :label => "Person Category", :instructions => 'Display people in this category.' %>
4
+ <%= f.cms_drop_down :sort_order, [
5
+ ['Last Name','sticky desc, last_name, first_name'],
6
+ ['Last Name reverse','sticky desc, last_name desc, first_name desc'],
7
+ ['First Name','sticky desc, first_name, last_name'],
8
+ ['First name reverse','sticky desc, first_name desc, last_name desc'],
9
+ ['Start date','sticky desc, start_date'],
10
+ ['Start date reverse','sticky desc, start_date desc']
11
+ ], :prompt => '- Choose a sort order -', :instructions => 'The sort order of people in this category.' %>
12
+ <%= f.cms_template_editor :template %>
13
+ <%= f.cms_check_box :display_name, :instructions => "Show the name of this portlet in an h2 tag" %>
14
+ <%= f.cms_text_editor :none_found_message, :instructions => 'Text to display if no people are found.' %>
@@ -0,0 +1,19 @@
1
+ <%
2
+ require_javascript_include(['jquery','../bcms/person/bcms_person'])
3
+ require_stylesheet_link(['../bcms/person/bcms_person'])
4
+ -%>
5
+ <div class="person-list person-category-<%= (@person_category.blank?) ? 'all' : @person_category.name.gsub(/[^a-z\d]/i,'-').downcase %>">
6
+ <% if @portlet.display_name %>
7
+ <h2><%=h @portlet.name %></h2>
8
+ <% end %>
9
+ <% unless @portlet.description.blank? %>
10
+ <div class="description"><%= @portlet.description %></div>
11
+ <% end %>
12
+ <% unless @people.blank? %>
13
+ <% @people.each do |person| %>
14
+ <%= render_connectable person %>
15
+ <% end %>
16
+ <% else %>
17
+ <%= @portlet.none_found_message %>
18
+ <% end %>
19
+ </div>
@@ -0,0 +1,37 @@
1
+ class CreatePeople < ActiveRecord::Migration
2
+ def self.up
3
+ create_content_table :people do |t|
4
+ t.string :first_name
5
+ t.string :middle_name
6
+ t.string :last_name
7
+ t.string :job_title
8
+ t.string :phone
9
+ t.string :office
10
+ t.text :summary, :size => (64.kilobytes + 1)
11
+ t.text :description, :size => (64.kilobytes + 1)
12
+ t.belongs_to :attachment
13
+ t.integer :attachment_version
14
+ t.date :start_date
15
+ t.date :end_date
16
+ t.string :type_of_person
17
+ t.boolean :sticky
18
+ t.references :person_category
19
+ end
20
+
21
+ add_index :people, :person_category_id
22
+ add_index :people, :sticky
23
+
24
+ unless Section.with_path('/people').exists?
25
+ Section.create!(:name => "Person", :parent => Section.system.first, :path => '/people', :allow_groups=>:all)
26
+ end
27
+ ContentType.create!(:name => "Person", :group_name => "Person")
28
+ end
29
+
30
+ def self.down
31
+ ContentType.delete_all(['name = ?', 'Person'])
32
+ CategoryType.all(:conditions => ['name = ?', 'Person']).each(&:destroy)
33
+ #If you aren't creating a versioned table, be sure to comment this out.
34
+ drop_table :person_versions
35
+ drop_table :people
36
+ end
37
+ end
@@ -0,0 +1,24 @@
1
+ class CreatePersonCategories < ActiveRecord::Migration
2
+ def self.up
3
+ create_content_table :person_categories do |t|
4
+ t.string :name
5
+ t.string :description
6
+ t.integer :position
7
+ end
8
+ ContentType.create!(:name => "PersonCategory", :group_name => "Person")
9
+ ['Staff','Board Member','Alumni'].each do |cat|
10
+ PersonCategory.create(:publish_on_save => true, :name => cat)
11
+ end
12
+ [:position].each do|col|
13
+ add_index :person_categories, col
14
+ end
15
+ end
16
+
17
+ def self.down
18
+ ContentType.delete_all(['name = ?', 'PersonCategory'])
19
+ CategoryType.all(:conditions => ['name = ?', 'Person Category']).each(&:destroy)
20
+ #If you aren't creating a versioned table, be sure to comment this out.
21
+ drop_table :person_category_versions
22
+ drop_table :person_categories
23
+ end
24
+ end
@@ -0,0 +1 @@
1
+ require 'bcms_person/routes'
@@ -0,0 +1,8 @@
1
+ module Cms::Routes
2
+ def routes_for_bcms_person
3
+ namespace(:cms) do |cms|
4
+ cms.content_blocks :person_categories
5
+ cms.content_blocks :people
6
+ end
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ Use this directory to add public files that should copied from the gem into the project.
@@ -0,0 +1,46 @@
1
+ .clear{
2
+ clear: both;
3
+ }
4
+
5
+ .person{
6
+ margin-bottom: 2em;
7
+ }
8
+
9
+ .person h2{
10
+ margin-bottom: 5px;
11
+ }
12
+
13
+ .person-photo{
14
+ float: left;
15
+ width: 110px;
16
+ text-align: center;
17
+ }
18
+
19
+ .person-photo img{
20
+ width: 100px;
21
+ }
22
+
23
+ .person-meta{
24
+ float: right;
25
+ text-align: left;
26
+ margin-left: 10px;
27
+ margin-bottom: 10px;
28
+ width: 150px;
29
+ }
30
+
31
+ .person-meta span{
32
+ font-weight: bold;
33
+ }
34
+
35
+ .person-content{
36
+ margin-left: 110px;
37
+ }
38
+
39
+ .person-toggle {
40
+ font-size: 10px;
41
+ }
42
+
43
+ .full-photo{
44
+ float: right;
45
+ margin: 0px 0px 10px 10px;
46
+ }
@@ -0,0 +1,15 @@
1
+ jQuery(document).ready(function(){
2
+ jQuery('.person-toggle').click(function(e){
3
+ e.preventDefault();
4
+ var personId = jQuery(this).attr('id').split('-')[1];
5
+ if(jQuery('#person-' + personId + '-summary').is(':visible')){
6
+ jQuery('#person-' + personId + '-summary').hide();
7
+ jQuery('#person-' + personId + '-description').show();
8
+ jQuery(this).html('&laquo; less');
9
+ } else {
10
+ jQuery('#person-' + personId + '-summary').show();
11
+ jQuery('#person-' + personId + '-description').hide();
12
+ jQuery(this).html('more &raquo;');
13
+ }
14
+ });
15
+ });
@@ -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/person/**/*"
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bcms_person
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
+ platform: ruby
12
+ authors:
13
+ - Dan Collis-Puro
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-18 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bcms_thumbnail
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 2
34
+ version: 1.0.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description:
38
+ email: dan@collispuro.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README
45
+ files:
46
+ - app/portlets/helpers/person_list_by_category_portlet_helper.rb
47
+ - app/portlets/person_list_by_category_portlet.rb
48
+ - app/helpers/application_helper.rb
49
+ - app/views/portlets/person_list_by_category/_form.html.erb
50
+ - app/views/portlets/person_list_by_category/render.html.erb
51
+ - app/views/cms/people/_form.html.erb
52
+ - app/views/cms/people/render.html.erb
53
+ - app/views/cms/person_categories/_form.html.erb
54
+ - app/views/cms/person_categories/render.html.erb
55
+ - app/controllers/application_controller.rb
56
+ - app/controllers/cms/person_categories_controller.rb
57
+ - app/controllers/cms/people_controller.rb
58
+ - app/models/person.rb
59
+ - app/models/person_category.rb
60
+ - db/migrate/20100416190408_create_person_categories.rb
61
+ - db/migrate/20100416173927_create_people.rb
62
+ - lib/bcms_person.rb
63
+ - lib/bcms_person/routes.rb
64
+ - rails/init.rb
65
+ - public/bcms/person/bcms_person.js
66
+ - public/bcms/person/README
67
+ - public/bcms/person/bcms_person.css
68
+ - README
69
+ has_rdoc: true
70
+ homepage: http://collispuro.com
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ requirements: []
97
+
98
+ rubyforge_project: bcms_person
99
+ rubygems_version: 1.3.7
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: A staffer / board member / general person module for BrowserCMS
103
+ test_files: []
104
+