-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpelicanconf.py
executable file
·337 lines (264 loc) · 9.39 KB
/
pelicanconf.py
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from datetime import date
from os.path import expanduser
#################################
#
# Basic Settings
#
#################################
AUTHOR = "Duncan Lock"
SITENAME = "duncan­lock­.net"
SITESCHEME = "http"
SITEURL = SITESCHEME + "://" + "duncanlock.test"
SITE_DOMAIN = "duncanlock.net"
RELATIVE_URLS = False
SITE_TITLE = "Duncan Locks personal site"
SITE_DESCRIPTION = "Duncan Locks personal site. Includes my blog, colitis resources, SCD recipes, portfolio and CV/Resume."
TIMEZONE = "America/Vancouver"
DEFAULT_LANG = "en"
COPYRIGHT_FROM = 1998
COPYRIGHT_UNTIL = date.today().year
SUMMARY_MAX_LENGTH = 140
SUMMARY_END_MARKER = "::PELICAN_END_SUMMARY"
#################################
#
# Cache Settings
#
#################################
CACHE_CONTENT = True
CHECK_MODIFIED_METHOD = "sha1"
LOAD_CONTENT_CACHE = True
GZIP_CACHE = False
#################################
#
# Setting for Feeds
#
#################################
# Feed generation is usually not required when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
FEED_ALL_RSS = None
CATEGORY_FEED_RSS = None
TRANSLATION_FEED_RSS = None
# Generate Feeds
# FEED_DOMAIN = SITEURL
# FEED_ATOM = 'feeds/all.atom.xml'
# CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
# FEED_RSS = 'feeds/all.rss.xml'
# CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'
#################################
#
# Setting for Paths
#
#################################
# static paths will be copied under the same name
STATIC_PATHS = ["images", "extras", "files"]
# A list of extra files to copy from the source to the destination
EXTRA_PATH_METADATA = {
"extras/.htaccess": {"path": ".htaccess"},
"extras/robots.txt": {"path": "robots.txt"},
"extras/favicon.ico": {"path": "favicon.ico"},
"extras/google9b8f9c7f2338fb3e.html": {"path": "google9b8f9c7f2338fb3e.html"},
"extras/keybase.txt": {"path": ".well-known/keybase.txt"},
}
# Do we want to wipe the /output folder every build,
# or just accumulate new stuff?
DELETE_OUTPUT_DIRECTORY = True
#################################
#
# Footer Links & Menu's
#
#################################
def load_icon(path):
from pathlib import Path
try:
return Path(f"./content/images/icons/{path}").read_text()
except:
print(f"Failed to load icon: {path}")
return ""
def make_icon_sheet(icon_list):
sprite_sheet = '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">\n\n'
for name, path in icon_list.items():
svg = load_icon(path)
sprite_sheet += svg.replace(
'<svg xmlns="http://www.w3.org/2000/svg" ', f'<symbol id="{name}" '
).replace("</svg>", "</symbol>")
sprite_sheet += "\n\n"
sprite_sheet += "</svg>"
from scour import scour
scour_options = scour.sanitizeOptions(options=None)
scour_options.remove_metadata = True
scour_options.strip_comments = True
scour_options.newlines = False
sprite_sheet = scour.scourString(sprite_sheet, options=scour_options)
with open("./content/images/icons/icon_sheet.svg", "w") as f:
f.write(sprite_sheet)
return sprite_sheet
def get_icons(icon_list):
tmp = {}
for name, path in icon_list.items():
# tmp[name] = load_icon(path)
tmp[name] = f'<svg><use href="#{name}" /></svg>'
# tmp[name] = f'<noscript><img src="/images/icons/{path}" width="18px" /></noscript><svg><use href="#{name}" /></svg>'
return tmp
def get_hash(s):
import hashlib
return hashlib.sha256(s.encode("utf-8")).hexdigest()[:8]
ICON_LIST = {
"home": "fa/solid/home-lg-alt.svg",
"archive": "fa/solid/archive.svg",
"tags": "fa/solid/tags.svg",
"tag": "fa/solid/tag.svg",
"feed": "fa/solid/rss.svg",
"clock": "fa/solid/clock.svg",
"read-more": "fa/solid/arrow-right.svg",
"category": "fa/solid/folder.svg",
"category_active": "fa/solid/folder-open.svg",
"email": "fa/solid/envelope.svg",
"resume": "fa/solid/user-tie.svg",
"twitter": "fa/brands/twitter.svg",
"mastodon": "fa/brands/mastodon.svg",
"github": "fa/brands/github.svg",
"linkedin": "fa/brands/linkedin.svg",
"stack": "fa/brands/stack-overflow.svg",
"globe": "fa/solid/globe-americas.svg",
"enumbers": "fa/solid/cheese-swiss.svg",
"next": "fa/solid/arrow-right.svg",
"previous": "fa/solid/arrow-left.svg",
"dark-theme": "fa/regular/moon-stars.svg",
"light-theme": "custom/bright.svg",
"stats": "fa/solid/chart-line-solid.svg",
"star-full": "fa/solid/star-solid.svg",
"star-half": "fa/solid/star-half-stroke-solid.svg",
"star-empty": "fa/solid/star-regular.svg",
}
ICON_SPRITE_SHEET = make_icon_sheet(ICON_LIST)
ICON_SPRITE_SHEET_HASH = get_hash(ICON_SPRITE_SHEET)
# make_icon_sheet(ICON_LIST)
ICONS = get_icons(ICON_LIST)
# Footer Links
# (anchor-text, icon, relative URL)
SITE_LINKS = (
("Home", ICONS["home"], "/"),
("Archives", ICONS["archive"], "/blog/"),
("Tags", ICONS["tags"], "/tags.html"),
("E-Numbers", ICONS["enumbers"], "/pages/e-numbers-food-additives.html"),
("Site Stats", ICONS["stats"], "/pages/stats.html"),
)
# (anchor-text, icon-name, URL)
LINKS = (
("CV/Resume", ICONS["resume"], "/pages/duncan-locks-resume.html"),
("LinkedIn", ICONS["linkedin"], "https://www.linkedin.com/in/duncanlock/"),
# ("Codeistry", ICONS["globe"], "http://codeistry.com/"),
("Blogroll & Links", ICONS["globe"], "/pages/blogroll-links.html"),
)
# Social widget
# (anchor-text, icon-name, URL)
SOCIAL = (
("Twitter", ICONS["twitter"], "https://twitter.com/duncanlock"),
("Mastodon", ICONS["mastodon"], "https://cosocial.ca/@duncanlock"),
("GitHub", ICONS["github"], "https://github.com/dflock"),
(
"Stack Overflow",
ICONS["stack"],
"https://stackoverflow.com/users/259698/duncan-lock",
),
)
# Extra Header Menu links
# (anchor-text, icon|"", URL)
HEADER_LINKS = (
# ("about", ICONS["resume"], "/pages/about.html"),
("til", ICONS["tag"], "/tag/til.html"),
)
DEFAULT_PAGINATION = 10
DEFAULT_ORPHANS = 1
OPEN_GRAPH_METADATA = True
DUBLIN_CORE_METADATA = True
DEFAULT_PAGESCHEMA = "article"
# Switch Typogrify on, to get fancier Typography
# See here for more: https://github.com/mintchaos/typogrify
TYPOGRIFY = True
# TYPOGRIFY_IGNORE_TAGS = ['pre', 'code', 'tty']
# Which theme to use
THEME = "../blueprint"
TEMPLATE_EXTENSIONS = [".html.j2"]
# Remove the authors template
DIRECT_TEMPLATES = ["index", "categories", "tags", "archives"]
SHOW_THEME_SWITCHER = True
# Where should Pelican look for content?
PATH = "content"
# These are relative to PATH, above
ARTICLE_PATHS = ["posts"]
PAGE_PATHS = ["pages"]
# Use filsystem folders for categories
USE_FOLDER_AS_CATEGORY = True
# Articles with a given tag can use a different template for their index entry:
INDEX_TEMPLATE_FOR_TAG = {"til": "minimal"}
# What do we want article URLs to look like?
ARTICLE_URL = "blog/{date:%Y}/{date:%m}/{date:%d}/{slug}/"
ARTICLE_SAVE_AS = "blog/{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html"
# What do we want archive URLs to look like?
YEAR_ARCHIVE_SAVE_AS = "blog/{date:%Y}/index.html"
MONTH_ARCHIVE_SAVE_AS = "blog/{date:%Y}/{date:%m}/index.html"
DAY_ARCHIVE_SAVE_AS = "blog/{date:%Y}/{date:%m}/{date:%d}/index.html"
# Do something if people visit /blog
ARCHIVES_SAVE_AS = "blog/index.html"
# Don't bother generating an Author page - we've only got one author
AUTHOR_SAVE_AS = False
# Do we want all our pages displayed in the theme's header?
DISPLAY_PAGES_ON_MENU = False
# Do we want all our categories displayed in the theme's header?
DISPLAY_CATEGORIES_ON_MENU = True
# Set Colophon variables, which can be output by the theme.
COLOPHON = True
COLOPHON_TITLE = "About"
COLOPHON_CONTENT = """<a href="/pages/duncan-locks-resume.html">
<img class="icon" src="/images/icons/hm_vertical_nobox_white-simplified.svg" />
<img class="icon right" src="/images/icons/carbon_neutral_vertical_white-simplified.svg" />
Designed, built, drawn, written <span class="amp">&</span> © 1998-2024 Duncan Lock - a human! No AI or Machine Generated works are included in this website - it's all just me!
I'm an adaptable, enthusiastic senior software developer <span class="amp">&</span> writer, with broad experience and an artistic background. Strong graphical communication, design, creative
<span class="amp">&</span> problem solving
skills — and an eye for detail.</a>
"""
#################################
#
# Social Settings
#
#################################
ARTICLE_TWEET_BUTTON = False
ARTICLE_GOOGLEPLUS_BUTTON = False
TWITTER_USERNAME = "duncanlock"
TWITTER_ACCOUNT_ID = "1512952557"
TWITTER_CARD = True
#################################
#
# Setting for plugins
#
#################################
# Where to look for plugins
PLUGIN_PATHS = [expanduser("~/dev/pelican-plugins"), "./plugins"]
# Which plugins to enable
PLUGINS = [
"jinja_filters",
"asciidoc_reader",
"pelican.plugins.webassets",
"related_posts",
"extract_toc",
"extract_asciidoc_toc",
"post_stats",
"pelican.plugins.series",
"summary",
"drafts",
]
WEBASSETS_DEBUG = False
ASCIIDOC_OPTIONS = [
"-a source-highlighter=rouge",
"-a rouge-style=monokai",
"-r asciidoctor-html5s",
"-b html5s",
]
# ASCIIDOC_OPTIONS = ['-a source-highlighter=rouge', '-a rouge-style=monokai', '-r asciidoctor-html5s', '-b html5s', '-T ~/dev/asciidoctor-html5s']
# Settings for the related_posts plugin
RELATED_POSTS_MAX = 4