-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.el
163 lines (143 loc) · 5.57 KB
/
publish.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
;; publish.el --- Publish org-mode project on Gitlab Pages
;; Author: Sachin
;;; Commentary:
;; This script will convert the org-mode files in this directory into
;; html.
;;; Code:
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)
(package-install 'htmlize)
(package-install 'org-plus-contrib)
(require 'org)
(require 'ox-publish)
;; setting to nil, avoids "Author: x" at the bottom
(setq org-export-with-section-numbers nil
org-export-with-smart-quotes t
org-export-with-toc nil)
(setq org-html-divs '((preamble "header" "top")
(content "main" "content")
(postamble "footer" "postamble"))
org-html-container-element "section"
org-html-metadata-timestamp-format "%Y-%m-%d"
org-html-checkbox-type 'html
org-html-html5-fancy t
org-html-validation-link nil
org-html-doctype "html5")
(defvar psachin-website-html-head
"<link rel='icon' type='image/x-icon' href='/images/favicon.ico'/>
<link rel='stylesheet' href='https://code.cdn.mozilla.net/fonts/fira.css'>
<link rel='stylesheet' href='/css/site.css?v=2' type='text/css'/>
<link rel='stylesheet' href='/css/custom.css' type='text/css'/>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script src='https://code.jquery.com/jquery-3.0.0.js'></script>
<script src='https://code.jquery.com/jquery-migrate-3.0.1.js'></script>
<link href='https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' rel='stylesheet'>")
(defvar psachin-website-html-preamble
"<div class='intro'>
<img src='/images/about/profile.png' alt='Sachin Patil' class='no-border'/>
<h1>Sachin</h1>
<p>Free software developer & Emacser</p>
</div>
<div class='nav'>
<ul>
<li><a href='/'>Home</a>.</li>
<li><a href='http://gitlab.com/psachin'>GitLab</a>.</li>
<li><a href='https://plus.google.com/u/0/+Sachinp'>Google Plus</a>.</li>
<li><a href='https://youtube.com/user/iclcoolsterU'>YouTube</a>.</li>
<li><a href='/about/about.html'>About</a>.</li>
<li><a href='/index.xml'>RSS feed</a></li>
</ul>
</div>")
(defvar psachin-disqus
"<div class='comments'>
<div id='disqus_thread'></div>
<script type='text/javascript'>
var disqus_shortname = 'darkstar';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href='http://disqus.com/?ref_noscript'>comments powered by Disqus.</a></noscript>
</div>")
(defvar psachin-website-html-postamble
"<div class='footer'>
Copyright © 2012-2018 Sachin Patil. <br>
Adapted from https://nicolas.petton.f r<br>
Last updated: %C. <br>
Built with %c.
</div>")
(defvar site-attachments
(regexp-opt '("jpg" "jpeg" "gif" "png" "svg"
"ico" "cur" "css" "js" "woff" "html" "pdf"))
"File types that are published as static files.")
(defun psachin-org-sitemap-format-entry (entry style project)
"Format posts with author and published data.
ENTRY: file-name
STYLE:
PROJECT: `posts in this case."
(cond ((not (directory-name-p entry))
(format "*[[file:%s][%s]]*
#+HTML: <p class='pubdate'>by %s, %s</p>"
entry
(org-publish-find-title entry project)
(car (org-publish-find-property entry :author project))
(format-time-string "%b %d, %Y"
(org-publish-find-date entry project))))
((eq style 'tree) (file-name-nondirectory (directory-file-name entry)))
(t entry)))
(setq org-publish-project-alist
`(("posts"
:base-directory "posts"
:base-extension "org"
:recursive t
:publishing-function org-html-publish-to-html
:publishing-directory "./public"
:exclude ,(regexp-opt '("README.org" "draft"))
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-title "Sachin's homepage"
:sitemap-file-entry-format "%d *%t*"
:sitemap-format-entry psachin-org-sitemap-format-entry
:sitemap-style list
:sitemap-sort-files anti-chronologically
:html-head ,psachin-website-html-head
:html-preamble ,psachin-website-html-preamble
:html-postamble ,psachin-website-html-postamble)
("about"
:base-directory "."
:base-extension "org"
:exclude ,(regexp-opt '("README.org" "draft"))
:index-filename "about.org"
:recursive nil
:publishing-function org-html-publish-to-html
:publishing-directory "./public/about"
:html-head ,psachin-website-html-head
:html-preamble ,psachin-website-html-preamble
:html-postamble ,psachin-website-html-postamble)
("css"
:base-directory "./css"
:base-extension "css"
:publishing-directory "./public/css"
:publishing-function org-publish-attachment
:recursive t)
("images"
:base-directory "./images"
:base-extension ,site-attachments
:publishing-directory "./public/images"
:publishing-function org-publish-attachment
:recursive t)
("rss"
:base-directory "posts"
:base-extension "org"
:publishing-function org-rss-publish-to-rss
:publishing-directory "./public"
:html-link-home "https://psachin.gitlab.io"
:html-link-use-abs-url t)
("all" :components ("posts" "about" "css" "images" "rss"))))
(provide 'publish)
;;; publish.el ends here