From a3ddc43746ac2160d13309e2db2f4983bbae56c5 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Wed, 5 Jun 2013 09:36:00 -0700 Subject: [PATCH] Improve ical plugin documentation --- ical/Readme.rst | 33 ++++++++++++++++++++++----------- ical/ical.py | 10 +++++----- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ical/Readme.rst b/ical/Readme.rst index 0260a72..e8897d1 100644 --- a/ical/Readme.rst +++ b/ical/Readme.rst @@ -1,28 +1,39 @@ ical --------- +---- -This plugin read the calendar defined in the page metadata : calendar : +This plugin looks for and parses an ``.ics`` file if it is defined in a given +page's ``calendar`` metadata. One calendar can be defined per page. -with:: +Dependencies +------------ + +This plugin depends on the ``icalendar`` package, which can be installed via +pip:: + + pip install icalendar + +Usage +----- + +For a reST-formatted page, include the following line in the metadata:: :calendar: /path/to/your/ics/file -Example of code that can be added in page template :: +For Markdown, include the following line in the page metadata:: + Calendar: /path/to/your/ics/file + +Following is some example code that can be added to your theme's ``page.html`` +template in order to display the calendar:: {% if page.calendar %}
- {% for vevent in events[page.slug] %} + {% for vevent in events[page.slug] %}
{{ vevent.summary }}
{{ vevent.description|replace('\n\n', '
') }}
{{ vevent.dtstart }}
{{ vevent.dtend }}
- + {% endfor %}
{% endif %} - -this plugins needs icalendar module installed:: - - pip install icalendar - diff --git a/ical/ical.py b/ical/ical.py index 26fdd12..ccfefaa 100644 --- a/ical/ical.py +++ b/ical/ical.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ ical plugin for Pelican -=========================== +======================= -This plugin parse the calendars defined in pages metadata :calendar: -One calendar per page +This plugin looks for and parses an .ics file if it is defined in a given +page's :calendar: metadata. One calendar can be defined per page. """ @@ -15,7 +15,7 @@ import datetime import os.path def init_cal(generator): - # initialisation of the dictionnary of calendar + # initialisation of the calendar dictionary # you can add one calendar per page calDict = {} generator.context['events'] = calDict @@ -42,7 +42,7 @@ def add_ical(generator, metadata): if element.get('dtend') != None: eventdict['dtend'] = element.get('dtend').dt summ.append(eventdict) - # the id of the calendar is the slugify name of the page + # the id of the calendar is the slugified name of the page calId = utils.slugify(metadata['title']) generator.context['events'][calId] = summ