1 # org2hpda - a small utility to generate hipster pda style printouts from org mode
2 # Copyright (C) 2007-2013 Christian Egli
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # set cal-tex-diary to true so that diary entries show up in the calendar
27 # run this makefile with
31 # The makfile will take the entries from your diary file and generate
32 # two PDFs containing nicely printed weekly and monthly calendars. One
33 # is done in the style of a pocketMod (http://www.pocketmod.com/) and
34 # the other is done in the style of the Hipster PDA
35 # (http://en.wikipedia.org/wiki/Hipster_PDA).
40 # the pdf* commands are part of the pdfjam package which can be found
41 # at http://www.warwick.ac.uk/go/pdfjam
43 EMACS = emacs -batch -l ~/.emacs
45 DIARY = $($(EMACS) -eval "diary-file")
47 # Number of weeks to be printed. Should be a multiple of 4, because 4
48 # of them are merged on one page. Can be set when invoking the script
49 # as follows: make NUMBER_OF_WEEKS=8 -f org2hpda
52 hipsterFiles = weekCalendar.pdf yearCalendar.pdf monthCalendar3.pdf monthCalendar2.pdf monthCalendar1.pdf
53 pocketModFiles = weekCalendar.pdf yearCalendar-rotated.pdf \
54 monthCalendar3-rotated.pdf monthCalendar2-rotated.pdf monthCalendar1-rotated.pdf
56 all: pocketMod.pdf hipsterPDA.pdf
59 # Quick hack to massage the LaTeX produced by cal-tex
60 # quote '@', then increase font size of week calendars,
61 # increase font of diary entries in moth calendar and
62 # finally reduce links to their destination, i.e.
63 # change '[[http://foo][bar]]' to 'bar'
64 sed -e 's/\\verb|@|/\@/g' \
65 -e 's/documentclass\[11pt\]/documentclass[12pt]/g' \
66 -e 's/{\\tiny \\raggedright #3}/{\\small \\raggedright #3}/g' \
67 -e 's/\[\[[^]]\+\]\[\([^]]\+\)\]\]/\1/g' \
68 < $< > /tmp/temp-org-file.$$$$; mv /tmp/temp-org-file.$$$$ $<
77 pdf90 --quiet --outfile tmp.pdf $@; mv tmp.pdf $@; \
80 weekCalendar.tex: $(DIARY)
81 $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-week-iso $(NUMBER_OF_WEEKS)) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
83 monthCalendar1.tex: $(DIARY)
84 $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
86 monthCalendar2.tex: $(DIARY)
87 $(EMACS) -eval "(progn (calendar) (calendar-forward-month 1) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
89 monthCalendar3.tex: $(DIARY)
90 $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
92 yearCalendar.tex: $(DIARY)
93 $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-year-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
95 pocketMod.pdf: $(pocketModFiles)
96 pdfjoin --quiet --outfile tmp.pdf $^
97 pdfnup tmp.pdf --quiet --outfile $@ --nup 4x2 --frame true
99 hipsterPDA.pdf: $(hipsterFiles)
100 pdfnup weekCalendar.pdf --quiet --outfile page1.pdf --batch --nup 2x2 --frame true --no-landscape
101 pdfjoin --quiet --outfile tmp.pdf monthCalendar[1-3]-rotated.pdf yearCalendar-rotated.pdf
102 pdfnup tmp.pdf --quiet --outfile page2.pdf --batch --nup 2x2 --frame true --no-landscape
103 pdfjoin --quiet --outfile $@ page1.pdf page2.pdf
106 rm -rf *.aux *.dvi *.tex *.log *.pdf