From d10ee842cff1bdcea7b87bb15856eb22500f3823 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 4 Sep 2024 11:23:52 +0300 Subject: [PATCH] fix(ebooks): Fix handling of ISBN input as number or text --- rules/ebooks.mk | 2 +- rules/functions.mk | 4 ++-- rules/rules.mk | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/ebooks.mk b/rules/ebooks.mk index 53c5f7b5..e5039336 100644 --- a/rules/ebooks.mk +++ b/rules/ebooks.mk @@ -89,7 +89,7 @@ $(ISBNMETADATAS): $(BUILDDIR)/%_playbooks.json: $$(call pattern_list,$$(call isb (.lang | sub("tr"; "tur") | sub("en"; "eng")) as $$lang | (.date[] | select(."file-as" == "1\\. Basım").text | strptime("%Y-%m") | strftime("D:%Y-%m-01")) as $$date | ([.creator[], .contributor[] | select (.role == "author").text + " [Author]", select (.role == "editor").text + " [Editor]", select (.role == "trl").text + " [Translator]"] | join("; ")) as $$contributors | - (.identifier[] | select(.text == "$*").key) as $$format | + (.identifier[] | select((.text|tostring) == "$*").key) as $$format | [ "ISBN:$*", (if $$isbncount >= 2 and $$format == "paperback" then "No" else "Yes" end), .title, diff --git a/rules/functions.mk b/rules/functions.mk index 06299d8e..dbecf561 100644 --- a/rules/functions.mk +++ b/rules/functions.mk @@ -37,8 +37,8 @@ series_sort = $(shell $(_ENV) SORTORDER=$(SORTORDER) TARGETS="$(TARGETS)" series metainfo = $(shell $(_ENV) $(YQ) -r '$1' < $(PROJECTYAML)) isbntouid = $(call cachevar,$1,uid,$(basename $(notdir $(shell $(_ENV) $(GREP) -l $1 $(YAMLSOURCES))))) isbnmask = $(call cachevar,$1,mask,$(shell $(_ENV) $(PYTHON) -c "import isbnlib; print(isbnlib.mask('$1'))")) -ebookisbn = $(call cachevar,$1,ebook,$(or $(shell $(_ENV) $(YQ) -r '.identifier[]? | select(.key == "ebook" ).text' $1.yml),$(call printisbn,$1))) -printisbn = $(call cachevar,$1,print,$(shell $(_ENV) $(YQ) -r '.identifier[]? | select(.key == "paperback").text' $1.yml)) +ebookisbn = $(call cachevar,$1,ebook,$(or $(shell $(_ENV) $(YQ) -r '.identifier[]? | select(.key == "ebook" ).text|tostring' $1.yml),$(call printisbn,$1))) +printisbn = $(call cachevar,$1,print,$(shell $(_ENV) $(YQ) -r '.identifier[]? | select(.key == "paperback").text|tostring' $1.yml)) ebooktoprint = $(call cachevar,$1,ep,$(call printisbn,$(call isbntouid,$1))) # Utility to modify recursive variables, see http://stackoverflow.com/a/36863261/313192 diff --git a/rules/rules.mk b/rules/rules.mk index f8fd7fc9..46f1a73d 100644 --- a/rules/rules.mk +++ b/rules/rules.mk @@ -31,7 +31,7 @@ SOURCES_DEF := $(filter $(basename $(notdir $(MARKDOWNSOURCES))),$(basename $(no SOURCES ?= $(SOURCES_DEF) TARGETS ?= $(SOURCES) -ISBNS := $(and $(YAMLSOURCES),$(shell $(_ENV) $(YQ) -M -e -r '.identifier[]? | select(.scheme == "ISBN-13").text' $(YAMLSOURCES))) +ISBNS := $(and $(YAMLSOURCES),$(shell $(_ENV) $(YQ) -M -e -r '.identifier[]? | select(.scheme == "ISBN-13").text|tostring' $(YAMLSOURCES))) # List of targets that don't have content but should be rendered anyway MOCKUPSOURCES ?=