Git Product home page Git Product logo

calendar_helper's Introduction

CalendarHelper

<img src=“https://secure.travis-ci.org/topfunky/calendar_helper.png?branch=master” alt=“Build Status” />

DESCRIPTION:

A simple helper for creating an HTML calendar. The “calendar” method will be automatically available to your Rails view templates, or can be used with Sinatra or other webapps.

Some example stylesheets are provided via the Rails asset pipeline. Add to your main stylesheet with one of the following:

/*
 *= require 'calendar_styles/grey'
 *   OR
 *= require 'calendar_styles/red'
 *   OR
 *= require 'calendar_styles/blue'
 */

SYNOPSIS:

# Simple
calendar(:year => 2005, :month => 6)

# Set table class
calendar({:year => 2005, :month => 6, :table_class => "calendar_helper"})

# Full featured
calendar(:year => 2005, :month => 5) do |d| # This generates a simple calendar, but gives special days
  if listOfSpecialDays.include?(d)          # (days that are in the array listOfSpecialDays) one CSS class,
    [d.mday, {:class => "specialDay"}]      # "specialDay", and gives the rest of the days another CSS class,
  else                                      # "normalDay". You can also use this highlight today differently
    [d.mday, {:class => "normalDay"}]       # from the rest of the days, etc.
  end
end

If using with ERb (Rails), put in a printing tag.

<%= calendar(:year => @year, :month => @month, :first_day_of_week => 1) do |d|
      render_calendar_cell(d)
    end
%>

With Haml, use a helper to set options for each cell.

= calendar(:year => @year, :month => @month, :first_day_of_week => 1) do |d|
  - render_calendar_cell(d)

In Sinatra, include the CalendarHelper module in your helpers:

helpers do
  include CalendarHelper
end

Accessibility & 508 Compliance:

  • The table tag has a summary attribute (overridable).

  • Each th has an id.

  • Each td as a headers attribute, containing the element id of the appropriate th.

AUTHORS:

Jeremy Voorhis – jvoorhis.com Original implementation

Geoffrey Grosenbach – nubyonrails.com Test suite and conversion to a Rails plugin

Contributors:

USAGE:

See the RDoc (or use “rake rdoc”).

To copy the CSS files, use

./script/generate calendar_styles

CSS will be copied to subdirectories of public/stylesheets/calendar.

calendar_helper's People

Contributors

benlieb avatar dzhlobo avatar eric1234 avatar jana4u avatar jhilden avatar johndouthat avatar mattscilipoti avatar monde avatar rubiii avatar stevenbristol avatar topfunky avatar wilkerlucio avatar wli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

calendar_helper's Issues

August 09 not showing days after 29th

Hi have a strange issue with date for aug 09 not showing on the calendar when in august but the show as greyed out when you are in September. Has this been an issue in the past and l just need to update my plugin?

Update gem

Can you please update the corresponding gem on rubygems.org? It's still on 0.2.5.

NoMethodError in action (Rails 3.1.3, ruby 1.9.2)

Hi!
I tried to render calendar in my view:

<%= calendar(:year => 2012, :month => 1, :first_day_of_week => 1) do |d|
    render_calendar_cell(d)
    end
%>

Got an error in first line:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.size

plugin depends on the behavior of "cal -y [month] [year]", which does seem to work for ubuntu 2.6 Paravirt

uname
Linux li195-141 2.6.32.12-x86_64-linode15 #1 SMP Sun Jul 25 22:20:38 UTC 2010 x86_64 GNU/Linux

cal -m 9 2008 # like in the example
2008

  January               February               March

Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 1 2 1
6 7 8 9 10 11 12 3 4 5 6 7 8 9 2 3 4 5 6 7 8
13 14 15 16 17 18 19 10 11 12 13 14 15 16 9 10 11 12 13 14 15
20 21 22 23 24 25 26 17 18 19 20 21 22 23 16 17 18 19 20 21 22
27 28 29 30 31 24 25 26 27 28 29 23 24 25 26 27 28 29
30 31
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 1 2 3 1 2 3 4 5 6 7
6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14
13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21
20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28
27 28 29 30 25 26 27 28 29 30 31 29 30

    July                 August              September

Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 5 1 2 1 2 3 4 5 6
6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13
13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20
20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27
27 28 29 30 31 24 25 26 27 28 29 30 28 29 30
31
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 4 1 1 2 3 4 5 6
5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13
12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20
19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27
26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31
30

Which makes the plugin ill as it parse January as a date for instance.

Not working on 2.3.8?

I tried evertything to get this working.. undefined method Calendar.. could you please provide some more details on how to implement this? Just installing the plugin and adding the haml string always gives me undefined method.. Need exact this plugins features, could you maybe update the code please? I can donate

undefined method `size' for nil:NilClass

<%= calendar({:year => Date.today.year, :month => Date.today.month, :calendar_title => "Eventos" }) %>

is throwing me an "undefined method size' for nil:NilClass" exception.

Any idea why this could be happening?

Discuss Accessibility/508 Compliance: requires th id and td headers.

Hey,

Thanks for accepting the table summary request. Here are the last steps for 508 Compliance:

id attribute
The id attribute, defined for th elements, should uniquely identify each header cell. This id is used in conjunction with the headers attribute of td elements to indicate headers for a particular data cell.

headers attribute
The headers attribute, defined for td elements, should point to the id of th elements that are the header cells for the data cell.

We have found that having these attributes present can also help with css styling.

A) Are you interested in accepting these additions to calendar_helper?
B) What do you think of these conventions for default values? Remembering, there may be more than one calendar per page.
table id: calendar-<year>-<month> --> calendar-2011-04
th id: <table_id>-<dow> --> calendar-2011-04-mon, calendar-2011-04-tue
C) is it necessary to provide a way to override the th id defaults? We can easily override the table id, which will change the generated th id. Calendar_helper does not currently have an api pattern that might allow a developer to define a block for th id creation.

weekly view

Hi,

it would be nice to have also a weekly view for a calendar.
Or is that already possible with that gem?

Doesn't render cell links in rails 3

When rendering sass it doesn't seem to render links from a "render_calendar_cell" method properly any longer in rails 3, probably due to the new implicit "raw".

If skipping raw it renders the links but outputs escaped text.

= raw calendar(:year => @year, :month => @month, :first_day_of_week => 1) do |d|
  - render_calendar_cell(d)  / returns <a href> link

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.