2019-10-06 21:57:14 +02:00
|
|
|
(require 'ox-publish)
|
|
|
|
(require 'ox-rss)
|
|
|
|
|
2019-10-07 03:21:13 +02:00
|
|
|
(setq org-export-exclude-tags '("noexport" "draft"))
|
|
|
|
|
2019-10-06 21:57:14 +02:00
|
|
|
(setq org-publish-project-alist
|
|
|
|
'(("ryuslash.org"
|
|
|
|
:base-directory "."
|
|
|
|
:publishing-directory "public_html"
|
|
|
|
:exclude "\\`README.org\\'"
|
|
|
|
:base-extension "org"
|
2019-10-07 03:29:15 +02:00
|
|
|
:publishing-function org-html-publish-to-html
|
2020-02-24 05:23:42 +01:00
|
|
|
:html-head "<link rel=\"stylesheet\" href=\"assets/css/main.css\" type=\"text/css\"/>"
|
|
|
|
:html-link-home "https://ryuslash.gitlab.io/ryuslash.org/"
|
2020-02-24 05:26:46 +01:00
|
|
|
:html-link-user-abs-url t)
|
|
|
|
("ryuslash.org Posts"
|
|
|
|
:base-directory "posts"
|
|
|
|
:publishing-directory "public_html/posts"
|
|
|
|
:exclude "\\`README.org\\'"
|
|
|
|
:base-extension "org"
|
|
|
|
:publishing-function org-html-publish-to-html
|
|
|
|
:html-head "<link rel=\"stylesheet\" href=\"../assets/css/main.css\" type=\"text/css\"/>"
|
|
|
|
:html-link-home "https://ryuslash.gitlab.io/ryuslash.org/"
|
|
|
|
:html-link-user-abs-url t)
|
2019-10-06 21:57:14 +02:00
|
|
|
("ryuslash-rss"
|
|
|
|
:base-directory "."
|
|
|
|
:publishing-directory "public_html"
|
|
|
|
:exclude ".*"
|
|
|
|
:include ("index.org")
|
|
|
|
:base-extension "org"
|
|
|
|
:publishing-function org-rss-publish-to-rss)))
|
|
|
|
|
|
|
|
(defun publish-ryuslash.org ()
|
2020-02-24 05:23:42 +01:00
|
|
|
(with-current-buffer (find-file "index.org")
|
|
|
|
(org-update-all-dblocks)
|
|
|
|
(save-buffer))
|
2019-10-06 21:57:14 +02:00
|
|
|
(org-publish-all))
|
2020-02-24 05:23:42 +01:00
|
|
|
|
|
|
|
(defun project-config-parse-element (org-element)
|
|
|
|
(pcase org-element
|
2020-02-24 06:02:26 +01:00
|
|
|
(`(keyword ,something) (cons (intern (plist-get something :key))
|
2020-02-24 05:23:42 +01:00
|
|
|
(plist-get something :value)))
|
|
|
|
(`(paragraph ,something) (cons
|
2020-02-24 06:02:26 +01:00
|
|
|
'BODY
|
2020-02-24 05:23:42 +01:00
|
|
|
(buffer-substring-no-properties
|
|
|
|
(plist-get something :contents-begin)
|
|
|
|
(plist-get something :contents-end))))))
|
|
|
|
|
|
|
|
(defun project-config-parse-document (document)
|
|
|
|
(with-current-buffer (find-file document)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let (alist)
|
2020-02-24 06:02:26 +01:00
|
|
|
(while (not (alist-get 'BODY alist nil nil #'equal))
|
2020-02-24 05:23:42 +01:00
|
|
|
(setq alist (cons (project-config-parse-element (org-element-at-point))
|
|
|
|
alist))
|
|
|
|
(org-forward-element))
|
|
|
|
alist)))
|
|
|
|
|
2020-02-24 06:02:26 +01:00
|
|
|
(defun project-config-print-element (alist)
|
|
|
|
(format "* %s\n :PROPERTIES:\n :ID: %s\n :PUBDATE: %s\n :END:\n\n %s\n[[file:%s][Read more (%d minutes)]]\n"
|
|
|
|
(alist-get 'TITLE alist)
|
|
|
|
(alist-get 'ID alist)
|
|
|
|
(alist-get 'PUBDATE alist)
|
|
|
|
(alist-get 'BODY alist)
|
|
|
|
(alist-get 'NAME alist)
|
|
|
|
(alist-get 'LENGTH alist)))
|
|
|
|
|
|
|
|
(defun project-config-reading-time (file)
|
|
|
|
(with-current-buffer (find-file file)
|
2020-02-26 02:18:20 +01:00
|
|
|
(max 1 (/ (count-words (point-min) (point-max)) 228))))
|
2020-02-24 06:02:26 +01:00
|
|
|
|
|
|
|
(defun project-config-print-file (file)
|
|
|
|
(project-config-print-element
|
|
|
|
(append `((NAME . ,(concat "posts/" file))
|
|
|
|
(LENGTH . ,(project-config-reading-time (concat "posts/" file))))
|
|
|
|
(project-config-parse-document (concat "posts/" file)))))
|
2020-02-24 05:23:42 +01:00
|
|
|
|
|
|
|
(defun org-dblock-write:blog-posts (params)
|
|
|
|
(let ((files (cl-remove-if (lambda (item) (string-prefix-p "." item)) (directory-files "posts"))))
|
2020-02-24 06:02:26 +01:00
|
|
|
(insert (format "%s" (apply #'concat (mapcar #'project-config-print-file files))))))
|