From c8d35bb5d2d7a0857f09e8d38d2c86ae13b3516e Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 24 Jul 2020 17:46:24 +0200 Subject: Add metadata reading support for covers --- utils/cover/cover.scm | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/utils/cover/cover.scm b/utils/cover/cover.scm index cde9c10..0cc573e 100644 --- a/utils/cover/cover.scm +++ b/utils/cover/cover.scm @@ -69,6 +69,17 @@ #\newline)))))) +(define (get-string key alist) + (let ((val (assoc key alist))) + (if (pair? val) + (cdr val) + ""))) +(define (get-list key alist) + (let ((val (assoc key alist))) + (if (pair? val) + (vector->list (cdr val)) + '()))) + (define (metadata->svg metadata outport) (let* (;B5 Paper size @@ -76,15 +87,16 @@ (page-width 176) ;mm (margin 3) ;mm - (isbn "9780201379624") - (book-title "Programación en Python") - (book-subtitle "Introducción a la programación y al lenguaje") + (isbn (if (equal? "" (get-string 'isbn metadata)) + "0000000000000")) + (book-title (get-string 'title metadata)) + (book-subtitle (get-string 'subtitle metadata)) (book-title-before "") ; TODO: Thinking about removing this (book-title-after book-subtitle) - (book-category "Básico") - (book-authors '("Giacomo Tesio" "Ekaitz Zarraga")) - (book-summary " ") - (company-info "") + (book-category (get-string 'category metadata)) + (book-authors (get-list 'author metadata)) + (book-summary (get-string 'summary metadata)) + (company-info (get-string 'company-info metadata)) (main-title-size (let ((size (exact->inexact @@ -198,8 +210,8 @@ (display "" outport) (display (sxml->xml `(svg - (@ (width ,(mm width)) - (height ,(mm height)) + (@ (width ,(mm width)) + (height ,(mm height)) (viewBox ,viewBox)) (defs (style ,style)) -- cgit v1.2.3