From fd902d67a43be8ccd326f67a31461b54155ddfe8 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 18 Aug 2022 23:33:03 +0530 Subject: Introduce :required-metadata setting. * ennum.el (ennum-mandatory-metadata): Delete variable. (ennum-setting): Define the :required-metadata setting. (ennum-blog): Document the :required-metadata property. (ennum--read-post): Use the :required-metadata setting instead of ennum-mandatory-metadata. --- ennum.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ennum.el b/ennum.el index 46d4bd1..28109a5 100644 --- a/ennum.el +++ b/ennum.el @@ -127,6 +127,12 @@ pixels. Association list mapping languages to locales. Defaults to ((\"en\" . \"C\")). +`:required-metadata' + +List of post metadata properties that are required. If any post +does not have the listed metadata properties, an error is +raised. Defaults to (:title :date). + `:store' Path to the ennum store. The store is a temporary directory used @@ -376,7 +382,7 @@ the current state of all its variables." (ennum-with-file-contents filename (let ((metadata (org-export-get-environment 'ennum-html)) (export (apply-partially 'org-export-with-backend 'ennum-html))) - (dolist (key ennum-mandatory-metadata) + (dolist (key (ennum-setting :required-metadata)) (unless (plist-member metadata key) (user-error "Metadata %s not specified" key))) (let* ((tree (org-element-parse-buffer)) @@ -428,9 +434,6 @@ the current state of all its variables." :translation-group (or (plist-get metadata :translation-group) (file-name-base filename))))))) -(defvar ennum-mandatory-metadata - (list :title :date)) - (defun ennum-directory-files (&optional directory full include-directories) "Return recursively the list of all files under DIRECTORY. Files are returned in depth first order. @@ -663,7 +666,8 @@ result as a string." :blog-scheme :index-posts-per-page :image-width :image-link-width :locale-alist :other-files-directory - :store :tag-directory :image-thumbnail-width) + :store :tag-directory :image-thumbnail-width + :required-metadata) (plist-get (org-combine-plists (list :atom-feed-number-of-posts 12 :atom-feed-file "blog.atom" @@ -674,7 +678,8 @@ result as a string." :locale-alist '(("en" . "C")) :store ".ennum" :tag-directory "tag" - :image-thumbnail-width 320) + :image-thumbnail-width 320 + :required-metadata (list :title :date)) ennum-blog) property)) (_ (error "Unknown property %s" property)))) -- cgit v1.2.3