Function: image-dired-gallery-generate
image-dired-gallery-generate is an interactive and byte-compiled
function defined in image-dired.el.gz.
This command is obsolete since 29.1.
Signature
(image-dired-gallery-generate)
Documentation
Generate gallery pages.
First we create a couple of Lisp structures from the database to make
it easier to generate, then HTML-files are created in
image-dired-gallery-dir.
Probably introduced at or before Emacs version 29.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/image/image-dired.el.gz
(defun image-dired-gallery-generate ()
"Generate gallery pages.
First we create a couple of Lisp structures from the database to make
it easier to generate, then HTML-files are created in
`image-dired-gallery-dir'."
(declare (obsolete nil "29.1"))
(interactive)
(if (eq 'per-directory image-dired-thumbnail-storage)
(error "Currently, gallery generation is not supported \
when using per-directory thumbnail file storage"))
(with-suppressed-warnings ((obsolete image-dired--create-gallery-lists))
(image-dired--create-gallery-lists))
(let ((tags image-dired-tag-file-list)
(index-file (format "%s/index.html" image-dired-gallery-dir))
count tag tag-file
comment file-tags tag-link tag-link-list)
;; Make sure gallery root exist
(if (file-exists-p image-dired-gallery-dir)
(if (not (file-directory-p image-dired-gallery-dir))
(error "Variable image-dired-gallery-dir is not a directory"))
(with-file-modes #o700
(make-directory image-dired-gallery-dir)))
;; Open index file
(with-temp-file index-file
(if (file-exists-p index-file)
(insert-file-contents index-file))
(insert "<html>\n")
(insert " <body>\n")
(insert " <h2>Image-Dired Gallery</h2>\n")
(insert (format "<p>\n Gallery generated %s\n <p>\n"
(current-time-string)))
(insert " <h3>Tag index</h3>\n")
(setq count 1)
;; Pre-generate list of all tag links
(dolist (curr tags)
(setq tag (car curr))
(when (not (member tag image-dired-gallery-hidden-tags))
(setq tag-link (format "<a href=\"%d.html\">%s</a>" count tag))
(if tag-link-list
(setq tag-link-list
(append tag-link-list (list (cons tag tag-link))))
(setq tag-link-list (list (cons tag tag-link))))
(incf count)))
(setq count 1)
;; Main loop where we generated thumbnail pages per tag
(dolist (curr tags)
(setq tag (car curr))
;; Don't display hidden tags
(when (not (member tag image-dired-gallery-hidden-tags))
;; Insert link to tag page in index
(insert (format " %s<br>\n" (cdr (assoc tag tag-link-list))))
;; Open per-tag file
(setq tag-file (format "%s/%s.html" image-dired-gallery-dir count))
(with-temp-file tag-file
(if (file-exists-p tag-file)
(insert-file-contents tag-file))
(erase-buffer)
(insert "<html>\n")
(insert " <body>\n")
(insert " <p><a href=\"index.html\">Index</a></p>\n")
(insert (format " <h2>Images with tag "%s"</h2>" tag))
;; Main loop for files per tag page
(dolist (file (cdr curr))
(unless (image-dired-hidden-p file)
;; Insert thumbnail with link to full image
(insert
(format "<a href=\"%s/%s\"><img src=\"%s/%s\"%s></a>\n"
image-dired-gallery-image-root-url
(file-name-nondirectory file)
image-dired-gallery-thumb-image-root-url
(file-name-nondirectory (image-dired-thumb-name file)) file))
;; Insert comment, if any
(if (setq comment (cdr (assoc file image-dired-file-comment-list)))
(insert (format "<br>\n%s<br>\n" comment))
(insert "<br>\n"))
;; Insert links to other tags, if any
(when (> (length
(setq file-tags (assoc file image-dired-file-tag-list))) 2)
(insert "[ ")
(dolist (extra-tag file-tags)
;; Only insert if not file name or the main tag
(if (and (not (equal extra-tag tag))
(not (equal extra-tag file)))
(insert
(format "%s " (cdr (assoc extra-tag tag-link-list))))))
(insert "]<br>\n"))))
(insert " <p><a href=\"index.html\">Index</a></p>\n")
(insert " </body>\n")
(insert "</html>\n"))
(incf count)))
(insert " </body>\n")
(insert "</html>"))))