-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path#build-project.el#
132 lines (117 loc) · 4.72 KB
/
#build-project.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
(let ((default-directory "~/.emacs.d/"))
(normal-top-level-add-subdirs-to-load-path ))
(add-to-list 'load-path "~/.emacs.d/elpa")
;;needed for a bug when setting property (seems a 9.6 issue)
(load (expand-file-name "~/.emacs.d/ox-rss.el"))
(require 'org-loaddefs)
(require 'ox-publish)
(require 'citeproc)
(require 'oc-csl)
(setq org-cite-global-bibliography '("/home/britt/gitRepos/masterBib/britt.bib"))
(setq org-cite-export-processors '((csl "/home/britt/gitRepos/brittAnderson.github.io/raw/assets/chicago-note-bibliography-16th-edition.cls")))
(defun get-first-paragraph (fn)
(with-temp-buffer
(insert-file-contents fn)
(goto-char (point-min))
(kill-region 1 (search-forward "\n\n"))
(forward-paragraph)
(kill-region (point) (point-max))
(buffer-string)))
;; In order to have a common navigation list at the top I add this to pages
;; via a function and file rather than just re-typing the string over and over.
(setq brittgithub-header-file (expand-file-name "/home/britt/gitRepos/brittAnderson.github.io/raw/assets/html-preamble.html"))
(defun brittgithub-header (arg)
(with-temp-buffer
(insert-file-contents brittgithub-header-file)
(buffer-string)))
(defun get-link (entries)
(let ((fpths
(mapcar #'(lambda (l)
(with-temp-buffer
(insert (car l))
(org-mode)
(goto-char (point-min))
(org-element-link-parser)))
(cdr entries))))
fpths))
(defun test-sitemap (title my-list)
(when (> (length my-list) 1)
(with-temp-buffer
(goto-char 1)
(let* ((my-proj-plist (assoc "britt-blog-sitemap" org-publish-project-alist))
(bd (plist-get (cdr my-proj-plist) :base-directory))
(hl (plist-get (cdr (assoc "britt-blog-rss" org-publish-project-alist)) :html-link-home))
(fpths (get-link my-list)))
(dolist (fp fpths)
(let* ((fn (plist-get (elt fp 1) :path))
(my-date (format-time-string (car org-time-stamp-formats) (org-publish-find-date fn my-proj-plist)))
(full-fn (expand-file-name fn bd)))
(insert (format "* %s\n" (org-publish-find-title fn my-proj-plist)))
(insert (format ":PROPERTIES:\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:PERMALINK: %s\n:END:\n" my-date
(concat "posts/" (file-name-sans-extension fn) ".html") (concat (file-name-sans-extension full-fn) ".html")))
(insert (format " - %s\n" my-date))
(insert (get-first-paragraph full-fn))
(insert (concat "#+begin_export html\n<a href=\"" (concat hl "/posts/" (file-name-sans-extension fn) ".html") "\">To Read More ...</a>\n#+end_export\n"))))
(goto-char (point-min))
(insert "#+OPTIONS: title:nil\n")
(insert "#+TITLE: Blog - Britt Anderson's Personal Website\n")
(insert "#+AUTHOR: Britt Anderson\n")
(insert "#+EMAIL: [email protected]\n")
(buffer-string)))))
(setq org-publish-project-alist
'(
("britt-blog-base"
:base-directory "~/gitRepos/brittAnderson.github.io/raw/"
:base-extension "org"
:publishing-directory "~/gitRepos/brittAnderson.github.io/docs/"
:recursive nil
:publishing-function org-html-publish-to-html
:headline-levels 4
:html-head nil
:html-preamble brittgithub-header
:with-author t
)
("britt-blog-sitemap"
:base-directory "~/gitRepos/brittAnderson.github.io/raw/posts/"
:base-extension "org"
:publishing-directory "~/gitRepos/brittAnderson.github.io/docs/posts/"
:recursive nil
:publishing-function org-html-publish-to-html
:headline-levels 4
:auto-sitemap t
:html-preamble brittgithub-header
:sitemap-function test-sitemap
:sitemap-filename "sitemap.org"
:sitemap-title "Britt Anderson's Personal Web Log"
:sitemap-sort-files anti-chronologically
:exclude "theindex.org"
:makeindex t)
("britt-blog-rss"
:base-directory "~/gitRepos/brittAnderson.github.io/raw/posts/"
:base-extension "org"
:html-link-home "https://brittanderson.github.io"
:html-link-use-abs-url t
:rss-extension "xml"
:publishing-directory "~/gitRepos/brittAnderson.github.io/docs/posts/"
:publishing-function org-rss-publish-to-rss
:section-numbers nil
:exclude ".*"
:include ("sitemap.org")
:table-of-contents nil
)
("britt-blog-static"
:base-directory "~/gitRepos/brittAnderson.github.io/raw/"
:base-extension "css\\|jpg\\|pdf"
:publishing-directory "~/gitRepos/brittAnderson.github.io/docs/"
:recursive t
:publishing-function org-publish-attachment)
("britt-blog-all" :components ("britt-blog-base" "britt-blog-sitemap" "britt-blog-static" "britt-blog-rss"))))
(setq org-fold-core-style 'overlay)
(org-publish "britt-blog-base" t)
(org-publish "britt-blog-sitemap" t)
(org-publish "britt-blog-static" t)
(org-publish "britt-blog-rss" t)
;(org-publish-all t)
(message (org-version))
(message "Done")
;; add in the css