refinerycms-calendar 1.1.0 → 2.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/app/controllers/refinery/calendar/admin/events_controller.rb +43 -0
  2. data/app/controllers/refinery/calendar/events_controller.rb +34 -0
  3. data/app/models/refinery/calendar/core_calendar.rb +36 -0
  4. data/app/models/refinery/calendar/event.rb +51 -0
  5. data/app/views/refinery/calendar/admin/events/_actions.html.erb +25 -0
  6. data/app/views/refinery/calendar/admin/events/_event.html.erb +10 -0
  7. data/app/views/refinery/calendar/admin/events/_events.html.erb +2 -0
  8. data/app/views/refinery/calendar/admin/events/_form.html.erb +31 -0
  9. data/app/views/refinery/calendar/admin/events/_records.html.erb +18 -0
  10. data/app/views/refinery/calendar/admin/events/_sortable_list.html.erb +5 -0
  11. data/app/views/refinery/calendar/admin/events/edit.html.erb +1 -0
  12. data/app/views/refinery/calendar/admin/events/index.html.erb +8 -0
  13. data/app/views/refinery/calendar/admin/events/new.html.erb +1 -0
  14. data/app/views/refinery/calendar/events/index.html.erb +11 -0
  15. data/app/views/refinery/calendar/events/show.html.erb +27 -0
  16. data/config/locales/en.yml +25 -43
  17. data/config/locales/es.yml +28 -0
  18. data/config/locales/fr.yml +25 -43
  19. data/config/locales/nb.yml +25 -18
  20. data/config/locales/nl.yml +25 -18
  21. data/config/routes.rb +12 -10
  22. data/db/seeds.rb +23 -0
  23. data/lib/generators/refinery/calendar_generator.rb +29 -0
  24. data/lib/refinery/calendar.rb +28 -0
  25. data/lib/refinery/calendar/configuration.rb +7 -0
  26. data/lib/refinery/calendar/engine.rb +26 -0
  27. data/lib/refinery/calendar/version.rb +17 -0
  28. data/lib/refinery/engine/multi_parameter_assignment.rb +6 -0
  29. data/lib/refinerycms-calendar.rb +1 -24
  30. data/lib/tasks/{events.rake → refinery/calendar.rake} +6 -6
  31. data/readme.md +8 -40
  32. metadata +56 -96
  33. data/app/controllers/admin/event_categories_controller.rb +0 -9
  34. data/app/controllers/admin/events_controller.rb +0 -26
  35. data/app/controllers/event_categories_controller.rb +0 -15
  36. data/app/controllers/events_controller.rb +0 -65
  37. data/app/helpers/event_categories_helper.rb +0 -3
  38. data/app/helpers/events_helper.rb +0 -44
  39. data/app/models/event.rb +0 -86
  40. data/app/models/event_categorization.rb +0 -4
  41. data/app/models/event_category.rb +0 -10
  42. data/app/views/admin/event_categories/_event_categories.html.erb +0 -1
  43. data/app/views/admin/event_categories/_event_category.html.erb +0 -18
  44. data/app/views/admin/event_categories/_form.html.erb +0 -26
  45. data/app/views/admin/event_categories/_sortable_list.html.erb +0 -3
  46. data/app/views/admin/event_categories/edit.html.erb +0 -1
  47. data/app/views/admin/event_categories/index.html.erb +0 -40
  48. data/app/views/admin/event_categories/new.html.erb +0 -1
  49. data/app/views/admin/events/_event.html.erb +0 -18
  50. data/app/views/admin/events/_events.html.erb +0 -1
  51. data/app/views/admin/events/_form.html.erb +0 -126
  52. data/app/views/admin/events/_sortable_list.html.erb +0 -20
  53. data/app/views/admin/events/edit.html.erb +0 -1
  54. data/app/views/admin/events/index.html.erb +0 -41
  55. data/app/views/admin/events/new.html.erb +0 -1
  56. data/app/views/event_categories/show.html.erb +0 -15
  57. data/app/views/events/_event.html.erb +0 -111
  58. data/app/views/events/_sidebar.html.erb +0 -38
  59. data/app/views/events/archive.html.erb +0 -17
  60. data/app/views/events/index.html.erb +0 -17
  61. data/app/views/events/index.rss.builder +0 -24
  62. data/app/views/events/show.html.erb +0 -15
  63. data/app/views/events/show.ics.erb +0 -16
  64. data/changelog.md +0 -35
  65. data/config/locales/lolcat.yml +0 -24
  66. data/db/migrate/01_create_events.rb +0 -33
  67. data/db/migrate/02_create_event_categories.rb +0 -13
  68. data/db/migrate/03_create_event_categorizations.rb +0 -17
  69. data/db/migrate/04_add_cached_slugs.rb +0 -11
  70. data/db/seeds/events.rb +0 -17
  71. data/features/manage_events.feature +0 -54
  72. data/features/step_definitions/event_steps.rb +0 -14
  73. data/features/support/factories/event_categories.rb +0 -3
  74. data/features/support/factories/events.rb +0 -6
  75. data/features/support/paths.rb +0 -17
  76. data/lib/generators/refinerycms_calendar_generator.rb +0 -6
  77. data/public/stylesheets/refinerycms-events.css +0 -73
  78. data/refinerycms-calendar-1.0.4.gem +0 -0
  79. data/refinerycms-calendar.gemspec +0 -17
  80. data/spec/controllers/events_controller_spec.rb +0 -14
  81. data/spec/helpers/events_helper_spec.rb +0 -16
  82. data/spec/models/event_category_spec.rb +0 -29
  83. data/spec/models/event_spec.rb +0 -77
@@ -0,0 +1,43 @@
1
+ module Refinery
2
+ module Calendar
3
+ module Admin
4
+ class EventsController < ::Refinery::AdminController
5
+ before_filter :init_calendar
6
+
7
+ def index
8
+ @events = @calendar.entries
9
+ end
10
+
11
+ def new
12
+ @event = @calendar.new_event
13
+ end
14
+
15
+ def create
16
+ @event = @calendar.new_event(params[:event])
17
+ if @event.publish
18
+ redirect_to refinery.calendar_admin_events_path
19
+ else
20
+ render :new
21
+ end
22
+ end
23
+
24
+ def self.searchable?
25
+ false
26
+ end
27
+
28
+ def self.pageable?
29
+ false
30
+ end
31
+
32
+ def self.sortable?
33
+ false
34
+ end
35
+
36
+ private
37
+ def init_calendar
38
+ @calendar = REFINERY_CALENDAR
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ module Refinery
2
+ module Calendar
3
+ class EventsController < ::ApplicationController
4
+
5
+ before_filter :find_all_events
6
+ before_filter :find_page
7
+
8
+ def index
9
+ # you can use meta fields from your model instead (e.g. browser_title)
10
+ # by swapping @page for @event in the line below:
11
+ present(@page)
12
+ end
13
+
14
+ def show
15
+ @event = Event.find(params[:id])
16
+
17
+ # you can use meta fields from your model instead (e.g. browser_title)
18
+ # by swapping @page for @event in the line below:
19
+ present(@page)
20
+ end
21
+
22
+ protected
23
+
24
+ def find_all_events
25
+ @events = Event.order('position ASC')
26
+ end
27
+
28
+ def find_page
29
+ @page = ::Refinery::Page.where(:link_url => "/events").first
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ module Refinery
2
+ module Calendar
3
+ class CoreCalendar
4
+ attr_accessor :entries
5
+ attr_writer :event_source
6
+
7
+ def initialize
8
+ @entries = []
9
+ end
10
+
11
+ def title
12
+ Refinery::Calendar.title
13
+ end
14
+
15
+ def new_event(*args)
16
+ event_source.call(*args).tap do |e|
17
+ e.calendar = self
18
+ end
19
+ end
20
+
21
+ def add_entry(entry)
22
+ @entries << entry
23
+ end
24
+
25
+ def entries
26
+ @entries.sort_by { |e| e.starts }
27
+ end
28
+
29
+ private
30
+
31
+ def event_source
32
+ @event_source ||= Event.public_method(:new)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,51 @@
1
+ module Refinery
2
+ module Calendar
3
+ class Event
4
+ extend ActiveModel::Naming
5
+ include ActiveModel::Conversion
6
+ include ActiveModel::Validations
7
+
8
+ attr_accessor :title, :starts, :ends, :body, :calendar
9
+
10
+ validates :title, :presence => true
11
+
12
+ def initialize(attrs={})
13
+ setup_parameters(attrs).each do |k,v| send("#{k}=",v) end
14
+ end
15
+
16
+ def publish
17
+ return false unless valid?
18
+ calendar.add_entry(self)
19
+ end
20
+
21
+ def persisted?
22
+ false
23
+ end
24
+
25
+ def setup_parameters(attrs={})
26
+ i = 0
27
+ datetime = ''
28
+ new_params = {}
29
+ attrs.each do |key, value|
30
+ if (k = key.to_s.match(/^(starts|ends)\(/) { |m| m[1] })
31
+ sep = '-'
32
+ sep = 'T' if i == 2
33
+ sep = ':' if i > 2
34
+ datetime += "#{value}#{sep}"
35
+ i += 1
36
+ else
37
+ new_params[key] = value
38
+ end
39
+
40
+ if datetime.split(':').length == 2
41
+ datetime += Time.new.zone
42
+ new_params[k] = DateTime.parse(datetime.gsub(/:$/,''))
43
+ datetime = ''
44
+ i = 0
45
+ end
46
+ end
47
+ return new_params
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,25 @@
1
+ <ul>
2
+ <% if ::Refinery::Calendar::Admin::EventsController.searchable? %>
3
+ <li>
4
+ <%= render '/refinery/admin/search', :url => refinery.calendar_admin_events_path %>
5
+ </li>
6
+ <% end %>
7
+ <li>
8
+ <%= link_to t('.create_new'), refinery.new_calendar_admin_event_path,
9
+ :class => "add_icon" %>
10
+ </li>
11
+ <% if !searching? && ::Refinery::Calendar::Admin::EventsController.sortable? && ::Refinery::Calendar::Event.any? %>
12
+ <li>
13
+ <%= link_to t('.reorder', :what => "Events"),
14
+ refinery.calendar_admin_events_path,
15
+ :id => "reorder_action",
16
+ :class => "reorder_icon" %>
17
+
18
+ <%= link_to t('.reorder_done', :what => "Events"),
19
+ refinery.calendar_admin_events_path,
20
+ :id => "reorder_action_done",
21
+ :style => "display: none;",
22
+ :class => "reorder_icon" %>
23
+ </li>
24
+ <% end %>
25
+ </ul>
@@ -0,0 +1,10 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(event) -%>">
2
+ <span class='title'>
3
+ <%= event.title %>
4
+ </span>
5
+ <span class='preview'>
6
+ <%= event.starts.strftime('%b %e, %Y %I:%M%p') %> to <%= event.ends.strftime('%b %e, %Y %I:%M%p') %>
7
+ </span>
8
+ <span class='actions'>
9
+ </span>
10
+ </li>
@@ -0,0 +1,2 @@
1
+ <%= will_paginate @events if Refinery::Calendar::Admin::EventsController.pageable? %>
2
+ <%= render 'sortable_list' %>
@@ -0,0 +1,31 @@
1
+ <%= form_for [refinery, :calendar_admin, @event] do |f| -%>
2
+ <%= render '/refinery/admin/error_messages',
3
+ :object => @event,
4
+ :include_object_name => true %>
5
+
6
+
7
+ <div class='field'>
8
+ <%= f.label :title -%>
9
+ <%= f.text_field :title, :class => 'larger widest' -%>
10
+ </div>
11
+
12
+ <div class='field'>
13
+ <%= f.label :body -%>
14
+ <%= f.text_area :body, :class => 'wymeditor widest' -%>
15
+ </div>
16
+
17
+ <div class='field'>
18
+ <%= f.label :starts %>
19
+ <%= f.datetime_select :starts %>
20
+ </div>
21
+
22
+ <div class='field'>
23
+ <%= f.label :ends %>
24
+ <%= f.datetime_select :ends %>
25
+ </div>
26
+
27
+ <%= render '/refinery/admin/form_actions', :f => f,
28
+ :continue_editing => false,
29
+ :delete_title => t('delete', :scope => 'refinery.events.admin.events.event'),
30
+ :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @event.title) %>
31
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ <% if searching? %>
2
+ <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
3
+ <% end %>
4
+ <div class='pagination_container'>
5
+ <% if @events.any? %>
6
+ <%= render 'events' %>
7
+ <% else %>
8
+ <p>
9
+ <% unless searching? %>
10
+ <strong>
11
+ <%= t('.no_items_yet') %>
12
+ </strong>
13
+ <% else %>
14
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
15
+ <% end %>
16
+ </p>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,5 @@
1
+ <ul id='sortable_list'>
2
+ <%= render :partial => 'event', :collection => @events %>
3
+ </ul>
4
+ <%= render '/refinery/admin/sortable_list',
5
+ :continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,8 @@
1
+ <section id='records'>
2
+ <h2><%= @calendar.title %></h2>
3
+ <%= render 'records' %>
4
+ </section>
5
+ <aside id='actions'>
6
+ <%= render 'actions' %>
7
+ </aside>
8
+ <%= render '/refinery/admin/make_sortable', :tree => false if !searching? and ::Refinery::Calendar::Admin::EventsController.sortable? and ::Refinery::Calendar::Event.count > 1 %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,11 @@
1
+ <% content_for :body_content_left do %>
2
+ <ul id="events">
3
+ <% @events.each do |event| %>
4
+ <li>
5
+ <%= link_to event.title, refinery.calendar_event_path(event) %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
9
+ <% end %>
10
+
11
+ <%= render '/refinery/content_page' %>
@@ -0,0 +1,27 @@
1
+ <% content_for :body_content_title do %>
2
+ <%= @event.title %>
3
+ <% end %>
4
+
5
+ <% content_for :body_content_left do %>
6
+ <section>
7
+ <h1>Title</h1>
8
+ <p>
9
+ <%=raw @event.title %>
10
+ </p>
11
+ </section>
12
+ <% end %>
13
+
14
+ <% content_for :body_content_right do %>
15
+ <aside>
16
+ <h2><%= t('.other') %></h2>
17
+ <ul id="events">
18
+ <% @events.each do |event| %>
19
+ <li>
20
+ <%= link_to event.title, refinery.calendar_event_path(event) %>
21
+ </li>
22
+ <% end %>
23
+ </ul>
24
+ </aside>
25
+ <% end %>
26
+
27
+ <%= render '/refinery/content_page' %>
@@ -1,45 +1,27 @@
1
1
  en:
