Donnerstag, 4. Dezember 2008

HTMLCalendar and HTMLTemplates fresh off the openSUSE Build Service

Have you ever wanted to display a calendar on your webpage and seen how complicated this can be? Well, you probably missed HTMLCalendar, then. HTMLCalendar makes it extremely easy to just roll a simple HTML calendar without any overhead. You can even add events on certain days and link these to other pages.

With this in mind, I decided to build packages for openSUSE to make it even easier to install the package. So, if you're on openSUSE, (make sure you have the devel:languages:python repository registered with zypper - but this goes without saying), just run a:
zypper in python-htmlcalendar

and you should be good to go.

Once you've got the packages installed (python-htmlcalendar automatically pulls in python-htmltemplate which is required), try writing a small python script. Mine's called testcal.py:

#!/usr/bin/python
import HTMLCalendar

month = 12
year = 2008
links = {1:'#day1', 2:'#day2', 3:'#day3', 12:'#day12', 27:'#day27'}

print HTMLCalendar.MonthCal().render(year, month, links)


Then call the script like this:
python testcal.py > calendar.html

Once you're done, call up calendar.html with your browser of choice and voila - there's your calendar. Now I have to go and read the documentation to see what cool options are supported. I'm thinking along the lines of CSS formatting, colours etc.

Maybe it's even possible to combine some images with the outputted HTML so as to create a 12 month calendar with a picture for every month. This could then by exported to PDF for printing.

Keine Kommentare: