-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
export-course.el
64 lines (54 loc) · 2.29 KB
/
export-course.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;; TODO: swap the theme to be more easily readable on white background
(defun nix-course--clean-dir (file-liste)
(nix-course--rm-special
(delete "*.html" (delete "README.org" file-liste))))
(defun nix-course--rm-special (file-liste)
(delete "." (delete ".." file-liste)))
(defun export-all-courses ()
"Export all courses from a particular course-tree to HTML"
(interactive)
(setq nix-course-export-root (read-directory-name "Select root of course tree"))
;; Manually require ox-reveal
(require 'ox-reveal)
;; Make sure org-reveal is loaded and set-up
(load-library "reveal")
(setq org-reveal-root (concat nix-course-export-root "../.templates"))
(setq org-html-preamble nil)
(setq org-html-postamble nil)
;; Export the root README
(find-file (concat nix-course-export-root "../README.org"))
(org-html-export-to-html)
;; Export all the sub-course README's
(mapcar
;; This function takes a directory, and for every .org file in it,
;; executes another lambda
(lambda (dir)
(mapcar
;; This function takes a file, constructs an absolute path to it
;; and exports it to reveal HTML. If the file was not
;; previously open, it closes the buffer again to prevent buffer
;; spam
(lambda (file)
(setq target-file (concat nix-course-export-root dir "/" file))
(setq buffer-exists (get-buffer file))
(find-file target-file)
(org-reveal-export-to-html)
(unless buffer-exists
(kill-buffer file))
)
;; Construct a list of files based on the current course category
(nix-course--clean-dir (directory-files (concat nix-course-export-root dir) nil "\.org$" t))
)
)
;; Construct a list of directories from the nix-course-export-root
(nix-course--clean-dir (directory-files nix-course-export-root))
)
;; Then iterate over the same directories but only export the README.org files
(mapcar (lambda (dir)
(setq target-file (concat nix-course-export-root dir "/" "README.org"))
(find-file target-file)
(org-html-export-to-html))
;; Construct a list of directories based on the
;; nix-course-export-root variable
(nix-course--rm-special (directory-files nix-course-export-root))))
(provide 'export-course)