Skip to content

dangerouse/event_cal

 
 

Repository files navigation

Travis CI Code Climate Dependency Status

EventCal

EventCal is a calendar with events on it.

You can easily

  • create and display many kinds of events
  • customize how events displayed
  • integrate events with existing model

Use EventCal

gem 'event_cal', github: 'shin1ohno/event_cal'
  1. create calendar instance in controller and call render_monthly(@calendar) in view. simple sample code is below. only with this step, you basically can get calendar view
  2. create event class that extends ::EventCal::Events
  3. create partial for each event. with sptep 2 and 3 it's automatically shown in calendar view

sample/app_*** directory contains sample rails application that shows how you do. This sample runs as normal rails application.

class MyCalendarController < ApplicationController
  def index
    @calendar = ::EventCal::Calendar.new(Date.today)
  end

  def show
    date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:date]}")
    @calendar = ::EventCal::Calendar.new(date)
  end
end
.calendar_view
  = render_monthly(@calendar)
  = render_event_details(@calendar.events) # if you need event details view
# typically, you may want to draw routes like this
App3211::Application.routes.draw do
  resources :my_calendar do
    collection do
      get ':year/:month/:date' => 'my_calendar#show', :constraints => { :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ }
    end
  end
end

you can use default style for 7days * 4~5 weeks calendar

/*
 in application.css... add sprockets manifest like
 *= require_self
 *= require event_cal
 *= require_tree .
 */

you can use basic event detail selector implemented in JavaScript with Spine.js

// in application.js... add sprockets manifest like
//= require jquery
//= require jquery_ujs
//= require event_cal
//= require_tree .
// and then initialize like this...

jQuery(function($) {
  var baseDatelement;
  CalendarApplication.initialize();
  baseDatelement = CalendarDate.findByAttribute('date', $('.calendar').data('base-date')).element;
  if (baseDatelement.hasClass('has_events')) {
    return baseDatelement.click();
  }
});

Develop EventCal

running tests

bundle exec rake runs all examples

bundle first. bundle exec tork then hit a to run all rspec examples. bundle exec guard then hit return to run all jasmine expamples

Thanks

License

This project uses MIT-LICENSE.

About

Calendar that easy to use, easy to customise

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 64.0%
  • JavaScript 27.7%
  • CoffeeScript 7.3%
  • CSS 1.0%