blob: 2ea510bf3cec925b0b36c4c5e38dc66b79888c35 (
plain)
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
|
# -*- mode: org; -*-
#+TITLE: Publish
#+SUBTITLE: Publishing this very website.
#+AUTHOR: Marius Peter
#+DATE: <2022-01-26 Wed>
#+OPTIONS: toc:nil
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="resources/mlnp.css" />
#+INCLUDE: resources/topnav.org
#+TOC: headlines 3
#+begin_abstract
In the spirit of [[https://en.wikipedia.org/wiki/Literate_programming][literate programming]] encouraged by Org mode, this
entire website's build process is documented on this very page. When
Emacs builds this website, it parses and executes the code blocks
contained on this page. By mixing behavior with the behavior's
documentation, we can future-proof our understanding of the build
logic, making it possible to efficiently revisit this website at a
later date in order to bring improvements.
#+end_abstract
* Publishing targets
This first section lays out the interactive prompts used to bind
export-related symbols with the following publishing targets:
- location :: Where should the website be published?
- components :: What parts of the website should be built?
** Location
Two possible publishing locations are considered:
- Local :: The website would be built on the local machine.
- Remote :: The website would be built on a remote server, after
uploading the selected files via ssh.
#+NAME: org-publish-location
#+BEGIN_SRC elisp
(setq org-publish-location
(read-answer
"Should the website be built on the local or remote target? "
'(("~/tmp-mlnp.fr/"
?l "build website on the local machine")
("/ssh:root@192.162.71.223:/var/www/html/mlnp.fr/"
?r "build website on the remote machine"))))
#+END_SRC
** Components
#+NAME: org-publish-components
#+begin_src elisp
(setq org-publish-components
(read-answer
"Which `org-publish-project-alist' component should be built? "
'(("content"
?c "build content (html) website components")
("all"
?a "build all website components"))))
#+end_src
* Resources
This section explores the =.css= and (maybe later) =.js= resources
available on the website.
** CSS
The main CSS file is located at [[file:resources/css.org]].
* Project components
The ~org-publish-project-alist~ variable is used by ~org-publish~ to
identify website components and their properties upon export.
#+NAME: org-publish-project-alist
#+BEGIN_SRC elisp
(require 'ox-publish)
(setq org-publish-project-alist
`(("site"
:base-directory "./"
:base-extension "org"
:publishing-directory ,org-publish-location
:recursive nil ; Top-level pages are all in top-level org directory.
:publishing-function org-html-publish-to-html
:auto-sitemap t
:sitemap-filename "resources/topnav-items.org"
:sitemap-title "Top-level site links")
("posts"
:base-directory "posts/"
:base-extension "org"
:publishing-directory ,(concat org-publish-location "posts/")
:recursive t
:publishing-function org-html-publish-to-html)
("styles"
:base-directory "resources/"
:base-extension "css"
:publishing-directory ,(concat org-publish-location "resources/")
:publishing-function org-publish-attachment)
("images"
:base-directory "images/"
:base-extension "jpg\\|gif\\|png\\|svg"
:publishing-directory ,(concat org-publish-location "images/")
:recursive t
:publishing-function org-publish-attachment)
("content"
:components ("site"
"posts"))
("all"
:components ("content"
"styles"
"images"))))
#+END_SRC
* Main publishing logic
This is the main publishing logic. Execute the following source block
to build the entire website.
#+NAME: main
#+BEGIN_SRC elisp :noweb no-export
<<org-publish-location>>
<<org-publish-components>>
<<org-publish-html-preamble>>
<<org-publish-project-alist>>
(org-babel-tangle-file "resources/css.org")
(org-publish-remove-all-timestamps)
(org-publish org-publish-components)
#+END_SRC
Open the website.
[[file:~/tmp-mlnp.fr/index.html]]
|