simple_calendar 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -9
- data/lib/simple_calendar/version.rb +1 -1
- data/lib/simple_calendar/view_helpers.rb +3 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Installation
|
|
13
13
|
|
14
14
|
Just add this into your Gemfile followed by a bundle install:
|
15
15
|
|
16
|
-
gem "simple_calendar", "~> 0.1.
|
16
|
+
gem "simple_calendar", "~> 0.1.5"
|
17
17
|
|
18
18
|
Usage
|
19
19
|
-----
|
@@ -69,9 +69,11 @@ Here's an example that uses SimpleCalendar to simply render a link to
|
|
69
69
|
each event on its own line inside the table. You would simply query for
|
70
70
|
the `@events` as discussed above in the querying section.
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
```erb
|
73
|
+
<%= calendar @events do |event| %>
|
74
|
+
<div><%= link_to event.title, event %></div>
|
75
|
+
<% end %>
|
76
|
+
```
|
75
77
|
|
76
78
|
When the calendar is rendering, it yields to the block to allow you to
|
77
79
|
render whatever you like for the item. In this example, I use the title
|
@@ -79,9 +81,11 @@ attribute on the event with a link to the event.
|
|
79
81
|
|
80
82
|
You may even pass options to calendar renderer to customize it's behavior
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
```erb
|
85
|
+
<%= calendar @events, {:prev_text=>"prev", :next_text=>"next"} do |event| %>
|
86
|
+
<div><%= link_to event.title, event %></div>
|
87
|
+
<% end %>
|
88
|
+
```
|
85
89
|
|
86
90
|
This time calendar will use prev and next as labels for previous and next month
|
87
91
|
links (which are normally set to &laquo; («) and &raquo; (»)
|
@@ -99,7 +103,7 @@ If you wish to have Monday as the first day of the week, you'll need to
|
|
99
103
|
change a couple things. First, when rendering the calendar, use the
|
100
104
|
`:start_day => :monday` option like so:
|
101
105
|
|
102
|
-
```
|
106
|
+
```erb
|
103
107
|
<%= calendar @events, :start_day => :monday do |event| %>
|
104
108
|
<%= link_to event.title, event %>
|
105
109
|
<% end %>
|
@@ -109,6 +113,16 @@ And the second step is to make sure you've set your `I18n.locale` to the
|
|
109
113
|
correct one. There is a lot of information here regarding use of locales in Rails:
|
110
114
|
https://github.com/svenfuchs/rails-i18n
|
111
115
|
|
116
|
+
The `empty_date` option accepts a block that will be called when a day
|
117
|
+
in the calendar is empty. It will be called with the date object that
|
118
|
+
represents the day that has no events.
|
119
|
+
|
120
|
+
```erb
|
121
|
+
<%= calendar @events, empty_date: lambda{ |date| "hello from #{date}" } do |event| %>
|
122
|
+
<%= event.name %>
|
123
|
+
<% end %>
|
124
|
+
```
|
125
|
+
|
112
126
|
CSS
|
113
127
|
---
|
114
128
|
|
@@ -116,7 +130,9 @@ You will probably want to customize the height of the calendar so that
|
|
116
130
|
all the rows are the same heights and widths. You can do this by adding
|
117
131
|
the following line to your css:
|
118
132
|
|
119
|
-
|
133
|
+
```css
|
134
|
+
.calendar td { height: 100px; width: 14.28%; }
|
135
|
+
```
|
120
136
|
|
121
137
|
By default simple_calendar will set the calendar to use .bordered-table
|
122
138
|
and .calendar classes.
|
@@ -59,7 +59,9 @@ module SimpleCalendar
|
|
59
59
|
today = Date.today
|
60
60
|
content_tag(:table, :class => "table table-bordered table-striped calendar") do
|
61
61
|
tags << month_header(selected_month, options)
|
62
|
-
|
62
|
+
day_names = I18n.t("date.abbr_day_names")
|
63
|
+
day_names.rotate(1) if options[:start_date] == :monday
|
64
|
+
tags << content_tag(:thead, content_tag(:tr, day_names.collect { |name| content_tag :th, name, :class => (selected_month.month == Date.today.month && Date.today.strftime("%a") == name ? "current-day" : nil)}.join.html_safe))
|
63
65
|
tags << content_tag(:tbody, :'data-month'=>selected_month.month, :'data-year'=>selected_month.year) do
|
64
66
|
|
65
67
|
month.collect do |week|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -57,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
57
|
version: '0'
|
58
58
|
segments:
|
59
59
|
- 0
|
60
|
-
hash:
|
60
|
+
hash: 676043402436518100
|
61
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
segments:
|
68
68
|
- 0
|
69
|
-
hash:
|
69
|
+
hash: 676043402436518100
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project: simple_calendar
|
72
72
|
rubygems_version: 1.8.24
|