2
- shared:
3
- admin:
4
- image_picker:
5
- image: image
6
- plugins:
2
+ refinery:
3
+ plugins:
4
+ calendar:
5
+ title: Calendar
7
6
  calendar:
8
- title: Events
9
- admin:
10
- events:
11
- index:
12
- title: Events
13
- create_new: Add New Event
14
- reorder: Reorder Events
15
- reorder_done: Done Reordering Events
16
- sorry_no_results: Sorry! There are no results found.
17
- no_items_yet: There are no Events yet. Click "Add New Event" to add your first event.
18
- manage_categories: Manage Categories
19
- event:
20
- view_live_html: View this event live <br/><em>(opens in a new window)</em>
21
- edit: Edit this event
22
- delete: Remove this event forever
23
- sortable_list:
24
- current_events: Current Events
25
- upcoming_events: Upcoming Events
26
- archived_events: Archived Events
27
- event_categories:
28
- index:
29
- title: Event Categories
30
- create_new: Add New Event Category
31
- reorder: Reorder Event Categories
32
- reorder_done: Done Reordering Event Categories
33
- sorry_no_results: Sorry! There are no results found.
34
- no_items_yet: There are no Event Categories yet. Click "Add New Event Category" to add your first event category.
35
- manage_events: Manage Events
36
- event_category:
37
- view_live_html: View this event category live <br/><em>(opens in a new window)</em>
38
- edit: Edit this event category
39
- delete: Remove this event category forever
40
- events:
41
- index:
42
- archives: Archives
43
- show:
44
- sidebar:
45
- other: Other Events
7
+ admin:
8
+ events:
9
+ actions:
10
+ create_new: Add New Event
11
+ reorder: Reorder Events
12
+ reorder_done: Done Reordering Events
13
+ records:
14
+ title: Events
15
+ sorry_no_results: Sorry! There are no results found.
16
+ no_items_yet: There are no Events yet. Click "Add New Event" to add your first event.
17
+ event:
18
+ view_live_html: View this event live <br/><em>(opens in a new window)</em>
19
+ edit: Edit this event
20
+ delete: Remove this event forever
21
+ events:
22
+ show:
23
+ other: Other Events
24
+ activerecord:
25
+ attributes:
26
+ 'refinery/calendar/event':
27
+ title: Title
@@ -0,0 +1,28 @@
1
+ es:
2
+ refinery:
3
+ plugins:
4
+ events:
5
+ title: Events
6
+ # article: masculino/femenino
7
+ calendar:
8
+ admin:
9
+ events:
10
+ actions:
11
+ create_new: Crear nuevo event
12
+ reorder: Reordenar events
13
+ reorder_done: Reordenación de events completada
14
+ records:
15
+ title: Events
16
+ sorry_no_results: Lo siento, no hay resultados
17
+ no_items_yet: No hay events todavía. Pulsa en "Crear nuevo Event" para crear tu primer event.
18
+ event:
19
+ view_live_html: Ver este event como abierto al público <br/><em>(abre en ventana nueva)</em>
20
+ edit: Editar este event
21
+ delete: Borrar este event para siempre
22
+ events:
23
+ show:
24
+ other: Otros events
25
+ activerecord:
26
+ attributes:
27
+ 'refinery/calendar/event':
28
+ title: Title
@@ -1,45 +1,27 @@
1
1
  fr:
