summaryrefslogtreecommitdiff
path: root/utils/cover
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2020-07-24 17:46:24 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2020-07-24 17:46:24 +0200
commitc8d35bb5d2d7a0857f09e8d38d2c86ae13b3516e (patch)
tree8a34df4080de915a096ec66145123ac9663c8b37 /utils/cover
parentc57af42138df31b2925752ca3b67bb0116883f36 (diff)
Add metadata reading support for covers
Diffstat (limited to 'utils/cover')
-rw-r--r--utils/cover/cover.scm30
1 files 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 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" outport)
(display (sxml->xml
`(svg
- (@ (width ,(mm width))
- (height ,(mm height))
+ (@ (width ,(mm width))
+ (height ,(mm height))
(viewBox ,viewBox))
(defs
(style ,style))