.SUFFIXES: .ics .m4

DCLOUD_OWNER?=$(shell id -u -n)
CATEGORIES?=personal,Work,Holiday

all: calendar.html index.html Documents/index.html

publish: all
	if type upload >/dev/null 2>&1 ; \
	then \
		upload cloud ; \
	fi

clean:
	rm -f calendar.html calendar.m4
	rm -f index.html schedule.m4 tasks.m4
	rm -f *.ics index.m4


####################
# Custom colors for calendar events
####################
custom.css:
	echo "TABLE DIV.Holiday {background: #fcc}" > custom.css
	echo "TABLE DIV.personal {background: #cfc}" >> custom.css
	echo "TABLE DIV.Work {background: #ccf}" >> custom.css
	echo "LI DIV.personal span.summary {color: green}" >> custom.css
	echo "LI DIV.Work span.summary {color: blue}" >> custom.css
	echo "LI DIV.Holiday span.summary {color: #800}" >> custom.css



####################
# Integrated Calendar
####################

calendar.html: calendar.web calendar.m4 Makefile template.m4 calendar-support.m4 custom.css
	m4 -P -D_DCLOUD_CATEGORIES="${CATEGORIES}" -D_DCLOUD_OWNER="${DCLOUD_OWNER}" -D_ROOTPATH template.m4 calendar.web > "$@"





####################
# Index & Agenda
####################
schedule.m4: calendar.ics
	queue2ics.py -s "$<" -o "$@" -b $$(date '+%Y-%m-%d') -l list -u - -L 'http://maps.google.com?q='

index.html: index.web tasks.m4 template.m4 schedule.m4 Makefile calendar-support.m4 custom.css
	m4 -P -D_DCLOUD_CATEGORIES="${CATEGORIES}" -D_DCLOUD_OWNER="${DCLOUD_OWNER}" -D_ROOTPATH template.m4 index.web > "$@"



####################
# Index for documents
####################

Documents/index.html: Documents template.m4 cloud-index.web Makefile
	m4 -P -D_DCLOUD_OWNER="${DCLOUD_OWNER}" -D_ROOTPATH=../ template.m4 cloud-index.web > "$@"

Documents:
	mkdir Documents

