diff options
Diffstat (limited to 'macros/latex/contrib/photobook')
-rw-r--r-- | macros/latex/contrib/photobook/Makefile | 24 | ||||
-rw-r--r-- | macros/latex/contrib/photobook/photobook.cls | 17 | ||||
-rw-r--r-- | macros/latex/contrib/photobook/photobook.pdf | bin | 140737 -> 141191 bytes | |||
-rw-r--r-- | macros/latex/contrib/photobook/scripts/README.md | 10 | ||||
-rw-r--r-- | macros/latex/contrib/photobook/scripts/make-spreads.cfg.example | 39 | ||||
-rw-r--r-- | macros/latex/contrib/photobook/scripts/make-spreads.sh | 78 |
6 files changed, 136 insertions, 32 deletions
diff --git a/macros/latex/contrib/photobook/Makefile b/macros/latex/contrib/photobook/Makefile index 39b57fa353..ddbd047536 100644 --- a/macros/latex/contrib/photobook/Makefile +++ b/macros/latex/contrib/photobook/Makefile @@ -45,6 +45,8 @@ .EXPORT_ALL_VARIABLES: +#.ONESHELL: + # NOTE: this makes things run consistently on different systems including # things like Android... SHELL := bash @@ -287,7 +289,6 @@ ctan-dist: dist cp -f $(DIST_DIR)/$(DIST_NAME).zip $(DIST_DIR)/$(MODULE).zip - .PHONY: tag tag: @echo "Will create and publish git tag:" @@ -297,8 +298,25 @@ tag: | tail -n 5 \ | sed 's/^/ /' \ | tac - @echo "Note that this must be done after a commit." - @read -p "(press any key to continue or ctrl-c to cancel)" +# # check if we need to bug the user about committing and/or pushing stuff... + @\ + UNCOMITTED=$$(git status --porcelain=v1 2> /dev/null | grep -v '??' | wc -l) ;\ + UNPUSHED=$$(git log origin..HEAD | wc -l) ;\ + if ! [ $$UNCOMITTED = 0 ] ; then \ + echo ;\ + echo "WARNING: Uncommited changes found!" ;\ + fi ;\ + if ! [ $$UNPUSHED = 0 ] ; then \ + [ $$UNCOMITTED = 0 ] \ + && echo ;\ + echo "WARNING: Unpushed commits found!" ;\ + fi ;\ + if ! [ $$UNCOMITTED = 0 ] || ! [ $$UNPUSHED = 0 ] ; then \ + echo ;\ + echo "Note that this must be done after a commit and a push." ;\ + echo "(press any key to continue or ctrl-c to cancel)" ;\ + read ;\ + fi ;\ git tag "v$(VERSION)" git push origin "v$(VERSION)" diff --git a/macros/latex/contrib/photobook/photobook.cls b/macros/latex/contrib/photobook/photobook.cls index 8f9da6cf24..fc9a349c3a 100644 --- a/macros/latex/contrib/photobook/photobook.cls +++ b/macros/latex/contrib/photobook/photobook.cls @@ -76,8 +76,8 @@ %%% NOTE: \def\<module-name>@[A-Z]+ macros will be visible to both the %%% code and the generated docs... -\edef\photobook@FILEVERSION{v0.1.10} -\edef\photobook@FILEDATE{2023-03-11} +\edef\photobook@FILEVERSION{v0.1.13} +\edef\photobook@FILEDATE{2023-03-13} %% \documentclass{ltxdoc} @@ -1156,6 +1156,19 @@ \InitPages% \ResetFoldMarks} +%% \DescribeMacro{\ChangeLayout} +% +%% Change document layout. +% +%% >> \ChangeLayout{<layoutmode>} +% +%% This is a shorthand for |\def\layoutmode{<layoutmode>}| and then +%% |\ReInitPages|, and as this is changing any other parameters that may +%% affect the layout, this should be done last. +%% +\newcommand\ChangeLayout[1]{% + \def\layoutmode{#1}% + \ReInitPages} %---------------------------------------------------------------------- diff --git a/macros/latex/contrib/photobook/photobook.pdf b/macros/latex/contrib/photobook/photobook.pdf Binary files differindex 64778bbbf3..59b9da74cd 100644 --- a/macros/latex/contrib/photobook/photobook.pdf +++ b/macros/latex/contrib/photobook/photobook.pdf diff --git a/macros/latex/contrib/photobook/scripts/README.md b/macros/latex/contrib/photobook/scripts/README.md index 5970cfbb72..223578f7bb 100644 --- a/macros/latex/contrib/photobook/scripts/README.md +++ b/macros/latex/contrib/photobook/scripts/README.md @@ -23,7 +23,7 @@ Support scripts `make-spreads.sh` ---------------- -Generate LaTeX block of pages from a directory tree. +Generate LaTeX block of pages/spreads from a directory tree. This was initially intended as a means to convert the exported directory tree from an image viewer where image/text sequencing was done, but it @@ -315,8 +315,7 @@ but with a .txt extension. All the configuration options can be given in a configuration file as well as environment variables. -<!-- XXX this is not true at the moment, not sure if this is a bug or a feature... -Environment variables take precedence over the configuration file. --> +Environment variables take precedence over the configuration file. The default `make-images.cfg` would look something like: ```shell @@ -361,6 +360,11 @@ IMAGE_SPREAD=( ) ``` +An explicit configuration file can be manually specified: +```shell +$ make-spreads.sh -c <path> .. +``` + --- diff --git a/macros/latex/contrib/photobook/scripts/make-spreads.cfg.example b/macros/latex/contrib/photobook/scripts/make-spreads.cfg.example new file mode 100644 index 0000000000..4627fee339 --- /dev/null +++ b/macros/latex/contrib/photobook/scripts/make-spreads.cfg.example @@ -0,0 +1,39 @@ +# if non-empty make-spreads.sh will add image paths to pdf notes... +ANOTATE_IMAGE_PATHS= + +# file extensions to treat as text (separated with "|") +TEXT_FORMATS=txt + +# file extensions to treat as images (separated with "|") +IMAGE_FORMATS=jpeg|jpg|png|pdf|svg|eps + +# default directory spread definitions are located in... +SPREADS_DIR=spreads/ + +# if non-empty link link images to matching ones from this directory... +IMAGE_HIRES_DIR= + +# directory where external captions are stored... +CAPTION_DIR=captions/ + +# root template directory... +TEMPLATE_DIR=templates/ + +# empty page template... +EMPTY_PAGE=emptypage + +# text page template... +TEXT_PAGE=textpage + +# image page template... +IMAGE_PAGE=imagepage + +# spread templates... +IMAGE_SPREAD=( + # + # +------- number of found images + # / +-- template name + # / / + [0]=text-spread + [2]=image-image +) diff --git a/macros/latex/contrib/photobook/scripts/make-spreads.sh b/macros/latex/contrib/photobook/scripts/make-spreads.sh index 57be2ff448..05979ae03d 100644 --- a/macros/latex/contrib/photobook/scripts/make-spreads.sh +++ b/macros/latex/contrib/photobook/scripts/make-spreads.sh @@ -18,12 +18,12 @@ shopt -s nullglob extglob # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Template structure: -# templates/ +# $TEMPLATE_DIR/ # spread.tex # imagepage.tex # textpage.tex # ... -# captions/ +# $CAPTION_DIR/ # <image>.txt # image caption. # this is separated to decouple caption writing from the @@ -131,29 +131,45 @@ shopt -s nullglob extglob # # #---------------------------------------------------------------------- - # load config... + CONFIG=${CONFIG:=$(basename ${0%.*}).cfg} +# prepend CFG_ to settings in config... +# NOTE: this is done to prevent them overriding the environment... [ -e $CONFIG ] \ - && source "$CONFIG" + && eval $(cat "$CONFIG" \ + | sed -e 's/^\(\s*\)\([A-Z_]\+=\)/\1CFG_\2/') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # defaults... +# # NOTE: all of these options can be either set in the $CONFIG file or # set in the script env. # NOTE: env takes priority over $CONFIG # if set add pdf annotations of paths to each image... +ANOTATE_IMAGE_PATHS=${ANOTATE_IMAGE_PATHS:=$CFG_ANOTATE_IMAGE_PATHS} ANOTATE_IMAGE_PATHS=${ANOTATE_IMAGE_PATHS:=} # supported formats/extensions... +TEXT_FORMATS=${TEXT_FORMATS:=$CFG_TEXT_FORMATS} TEXT_FORMATS=${TEXT_FORMATS:=txt} + +IMAGE_FORMATS=${IMAGE_FORMATS:=$CFG_IMAGE_FORMATS} IMAGE_FORMATS=${IMAGE_FORMATS:=jpeg|jpg|png|pdf|svg|eps} + +SPREADS_DIR=${SPREADS_DIR:=$CFG_SPREADS_DIR} SPREADS_DIR=${SPREADS_DIR:=spreads/} + +IMAGE_HIRES_DIR=${IMAGE_HIRES_DIR:=$CFG_IMAGE_HIRES_DIR} IMAGE_HIRES_DIR=${IMAGE_HIRES_DIR:=} + +CAPTION_DIR=${CAPTION_DIR:=$CFG_CAPTION_DIR} CAPTION_DIR=${CAPTION_DIR:=captions/} + +TEMPLATE_DIR=${TEMPLATE_DIR:=$CFG_TEMPLATE_DIR} TEMPLATE_DIR=${TEMPLATE_DIR:=templates/} # Default templates @@ -161,18 +177,30 @@ TEMPLATE_DIR=${TEMPLATE_DIR:=templates/} # page components... # page templates... +EMPTY_PAGE=${EMPTY_PAGE:=$CFG_EMPTY_PAGE} EMPTY_PAGE=${EMPTY_PAGE:=emptypage} + +TEXT_PAGE=${TEXT_PAGE:=$CFG_TEXT_PAGE} TEXT_PAGE=${TEXT_PAGE:=textpage} + +IMAGE_PAGE=${IMAGE_PAGE:=$CFG_IMAGE_PAGE} IMAGE_PAGE=${IMAGE_PAGE:=imagepage} # dynamic spread templates... # NOTE: the index here corresponds to the number of images found in a # spread directory... if [ ${#IMAGE_SPREAD[@]} = 0 ] ; then - IMAGE_SPREAD=( - [0]=text-spread - [2]=image-image - ) + if ! [ ${#CFG_IMAGE_SPREAD[@]} = 0 ] ; then + IMAGE_SPREAD=() + for i in ${!CFG_IMAGE_SPREAD[@]} ; do + IMAGE_SPREAD[$i]=${CFG_IMAGE_SPREAD[$i]} + done + else + IMAGE_SPREAD=( + [0]=text-spread + [2]=image-image + ) + fi fi @@ -188,17 +216,18 @@ printhelp(){ echo echo "Arguments:" echo " -h --help - print this help and exit." + echo " -c PATH - load configuration from PATH." echo " -a --annotate" echo " - add annotations with image paths to pages." - echo " --templates=PATH" + echo " --templates PATH" echo " - path to search for templates (default: $TEMPLATE_DIR)." - echo " --single-image-tpl=NAME" + echo " --single-image-tpl NAME" echo " - single image default template (default: ${IMAGE_SPREAD[1]})." - echo " --double-image-tpl=NAME" + echo " --double-image-tpl NAME" echo " - double image default template (default: ${IMAGE_SPREAD[2]})." - echo " --text-spread-tpl=NAME" + echo " --text-spread-tpl NAME" echo " - text spread default template (default: ${IMAGE_SPREAD[0]})." - echo " --captions=PATH" + echo " --captions PATH" echo " - path to search for captions (default: $CAPTION_DIR)." echo echo "Parameters:" @@ -248,31 +277,32 @@ while true ; do ANOTATE_IMAGE_PATHS=1 shift ;; + -c) + $CONFIG="$2" + [ -e "$CONFIG" ] \ + && source "$CONFIG" + shift 2 + ;; --templates) TEMPLATE_DIR=$2 - shift - shift + shift 2 ;; --single-image-tpl) IMAGE_SPREAD[1]=$2 - shift - shift + shift 2 ;; --double-image-tpl) IMAGE_SPREAD[2]=$2 - shift - shift + shift 2 ;; --text-spread-tpl) IMAGE_SPREAD[0]=$2 - shift - shift + shift 2 ;; --captions) CAPTION_DIR=$2 - shift - shift + shift 2 ;; # handle unknown options... @@ -289,7 +319,7 @@ done if [ -z $1 ] ; then - SPREADS_DIR=pages/ + SPREADS_DIR=spreads/ else SPREADS_DIR=$1/ fi |