forked from emacsorphanage/org-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op-vars.el
210 lines (174 loc) · 7.18 KB
/
op-vars.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
;;; op-vars.el --- Variable configurations required by org-page
;; Copyright (C) 2012, 2013, 2014 Kelvin Hu
;; Author: Kelvin Hu <ini DOT kelvin AT gmail DOT com>
;; Keywords: convenience
;; Homepage: https://github.com/kelvinh/org-page
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; op-vars.el contains almost all variable definitions and configurations.
;;; Code:
(require 'ox)
(require 'ht)
(defgroup org-page nil
"Options for generating static pages using org-page."
:tag "Org static page generator" :group 'org)
(defconst op/temp-buffer-name "*Org Page Output*"
"Name of the temporary buffer used by org-page.")
(defconst op/load-directory
(cond
(load-file-name (file-name-directory load-file-name))
((symbol-file 'op/temp-buffer-name)
(file-name-directory (symbol-file 'op/temp-buffer-name)))
((string= (file-name-nondirectory buffer-file-name) "op-vars.el")
(file-name-directory buffer-file-name))
(t nil))
"The directory where org-page is loaded from.")
(defcustom op/repository-directory nil
"The git repository directory, where org files stored on branch
`op/repository-org-branch', and generated html files stored on branch
`op/repository-html-branch'."
:group 'org-page :type 'string)
(defcustom op/site-domain nil
"The domain name of entire site, it is recommended to assign with prefix
http:// or https://, http will be considered if not assigned."
:group 'org-page :type 'string)
(defcustom op/site-main-title "org-page"
"The main title of entire site."
:group 'org-page :type 'string)
(defcustom op/site-sub-title "static site generator"
"The subtitle of entire site."
:group 'org-page :type 'string)
(defcustom op/repository-org-branch "source"
"The branch where org files stored on, it is within repository presented by
`op/repository-directory'."
:group 'org-page :type 'string)
(defcustom op/repository-html-branch "master"
"The branch where generated html files stored on, it is within repository
presented by `op/repository-directory'."
:group 'org-page :type 'string)
(defcustom op/theme-root-directory
(concat op/load-directory "themes/")
"The root directory that stores themes for page rendering. By default, it
points to the directory `themes' in org-page installation directory."
:group 'org-page :type 'string)
(defcustom op/theme 'mdo
"The theme used for page generation."
:group 'org-page :type 'symbol)
(defcustom op/personal-github-link "https://github.com/kelvinh/org-page"
"The personal github link."
:group 'org-page :type 'string)
(defcustom op/personal-disqus-shortname nil
"The personal disqus shortname."
:group 'org-page :type 'string)
(defcustom op/personal-duoshuo-shortname nil
"The personal duoshuo shortname."
:group 'org-page :type 'string)
(defcustom op/personal-google-analytics-id nil
"Personal google analytics id."
:group 'org-page :type 'string)
(defcustom op/template-directory
(concat (file-name-as-directory op/theme-root-directory)
(format "%s/templates/" (symbol-name (or op/theme 'mdo))))
"The directory stores templates for page rendering."
:group 'org-page :type 'string)
;;; this variable is deprecated
(defcustom op/page-template
(file-to-string (concat op/template-directory "container.mustache"))
"The template used to render pages, see the template itself for detail."
:group 'org-page :type 'string)
(defcustom op/retrieve-category-function 'op/get-file-category
"The function used to retrieve an org file's category, its parameter is the
org file's path, if parameter is nil, it should return all categories, the
default value is `op/get-file-category'."
:group 'org-page :type 'function)
(defvar op/category-config-alist
'(("blog" ;; this is the default configuration
:show-meta t
:show-comment t
:uri-generator op/generate-uri
:uri-template "/blog/%y/%m/%d/%t/"
:sort-by :date ;; how to sort the posts
:category-index t) ;; generate category index or not
("index"
:show-meta nil
:show-comment nil
:uri-generator op/generate-uri
:uri-template "/"
:sort-by :date
:category-index nil)
("about"
:show-meta nil
:show-comment nil
:uri-generator op/generate-uri
:uri-template "/about/"
:sort-by :date
:category-index nil))
"Configurations for different categories, can and should be customized.")
;;; this variable is deprecated
(defvar op/default-template-parameters
(ht ("blog-uri" "/blog/")
("wiki-uri" "/wiki/")
("tags-uri" "/tags/")
("about-uri" "/about/")
("site-main-title" op/site-main-title)
("site-sub-title" op/site-sub-title)
("github" op/personal-github-link)
("site-domain" (if (and op/site-domain
(string-match "\\`https?://\\(.*[a-zA-Z]\\)/?\\'"
op/site-domain))
(match-string 1 op/site-domain)
op/site-domain))
("disqus-shortname" op/personal-disqus-shortname)
("disqus-comment" (if op/personal-disqus-shortname t nil))
("duoshuo-shortname" op/personal-duoshuo-shortname)
("duoshuo-comment" (if op/personal-duoshuo-shortname t nil))
("google-analytics-id" op/personal-google-analytics-id)
("google-analytics" (if op/personal-google-analytics-id t nil))
("creator-info" org-html-creator-string))
"Default template rendering parameters.")
(defvar op/item-cache nil
"The cache for general purpose.")
(defconst op/rss-template "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<rss version=\"2.0\">
<channel>
<title>{{title}}</title>
<link>{{link}}</link>
<description>{{description}}</description>
<pubDate>{{date}}</pubDate>
<lastBuildDate>{{date}}</lastBuildDate>
<docs>http://www.rssboard.org/rss-specification</docs>
<generator>Org-page static site generator \
(https://github.com/kelvinh/org-page)</generator>
{{#items}}
<item>
<title>{{item-title}}</title>
<link>{{item-link}}</link>
<description>{{item-description}}</description>
<pubDate>{{item-update-date}}</pubDate>
<guid>{{item-link}}</guid>
</item>
{{/items}}
</channel>
</rss>"
"Template for RSS rendering.")
(defcustom op/html-creator-string
(format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s\
(<a href=\"http://orgmode.org\">Org mode</a> %s)"
(format "%s.x" emacs-major-version)
(if (fboundp 'org-version)
(replace-regexp-in-string "\\..*" ".x" (org-version))
"Unknown Version"))
"Information about the creator of the HTML document."
:group 'org-page
:type 'string)
(provide 'op-vars)
;;; op-vars.el ends here