branch: externals/calibre
commit feb2745f2dcb3a7ef245bb47f5be9e2e07fdfad4
Author: Kjartan Oli Agustsson <[email protected]>
Commit: Kjartan Oli Agustsson <[email protected]>

    Add ability to view detailed information about a particular book
    
    * calibre-info.el: New file.
    (calibre-info-view-book): New function.
---
 calibre-info.el | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/calibre-info.el b/calibre-info.el
new file mode 100644
index 0000000000..41c34cd0eb
--- /dev/null
+++ b/calibre-info.el
@@ -0,0 +1,83 @@
+;;; calibre-info.el --- View details about a particular book -*- 
lexical-binding:t -*-
+
+;; Copyright (C) 2023-2025  Free Software Foundation, Inc.
+
+;; Author: Kjartan Oli Agustsson <[email protected]>
+;; Maintainer: Kjartan Oli Agustsson <[email protected]>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; View detailed information about a particular book.
+
+;;; Code:
+(require 'calibre-book)
+(require 'calibre-core)
+
+(declare-function calibre-library-book-at-point "calibre-library" ())
+
+(defun calibre-info-view-book (book)
+  "Display information about BOOK."
+  (interactive (list (calibre-library-book-at-point))
+               calibre-library-mode)
+  (let ((buffer (get-buffer-create (format "*%s*" (calibre-book-title book)))))
+    (with-current-buffer buffer
+      (let ((inhibit-read-only t))
+        (erase-buffer)
+        (insert "Title: " (calibre-book-title book) "\n")
+        (insert "Authors:\n")
+        (dolist (author (calibre-book-authors book))
+          (insert " " author "\n"))
+        (when (calibre-book-publisher book)
+          (insert "Publisher: " (calibre-book-publisher book) "\n"))
+        (insert "Published: "
+                (if (calibre-book-pubdate book)
+                    (format-time-string calibre-library-time-format
+                                        (calibre-book-pubdate book))
+                  "Invalid")
+                "\n")
+        (insert "Last modified: "
+                (if (calibre-book-last-modified book)
+                    (format-time-string calibre-library-time-format
+                                        (calibre-book-last-modified book))
+                  "Invalid")
+                "\n")
+        (when (calibre-book-series book)
+          (insert "Series: " (calibre-book-series book)
+                  " (book " (number-to-string
+                             (calibre-book-series-index book))
+                  ")\n"))
+        (when (calibre-book-tags book)
+          (insert "Tags:\n")
+          (dolist (tag (calibre-book-tags book))
+            (insert " " tag "\n")))
+        (insert "\n")
+        (insert "Formats:\n")
+        (dolist (format (calibre-book-formats book))
+          (insert " " (upcase (symbol-name format)) "\n"))
+        (when (calibre-book-summary book)
+          (insert "\n")
+          (insert
+           (with-temp-buffer
+             (insert (calibre-book-summary book))
+             (goto-char (point-min))
+             (while (not (eobp))
+               (fill-paragraph)
+               (forward-paragraph))
+             (buffer-substring (point-min) (point-max))))))
+      (read-only-mode t))
+    (display-buffer buffer)))
+
+(provide 'calibre-info)
+;;; calibre-info.el ends here

Reply via email to