This gem provide simple and easy way to create calendar with Twitter Bootstrap and Rails.
First of all you should include twitter bootstrap in your app. You can do it manually, or use twitter-bootstrap-rails gem.
To use Less stylesheets, you'll need the less-rails gem, and one of Javascript runtimes supported by CommonJS.
Include these lines in the Gemfile to install the gems from RubyGems.org:
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "bootstrap_calendar_rails"
Then run bundle install
from the command line:
bundle install
Then run the bootstrap generator to add Calendar includes into your assets:
rails generate calendar:install less
If you don't need to customize the stylesheets using Less, the only gem you need is the bootstrap_calendar_rails
gem:
gem "bootstrap_calendar_rails"
After running bundle install
, run the generator:
rails generate calendar:install static
You should use something like this in the view
bootstrap_calendar Date.today {} do |date|
date.day.to_s
end
it show you calendar for the current month.
You can specify another start week day. Use start_day
key for this:
bootstrap_calendar Date.today { start_day: :wednesday } do |date|
date.day.to_s
end
You can extend day classes. Use extra_day_classes
key and lambda for this:
options = { extra_day_classes: lambda { |classes, date|
classes << 'cal-day-daylight' if true
}
}
bootstrap_calendar Date.today, options do |date|
date.day.to_s
end
An example application is available at sharpyfox/bootstrap_calendar_rails_example. You can view it running on heroku here. Contributions welcome.
This gem are highly inspired by:
davidray and davidray / twitter-bootstrap-calendar Basically this gem is an adoptation davidray / twitter-bootstrap-calendar
for my flavour
Serhioromano and Serhioromano / bootstrap-calendar I stole all css markup from him
Thanks guys!
If you'd like to add features (or bug fixes) to improve the gem, you can fork the GitHub repo and make pull requests. Your code contributions are welcome!