org2hpda 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # org2hpda - a small utility to generate hipster pda style printouts from org mode
  2. # Copyright (C) 2007-2013 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. # Number of weeks to be printed. Should be a multiple of 4, because 4
  46. # of them are merged on one page. Can be set when invoking the script
  47. # as follows: make NUMBER_OF_WEEKS=8 -f org2hpda
  48. NUMBER_OF_WEEKS = 4
  49. hipsterFiles = weekCalendar.pdf yearCalendar.pdf monthCalendar3.pdf monthCalendar2.pdf monthCalendar1.pdf
  50. pocketModFiles = weekCalendar.pdf yearCalendar-rotated.pdf \
  51. monthCalendar3-rotated.pdf monthCalendar2-rotated.pdf monthCalendar1-rotated.pdf
  52. all: pocketMod.pdf hipsterPDA.pdf
  53. %.dvi: %.tex
  54. # Quick hack to massage the LaTeX produced by cal-tex
  55. # quote '@', then increase font size of week calendars,
  56. # increase font of diary entries in moth calendar and
  57. # finally reduce links to their destination, i.e.
  58. # change '[[http://foo][bar]]' to 'bar'
  59. sed -e 's/\\verb|@|/\@/g' \
  60. -e 's/documentclass\[11pt\]/documentclass[12pt]/g' \
  61. -e 's/{\\tiny \\raggedright #3}/{\\small \\raggedright #3}/g' \
  62. -e 's/\[\[[^]]\+\]\[\([^]]\+\)\]\]/\1/g' \
  63. < $< > /tmp/temp-org-file.$$$$; mv /tmp/temp-org-file.$$$$ $<
  64. $(LATEX) $^
  65. %.pdf: %.dvi
  66. dvipdf $^
  67. %-rotated.pdf: %.pdf
  68. cp $^ $@
  69. for n in 1 2 3; do \
  70. pdf90 --quiet --outfile tmp.pdf $@; mv tmp.pdf $@; \
  71. done
  72. weekCalendar.tex: $(DIARY)
  73. $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-week-iso $(NUMBER_OF_WEEKS)) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  74. monthCalendar1.tex: $(DIARY)
  75. $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  76. monthCalendar2.tex: $(DIARY)
  77. $(EMACS) -eval "(progn (calendar) (calendar-forward-month 1) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  78. monthCalendar3.tex: $(DIARY)
  79. $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  80. yearCalendar.tex: $(DIARY)
  81. $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-year-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
  82. pocketMod.pdf: $(pocketModFiles)
  83. pdfjoin --quiet --outfile tmp.pdf $^
  84. pdfnup tmp.pdf --quiet --outfile $@ --nup 4x2 --frame true
  85. hipsterPDA.pdf: $(hipsterFiles)
  86. pdfnup weekCalendar.pdf --quiet --outfile page1.pdf --batch --nup 2x2 --frame true --no-landscape
  87. pdfjoin --quiet --outfile tmp.pdf monthCalendar[1-3]-rotated.pdf yearCalendar-rotated.pdf
  88. pdfnup tmp.pdf --quiet --outfile page2.pdf --batch --nup 2x2 --frame true --no-landscape
  89. pdfjoin --quiet --outfile $@ page1.pdf page2.pdf
  90. clean:
  91. rm -rf *.aux *.dvi *.tex *.log *.pdf