diff --git a/docs/changelog.lisp b/docs/changelog.lisp index 9966295..a68adb8 100644 --- a/docs/changelog.lisp +++ b/docs/changelog.lisp @@ -9,6 +9,9 @@ "ASDF" "REPL" "HTTP")) + (0.2.0 2024-05-26 + "* `Excerpt` field was added to the `content` objects such as posts and pages. It can be used in the description HTML tags. + * Filters `remove-html-tags` and `first-line` were added to the template engine base on Closure Templates.") (0.1.1 2024-05-11 "* Fixed error in `serve` command when xdg-open ultility is not available. * Installation using Roswell was updated in the docs.") diff --git a/qlfile.lock b/qlfile.lock index 45e3660..7d03029 100644 --- a/qlfile.lock +++ b/qlfile.lock @@ -1,11 +1,11 @@ ("quicklisp" . (:class qlot/source/dist:source-dist - :initargs (:distribution "https://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest) + :initargs (:distribution "http://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest) :version "2023-10-21")) ("ultralisp" . (:class qlot/source/dist:source-dist - :initargs (:distribution "https://dist.ultralisp.org/" :%version :latest) - :version "20240504133502")) + :initargs (:distribution "http://dist.ultralisp.org/" :%version :latest) + :version "20240526155501")) ("slynk" . (:class qlot/source/github:source-github :initargs (:repos "svetlyak40wt/sly" :ref nil :branch "patches" :tag nil) diff --git a/src/content.lisp b/src/content.lisp index b2a27cf..34cfdd9 100644 --- a/src/content.lisp +++ b/src/content.lisp @@ -359,7 +359,6 @@ (content-format content))) - (defmethod content-html-excerpt ((content content-from-file)) (let* ((separator (content-excerpt-separator content)) (full-content (content-text content)) @@ -381,6 +380,8 @@ (content-title content) (gethash "html" hash) (content-html content) + (gethash "excerpt" hash) + (content-html-excerpt content) (gethash "created-at" hash) (content-created-at content) diff --git a/src/content/reader.lisp b/src/content/reader.lisp index 794b679..c90510a 100644 --- a/src/content/reader.lisp +++ b/src/content/reader.lisp @@ -42,7 +42,7 @@ appending (parse-initarg line)))) -(-> read-content (pathname &key (:separator string)) +(-> read-content-file (pathname &key (:separator string)) (values proper-list &optional)) (defun read-content-file (file &key (separator *default-metadata-separator*)) diff --git a/src/index/paginated.lisp b/src/index/paginated.lisp index bdfaab5..5e4132f 100644 --- a/src/index/paginated.lisp +++ b/src/index/paginated.lisp @@ -93,7 +93,7 @@ can be overriden by PAGE-FILENAME-FN argument. The same way page title may be overriden by providing a function as PAGE-TITLE-FN argument. -# Arguments: +**Arguments:** **PAGE-FILENAME-FN**: diff --git a/src/index/tags.lisp b/src/index/tags.lisp index df0fa5c..1fc48aa 100644 --- a/src/index/tags.lisp +++ b/src/index/tags.lisp @@ -110,7 +110,7 @@ can be overriden by PAGE-FILENAME-FN argument. The same way page title may be overriden by providing a function as PAGE-TITLE-FN argument. -# Arguments: +**Arguments:** **PAGE-FILENAME-FN**: diff --git a/src/site.lisp b/src/site.lisp index 314b815..59ea1f4 100644 --- a/src/site.lisp +++ b/src/site.lisp @@ -50,7 +50,7 @@ :type string :reader site-title :documentation "Site's title.") - (description :initarg :title + (description :initarg :description :type string :reader site-description :documentation "Site's description.") diff --git a/src/themes/closure-template.lisp b/src/themes/closure-template.lisp index 36f8229..1c3154d 100644 --- a/src/themes/closure-template.lisp +++ b/src/themes/closure-template.lisp @@ -12,7 +12,9 @@ (:import-from #:str #:replace-all) (:import-from #:local-time - #:format-timestring)) + #:format-timestring) + (:import-from #:html2text + #:html2text)) (in-package #:staticl/themes/closure-template) @@ -44,6 +46,8 @@ ;; as "date" rule: (define-print-syntax print-datetime "datetime" (:constant t)) (define-print-syntax print-date "date" (:constant t)) + (define-print-syntax remove-html-tags "remove-html-tags" (:constant t)) + (define-print-syntax first-line "first-line" (:constant t)) (flet ((format-date (params end value) (declare (ignore params end)) @@ -54,13 +58,33 @@ (declare (ignore params end)) (when value (format-timestring nil value - :format (datetime-format theme))))) + :format (datetime-format theme)))) + (remove-html-tags (params end value) + (declare (ignore params end)) + (when value + (html2text value + :tags-to-remove (list :img + :style + :script)))) + (first-line (params end value) + (declare (ignore params end)) + (when value + (first + (str:split #\Newline value + :omit-nulls t + :limit 2))))) (register-print-handler :common-lisp-backend 'print-date :function #'format-date) (register-print-handler :common-lisp-backend 'print-datetime - :function #'format-datetime)))) + :function #'format-datetime) + (register-print-handler :common-lisp-backend + 'remove-html-tags + :function #'remove-html-tags) + (register-print-handler :common-lisp-backend + 'first-line + :function #'first-line)))) (defmethod initialize-instance :after ((obj closure-template) &rest initargs &key path &allow-other-keys) (declare (ignore initargs))