Links
WeeklyBuilder
Categories
WeeklyBuilder
A weekly calendar builder for Ruby on Rails. Although there are countless monthly calendars on Github I couldn't find any with a weekly view, so I built my own.
The calendar is horizontally scrolling with a completely fluid CSS layout and an option for business/24 hours. Weekly views are useful because the events are plotted based on time and the width is determined by how long the event is scheduled for. So there is a visual representation of when the event is, not just a list.
The code is inspired by P8s table_builder which I recommend for monthly calendars.
Live demo: http://scheduler.integratehq.com
script/install git://github.com/dmix/weekly_builder.git
Then copy images/stylesheets to public folder
The calendar builder: <% weeklycalendar(@events, :date => @date, :include24_hours => true) do |w| %> <% w.week(:businesshours => params[:businesshours]) do |event| %> <%= event.starts_at.strftime('%I:%M%p') %> <%= linkto truncate(event.name,35), eventpath(event) %> <% end -%> <% end -%>
The Next/Previous week links helper: <% weekly_links(:date => @date) %>
In your controller: @date = Time.parse("#{params[:start_date]} || Time.now.utc") @start_date = Date.new(@date.year, @date.month, @date.day) @events = Event.find(:all, :conditions => ['startsat between ? and ?', @startdate, @start_date + 7])
The event model only requires 2 attributes: startsat:datetime and endsat:datetime to calculate width and position on the calendar. In my demo app I ask the user for one date/time (startsat) and estimated time to complete (for example 2hrs), it then calculates endsat after it is submitted.
Options available:
:include_24_hours: Default hours are 6am-8pm, if this set as "true" then an option to switch to a 24-hour schedule appears at the bottom
Copyright (c) 2009 Dan McGrady http://dmix.ca, released under the MIT license
Thanks to P8 http://github.com/p8/table_builder/
- IE6 Friendly (so far only tested on FF3 + Safari 4)
- Testing
- Refactor concats to be nested
- Single @date instead of @startdate + @enddate
Vitals
| Home | http://dmix.ca/2009/06/weeklybuilder-a-weekly-calendar-plugin-for-rails/ |
|---|---|
| Repository | git://github.com/dmix/weekly_builder.git |
| License | Rails' (MIT) |
| Tags |
|
| Rating | (0 votes) |
| Owner | dmix |
| Created | 3 June 2009 |

