calendar_view 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,5 +1,5 @@
1
1
  ## Introduction
2
- _Calendar view_ is a rails plugin which extends application of calendar views.
2
+ _Calendar view_ is a rails plugin which extends application of calendar views. Got to [this page](http://todryk.pl/calendar-view) to see samples.
3
3
 
4
4
  ## Requirements
5
5
 
@@ -10,7 +10,7 @@ Plugin was built as Rails 3 Engine plugin.
10
10
  Add to Gemfile of application:
11
11
 
12
12
  ```ruby
13
- gem "calendar_view", "~> 0.0.3"
13
+ gem "calendar_view", "~> 0.0.5"
14
14
  ```
15
15
 
16
16
  than
@@ -24,6 +24,7 @@ to install gem.
24
24
  In views of Your application add:
25
25
 
26
26
  ```ruby
27
+ <%= calendar_window(:back=>10,:forward=>20) %>
27
28
  <% 1.upto(6) do |i| %>
28
29
  <%= calendar_square(:month=>i,:highlight_between => Date.new(2011,9,19)..Date.new(2011,9,25)) %>
29
30
  <% end %>
@@ -17,6 +17,68 @@ module CalendarViewHelper
17
17
  html
18
18
  end
19
19
 
20
+ def calendar_window(options={})
21
+ html = ""
22
+ now = DateTime.now
23
+ year = now.year
24
+ month = now.month
25
+ back = options[:back] ? options[:back] : 10
26
+ forward = options[:forward] ? options[:forward] : 20
27
+ highlight = options[:highlight_date] ? options[:highlight_date] : nil
28
+ if options[:highlight_day] && options[:highlight_month] && options[:highlight_year]
29
+ highlight = Date.new(options[:highlight_year],options[:highlight_month],options[:highlight_day])
30
+ end
31
+ highlight = options[:highlight_between] if options[:highlight_between]
32
+ fday = Date.new(now.year,now.month,now.day)
33
+ nowday = Date.new(now.year,now.month,now.day)
34
+ fday -= back
35
+ wdays = []
36
+ days = []
37
+ weeks = []
38
+ months = []
39
+ colspan = 1
40
+ mcolspan = 1
41
+ html = ""
42
+ html << "<div class=\"calendar window\">"
43
+ html << "<h3>#{options[:title]}</h3>" if options[:title]
44
+ html << "<div class=\"content\">"
45
+ html << "<table>"
46
+
47
+ 1.upto(back + forward) do
48
+ if fday == Date.new(fday.year,fday.month,-1)
49
+ months << "<td class=\"monthnum\" colspan=\""+mcolspan.to_s+"\">"+fday.month.to_s+"</td>"
50
+ mcolspan=1
51
+ else
52
+ mcolspan+=1
53
+ end
54
+ if fday.wday == 0
55
+ weeks << "<td class=\"weeknum\" colspan=\""+colspan.to_s+"\">"+fday.cweek.to_s+"</td>"
56
+ colspan=1
57
+ else
58
+ colspan+=1
59
+ end
60
+ wdays << "<td class=\"wday\">#{t(:abbr_day_names,:scope=>:date)[fday.wday == 7 ? 0 : fday.wday]}</td>"
61
+ days << color_follow_day(nowday,fday,highlight)
62
+ fday = fday + 1
63
+ end
64
+ months << "<td class=\"monthnum\" colspan=\""+mcolspan.to_s+"\">"+fday.month.to_s+"</td>"
65
+ weeks << "<td class=\"weeknum\" colspan=\""+colspan.to_s+"\">"+fday.cweek.to_s+"</td>"
66
+ html << "<tr>"
67
+ html << months.join
68
+ html << "</tr>"
69
+ html << "<tr>"
70
+ html << weeks.join
71
+ html << "</tr>"
72
+ html << "<tr>"
73
+ html << wdays.join
74
+ html << "</tr>"
75
+ html << "<tr>"
76
+ html << days.join
77
+ html << "</tr>"
78
+ html << "</table></div></div>"
79
+ html.html_safe
80
+ end
81
+
20
82
  def calendar_square(options={})
21
83
 
22
84
  now = DateTime.now
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Wojciech Todryk"]
10
10
  s.email = ["wojciech@todryk.pl"]
11
- s.homepage = "https://github.com/musashimm/calendar_view"
11
+ s.homepage = "http://todryk.pl/calendar-view"
12
12
  s.summary = %q{Calendar view}
13
13
  s.description = %q{Extends Rails application of calendar view}
14
14
 
@@ -1,3 +1,3 @@
1
1
  module CalendarView
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calendar_view
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wojciech Todryk
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-29 00:00:00 Z
18
+ date: 2011-10-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -52,7 +52,7 @@ files:
52
52
  - lib/calendar_view.rb
53
53
  - lib/calendar_view/version.rb
54
54
  - public/stylesheets/calendar_olive.css
55
- homepage: https://github.com/musashimm/calendar_view
55
+ homepage: http://todryk.pl/calendar-view
56
56
  licenses: []
57
57
 
58
58
  post_install_message: