html.mk

static html creation framework using make(1) and cpp(1)
Log | Files | Refs | README | LICENSE

commit 88f859f6143012f02497e70e659275d615c973f8
parent 2e73d29918a7bb24edd07c99ef0f179a0f6a59f6
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Sun,  2 May 2021 05:46:43 +0000

mk: use _img/ dir instead of changing filenames

Previously `_cp` was appended to filenames such that make would find them
unique. Instead, use a dedicated _img/ directory such that complicated file
renaming does not need to happen.

Diffstat:
Mmk/html.mk | 14+++++++-------
Mt/img_html.t | 4++--
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/mk/html.mk b/mk/html.mk @@ -71,22 +71,22 @@ depend: ${SRCS:.in=.depend} _SUBDIRUSE .SUFFIXES: .jpg .SUFFIXES: .png .jpeg.img_html .jpg.img_html .png.img_html: - @# Copy original image to object dir with `_cp' appended to file name. - @# Make gets confused when two files have the same names - @# in different directories. - cp $? ${.OBJDIR}/${<F:R}_cp.${<F:E} + mkdir -p ${.OBJDIR}/_img + cp $? ${.OBJDIR}/_img/ @# Generate thumbnail of image with `_thumb' appended to file name. - convert -resize 710x $? ${<F:R}_thumb.${<F:E} + convert -resize 800x $? ${.OBJDIR}/_img/${<F:R}_thumb.${<F:E} + @# @# Create HTML fragment that uses the thumbnail as a base image @# that is a link to the full size (copied) image, like this: @# @# <a href="pic_cp.jpg"><img src="pic_thumb.jpg" @# - @# NOTE: The <img> tag is not closed! You must close it, hopefully with: + @# NOTE: The <img> tag is not closed! You must close it, maybe with: @# alt="description of image for blind people" /></a> - echo "\t<a href='${<F:R}_cp.${<F:E}'><img src='${<F:R}_thumb.${<F:E}' " > $@ + @# + echo "\t<a href='_img/${<F}'><img src='_img/${<F:R}_thumb.${<F:E}' " > $@ # # Generate `*_html' html fragments that link to videos using <video> tag. diff --git a/t/img_html.t b/t/img_html.t @@ -54,8 +54,8 @@ is( $? >> 8, 0, 'make exit status' ); my $index_good = "\n\n"; for my $sfx (@sfxs) { - my $cp_file = "pic_${sfx}_cp.${sfx}"; - my $thumb_file = "pic_${sfx}_thumb.${sfx}"; + my $cp_file = catfile( '_img', "pic_${sfx}.${sfx}" ); + my $thumb_file = catfile( '_img', "pic_${sfx}_thumb.${sfx}" ); file_exists_ok( catfile( $cmd->workdir, $cp_file ) ); file_exists_ok( catfile( $cmd->workdir, $thumb_file ) );