2009
06
June

WeeklyBuilder: A weekly calendar plugin for Rails

WeeklyBuilder

I implemented a scheduling system into an app this month and I needed a calendar with monthly and weekly views.

There are over 80 repo’s on github for calendar + ruby. Calendars in rails are a solved problem, right? But oddly I couldn’t find one with a weekly view. All of them are either date pickers or monthly calendars.

So I decided to build my own and I’m happy to announce my first plugin: WeeklyBuilder [Github | Live Demo]

The builder creates a horizontal scrolling calendar, mapping events for each day of the week. The layout is fluid CSS and the hours can be switched from business hours to 24 hours.

The code was inspired by table_builder by Petrik de Heus which is a clean way to generate monthly calenders.

How to Use WeeklyBuilder

First install by downloading the source from github or via command line:
The weekly calendar builder:
The Next/Previous link helper:
The controller code:
Example events model:

The event model only requires 2 attributes: starts_at:datetime and ends_at:datetime to calculate width and position on the calendar. To simplify this for the user, I only ask the user for one datetime (starts_at) and how long it will take to complete, it then calculates ends_at based on those 2 attributes.

Github: http://github.com/dmix/weekly_builder/
Example: http://scheduler.integratehq.com/
Note: The demo uses table_builder for the monthly view and includes a few extra styles on the weekly. Not yet tested on IE6.

Update (03/06): Added a truncate_width method so that long event names are truncated in proportion to the width of the event, this is passed through the week block: |event, truncate|.

- By Dan McGrady

7 Tweets

15 Comments

  1. Posted June 3, 2009 at 3:15 pm | Permalink

    Looks awesome.

    In fact it’s exactly what I need for a current project :D

  2. Posted June 3, 2009 at 10:04 pm | Permalink

    Nice plugin Dan.
    Surely will come handy.

  3. Mario
    Posted June 4, 2009 at 1:15 am | Permalink

    Thank you. Thank you!

  4. Posted June 4, 2009 at 9:31 am | Permalink

    This seems pretty great, but isn’t this usually done the other way around? I’ve never seen a weekly view calendar that didn’t have the hours down the left hand side and the days across the top.

  5. Posted June 4, 2009 at 12:21 pm | Permalink

    @Morgan Currie
    In consumer calendars like iCal it’s often vertical. But I originally built it for a business app for field workers; in scheduling systems horizontal seems to be the standard.

    Horizontal also works well for having multiple users instead of week days so you can see everyone’s calendar for a certain day on one page. I plan on adding that functionality soon.

  6. Posted June 4, 2009 at 1:59 pm | Permalink

    That makes a lot of sense. Thanks for the quick reply!

  7. Posted June 10, 2009 at 5:48 pm | Permalink

    Nice UI. Good work.

  8. John
    Posted June 12, 2009 at 12:55 pm | Permalink

    I’ve played with this for the last couple of days and I quite like it. Will there be some documentation available sometime soon?

    Also have you thought about planning to implement the ability to add recurring events?

    All in all, great stuff!

2 Trackbacks

  1. [...] WeeklyBuilder: A weekly calendar plugin for Rails | dMix | Dan McGrady – June 11th ( tags: calendar rails plugin ruby rubyonrails schedule weekly scheduling development ) [...]

  2. [...] can also find calendar helpers for display such as http://dmix.ca/2009/06/weeklybuilder-a-weekly-calendar-plugin-for-rails/ or [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

Additional comments powered by BackType