Skip to content

Commit

Permalink
fix(ebooks): Fix handling of ISBN input as number or text
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Sep 4, 2024
1 parent 2fa6798 commit d10ee84
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rules/ebooks.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions rules/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rules/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?=
Expand Down

0 comments on commit d10ee84

Please sign in to comment.