twitter-bootstrap-calendar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +42 -0
- data/Rakefile +34 -0
- data/app/helpers/bootstrap_calendar_helper.rb +64 -0
- data/lib/twitter-bootstrap-calendar.rb +9 -0
- data/lib/twitter/bootstrap/calendar/bootstrap.rb +2 -0
- data/lib/twitter/bootstrap/calendar/engine.rb +17 -0
- data/lib/twitter/bootstrap/calendar/version.rb +7 -0
- data/test/test_helper.rb +8 -0
- data/vendor/assets/stylesheets/twitter-bootstrap-calendar/index.css.scss +265 -0
- metadata +100 -0
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Twitter::Bootstrap::Calendar
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'twitter-bootstrap-calendar'
|
10
|
+
|
11
|
+
Add this line to your application.css:
|
12
|
+
|
13
|
+
*= require twitter-bootstrap-calendar
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install twitter-bootstrap-calendar
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To create a calendar in your view, just call the helper method and pass in a block, like so:
|
26
|
+
```haml
|
27
|
+
= bootstrap_calendar month do |date|
|
28
|
+
= link_to date.day, new_plan_event_path(:event => {:activity_at => date.beginning_of_day + 12.hours})
|
29
|
+
- if @events_by_date[date]
|
30
|
+
ul.event_summary
|
31
|
+
- @events_by_date[date].each do |event|
|
32
|
+
li style=event_style(event)
|
33
|
+
= link_to "#{event.title}: #{event.activity_at.to_s(:time_only)}", menu_plan_event_path(event), :remote => true, :style => event_link_style(event)
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
desc "Bundle the gem"
|
6
|
+
task :bundle do
|
7
|
+
sh('bundle install')
|
8
|
+
sh 'gem build *.gemspec'
|
9
|
+
sh 'gem install *.gem'
|
10
|
+
sh 'rm *.gem'
|
11
|
+
end
|
12
|
+
|
13
|
+
# desc "Build the static precompiled stylesheets from Less sources"
|
14
|
+
# task :build_static_stylesheets do
|
15
|
+
# require 'less'
|
16
|
+
|
17
|
+
# toolkit_path = File.join('vendor', 'toolkit')
|
18
|
+
|
19
|
+
# parser = Less::Parser.new :paths => [toolkit_path]
|
20
|
+
|
21
|
+
# target_directory = File.expand_path('vendor/assets/stylesheets/twitter-bootstrap-static')
|
22
|
+
|
23
|
+
# sh "rm -rf #{target_directory}"
|
24
|
+
# sh "mkdir -p #{target_directory}"
|
25
|
+
# Dir['vendor/static-source/*.less'].each do |source_file|
|
26
|
+
# puts "Compiling #{source_file}"
|
27
|
+
# target_file = File.join(target_directory, File.basename(source_file, '.less')+'.css.erb')
|
28
|
+
# tree = parser.parse(File.read(source_file))
|
29
|
+
# File.open(target_file, 'w') {|f| f.puts tree.to_css(:compress => true) }
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
|
33
|
+
task(:default).clear
|
34
|
+
task :default => :bundle
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module BootstrapCalendarHelper
|
2
|
+
def bootstrap_calendar(date = Date.today, &block)
|
3
|
+
BootstrapCalendar.new(self, date, block).calendar_div
|
4
|
+
end
|
5
|
+
|
6
|
+
BootstrapCalendar = Struct.new(:view, :date, :callback) do
|
7
|
+
HEADER = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
|
8
|
+
START_DAY = :sunday
|
9
|
+
|
10
|
+
delegate :content_tag, to: :view
|
11
|
+
|
12
|
+
def calendar_div
|
13
|
+
content_tag 'div', class: "calendar_grid" do
|
14
|
+
header + week_rows
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def header
|
19
|
+
content_tag 'div', class: 'month_header row-fluid' do
|
20
|
+
HEADER.map { |day| content_tag :div, class: 'span1' do
|
21
|
+
day
|
22
|
+
end }.join.html_safe
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def week_rows
|
27
|
+
weeks.map {|week|
|
28
|
+
content_tag :div, class: 'row-fluid week' do
|
29
|
+
week.map { |day| day_cell(day) }.join.html_safe
|
30
|
+
end
|
31
|
+
}.join.html_safe
|
32
|
+
end
|
33
|
+
|
34
|
+
def day_cell(day)
|
35
|
+
content_tag :div, view.capture(day, &callback), class: day_classes(day)
|
36
|
+
end
|
37
|
+
|
38
|
+
def day_classes(day)
|
39
|
+
classes = ['span1']
|
40
|
+
classes << "today" if day == Date.today
|
41
|
+
classes << "notmonth" if day.month != date.month
|
42
|
+
classes << "month" if day.month == date.month
|
43
|
+
classes.empty? ? nil : classes.join(" ")
|
44
|
+
end
|
45
|
+
|
46
|
+
def weeks
|
47
|
+
first = date.beginning_of_month.beginning_of_week(START_DAY)
|
48
|
+
last = date.end_of_month.end_of_week(START_DAY)
|
49
|
+
(first..last).to_a.in_groups_of(7)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def event_style(event)
|
54
|
+
"background-color: #{event.color};"
|
55
|
+
end
|
56
|
+
|
57
|
+
def event_link_style(event)
|
58
|
+
if %w(white silver yellow lime aqua teal fuchsia).include?(event.color)
|
59
|
+
"color: black;"
|
60
|
+
else
|
61
|
+
"color: white;"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../../app/helpers/bootstrap_calendar_helper.rb'
|
4
|
+
|
5
|
+
module Twitter
|
6
|
+
module Bootstrap
|
7
|
+
module Calendar
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
initializer 'twitter-bootstrap-calendar.setup_helpers' do |app|
|
10
|
+
app.config.to_prepare do
|
11
|
+
ActionController::Base.send :helper, BootstrapCalendarHelper
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
.calendar_grid {
|
2
|
+
border: 1px solid gray;
|
3
|
+
margin-bottom: 30px;
|
4
|
+
.month_header {
|
5
|
+
background-color: gray;
|
6
|
+
.span1 {
|
7
|
+
padding-top: 5px;
|
8
|
+
font-weight: bold;
|
9
|
+
text-align: center;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
.notmonth {
|
13
|
+
background-color: darken(#ededed, 5%);
|
14
|
+
}
|
15
|
+
.notmonth, .notmonth a { color: white; }
|
16
|
+
.month.today {
|
17
|
+
background-color: #D7F2FF;
|
18
|
+
}
|
19
|
+
.month {
|
20
|
+
a {
|
21
|
+
color: gray;
|
22
|
+
}
|
23
|
+
background-color: #ededed;
|
24
|
+
border: 1px solid whitesmoke;
|
25
|
+
}
|
26
|
+
.week .span1 {
|
27
|
+
padding: 2px;
|
28
|
+
// height: 100px;
|
29
|
+
ul.event_summary {
|
30
|
+
margin: 0;
|
31
|
+
li {
|
32
|
+
list-style: none;
|
33
|
+
padding: 2px;
|
34
|
+
-moz-border-radius:4px;
|
35
|
+
-webkit-border-radius:4px;
|
36
|
+
border-radius:4px;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
/*!
|
41
|
+
* Bootstrap v2.2.1
|
42
|
+
*
|
43
|
+
* Copyright 2012 Twitter, Inc
|
44
|
+
* Licensed under the Apache License v2.0
|
45
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
46
|
+
*
|
47
|
+
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
48
|
+
*/
|
49
|
+
.clearfix {
|
50
|
+
*zoom: 1;
|
51
|
+
}
|
52
|
+
.clearfix:before,
|
53
|
+
.clearfix:after {
|
54
|
+
display: table;
|
55
|
+
content: "";
|
56
|
+
line-height: 0;
|
57
|
+
}
|
58
|
+
.clearfix:after {
|
59
|
+
clear: both;
|
60
|
+
}
|
61
|
+
.hide-text {
|
62
|
+
font: 0/0 a;
|
63
|
+
color: transparent;
|
64
|
+
text-shadow: none;
|
65
|
+
background-color: transparent;
|
66
|
+
border: 0;
|
67
|
+
}
|
68
|
+
.input-block-level {
|
69
|
+
display: block;
|
70
|
+
width: 100%;
|
71
|
+
min-height: 30px;
|
72
|
+
-webkit-box-sizing: border-box;
|
73
|
+
-moz-box-sizing: border-box;
|
74
|
+
box-sizing: border-box;
|
75
|
+
}
|
76
|
+
.row {
|
77
|
+
margin-left: -1px;
|
78
|
+
*zoom: 1;
|
79
|
+
}
|
80
|
+
.row:before,
|
81
|
+
.row:after {
|
82
|
+
display: table;
|
83
|
+
content: "";
|
84
|
+
line-height: 0;
|
85
|
+
}
|
86
|
+
.row:after {
|
87
|
+
clear: both;
|
88
|
+
}
|
89
|
+
[class*="span"] {
|
90
|
+
float: left;
|
91
|
+
min-height: 1px;
|
92
|
+
margin-left: 1px;
|
93
|
+
}
|
94
|
+
.container,
|
95
|
+
.navbar-static-top .container,
|
96
|
+
.navbar-fixed-top .container,
|
97
|
+
.navbar-fixed-bottom .container {
|
98
|
+
width: 958px;
|
99
|
+
}
|
100
|
+
.span7 {
|
101
|
+
width: 958px;
|
102
|
+
}
|
103
|
+
.span6 {
|
104
|
+
width: 821px;
|
105
|
+
}
|
106
|
+
.span5 {
|
107
|
+
width: 684px;
|
108
|
+
}
|
109
|
+
.span4 {
|
110
|
+
width: 547px;
|
111
|
+
}
|
112
|
+
.span3 {
|
113
|
+
width: 410px;
|
114
|
+
}
|
115
|
+
.span2 {
|
116
|
+
width: 273px;
|
117
|
+
}
|
118
|
+
.span1 {
|
119
|
+
width: 136px;
|
120
|
+
}
|
121
|
+
.offset7 {
|
122
|
+
margin-left: 960px;
|
123
|
+
}
|
124
|
+
.offset6 {
|
125
|
+
margin-left: 823px;
|
126
|
+
}
|
127
|
+
.offset5 {
|
128
|
+
margin-left: 686px;
|
129
|
+
}
|
130
|
+
.offset4 {
|
131
|
+
margin-left: 549px;
|
132
|
+
}
|
133
|
+
.offset3 {
|
134
|
+
margin-left: 412px;
|
135
|
+
}
|
136
|
+
.offset2 {
|
137
|
+
margin-left: 275px;
|
138
|
+
}
|
139
|
+
.offset1 {
|
140
|
+
margin-left: 138px;
|
141
|
+
}
|
142
|
+
.row-fluid {
|
143
|
+
width: 100%;
|
144
|
+
*zoom: 1;
|
145
|
+
}
|
146
|
+
.row-fluid:before,
|
147
|
+
.row-fluid:after {
|
148
|
+
display: table;
|
149
|
+
content: "";
|
150
|
+
line-height: 0;
|
151
|
+
}
|
152
|
+
.row-fluid:after {
|
153
|
+
clear: both;
|
154
|
+
}
|
155
|
+
.row-fluid [class*="span"] {
|
156
|
+
display: block;
|
157
|
+
width: 100%;
|
158
|
+
min-height: 30px;
|
159
|
+
-webkit-box-sizing: border-box;
|
160
|
+
-moz-box-sizing: border-box;
|
161
|
+
box-sizing: border-box;
|
162
|
+
float: left;
|
163
|
+
margin-left: 0.10438413361169101%;
|
164
|
+
*margin-left: 0.052192066805845504%;
|
165
|
+
}
|
166
|
+
.row-fluid [class*="span"]:first-child {
|
167
|
+
margin-left: 0;
|
168
|
+
}
|
169
|
+
.row-fluid .controls-row [class*="span"] + [class*="span"] {
|
170
|
+
margin-left: 0.10438413361169101%;
|
171
|
+
}
|
172
|
+
.row-fluid .span7 {
|
173
|
+
width: 100%;
|
174
|
+
*width: 99.94780793319416%;
|
175
|
+
}
|
176
|
+
.row-fluid .span6 {
|
177
|
+
width: 85.69937369519833%;
|
178
|
+
*width: 85.64718162839249%;
|
179
|
+
}
|
180
|
+
.row-fluid .span5 {
|
181
|
+
width: 71.39874739039666%;
|
182
|
+
*width: 71.34655532359082%;
|
183
|
+
}
|
184
|
+
.row-fluid .span4 {
|
185
|
+
width: 57.09812108559499%;
|
186
|
+
*width: 57.045929018789145%;
|
187
|
+
}
|
188
|
+
.row-fluid .span3 {
|
189
|
+
width: 42.79749478079332%;
|
190
|
+
*width: 42.74530271398748%;
|
191
|
+
}
|
192
|
+
.row-fluid .span2 {
|
193
|
+
width: 28.49686847599165%;
|
194
|
+
*width: 28.444676409185806%;
|
195
|
+
}
|
196
|
+
.row-fluid .span1 {
|
197
|
+
width: 14.19624217118998%;
|
198
|
+
*width: 14.144050104384133%;
|
199
|
+
}
|
200
|
+
.row-fluid .offset7 {
|
201
|
+
margin-left: 100.20876826722338%;
|
202
|
+
*margin-left: 100.10438413361169%;
|
203
|
+
}
|
204
|
+
.row-fluid .offset7:first-child {
|
205
|
+
margin-left: 100.10438413361169%;
|
206
|
+
*margin-left: 100%;
|
207
|
+
}
|
208
|
+
.row-fluid .offset6 {
|
209
|
+
margin-left: 85.90814196242171%;
|
210
|
+
*margin-left: 85.80375782881002%;
|
211
|
+
}
|
212
|
+
.row-fluid .offset6:first-child {
|
213
|
+
margin-left: 85.80375782881002%;
|
214
|
+
*margin-left: 85.69937369519833%;
|
215
|
+
}
|
216
|
+
.row-fluid .offset5 {
|
217
|
+
margin-left: 71.60751565762004%;
|
218
|
+
*margin-left: 71.50313152400835%;
|
219
|
+
}
|
220
|
+
.row-fluid .offset5:first-child {
|
221
|
+
margin-left: 71.50313152400835%;
|
222
|
+
*margin-left: 71.39874739039666%;
|
223
|
+
}
|
224
|
+
.row-fluid .offset4 {
|
225
|
+
margin-left: 57.306889352818374%;
|
226
|
+
*margin-left: 57.202505219206685%;
|
227
|
+
}
|
228
|
+
.row-fluid .offset4:first-child {
|
229
|
+
margin-left: 57.20250521920668%;
|
230
|
+
*margin-left: 57.09812108559499%;
|
231
|
+
}
|
232
|
+
.row-fluid .offset3 {
|
233
|
+
margin-left: 43.006263048016706%;
|
234
|
+
*margin-left: 42.90187891440502%;
|
235
|
+
}
|
236
|
+
.row-fluid .offset3:first-child {
|
237
|
+
margin-left: 42.90187891440501%;
|
238
|
+
*margin-left: 42.79749478079332%;
|
239
|
+
}
|
240
|
+
.row-fluid .offset2 {
|
241
|
+
margin-left: 28.70563674321503%;
|
242
|
+
*margin-left: 28.601252609603343%;
|
243
|
+
}
|
244
|
+
.row-fluid .offset2:first-child {
|
245
|
+
margin-left: 28.601252609603343%;
|
246
|
+
*margin-left: 28.496868475991654%;
|
247
|
+
}
|
248
|
+
.row-fluid .offset1 {
|
249
|
+
margin-left: 14.405010438413361%;
|
250
|
+
*margin-left: 14.30062630480167%;
|
251
|
+
}
|
252
|
+
.row-fluid .offset1:first-child {
|
253
|
+
margin-left: 14.30062630480167%;
|
254
|
+
*margin-left: 14.196242171189978%;
|
255
|
+
}
|
256
|
+
[class*="span"].hide,
|
257
|
+
.row-fluid [class*="span"].hide {
|
258
|
+
display: none;
|
259
|
+
}
|
260
|
+
[class*="span"].pull-right,
|
261
|
+
.row-fluid [class*="span"].pull-right {
|
262
|
+
float: right;
|
263
|
+
}
|
264
|
+
|
265
|
+
}
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter-bootstrap-calendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Christiansen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sass
|
16
|
+
requirement: &70309126360700 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70309126360700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: railties
|
27
|
+
requirement: &70309126360160 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.1'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70309126360160
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: actionpack
|
38
|
+
requirement: &70309126359600 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.1'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70309126359600
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rails
|
49
|
+
requirement: &70309126358880 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70309126358880
|
58
|
+
description: Adds a helper and 7-column grid for creating calendar views
|
59
|
+
email:
|
60
|
+
- dave@trooptrack.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- lib/twitter/bootstrap/calendar/bootstrap.rb
|
66
|
+
- lib/twitter/bootstrap/calendar/engine.rb
|
67
|
+
- lib/twitter/bootstrap/calendar/version.rb
|
68
|
+
- lib/twitter-bootstrap-calendar.rb
|
69
|
+
- vendor/assets/stylesheets/twitter-bootstrap-calendar/index.css.scss
|
70
|
+
- app/helpers/bootstrap_calendar_helper.rb
|
71
|
+
- Rakefile
|
72
|
+
- README.md
|
73
|
+
- test/test_helper.rb
|
74
|
+
homepage: https://github.com/davidray/twitter-bootstrap-calendar
|
75
|
+
licenses: []
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.8.15
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Bootstrap based responsive calendar
|
98
|
+
test_files:
|
99
|
+
- test/test_helper.rb
|
100
|
+
has_rdoc:
|