org2hpda 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # org2hpda - a small utility to generate hipster pda style printouts from org mode
  2. # Copyright (C) 2007 Christian Egli
  3. #
  4. # Version: 0.6
  5. #
  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.
  10. #
  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.
  15. #
  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/>.
  18. #
  19. # Commentary:
  20. # ===========
  21. #
  22. # set cal-tex-diary to true so that diary entries show up in the calendar
  23. #
  24. # Usage:
  25. # ======
  26. #
  27. # run this makefile with
  28. #
  29. # make -f org2hpda
  30. #
  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).
  36. #
  37. # Requirements:
  38. # =============
  39. #
  40. # the pdf* commands are part of the pdfjam package which can be found
  41. # at http://www.warwick.ac.uk/go/pdfjam
  42. EMACS = emacs -batch -l ~/.emacs
  43. LATEX = latex
  44. DIARY = $($(EMACS) -eval "diary-file")
  45. hipsterFiles = weekCalendar.pdf yearCalendar.pdf monthCalendar3.pdf monthCalendar2.pdf monthCalendar1.pdf
  46. pocketModFiles = weekCalendar.pdf yearCalendar-rotated.pdf \
  47. monthCalendar3-rotated.pdf monthCalendar2-rotated.pdf monthCalendar1-rotated.pdf
  48. all: pocketMod.pdf hipsterPDA.pdf
  49. %.dvi: %.tex
  50. # Quick hack to massage the LaTeX produced by cal-tex
  51. # quote '@', then increase font size of week calendars,
  52. # increase font of diary entries in moth calendar and
  53. # finally reduce links to their destination, i.e.
  54. # change '[[http://foo][bar]]' to 'bar'
  55. sed -e 's/\\verb|@|/\@/g' \
  56. -e 's/documentclass\[11pt\]/documentclass[12pt]/g' \
  57. -e 's/{\\tiny \\raggedright #3}/{\\small \\raggedright #3}/g' \
  58. -e 's/\[\[[^]]\+\]\[\([^]]\+\)\]\]/\1/g' \
  59. < $< > /tmp/temp-org-file.$$$$; mv /tmp/temp-org-file.$$$$ $<
  60. $(LATEX) $^
  61. %.pdf: %.dvi
  62. dvipdf $^
  63. %-rotated.pdf: %.pdf
  64. cp $^ $@
  65. for n in 1 2 3; do \
  66. pdf90 --outfile tmp.pdf $@; mv tmp.pdf $@; \
  67. done
  68. weekCalendar.tex: $(DIARY)
  69. $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-week-iso 4) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  70. monthCalendar1.tex: $(DIARY)
  71. $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  72. monthCalendar2.tex: $(DIARY)
  73. $(EMACS) -eval "(progn (calendar) (calendar-forward-month 1) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  74. monthCalendar3.tex: $(DIARY)
  75. $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  76. yearCalendar.tex: $(DIARY)
  77. $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-year-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  78. pocketMod.pdf: $(pocketModFiles)
  79. pdfjoin --outfile tmp.pdf $^
  80. pdfnup tmp.pdf --outfile $@ --nup 4x2 --frame true
  81. hipsterPDA.pdf: $(hipsterFiles)
  82. pdfnup weekCalendar.pdf --outfile page1.pdf --nup 2x2 --frame true
  83. pdfjoin --outfile tmp.pdf monthCalendar[1-3]-rotated.pdf yearCalendar-rotated.pdf
  84. pdfnup tmp.pdf --outfile page2.pdf --nup 2x2 --frame true
  85. pdfjoin --outfile $@ page1.pdf page2.pdf
  86. clean:
  87. rm -rf *.aux *.dvi *.tex *.log *.pdf