Tuesday, February 13, 2007

Ward websites

I'm the ward website administrator for my ward. This means I'm supposed to update the calendar and do other helpful things.

Today there was a training meeting where we discussed the proper use of the ward websites. I being the restless person that I am decided to figure out how to automate exporting the calendar. It took about an hour.

Here's how I did it. wget is a wonderful tool. It's good for downloading web pages.

wget --keep-session-cookies --save-cookies cookies.txt\
--post-data="username=&password="\
https://secure.lds.org/
wget --load-cookies cookies.txt\
"https://secure.lds.org/?monthIndex=&currentYear="

You find the loginForm target path by looking at the source of https://secure.lds.org/units/

You find the path to the calendar by observing the calendar link target.

The monthIndex and currentYear variable are required. You will end up with an error page if you don't supply them.
I generate their values using the date command:
MONTH=`/bin/date +%m|sed -e s/0//g`;
YEAR=`/bin/date +%Y`;

The sed command is meant to strip the leading 0 off of the month number.

The final thing I do is
grep `date +%m/%d/%y` calendar.csv
This returns the list of records for the current date. This is going to allow me to generate an RSS feed so that I can see each activity on the day when it comes up.

I just won't be able to tell you where the feed is. I have to keep it to myself because this data doesn't have easy public exports (like RSS feeds and ical subscriptions) for confidentiality reasons.

However, this does not diminish the coolness of the hack.

I can supply the shell script (passwords removed) to anyone interested in downloading their calendars in an automated way.

Disclaimer: This is in no way supported by the LDS church. If you use this information to automate the downloading things from your ward website it is up to you to act responsibly and not break the terms of use. This information was obtained by viewing the source of the main login page and reading the wget(1) man page.

1 comment:

JSmith said...

I would love to have this for my own use, as I believe I will becoming the Website Administrator as well. Plus its way handy!