Skip to content

A Rails view helper for creating weekly calendars (horizontal scrolling), inspired by TableBuilder.

License

Notifications You must be signed in to change notification settings

seanhussey/weekly_builder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeeklyBuilder

Fork of dmix/weekly_builder

Modifying weekly builder to meet the needs of our project.

Install

script/plugin install git://github.com/timstephenson/weekly_builder.git 

Then check the output if all images and stylesheets have been copied successfully.

How to Use WeeklyBuilder

The calendar builder: <% weekly_calendar(@events, :date => @date, :include_24_hours => true) do |w| %> <% w.week(:business_hours => params[:business_hours], :clickable_hours => true) do |event,truncate| %> <%= event.starts_at.strftime('%I:%M%p') %> <%= link_to truncate(event.name,truncate), event_path(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 => ['starts_at between ? and ?', @start_date, @start_date + 7])

The event model only requires 2 attributes: starts_at:datetime and ends_at:datetime to calculate width and position on the calendar. In my demo app I ask the user for one date/time (starts_at) and estimated time to complete (for example 2hrs), it then calculates ends_at after it is submitted.

UPDATE: 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 with |truncate|.

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/

TODO

  • Testing
  • Refactor

About

A Rails view helper for creating weekly calendars (horizontal scrolling), inspired by TableBuilder.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%