org-mode/contrib/scripts/org2hpda
Bastien Guerry 6e534f9c61 Manually revert back to commit e85080.
This fixes a wrong merge that should not have happened:
commit 7e903a merges the master branch into the maint branch,
while we really want to keep the maint branch a bugfix-only
branch.

This commit reverts back the maint branch to its state before
merging the master branch.  From there, we will fix remaining
problems with the maint branch (e.g. copyright issues) then
release this maint branch as Org-mode 7.8.05.
2012-03-17 14:34:01 +01:00

107 lines
3.9 KiB
Plaintext
Executable file

# org2hpda - a small utility to generate hipster pda style printouts from org mode
# Copyright (C) 2007 Christian Egli
#
# Version: 0.6
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Commentary:
# ===========
#
# set cal-tex-diary to true so that diary entries show up in the calendar
#
# Usage:
# ======
#
# run this makefile with
#
# make -f org2hpda
#
# The makfile will take the entries from your diary file and generate
# two PDFs containing nicely printed weekly and monthly calendars. One
# is done in the style of a pocketMod (http://www.pocketmod.com/) and
# the other is done in the style of the Hipster PDA
# (http://en.wikipedia.org/wiki/Hipster_PDA).
#
# Requirements:
# =============
#
# the pdf* commands are part of the pdfjam package which can be found
# at http://www.warwick.ac.uk/go/pdfjam
EMACS = emacs -batch -l ~/.emacs
LATEX = latex
DIARY = $($(EMACS) -eval "diary-file")
# Number of weeks to be printed. Should be a multiple of 4, because 4
# of them are merged on one page. Can be set when invoking the script
# as follows: make NUMBER_OF_WEEKS=8 -f org2hpda
NUMBER_OF_WEEKS = 4
hipsterFiles = weekCalendar.pdf yearCalendar.pdf monthCalendar3.pdf monthCalendar2.pdf monthCalendar1.pdf
pocketModFiles = weekCalendar.pdf yearCalendar-rotated.pdf \
monthCalendar3-rotated.pdf monthCalendar2-rotated.pdf monthCalendar1-rotated.pdf
all: pocketMod.pdf hipsterPDA.pdf
%.dvi: %.tex
# Quick hack to massage the LaTeX produced by cal-tex
# quote '@', then increase font size of week calendars,
# increase font of diary entries in moth calendar and
# finally reduce links to their destination, i.e.
# change '[[http://foo][bar]]' to 'bar'
sed -e 's/\\verb|@|/\@/g' \
-e 's/documentclass\[11pt\]/documentclass[12pt]/g' \
-e 's/{\\tiny \\raggedright #3}/{\\small \\raggedright #3}/g' \
-e 's/\[\[[^]]\+\]\[\([^]]\+\)\]\]/\1/g' \
< $< > /tmp/temp-org-file.$$$$; mv /tmp/temp-org-file.$$$$ $<
$(LATEX) $^
%.pdf: %.dvi
dvipdf $^
%-rotated.pdf: %.pdf
cp $^ $@
for n in 1 2 3; do \
pdf90 --outfile tmp.pdf $@; mv tmp.pdf $@; \
done
weekCalendar.tex: $(DIARY)
$(EMACS) -eval "(progn (calendar) (cal-tex-cursor-week-iso $(NUMBER_OF_WEEKS)) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
monthCalendar1.tex: $(DIARY)
$(EMACS) -eval "(progn (calendar) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
monthCalendar2.tex: $(DIARY)
$(EMACS) -eval "(progn (calendar) (calendar-forward-month 1) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
monthCalendar3.tex: $(DIARY)
$(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
yearCalendar.tex: $(DIARY)
$(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-year-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))"
pocketMod.pdf: $(pocketModFiles)
pdfjoin --outfile tmp.pdf $^
pdfnup tmp.pdf --outfile $@ --nup 4x2 --frame true
hipsterPDA.pdf: $(hipsterFiles)
pdfnup weekCalendar.pdf --outfile page1.pdf --nup 2x2 --frame true
pdfjoin --outfile tmp.pdf monthCalendar[1-3]-rotated.pdf yearCalendar-rotated.pdf
pdfnup tmp.pdf --outfile page2.pdf --nup 2x2 --frame true
pdfjoin --outfile $@ page1.pdf page2.pdf
clean:
rm -rf *.aux *.dvi *.tex *.log *.pdf