|
|
|
@ -51,24 +51,27 @@
@@ -51,24 +51,27 @@
|
|
|
|
|
(seq-reduce |
|
|
|
|
;; all-tags is in (tags . tags->files) form |
|
|
|
|
(lambda (all-tags file) |
|
|
|
|
(with-temp-buffer |
|
|
|
|
(insert-file-contents file) |
|
|
|
|
(let ((tags (mapcar #'car (org-get-buffer-tags)))) |
|
|
|
|
(seq-reduce |
|
|
|
|
(lambda (result tag) |
|
|
|
|
(let ((tag-list (car result)) |
|
|
|
|
(tag->file (cdr result))) |
|
|
|
|
(cons |
|
|
|
|
;; Tag list |
|
|
|
|
(if (member tag tag-list) tag-list (sort (cons tag tag-list) 'string<)) |
|
|
|
|
;; tag->file |
|
|
|
|
(cons (cons tag |
|
|
|
|
;; Current value of the the given tag (all the files |
|
|
|
|
;; that contain that tag) |
|
|
|
|
(append (list file) (cdr (assoc tag tag->file)))) |
|
|
|
|
tag->file)))) |
|
|
|
|
tags |
|
|
|
|
all-tags)))) |
|
|
|
|
(if (get-file-global-props file "PAGE") |
|
|
|
|
;; Ignore pages |
|
|
|
|
all-tags |
|
|
|
|
(with-temp-buffer |
|
|
|
|
(insert-file-contents file) |
|
|
|
|
(let ((tags (mapcar #'car (org-get-buffer-tags)))) |
|
|
|
|
(seq-reduce |
|
|
|
|
(lambda (result tag) |
|
|
|
|
(let ((tag-list (car result)) |
|
|
|
|
(tag->file (cdr result))) |
|
|
|
|
(cons |
|
|
|
|
;; Tag list |
|
|
|
|
(if (member tag tag-list) tag-list (sort (cons tag tag-list) 'string<)) |
|
|
|
|
;; tag->file |
|
|
|
|
(cons (cons tag |
|
|
|
|
;; Current value of the the given tag (all the files |
|
|
|
|
;; that contain that tag) |
|
|
|
|
(append (list file) (cdr (assoc tag tag->file)))) |
|
|
|
|
tag->file)))) |
|
|
|
|
tags |
|
|
|
|
all-tags))))) |
|
|
|
|
(all-org-files) |
|
|
|
|
'())) |
|
|
|
|
|
|
|
|
@ -149,7 +152,7 @@ Not pages."
@@ -149,7 +152,7 @@ Not pages."
|
|
|
|
|
(mapconcat |
|
|
|
|
(lambda (cat) |
|
|
|
|
(let ((count (length (cdr (assoc cat (cdr categories)))))) |
|
|
|
|
(format " - [[//categories/%s.html][%s(%s)]]" cat cat count))) |
|
|
|
|
(format " - [[./%s.html][%s(%s)]]" cat cat count))) |
|
|
|
|
(car categories) |
|
|
|
|
"\n"))) |
|
|
|
|
|
|
|
|
@ -160,7 +163,7 @@ Not pages."
@@ -160,7 +163,7 @@ Not pages."
|
|
|
|
|
(mapconcat |
|
|
|
|
(lambda (tag) |
|
|
|
|
(let ((count (length (cdr (assoc tag (cdr tags)))))) |
|
|
|
|
(format " - [[//tags/%s.html][%s(%s)]]" tag tag count))) |
|
|
|
|
(format " - [[./%s.html][%s(%s)]]" tag tag count))) |
|
|
|
|
(car tags) |
|
|
|
|
"\n"))) |
|
|
|
|
|
|
|
|
@ -179,6 +182,61 @@ Not pages."
@@ -179,6 +182,61 @@ Not pages."
|
|
|
|
|
(latest-org-list)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun pair-file-with-date (file) |
|
|
|
|
"Return a pair for the given FILE with date as car and file as cdr." |
|
|
|
|
(cons |
|
|
|
|
(->epoch (get-file-global-props file "DATE")) |
|
|
|
|
file)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun create-tag-pages (project-dir) |
|
|
|
|
"Create all the tag files in the PROJECT-DIR." |
|
|
|
|
(let ((tags (get-all-tags))) |
|
|
|
|
(mapcar |
|
|
|
|
(lambda (tag) |
|
|
|
|
(let ((out (format "%s/orgs/tags/%s.org" project-dir tag)) |
|
|
|
|
(files (cdr (assoc tag (cdr tags))))) |
|
|
|
|
(copy-template |
|
|
|
|
(format "%s/templates/links_template.org" project-dir) |
|
|
|
|
out |
|
|
|
|
(mapconcat |
|
|
|
|
(lambda (file-pair) |
|
|
|
|
(format "- [[file:..%s][%s]]" |
|
|
|
|
(replace-regexp-in-string (regexp-quote (from-root "/orgs")) "" (cdr file-pair) nil 'literal) |
|
|
|
|
(get-file-global-props (cdr file-pair) "TITLE"))) |
|
|
|
|
|
|
|
|
|
(sort |
|
|
|
|
(mapcar #'pair-file-with-date files) |
|
|
|
|
(lambda (x y) (< (car x) (car y)))) |
|
|
|
|
"\n") |
|
|
|
|
tag))) |
|
|
|
|
(car tags)))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun create-category-pages (project-dir) |
|
|
|
|
"Create all the category files in the PROJECT-DIR." |
|
|
|
|
(let ((tags (get-all-categories))) |
|
|
|
|
(mapcar |
|
|
|
|
(lambda (tag) |
|
|
|
|
(let ((out (format "%s/orgs/categories/%s.org" project-dir tag)) |
|
|
|
|
(files (cdr (assoc tag (cdr tags))))) |
|
|
|
|
(copy-template |
|
|
|
|
(format "%s/templates/links_template.org" project-dir) |
|
|
|
|
out |
|
|
|
|
(mapconcat |
|
|
|
|
(lambda (file-pair) |
|
|
|
|
(format "- [[file:..%s][%s]]" |
|
|
|
|
(replace-regexp-in-string (regexp-quote (from-root "/orgs")) "" (cdr file-pair) nil 'literal) |
|
|
|
|
(get-file-global-props (cdr file-pair) "TITLE"))) |
|
|
|
|
|
|
|
|
|
(sort |
|
|
|
|
(mapcar #'pair-file-with-date files) |
|
|
|
|
(lambda (x y) (< (car x) (car y)))) |
|
|
|
|
"\n") |
|
|
|
|
tag))) |
|
|
|
|
(car tags)))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun main () |
|
|
|
|
"The entry point to the build script." |
|
|
|
|
|
|
|
|
@ -217,6 +275,9 @@ Not pages."
@@ -217,6 +275,9 @@ Not pages."
|
|
|
|
|
(from-root "/orgs/tags/index.org") |
|
|
|
|
(tags-org-list)) |
|
|
|
|
|
|
|
|
|
(create-tag-pages project-root) |
|
|
|
|
(create-category-pages project-root) |
|
|
|
|
|
|
|
|
|
(setq org-html-preamble #'preamble-fn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|