refinerycms-calendar 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/app/controllers/admin/event_categories_controller.rb +9 -0
  2. data/app/controllers/admin/events_controller.rb +26 -0
  3. data/app/controllers/event_categories_controller.rb +10 -0
  4. data/app/controllers/events_controller.rb +64 -0
  5. data/app/helpers/event_categories_helper.rb +3 -0
  6. data/app/helpers/events_helper.rb +38 -0
  7. data/app/models/event.rb +72 -0
  8. data/app/models/event_categorization.rb +4 -0
  9. data/app/models/event_category.rb +10 -0
  10. data/app/views/admin/event_categories/_event_categories.html.erb +1 -0
  11. data/app/views/admin/event_categories/_event_category.html.erb +18 -0
  12. data/app/views/admin/event_categories/_form.html.erb +26 -0
  13. data/app/views/admin/event_categories/_sortable_list.html.erb +3 -0
  14. data/app/views/admin/event_categories/edit.html.erb +1 -0
  15. data/app/views/admin/event_categories/index.html.erb +40 -0
  16. data/app/views/admin/event_categories/new.html.erb +1 -0
  17. data/app/views/admin/events/_event.html.erb +18 -0
  18. data/app/views/admin/events/_events.html.erb +1 -0
  19. data/app/views/admin/events/_form.html.erb +126 -0
  20. data/app/views/admin/events/_sortable_list.html.erb +20 -0
  21. data/app/views/admin/events/edit.html.erb +1 -0
  22. data/app/views/admin/events/index.html.erb +41 -0
  23. data/app/views/admin/events/new.html.erb +1 -0
  24. data/app/views/event_categories/show.html.erb +15 -0
  25. data/app/views/events/_event.html.erb +103 -0
  26. data/app/views/events/_sidebar.html.erb +38 -0
  27. data/app/views/events/archive.html.erb +17 -0
  28. data/app/views/events/index.html.erb +17 -0
  29. data/app/views/events/index.rss.builder +24 -0
  30. data/app/views/events/show.html.erb +15 -0
  31. data/changelog.md +22 -0
  32. data/config/locales/en.yml +39 -0
  33. data/config/locales/lolcat.yml +24 -0
  34. data/config/locales/nb.yml +20 -0
  35. data/config/locales/nl.yml +20 -0
  36. data/config/routes.rb +11 -0
  37. data/db/migrate/01_create_events.rb +33 -0
  38. data/db/migrate/02_create_event_categories.rb +13 -0
  39. data/db/migrate/03_create_event_categorizations.rb +17 -0
  40. data/db/seeds/events.rb +17 -0
  41. data/features/manage_events.feature +64 -0
  42. data/features/step_definitions/event_steps.rb +14 -0
  43. data/features/support/factories/event_categories.rb +3 -0
  44. data/features/support/factories/events.rb +6 -0
  45. data/features/support/paths.rb +17 -0
  46. data/lib/generators/refinerycms_events_generator.rb +6 -0
  47. data/lib/refinerycms-events.rb +23 -0
  48. data/lib/tasks/events.rake +13 -0
  49. data/public/stylesheets/refinerycms-events.css +73 -0
  50. data/readme.md +49 -0
  51. data/refinerycms-calendar.gemspec +17 -0
  52. data/spec/controllers/events_controller_spec.rb +14 -0
  53. data/spec/helpers/events_helper_spec.rb +16 -0
  54. data/spec/models/event_category_spec.rb +29 -0
  55. data/spec/models/event_spec.rb +82 -0
  56. metadata +133 -0
