social_stream-events 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/app/models/event.rb CHANGED
@@ -9,23 +9,12 @@ class Event < ActiveRecord::Base
9
9
 
10
10
  validate :room_belongs_to_receiver
11
11
 
12
- class << self
13
- def ocurrences(start_date, end_date)
14
- between(start_date, end_date).
15
- map { |e|
16
- e.ocurrences(start_date, end_date)
17
- }.
18
- flatten.
19
- uniq
20
- end
21
- end
22
-
23
12
  def to_json(options = {})
24
13
  if recurrence
25
14
  st = options[:start].try(:to_date)
26
15
  en = (options[:end] || end_at.end_of_month + 7.days).to_date
27
16
 
28
- ocurrences(st, en).map do |d|
17
+ recurrence.events(:starts => st, :until => en).map do |d|
29
18
 
30
19
  start_diff = d - start_at.to_date
31
20
  end_diff = d - end_at.to_date
@@ -3,20 +3,21 @@
3
3
  <div class="block">
4
4
  <div class="content">
5
5
 
6
+ <% bow = (Time.now - 1.days).beginning_of_week %>
7
+
6
8
  <%= render :partial => 'events/calendar_month',
7
9
  :locals => {
8
10
  :position => :top,
9
- :date => Date.today.beginning_of_week
11
+ :date => bow.to_date
10
12
  } %>
11
13
 
12
14
  <table id="sidebar_calendar">
13
- <% bow = Time.now.beginning_of_week %>
14
15
 
15
16
  <% 28.times do |i| %>
16
17
  <% day = bow + i.days %>
17
18
 
18
19
  <%= raw cycle(*(Array.wrap("<tr>") + 6.times.map{""}) + Array.wrap(:name => "tr_start")) %>
19
- <td class="<%= event_class(day.to_date) %>">
20
+ <td id="sidebar_day_<%= day.day %>_<%= day.month %>_<%= day.year %>" class="sidebar_day">
20
21
  <%= link_to day.day, polymorphic_path([profile_or_current_subject, Event.new], :date => day.to_i, :view => "agendaDay") %>
21
22
  </td>
22
23
 
@@ -24,10 +25,42 @@
24
25
  <% end %>
25
26
  </table>
26
27
 
28
+ <%= javascript_tag do %>
29
+ var now = new Date();
30
+ $('#sidebar_day_' + now.getDate() + '_' + (now.getMonth()+1) + '_' + now.getFullYear()).addClass('today');
31
+ var re = new RegExp('sidebar_day_(..?)_(..?)_(..?.?.?)');
32
+ $('.sidebar_day').each(function(index, domEl){
33
+ var m = re.exec(domEl.id);
34
+ if(m == null) return;
35
+ var d = new Date(m[3], (m[2]-1), m[1], 23, 59, 59);
36
+ if(d < now) $(domEl).addClass('past');
37
+ if(m[2] != (now.getMonth()+1)) $(domEl).addClass('next_month');
38
+ });
39
+ $.ajax({
40
+ dataType: 'json',
41
+ cache: false,
42
+ url: "<%= escape_javascript polymorphic_path([@current_subject, Event.new]) %>",
43
+ data: {
44
+ start: <%= bow.to_i %>,
45
+ end: <%= (bow + 28.days).to_i %>
46
+ },
47
+ success: function(events) {
48
+ $.map(events, function(event) {
49
+ var start = new Date(event.start); // This applies TZ
50
+ var end = new Date(event.end);
51
+ for(loopTime=start.getTime(); loopTime <= end.getTime(); loopTime+=86400000) {
52
+ var d = new Date(loopTime);
53
+ $('#sidebar_day_'+ d.getDate() + '_' + (d.getMonth()+1) + '_' + d.getFullYear()).addClass("busy");
54
+ }
55
+ })
56
+ }
57
+ });
58
+ <% end %>
59
+
27
60
  <%= render :partial => 'events/calendar_month',
28
61
  :locals => {
29
62
  :position => :bottom,
30
- :date => Date.today.beginning_of_week + 28
63
+ :date => (bow + 28.days).to_date
31
64
  } %>
32
65
 
33
66
  </div>
@@ -33,6 +33,7 @@
33
33
  center: 'title',
34
34
  right: 'month,agendaWeek,agendaDay'
35
35
  },
36
+ ignoreTimezone: false,
36
37
  firstDay: 1,
37
38
  eventColor: SocialStream.Events.current.eventColor,
38
39
  <% if can? :create, new_post(profile_subject) %>
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.5.0".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.12.0')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.13.0')
16
16
  s.add_runtime_dependency('rails-scheduler', '~> 0.0.5')
17
17
  s.add_runtime_dependency('coffee-rails', '> 3.1.0')
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-11 00:00:00.000000000Z
13
+ date: 2012-01-23 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
17
- requirement: &83181790 !ruby/object:Gem::Requirement
17
+ requirement: &72729050 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.12.0
22
+ version: 0.13.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *83181790
25
+ version_requirements: *72729050
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rails-scheduler
28
- requirement: &83181320 !ruby/object:Gem::Requirement
28
+ requirement: &72728510 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.0.5
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *83181320
36
+ version_requirements: *72728510
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-rails
39
- requirement: &83164280 !ruby/object:Gem::Requirement
39
+ requirement: &72727880 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>'
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 3.1.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *83164280
47
+ version_requirements: *72727880
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: sqlite3-ruby
50
- requirement: &83163630 !ruby/object:Gem::Requirement
50
+ requirement: &72726860 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *83163630
58
+ version_requirements: *72726860
59
59
  description: ! 'Social Stream is a Ruby on Rails engine providing your application
60
60
  with social networking features and activity streams.
61
61
 
@@ -78,7 +78,6 @@ files:
78
78
  - app/assets/stylesheets/social_stream-events.css
79
79
  - app/controllers/events_controller.rb
80
80
  - app/controllers/rooms_controller.rb
81
- - app/helpers/events_helper.rb
82
81
  - app/models/event.rb
83
82
  - app/models/room.rb
84
83
  - app/views/events/_calendar_month.erb
@@ -1,26 +0,0 @@
1
- module EventsHelper
2
- def event_class(day)
3
- begin_date = Time.now.beginning_of_week.to_date
4
- end_date = begin_date + 28
5
-
6
- busy_dates =
7
- profile_or_current_subject.
8
- events.
9
- ocurrences(begin_date, end_date)
10
-
11
- [].tap { |css|
12
- css <<
13
- if day < Date.today
14
- "past"
15
- elsif day == Date.today
16
- "today"
17
- elsif day.month != Date.today.month
18
- "next_month"
19
- end
20
-
21
-
22
- css << "busy" if busy_dates.include?(day)
23
-
24
- }.join(" ")
25
- end
26
- end