From 10cf6bbc49155a719d0eb4d360b72ad340074f65 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 25 Feb 2020 23:32:48 -0800 Subject: Update reading time generation --- posts/a-very-important-blog-post.org | 1 - posts/my-new-emacs-configuration.org | 1 - posts/new-blog.org | 1 - posts/wdocker-compose.org | 1 - project-config.el | 16 +++++++++++++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/posts/a-very-important-blog-post.org b/posts/a-very-important-blog-post.org index 866f564..df9609e 100644 --- a/posts/a-very-important-blog-post.org +++ b/posts/a-very-important-blog-post.org @@ -1,5 +1,4 @@ #+TITLE: A very important blog post -#+SUBTITLE: Reading time: 0 minutes #+ID: a-very-important-blog-post #+PUBDATE: <2020-02-23 Sun 18:28> diff --git a/posts/my-new-emacs-configuration.org b/posts/my-new-emacs-configuration.org index 9162f0c..56902a2 100644 --- a/posts/my-new-emacs-configuration.org +++ b/posts/my-new-emacs-configuration.org @@ -1,5 +1,4 @@ #+TITLE: My new Emacs configuration -#+SUBTITLE: Reading time: 0 minutes #+ID: my-new-emacs-configuration #+PUBDATE: <2019-10-06 Sun 18:18> #+TAGS: draft diff --git a/posts/new-blog.org b/posts/new-blog.org index 496b0f3..68bc483 100644 --- a/posts/new-blog.org +++ b/posts/new-blog.org @@ -1,5 +1,4 @@ #+TITLE: New Blog -#+SUBTITLE: Reading time: 4 minutes #+ID: new-blog #+PUBDATE: <2019-10-06 Sun 12:55> diff --git a/posts/wdocker-compose.org b/posts/wdocker-compose.org index 32a65f1..eaa13e4 100644 --- a/posts/wdocker-compose.org +++ b/posts/wdocker-compose.org @@ -1,5 +1,4 @@ #+TITLE: Making docker-compose easier with wdocker -#+SUBTITLE: Reading time: 3 minutes #+PUBDATE: <2016-02-21> #+FILE_TAGS: wdocker docker docker-compose #+OPTIONS: num:nil toc:nil diff --git a/project-config.el b/project-config.el index 96cb365..b41fb1e 100644 --- a/project-config.el +++ b/project-config.el @@ -12,6 +12,7 @@ :publishing-function org-html-publish-to-html :html-head "" :html-link-home "https://ryuslash.gitlab.io/ryuslash.org/" + :html-link-up nil :html-link-user-abs-url t) ("ryuslash.org Posts" :base-directory "posts" @@ -21,7 +22,11 @@ :publishing-function org-html-publish-to-html :html-head "" :html-link-home "https://ryuslash.gitlab.io/ryuslash.org/" - :html-link-user-abs-url t) + :html-link-up "../" + :html-link-user-abs-url t + :html-preamble (lambda (_) + (project-config-print-reading-time + (project-config-reading-time (buffer-file-name))))) ("ryuslash-rss" :base-directory "." :publishing-directory "public_html" @@ -56,14 +61,19 @@ (org-forward-element)) alist))) +(defun project-config-print-reading-time (time) + (format "%d minute%s" + time + (if (= time 1) "" "s"))) + (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" + (format "* %s\n :PROPERTIES:\n :ID: %s\n :PUBDATE: %s\n :END:\n\n %s\n[[file:%s][Read more (%s)]]\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))) + (project-config-print-reading-time (alist-get 'LENGTH alist)))) (defun project-config-reading-time (file) (with-current-buffer (find-file file) -- cgit v1.2.3-54-g00ecf