Class Event
In: app/models/event.rb
Parent: Article

Methods

Included Modules

ActionView::Helpers::TagHelper ActionView::Helpers::UrlHelper ActionController::UrlWriter DatesHelper

Public Class methods

[Source]

    # File app/models/event.rb, line 31
31:   def self.by_month(year = nil, month = nil)
32:     self.find(:all, :conditions => { :start_date => date_range(year, month) })
33:   end

[Source]

    # File app/models/event.rb, line 35
35:   def self.date_range(year, month)
36:     if year.nil? || month.nil?
37:       today = Date.today
38:       year = today.year
39:       month = today.month
40:     else
41:       year = year.to_i
42:       month = month.to_i
43:     end
44: 
45:     first_day = Date.new(year, month, 1)
46:     last_day = Date.new(year, month, 1) + 1.month - 1.day
47: 
48:     first_day..last_day
49:   end

[Source]

    # File app/models/event.rb, line 19
19:   def self.description
20:     _('A calendar event')
21:   end

[Source]

    # File app/models/event.rb, line 23
23:   def self.short_description
24:     _('Event')
25:   end

Public Instance methods

[Source]

    # File app/models/event.rb, line 51
51:   def date_range
52:     start_date..(end_date||start_date)
53:   end

[Source]

    # File app/models/event.rb, line 27
27:   def icon_name
28:     'event'
29:   end

[Source]

     # File app/models/event.rb, line 99
 99:   def link
100:     maybe_add_http(self.body[:link])
101:   end

[Source]

    # File app/models/event.rb, line 95
95:   def link=(value)
96:     self.body[:link] = maybe_add_http(value)
97:   end

[Source]

    # File app/models/event.rb, line 61
61:   def to_html
62: 
63:     result = ''
64:     html = Builder::XmlMarkup.new(:target => result)
65: 
66:     html.div(:class => 'event-info' ) {
67: 
68:       html.ul(:class => 'event-data' ) {
69:         html.li(:class => 'event-dates' ) {
70:           html.span _('When:')
71:           html.text! show_period(start_date, end_date)
72:         }
73:         html.li {
74:           html.span _('URL:')
75:           html.a(self.link || "", 'href' => self.link || "")
76:         }
77:         html.li {
78:           html.span _('Address:')
79:           html.text! self.address || ""
80:         }
81:       }
82: 
83:       if self.description
84:         html.div('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', :class => 'event-description') 
85:       end
86:     }
87: 
88:     if self.description
89:       result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', self.description)
90:     end
91: 
92:     result
93:   end

Protected Instance methods

[Source]

     # File app/models/event.rb, line 105
105:   def maybe_add_http(value)
106:     return unless value
107:     if value =~ /https?:\/\//
108:       value
109:     else
110:       'http://' + value
111:     end
112:   end

[Validate]