summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--org-conf.el81
1 files changed, 66 insertions, 15 deletions
diff --git a/org-conf.el b/org-conf.el
index bf1d50d..b39bbae 100644
--- a/org-conf.el
+++ b/org-conf.el
@@ -546,7 +546,7 @@ If DESC is non-`nil', then it is the description of the new link."
;;; publishing settings
-;;;;; Custom preamble for the sidebar
+;;;; Custom preamble for the sidebar
(defvar durand-org-publish-sidebar nil
"The sidebar that provides the navigation of the website.")
@@ -563,7 +563,7 @@ If DESC is non-`nil', then it is the description of the new link."
"Return the sidebar."
durand-org-publish-sidebar)
-;;;;;; Add a custom head
+;;;;; Add a custom head
(defvar durand-org-publish-css-file nil
"A custom css-file for publishing.")
@@ -579,7 +579,11 @@ href=\"website.css\"/>")
"<link rel='shortcut icon' \
href='https://jsdurand.xyz/favicon.ico'/>")
-;;;;; Projects settings
+;;;; Don't include JavaScript in the HTML
+
+(setq org-html-head-include-scripts nil)
+
+;;;; Projects settings
(setq org-publish-project-alist
(list
@@ -700,9 +704,9 @@ href='https://jsdurand.xyz/favicon.ico'/>")
:html-home/up-format ""
:html-preamble #'durand-org-publish-insert-sidebar)))
-;;;;; Sitemap function
+;;;; Sitemap function
-;;;;;; A hack to insert some string in the sitemap file.
+;;;;; A hack to insert some string in the sitemap file.
(defvar durand-sitemap-custom-string-alist nil
"An association list that relates the title of the sitemap and the string to insert.")
@@ -721,7 +725,7 @@ life."
"My Mathematics-related articles are put here."
"math-atom.xml")))
-;;;;;; Custom sitemap function
+;;;;; Custom sitemap function
(defun durand-org-publish-sitemap (title rep)
"Return the sitemap as a string.
@@ -746,7 +750,7 @@ project. Use such functions as `org-list-to-org' or
:isep "|---|"))
(caddr (assoc title durand-sitemap-custom-string-alist #'string=))))
-;;;;;; Custom sitemap format
+;;;;; Custom sitemap format
;; NOTE: I use a table to style the entries.
@@ -770,12 +774,12 @@ PROJECT is the current project."
entry
(org-publish-find-title entry project)))
-;;;;; Post-processing
+;;;; Post-processing
;; I post-process the sitemaps in order to generate a section
;; of "latest updates" on the index page.
-;;;;;; fix: plist-get not working
+;;;;; fix: plist-get not working
;; For some reason the built-in `plist-get' does not work...
(defun durand-org-publish-plist-get (prop plist)
@@ -788,7 +792,7 @@ PROJECT is the current project."
((setq plist (cddr plist)))))
res))
-;;;;;; Helper for converting the format from `parse-time-string'
+;;;;; Helper for converting the format from `parse-time-string'
(defun durand-org-publish-convert-time (spec)
"Convert SPEC to a valid time value.
@@ -807,7 +811,7 @@ are present."
(or hour 0))
(cdddr spec)))))
-;;;;;; Post process to generate the index page
+;;;;; Post process to generate the index page
(defvar durand-org-index-entries-max-num 10
"The maximal number of entries to show on the index page.")
@@ -1018,9 +1022,56 @@ The feeds are generated by the function `durand-org-generate-atom-feed'."
(reverse temp)))
(reverse temp)))))))
-;;;;; Atom feed
+;;;;; add date/time info
+
+;; I want to show the date of the article below the title, so that it
+;; is clearer when the article is written. The default display at the
+;; bottom of the page is too hidden.
-;;;;;; Fixed pre-amble, template, and post-amble.
+(defun durand-org-publish-html-advice (html-file-name)
+ "Advice `org-html-publish-html' to add a date/time info below the \
+title."
+ (with-temp-buffer
+ (insert-file-contents html-file-name)
+ (goto-char (point-min))
+ (cond
+ ((search-forward "h1 class=\"title\"" nil t)
+ ;; if it does not have a title, we do not add a time info.
+ (search-forward "</h1>" nil)
+ ;; if it already has a time info, don't generate again
+ (cond ((save-excursion
+ (forward-char 1)
+ (looking-at-p "<time datetime=")))
+ (t
+ (let* ((date (let (temp)
+ (save-excursion
+ (goto-char (point-max))
+ (cond
+ ((search-backward "<p class=\"date\">Date: " nil t)
+ (setq temp (match-end 0))
+ (buffer-substring-no-properties
+ temp (progn
+ (search-forward "</p>")
+ (match-beginning 0))))))))
+ (date-time (and date
+ (encode-time
+ (append
+ (durand-take 8 (parse-time-string date))
+ (list 28800))))))
+ (cond
+ (date
+ (insert
+ (format
+ "\n<time datetime=\"%s\">%s</time>\n"
+ (format-time-string "%FT%T%z" date-time)
+ (format-time-string "%F" date-time)))
+ (write-region nil nil html-file-name))))))))))
+
+(advice-add #'org-html-publish-to-html :filter-return #'durand-org-publish-html-advice)
+
+;;;; Atom feed
+
+;;;;; Fixed pre-amble, template, and post-amble.
(defvar durand-org-atom-titles-alist nil
"An assocuation list of Atom feed titles with the project name.")
@@ -1087,7 +1138,7 @@ CONTENT: a short content.
(setq durand-org-atom-postamble
"</feed>")
-;;;;;; Format time easily
+;;;;; Format time easily
(defun durand-org-atom-format-time (time)
"Format TIME in an acceptable way."
@@ -1100,7 +1151,7 @@ CONTENT: a short content.
(/ (car (current-time-zone)) 3600)
(% (car (current-time-zone)) 3600))))
-;;;;;; The Atom feeds are generated in this function.
+;;;;; The Atom feeds are generated in this function.
(defun durand-org-generate-atom-feed (project file-name entries)
"Generate an Atom feed for ENTRIES and save in FILE-NAME.