refinerycms-events 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  class Admin::EventsController < Admin::BaseController
2
- helper :calendars
3
2
  crudify :event, :title_attribute => :title, :sortable => false, :order => 'start_at DESC'
4
3
 
5
4
  end
@@ -1,7 +1,6 @@
1
1
  class EventsController < ApplicationController
2
2
 
3
3
  before_filter :find_page
4
- helper :calendars
5
4
 
6
5
  def index
7
6
  @date = Date.parse(params[:date]) rescue Date.today
@@ -1,4 +1,4 @@
1
- module CalendarsHelper
1
+ module EventsHelper
2
2
  def datetime(d)
3
3
  I18n.localize(d, :format => "%B %d, %Y %l:%M %p")
4
4
  end
@@ -49,11 +49,15 @@ module CalendarsHelper
49
49
  end
50
50
  end
51
51
 
52
- def event_list
52
+ def event_list(options = Hash.new)
53
53
  grouped_events = Event.
54
- all(:limit => 10, :order => 'start_at ASC',
55
- :conditions => [ 'start_at >= ?', Time.now ]).
54
+ all(:limit => options.fetch(:limit) { 10 }, :order => 'start_at ASC',
55
+ :conditions => [ 'start_at >= ? || end_at >= ?', Time.now, Time.now ]).
56
56
  group_by { |e| e.start_at.to_date }
57
- render :partial => '/events/event_list', :object => grouped_events
57
+
58
+ render(:partial => '/events/event_list',
59
+ :object => grouped_events,
60
+ :locals => { :heading => options[:heading],
61
+ :see_more_link => options.fetch(:see_more_link) { 'View the calendar' } } )
58
62
  end
59
63
  end
@@ -1,20 +1,23 @@
1
- <dl class="event-list">
2
- <% event_list.each do |d, events| -%>
3
- <dt><%= date(d) %></dt>
4
- <dd>
5
- <ul>
6
- <% events.each do |e| -%>
7
- <li class="event">
8
- <%= link_to(event_title(e), event_path(e)) %>
9
- <% unless e.location.blank? -%>
10
- @ <%= h(e.location) %>
11
- <% end -%>
12
- </li>
1
+ <% unless event_list.blank? -%>
2
+ <%= content_tag('h1', heading) if heading %>
3
+ <dl class="event-list">
4
+ <% event_list.each do |d, events| -%>
5
+ <dt><%= date(d) %></dt>
6
+ <dd>
7
+ <ul>
8
+ <% events.each do |e| -%>
9
+ <li class="event">
10
+ <%= link_to(event_title(e), event_path(e)) %>
11
+ <% unless e.location.blank? -%>
12
+ @ <%= h(e.location) %>
13
+ <% end -%>
14
+ </li>
15
+ <% end -%>
16
+ </ul>
13
17
  <% end -%>
14
- </ul>
15
- <% end -%>
16
- </dd>
17
- <dt>
18
- <%= link_to 'View the calendar', events_path %>
19
- </dt>
20
- </dl>
18
+ </dd>
19
+ <dt>
20
+ <%= link_to(see_more_link, events_path) %>
21
+ </dt>
22
+ </dl>
23
+ <% end -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SemanticGap
@@ -48,7 +48,7 @@ files:
48
48
  - app/models/event.rb
49
49
  - app/controllers/events_controller.rb
50
50
  - app/controllers/admin/events_controller.rb
51
- - app/helpers/calendars_helper.rb
51
+ - app/helpers/events_helper.rb
52
52
  - app/views/events/index.html.erb
53
53
  - app/views/events/show.html.erb
54
54
  - app/views/events/_event_list.html.erb