2
- shared:
3
- admin:
4
- image_picker:
5
- image: image
6
- plugins:
2
+ refinery:
3
+ plugins:
4
+ events:
5
+ title: Events
7
6
  calendar:
8
- title: Événements
9
- admin:
10
- events:
11
- index:
12
- title: Événements
13
- create_new: Ajouter un nouvel événement
14
- reorder: Reordrer les événements
15
- reorder_done: Finir de réordrer les événements
16
- sorry_no_results: Désolé! Aucun résultat n'a été trouvé
17
- no_items_yet: "Il n'y a pas encore d'événement. Cliquez sur &quot;Ajouter un événement&quot; pour en créer un."
18
- manage_categories: Gérer les catégories
19
- event:
20
- view_live_html: Voir cet événement <br/><em>(s'ouvre dans une nouvelle fenêtre)</em>
21
- edit: Editer cet événement
22
- delete: Effacer complètement cet événement
23
- sortable_list:
24
- current_events: Événements en cours
25
- upcoming_events: Événements à venir
26
- archived_events: Événements archivés
27
- event_categories:
28
- index:
29
- title: Catégories d'événements
30
- create_new: Ajouter une nouvelle catégorie d'événements
31
- reorder: Réordrer les catégories d'événements
32
- reorder_done: Finir de réordrer les catégories d'événements
33
- sorry_no_results: Désolé! Aucun résultat n'a été trouvé
34
- no_items_yet: "Il n'y a pas encore de catégories d'événements pour le moment. Cliquez sur &quot;Ajouter une catégorie d'événements&quot; pour en créer une."
35
- manage_events: Gérer les événements
36
- event_category:
37
- view_live_html: Voir cette catégorie <br/><em>(s'ouvre dans une nouvelle fenêtre)</em>
38
- edit: Editer cette catégorie d'événements
39
- delete: Effacer complètement cette catégorie
40
- events:
41
- index:
42
- archives: Archives
43
- show:
44
- sidebar:
45
- other: Autres événements
7
+ admin:
8
+ events:
9
+ actions:
10
+ create_new: Créer un(e) nouve(au/l/lle) Event
11
+ reorder: Réordonner les Events
12
+ reorder_done: Fin de réordonnancement des Events
13
+ records:
14
+ title: Events
15
+ sorry_no_results: "Désolé ! Aucun résultat."
16
+ no_items_yet: 'Il n''y a actuellement aucun(e) Event. Cliquer sur "Créer un(e) nouve(au/l/lle) Event" pour créer votre premi(er/ère) event.'
17
+ event:
18
+ view_live_html: Voir ce(t/tte) event <br/><em>(Ouvre une nouvelle fenêtre)</em>
19
+ edit: Modifier ce(t/tte) event
20
+ delete: Supprimer définitivement ce(t/tte) event
21
+ events:
22
+ show:
23
+ other: Autres Events
24
+ activerecord:
25
+ attributes:
26
+ 'refinery/calendar/event':
27
+ title: Title