@@ -0,0 +1,33 @@
1
+ class CreateEvents < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :events do |t|
5
+ t.string :title
6
+ t.datetime :start_at
7
+ t.datetime :end_at
8
+ t.string :venue_name
9
+ t.string :venue_address
10
+ t.decimal :ticket_price, :precision => 8, :scale => 2
11
+ t.string :ticket_link
12
+ t.text :description
13
+ t.boolean :featured
14
+ t.integer :image_id
15
+ t.integer :position
16
+
17
+ t.timestamps
18
+ end
19
+
20
+ add_index :events, :id
21
+
22
+ load(Rails.root.join('db', 'seeds', 'events.rb'))
23
+ end
24
+
25
+ def self.down
26
+ UserPlugin.destroy_all({:name => "events"})
27
+
28
+ Page.delete_all({:link_url => "/events"})
29
+
30
+ drop_table :events
31
+ end
32
+
33
+ end
@@ -0,0 +1,13 @@
1
+ class CreateEventCategories < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :event_categories do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :event_categories
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ class CreateEventCategorizations < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :event_categorizations do |t|
4
+ t.integer :event_id
5
+ t.integer :event_category_id
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :event_categorizations, :event_id
11
+ add_index :event_categorizations, :event_category_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :event_categorizations
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ User.find(:all).each do |user|
2
+ if user.plugins.find_by_name('events').nil?
3
+ user.plugins.create(:name => 'events',
4
+ :position => (user.plugins.maximum(:position) || -1) +1)
5
+ end
6
+ end
7
+
8
+ page = Page.create(
9
+ :title => 'Events',
10
+ :link_url => '/events',
11
+ :deletable => false,
12
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
13
+ :menu_match => '^/events(\/|\/.+?|)$'
14
+ )
15
+ Page.default_parts.each_with_index do |default_page_part, idx|
16
+ page.parts.create(:title => default_page_part, :body => nil, :position => idx)
17
+ end
@@ -0,0 +1,64 @@
1
+ @events
2
+ Feature: Events
3
+ In order to have events on my website
4
+ As an administrator
5
+ I want to manage events
6
+
7
+ Background:
8
+ Given I am a logged in refinery user
9
+ And I have no events
10
+
11
+ @events-list @list
12
+ Scenario: Events List
13
+ Given I have events titled UniqueTitleOne, UniqueTitleTwo
14
+ When I go to the list of events
15
+ # And show me the page
16
+ Then I should see "UniqueTitleOne"
17
+ And I should see "UniqueTitleTwo"
18
+
19
+ @events-valid @valid
20
+ Scenario: Create Valid Event
21
+ When I go to the list of events
22
+ And I follow "Add New Event"
23
+ And I fill in "Title" with "This is a test of the first string field"
24
+ And I press "Save"
25
+ Then I should see "'This is a test of the first string field' was successfully added."
26
+ And I should have 1 event
27
+
28
+ @events-invalid @invalid
29
+ Scenario: Create Invalid Event (without title)
30
+ When I go to the list of events
31
+ And I follow "Add New Event"
32
+ And I press "Save"
33
+ Then I should see "Title can't be blank"
34
+ And I should have 0 events
35
+
36
+ @events-edit @edit
37
+ Scenario: Edit Existing Event
38
+ Given I have events titled "A title"
39
+ When I go to the list of events
40
+ And I follow "Edit this event" within ".actions"
41
+ Then I fill in "Title" with "A different title"
42
+ And I press "Save"
43
+ Then I should see "'A different title' was successfully updated."
44
+ And I should be on the list of events
45
+ And I should not see "A title"
46
+
47
+ @events-duplicate @duplicate
48
+ Scenario: Create Duplicate Event
49
+ Given I only have events titled UniqueTitleOne, UniqueTitleTwo
50
+ When I go to the list of events
51
+ And I follow "Add New Event"
52
+ And I fill in "Title" with "UniqueTitleTwo"
53
+ And I press "Save"
54
+ Then I should see "There were problems"
55
+ And I should have 2 events
56
+
57
+ @events-delete @delete
58
+ Scenario: Delete Event
59
+ Given I only have events titled UniqueTitleOne
60
+ When I go to the list of events
61
+ And I follow "Remove this event forever"
62
+ Then I should see "'UniqueTitleOne' was successfully removed."
63
+ And I should have 0 events
64
+
@@ -0,0 +1,14 @@
1
+ Given /^I have no events$/ do
2
+ Event.delete_all
3
+ end
4
+
5
+ Given /^I (only )?have events titled "?([^\"]*)"?$/ do |only, titles|
6
+ Event.delete_all if only
7
+ titles.split(', ').each do |title|
8
+ Factory(:event, :title => title)
9
+ end
10
+ end
11
+
12
+ Then /^I should have ([0-9]+) events?$/ do |count|
13
+ Event.count.should == count.to_i
14
+ end
@@ -0,0 +1,3 @@
1
+ Factory.define :event_category do |f|
2
+ f.sequence(:name) { |n| "Class/Lecture #{n}" }
3
+ end
@@ -0,0 +1,6 @@
1
+ Factory.define :event do |f|
2
+ f.sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
3
+ f.description "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
4
+ f.start_at Time.now
5
+ f.end_at Time.now.advance(:hours => 1)
6
+ end
@@ -0,0 +1,17 @@
1
+ module NavigationHelpers
2
+ module Refinery
3
+ module Events
4
+ def path_to(page_name)
5
+ case page_name
6
+ when /the list of events/
7
+ admin_events_path
8
+
9
+ when /the new event form/
10
+ new_admin_event_path
11
+ else
12
+ nil
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class RefinerycmsEvents < Refinery::Generators::EngineInstaller
2
+
3
+ source_root File.expand_path('../../../', __FILE__)
4
+ engine_name "events"
5
+
6
+ end
@@ -0,0 +1,23 @@
1
+ require 'refinery'
2
+
3
+ module Refinery
4
+ module Events
5
+ class Engine < Rails::Engine
6
+ initializer "static assets" do |app|
7
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
8
+ end
9
+
10
+ config.after_initialize do
11
+ Refinery::Plugin.register do |plugin|
12
+ plugin.name = "events"
13
+ plugin.activity = [{
14
+ :class => Event
15
+ }, {
16
+ :class => EventCategory
17
+ }]
18
+ plugin.menu_match = /^(admin|refinery)\/(event(_categorie)?s)/
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :events do
4
+
5
+ # call this task my running: rake refinery:events:my_task
6
+ # desc "Description of my task below"
7
+ # task :my_task => :environment do
8
+ # # add your logic here
9
+ # end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,73 @@
1
+ .individual_event {
2
+ padding: 15px;
3
+ margin: 0 0 10px;
4
+ background-color: #f4f4f4;
5
+ }
6
+ .individual_event h1 {
7
+ margin: 0 0 10px;
8
+ padding: 0;
9
+ }
10
+ .individual_event .event_image {
11
+ float: left;
12
+ margin: 0 15px 10px 0;
13
+ }
14
+ #featured_events h2 {
15
+ margin: 15px 0 10px;
16
+ }
17
+
18
+ .sidebar_module {
19
+ padding: 15px;
20
+ }
21
+ .sidebar_module h2 {
22
+ margin: 0 0 10px;
23
+ }
24
+ .categories a {
25
+ display: block;
26
+ margin: 5px 0;
27
+ }
28
+ .sidebar_module ul {
29
+ list-style: square;
30
+ padding: 0 0 0 26px;
31
+ margin: 0;
32
+ }
33
+ .sidebar_module ul li {
34
+ margin: 2px 0;
35
+ padding: 2px 0;
36
+ }
37
+
38
+ #share_this_event {
39
+ border-top: 1px solid #ddd;
40
+ border-bottom: 1px solid #ddd;
41
+ padding: 20px 0;
42
+ margin: 20px 0;
43
+ }
44
+ #share_this_event ul {
45
+ list-style: none;
46
+ border: 0;
47
+ padding: 0;
48
+ margin: 0;
49
+ }
50
+ #share_this_event ul li {
51
+ float: left;
52
+ height: 70px;
53
+ margin: 0 15px 0 0;
54
+ }
55
+
56
+ #prevnext_nav {
57
+ clear: both;
58
+ display: block;
59
+ height: 100px;
60
+ }
61
+ #prevnext_nav .prev {
62
+ width: 33%;
63
+ float: left;
64
+ }
65
+ #prevnext_nav .home {
66
+ width: 33%;
67
+ float: left;
68
+ }
69
+ #prevnext_nav .next {
70
+ width: 33%;
71
+ float: left;
72
+ }
73
+
@@ -0,0 +1,49 @@
1
+ # Events engine for Refinery CMS.
2
+
3
+ * Venue Details
4
+ * Ticket pricing & Link
5
+ * Mark featured events
6
+ * Specify a main image
7
+ * Archives
8
+ * Categories
9
+ * Basic layout and styling to get started immediately [blake0102](http://github.com/blake0102)
10
+ * Easily hook onto a few semantic CSS classes built into the markup [blake0102](http://github.com/blake0102)
11
+ * Basic Facebook & Twitter sharing interface
12
+ * RSS feed
13
+
14
+ # Install
15
+
16
+ Using Rails 3 / Bundler Gemfile:
17
+
18
+ gem 'refinerycms-calendar', '~>1.0'
19
+
20
+ bash:
21
+
22
+ bundle install
23
+
24
+ rails g refinerycms_calendar
25
+
26
+ rake db:migrate
27
+
28
+
29
+
30
+ Maintained by [joemsak](http://github.com/joemsak)
31
+
32
+ ## TODO for 1.1 Release:
33
+
34
+ * Import events from Facebook fan page?
35
+ * JS datepicker in admin backend
36
+ * Calendar grid view? (can be kinda gross, honestly)
37
+ * iCal export
38
+
39
+ ## TODO for 1.2
40
+
41
+ * Google map of address
42
+ * Address finder?
43
+
44
+ ## Acknowledgements
45
+
46
+ * [Ed Blake](http://github.com/blake0102) structured semantic markup and design-minded workflow.
47
+ * [Neoteric Design, Inc.](http://www.neotericdesign.com) support and enthusiasm for my time & energy spent on helping the Refinery community.
48
+ * [Philip Arndt](http://github.com/parndt) Core team, RefineryCMS. Built the generator that makes this engine possible.
49
+ * [Resolve Digital](http://www.resolvedigital.com) The company behind the fabulous [RefineryCMS](http://www.refinerycms.com).
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'refinerycms-calendar'
4
+ s.version = '1.0'
5
+ s.description = 'Ruby on Rails Events engine for Refinery CMS'
6
+ s.date = '2011-03-03'
7
+ s.summary = 'Events engine for Refinery CMS'
8
+ s.require_paths = %w(lib)
9
+ s.files = Dir['**/*']
10
+ s.authors = ["Neoteric Design", "Joe Sak", "Philip Arndt"]
11
+ s.email = %q{joe@neotericdesign.com}
12
+ s.homepage = "https://github.com/resolve/refinerycms-calendar"
13
+
14
+ s.add_dependency 'refinerycms', '>= 0.9.9'
15
+ end
16
+
17
+
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
3
+
4
+ describe EventsController do
5
+
6
+ describe "GET 'index' RSS" do
7
+ it "should be successful" do
8
+ get 'index', :format => :rss
9
+ response.should be_success
10
+ end
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ # Specs in this file have access to a helper object that includes
4
+ # the EventsHelper. For example:
5
+ #
6
+ # describe EventsHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # helper.concat_strings("this","that").should == "this that"
10
+ # end
11
+ # end
12
+ # end
13
+
14
+ # describe EventsHelper do
15
+ # pending "add some examples to (or delete) #{__FILE__}"
16
+ # end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
3
+
4
+ describe EventCategory do
5
+ before(:each) do
6
+ @attr = Factory(:event_category).attributes
7
+ end
8
+
9
+ context "validations" do
10
+
11
+ it "requires a name" do
12
+ EventCategory.new(@attr.merge(:name => nil)).should_not be_valid
13
+ end
14
+
15
+ end
16
+
17
+ context "events" do
18
+ it "can associate with many events" do
19
+ event1 = Factory(:event)
20
+ event2 = Factory(:event)
21
+ category = Factory(:event_category)
22
+
23
+ category.events << event1
24
+ category.events << event2
25
+
26
+ category.events.size.should be 2
27
+ end
28
+ end
29
+ end