REBOL [ title: "CGI Event Calendar" date: 18-Apr-2010 file: %cgi-event-calendar.r author: Nick Antonaccio purpose: { A web site CGI application that displays events in the current calendar month, with links to specified event pages. Events are stored in the file %bb.db, in the format: ["event 1" 18-Apr-2010 http://website.com/event1.html] ["event 2" 20-Apr-2010 http://website.com/event2.html] ["event 3" 20-Apr-2010 http://website.com/event3.html] This script uses code derived from Bohdan Lechnowsky's "HTML calendar". Taken from the tutorial at http://re-bol.com } ] #! /home/path/public_html/rebol/rebol -cs REBOL [] print "content-type: text/html^/" print {Event Calendar} bbs: load %bb.db date: now/date html: copy rejoin [ {
} ] days: ["Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"] foreach day days [ append html rejoin [ {} ] ] append html {} sdate: date sdate/day: 0 loop sdate/weekday // 7 + 1 [append html {}] while [sdate/day: sdate/day + 1 sdate/month = date/month][ event-labels: {} foreach entry bbs [ date-in-entry: 1-Jan-1001 attempt [date-in-entry: (to-date entry/2)] if (date-in-entry = sdate) [ event-labels: rejoin [ {} event-labels "

" {} entry/1 {} "
" {
} ] ] ] append html rejoin [ {} ] if sdate/weekday = 6 [append html {}] ] loop 7 - sdate/weekday [append html rejoin [{}]] append html {
} pick system/locale/months date/month { } date/year {
} day {
} sdate/day event-labels {
} print html