branch: externals/calibre
commit 89e52d61c07f759506f41ad843960c12e1e6723d
Author: Kjartan Óli Ágústsson <[email protected]>
Commit: Kjartan Óli Ágústsson <[email protected]>

    Only allow single publisher per book
    
    * calibre-book.el (calibre-book): Replace publisher slot with publisher.
    (calibre-book-publishers, calibre-book-publisher): Rename
    calibre-book-publishers to calibre-book-publisher.
    * calibre-db.el (calibre-make-book, calibre-library-columns,
    calibre-library--header-format, calibre-book--print-info): Adjust to
    the singular publisher field.
    (calibre-db--get-book-publishers): Remove
    (calibre-db--get-book-publisher): Add
---
 calibre-book.el |  9 +++++----
 calibre-db.el   | 22 +++++++++++-----------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/calibre-book.el b/calibre-book.el
index 801c78f86e..991e599b7c 100644
--- a/calibre-book.el
+++ b/calibre-book.el
@@ -43,9 +43,10 @@ TIMESTAMP is a string of the form YYYY-MM-DD 
HH:MM:SS.xxxxxx+00:00."
    (authors :initarg :authors
             :type list
             :documentation "The authors of the book.")
-   (publishers :initarg :publishers
-               :type list
-               :documentation "The publishers of the book.")
+   (publisher :initarg :publisher
+               :type (or string null)
+               :documentation "The publisher of the book."
+               :custom (choice (const nil) string))
    (series :initarg :series
            :initform nil
            :type (or string null)
@@ -84,7 +85,7 @@ for private functions."
 (calibre-book--slot id)
 (calibre-book--slot title)
 (calibre-book--slot authors)
-(calibre-book--slot publishers)
+(calibre-book--slot publisher)
 (calibre-book--slot series)
 (calibre-book--slot series-index)
 (calibre-book--slot tags)
diff --git a/calibre-db.el b/calibre-db.el
index 55a25301fa..ddc3b71222 100644
--- a/calibre-db.el
+++ b/calibre-db.el
@@ -35,7 +35,7 @@ ENTRY is a list of the form:
     (calibre-book :id id
                   :title title
                   :authors (calibre-db--get-book-authors id)
-                  :publishers (calibre-db--get-book-publishers id)
+                  :publisher (calibre-db--get-book-publisher id)
                   :series series
                   :series-index series-index
                   :timestamp (calibre-parse-timestamp timestamp)
@@ -54,13 +54,13 @@ FROM authors
 INNER JOIN books_authors_link al ON authors.id = al.author
 WHERE al.book = ?" `[,id])))
 
-(defun calibre-db--get-book-publishers (id)
-  "Return a list of publishers for the book identified by ID."
-  (flatten-list (sqlite-select (calibre--db)
+(defun calibre-db--get-book-publisher (id)
+  "Return the publisher of the book identified by ID."
+  (car (flatten-list (sqlite-select (calibre--db)
                                "SELECT publishers.name
 FROM publishers
 INNER JOIN books_publishers_link pl ON publishers.id = pl.publisher
-WHERE pl.book = ?" `[,id])))
+WHERE pl.book = ?" `[,id]))))
 
 (defun calibre-db--get-book-file-name (id)
   "Return the file name, sans extension, of the book identified by ID."
@@ -297,7 +297,7 @@ string."
 (defcustom calibre-library-columns '((id . 4)
                                      (title . 35)
                                      (authors . 20)
-                                     (publishers . 10)
+                                     (publisher . 10)
                                      (series . 15)
                                      (series-index . 3)
                                      (tags . 10)
@@ -312,7 +312,7 @@ column should have."
                    (const :tag "ID" id)
                    (const :tag "Title" title)
                    (const :tag "Author(s)" authors)
-                   (const :tag "Publisher(s)" publishers)
+                   (const :tag "Publisher(s)" publisher)
                    (const :tag "Series" series)
                    (const :tag "Series Index" series-index)
                    (const :tag "Tags" tags)
@@ -323,7 +323,7 @@ column should have."
          (set-default symbol value)
          (calibre-library--set-header)
          (calibre-library--refresh))
-  :package-version '("calibre" . "0.1.0")
+  :package-version '("calibre" . "1.1.0")
   :group 'calibre)
 
 (defun calibre-library--header-format ()
@@ -341,7 +341,7 @@ with values determined by `calibre-library-columns'."
                        :right-align t))
                  (title `("Title" ,width t))
                  (authors `("Author(s)" ,width t))
-                 (publishers `("Publisher(s)" ,width t))
+                 (publisher `("Publisher" ,width t))
                  (series `("Series" ,width (lambda (a b)
                                              (calibre-book-sort-by-series (car 
a) (car b)))))
                  (series-index `("#" ,width (lambda (a b)
@@ -358,14 +358,14 @@ with values determined by `calibre-library-columns'."
   "Return list suitable as a value of `tabulated-list-entries'.
 BOOK is a `calibre-book'."
   (list book
-        (with-slots (id title authors publishers series series-index tags 
formats pubdate) book
+        (with-slots (id title authors publisher series series-index tags 
formats pubdate) book
           (vconcat (mapcar (lambda (x)
                              (let ((column (car x)))
                                (cl-case column
                                  (id (int-to-string id))
                                  (title title)
                                  (authors (string-join authors ", "))
-                                 (publishers (string-join publishers ", "))
+                                 (publisher (if (not publisher) "" publisher))
                                  (series (if (not series) "" series))
                                  (series-index (if series (format "%.1f" 
series-index) ""))
                                  (tags (string-join tags ", "))

Reply via email to