Code Monkey home page Code Monkey logo

acts_as_calendar's Introduction

Acts As Calendar

I haven’t touched this in a dog’s age, but angelic has taken the ball and run with it:

github.com/angelic/schedule_fu/tree/master

Anyone who found this interesting should work from her repository.

Old Readme

This rails plugin aims to provide support for calendar events, both discrete and recurring. The goal is to be able to attach a calendar to any model object, and to attach calendar events to any of that object’s children or possibly descendents. The calendar data should be publishable in ical format, and possibly editable from as well, to the extent that the data model allows.

Events may occur on specific dates, recur monthly on a given day (the 15th), a given day of a given week (1st Thursday, Last Saturday), or a given weekday (Every Friday), or any combination of the above.

Recurring events are stored as patterns in the database, and are joined against a table of dates, decomposed into parts, into a view of event instances. This has the advantages of being easy and efficient to query, and of bypassing the typically non-standard database date functions. The disadvantage, of course, is that it requires a table of all potential dates against which to join. That being said, a century’s worth of date data should only be a few hundred kilobytes, not large by today’s standards. The limiting factor at the moment is in initially populating these data, it’s fairly slow with ActiveRecord.

Status

The plugin is far from complete. Specifically it could use:

  1. A nice way of supplying a migration to the rails app

  2. A nice API for creating and querying events

  3. A suggested strategy for annotating events with metadata - names, categories, etc. I’ve purposedfully kept this out of the base models, figuring that folks would create, say, Course objects which would point to the CalendarEvent objects, but it’s unclear if this is really workable.

  4. The icalendar output is incomplete

Getting Started

If you want to play with the object model anyway, install the plugin and:

  1. Copy the contents of db/migration.rb into a migration in the rails app, and migrate it.

  2. Create a calendar, e.g. calendar = Calendar.create_for_dates(Date.parse(‘2008-01-01’), Date.parse(‘2008-12-31’))

  3. Create an event, e.g. event = calendar.events.create_for(‘2008-01-01’). The create_for method accepts strings, dates, recurrence hashes, and enumerables of these. In the case of exactly two string or date arguments, the dates are taken to be endpoints of a range, otherwise they’re taken to be specific occurrences of the event.

  4. Query for events:

calendar.events.find_by_date(Date.parse(‘2008-01-01’))

calendar.events.find_by_dates(Date.parse(‘2008-01-01’), Date.parse(‘2008-12-31’))

The good bit to figure out how would be how to combine date searches with searches for event metadata, e.g. categories. Probably some named scope stuff would work.

acts_as_calendar's People

Contributors

dball avatar

Stargazers

Christian Hochfilzer avatar

Watchers

Christian Hochfilzer avatar James Cloos avatar

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.