Extract ‘publish-get-summary-from-file’
This commit is contained in:
parent
4ccfc01c28
commit
1d6a9213cb
1 changed files with 15 additions and 13 deletions
28
publish.el
28
publish.el
|
@ -52,6 +52,20 @@
|
|||
time
|
||||
(if (= time 1) "" "s")))
|
||||
|
||||
(defun publish-get-summary-from-file (file props)
|
||||
(format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:END:\n\n%s\n\n[[file:%s][Read More]]\n\n"
|
||||
(car (org-publish-find-property file :title props))
|
||||
(file-name-nondirectory file)
|
||||
(format-time-string "[%Y-%m-%d %a %H:%M]" (org-timestamp-to-time (car (org-publish-find-property file :date props))))
|
||||
(file-name-nondirectory file)
|
||||
(car (org-map-entries (lambda () (let ((element-data (cadr (org-element-at-point))))
|
||||
(buffer-substring-no-properties
|
||||
(map-elt element-data :contents-begin)
|
||||
(map-elt element-data :contents-end))))
|
||||
"summary"
|
||||
(list file)))
|
||||
(file-name-nondirectory file)))
|
||||
|
||||
(defun publish-generate-index (props)
|
||||
"Generate an index from my posts.
|
||||
Argument PROPS
|
||||
|
@ -62,19 +76,7 @@ Argument PROPS
|
|||
(insert "#+options: num:nil\n")
|
||||
(insert "\n")
|
||||
(apply 'insert
|
||||
(mapcar (lambda (file)
|
||||
(format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:END:\n\n%s\n\n[[file:%s][Read More]]\n\n"
|
||||
(car (org-publish-find-property file :title props))
|
||||
(file-name-nondirectory file)
|
||||
(format-time-string "[%Y-%m-%d %a %H:%M]" (org-timestamp-to-time (car (org-publish-find-property file :date props))))
|
||||
(file-name-nondirectory file)
|
||||
(car (org-map-entries (lambda () (let ((element-data (cadr (org-element-at-point))))
|
||||
(buffer-substring-no-properties
|
||||
(map-elt element-data :contents-begin)
|
||||
(map-elt element-data :contents-end))))
|
||||
"summary"
|
||||
(list file)))
|
||||
(file-name-nondirectory file)))
|
||||
(mapcar (lambda (file) (publish-get-summary-from-file file props))
|
||||
(take 30 (reverse files))))
|
||||
(write-file "posts/index.org"))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue