summaryrefslogtreecommitdiffstats
path: root/site/cleopatra/theme.org
blob: cc3fc3e635aee88a3bd91e35cdaea4f3c4df3b3a (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
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
211
212
213
214
215
216
217
218
219
#+BEGIN_EXPORT html
<h1>Theming and Templating</h1>
#+END_EXPORT

The purpose of this build process is to implement the default layout of this
website. To that end, it provides a template file (~main.html~), and a
collection of SASS files that *~cleopatra~* then compiles into a single CSS file
using ~sassc~.

We first discuss the structure of the website, by defining the default HTML
template =soupault= will use to generate the website. Then, we specify its
minimal design, implemented in SASS. Finally, we discuss the necessary build
instructions for *~cleopatra~*.

* Main HTML Template

#+BEGIN_SRC html  :tangle templates/main.html :noweb yes
<html lang="en">
  <head>
    <<meta-tags>>
    <title><!-- page title will be inserted here --></title>
    <<syncloading_html>>
    <<asyncloading_html>>
  </head></head>
  <<body>>
</html>
#+END_SRC

** ~<head>~

#+NAME: meta-tags
#+BEGIN_SRC html :noweb no-export
<meta charset="utf-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0">
#+END_SRC

*** Assets Loading

#+NAME: syncloading_html
#+BEGIN_SRC html
<link
   href="https://soap.coffee/+vendors/normalize.css.8.0.1/normalize.css"
   rel="stylesheet">
<link rel="stylesheet" href="/style/main.css">
<link rel="icon" type="image/ico" href="/img/merida.webp">
#+END_SRC

#+NAME: asyncloading_js
#+BEGIN_SRC js
let noscript = document.getElementById('asyncloading');
noscript.insertAdjacentHTML('beforebegin', noscript.innerText);
noscript.parentNode.removeChild(noscript);
#+END_SRC

#+NAME: asyncloading_html
#+BEGIN_SRC html
<noscript id="asyncloading">
  <link href="https://soap.coffee/+vendors/fira-code.2+swap/font.css"
        rel="stylesheet">
  <link href="https://soap.coffee/+vendors/et-book+swap/font.css"
        rel="stylesheet">
  <link href="https://soap.coffee/+vendors/katex.0.11.1+swap/katex.css"
        rel="stylesheet">
  <link href="https://soap.coffee/+vendors/fork-awesome.1.1.7+swap/css/fork-awesome.min.css"
        rel="stylesheet">
</nolink>
#+END_SRC

** ~body~

#+NAME: body
#+BEGIN_SRC html :noweb no-export
<body>
  <header>
    <ul>
      <li> <a href="/">Technical Articles</a></li>
      <li> <a href="/opinions">Opinions</a></li>
      <li> <a href="/news">News</a></li>
      <li> <a href="/projects">Projects</a></li>
    </ul>
  </header>
  <main>
  <!-- page content will be inserted here -->
  </main>
  <footer>
    <img src="https://soap.coffee/~lthms/img/merida.webp"
         alt="Merida from the movie Ralph 2.0 from Disney is the
              avatar I use most of the time on the Internet"
         title="lthms’ avatar" />

    <p>
      Hi, I’m <strong>lthms</strong>, and this is my humble corner of the
      Internet. You are very welcome here! If you are interested in
      <em>functional programming</em>, <em>formal verification</em>, or <em>free
      software projects in the making</em>, you may even enjoy your stay!
    </p>

    <p>
      This website has been generated using a collection of <a
      href="/posts/Thanks.html">awesome free software projects</a>. You can have
      a look at <a href="https://code.soap.coffee/writing/lthms.git/">the source
      of this website</a> or <a href="/cleopatra.html">how it is being
      generated</a>, and if you run into an error, feel free to <a
      href="mailto:lthms@soap.coffee">shoot me a friendly email</a>.
    </p>
  </footer>
  <script>
    <<asyncloading_js>>
  </script>
</body>
#+END_SRC

* Main SASS File

#+BEGIN_SRC sass :tangle site/style/main.sass
*
    box-sizing : border-box

html
    width : 100%
    font-size : 110%

body
    font-family : 'et-book', serif
    padding : 2rem 5rem

main p,
main h1,
main h2,
main h3,
main h4,
main h5,
main h6,
main ul,
main dl,
main ol,
header,
footer
    max-width : 35rem
    line-height : 140%

header ul,
footer p
    font-size : 90%

header ul
    padding : 0
    margin : 0
    list-style-type : none
    display : flex
    gap : 1rem

main
    padding-top : 2rem
    padding-bottom : 2rem

footer img
    border-radius : 100%
    max-width : 7rem
    float : right
    margin-left : 1rem
    margin-bottom : 1rem

pre
    overflow-x : auto

code,
tt,
pre
    font-family : 'Fira Code', monospace
    font-size : 80%
    line-height : 140%

#gallery
    display : flex
    flex-wrap : wrap
    align-content : flex-start

    img
        max-width : 20rem

@import plugins
@import org
@import coq
#+END_SRC

* Build Instructions

The build instruction are pretty straightforward. We start by how to compile the
main CSS file.

#+BEGIN_SRC makefile :tangle theme.mk
SASS := $(wildcard site/style/*.sass)
MAIN_SASS := site/style/main.sass
CSS := $(MAIN_SASS:.sass=.css)

${CSS} : ${SASS}
	@cleopatra echo Compiling  "${CSS}"
	@sassc --style=compressed --sass ${MAIN_SASS} ${CSS}
#+END_SRC

Since the HTML template does not need any particular processing, the
=theme-build= phase is only responsible for generating the main CSS file.  The
[[./soupault.org][=soupault= build phase]] needs to start after the CSS file is
compiled (since it copies all relevant files to the ~build/~ directory), so we
explicit this dependency.

#+BEGIN_SRC makefile :tangle theme.mk
theme-build : ${CSS}
soupault-build : theme-build
#+END_SRC

Therefore, at the end of this generation process only one file has been
generated.

#+BEGIN_SRC makefile :tangle theme.mk
ARTIFACTS += ${CSS}
#+END_SRC