-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpelicanconf.py
More file actions
executable file
·279 lines (236 loc) · 7.53 KB
/
pelicanconf.py
File metadata and controls
executable file
·279 lines (236 loc) · 7.53 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
import os
import zoneinfo
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import Optional
@dataclass
class StyledLink:
name: str
link: str
style: Optional[str] = None
icon_style: Optional[str] = None
def __post_init__(self):
if self.style is None:
self.style = self.name.lower()
if self.icon_style is None:
self.icon_style = "fa-brands fa-{ self.style }"
@dataclass
class Social(StyledLink):
network: Optional[str] = None
def __post_init__(self):
if self.network is None:
self.network = self.name.lower()
self.style = f"sc-{self.network}"
self.icon_style = f"fa-brands fa-{self.network}"
AUTHOR = "Chris R"
AUTHOR_EMAIL = "offline@offby1.net"
SITENAME = "Ideas.Offby1"
DESCRIPTION = "This is such an <em>extremely</em> specific complaint"
if "SITEURL" in os.environ:
SITEURL = os.environ["SITEURL"]
RELATIVE_URLS = False
else:
SITEURL = "//offby1.website"
# Use relative URLs during development. This is overridden in publishconf.py
RELATIVE_URLS = True
PATH = Path("content")
# photos plugin configuration
PHOTO_LIBRARY = Path(__file__).parent / "photos"
# during development, the pelican listener and this feature are incompatible
PHOTO_RESIZE_JOBS = 1
PHOTO_WATERMARK_TEXT = "© Chris Rose"
PHOTO_EXIF_KEEP = True
PHOTO_EXIF_REMOVE_GPS = True
PHOTO_EXIF_COPYRIGHT = "CC-BY-NC-SA"
PHOTO_EXIF_COPYRIGHT_AUTHOR = "Chris Rose"
SITEMAP = {"format": "xml", "exclude": ["tag/", "category/"]}
TIMEZONE = "America/Los_Angeles"
TZ = zoneinfo.ZoneInfo(TIMEZONE)
PUBLICATION_TIME = datetime.now(TZ)
DEFAULT_LANG = "en"
# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
# Blogroll
# LINKS = (('Pelican', 'http://getpelican.com/'),
# ('Python.org', 'http://python.org/'),
# ('Jinja2', 'http://jinja.pocoo.org/'),
# ('You can modify those links in your config file', '#'),)
LINKS = [
StyledLink("CV", "/cv.html", style="cv", icon_style="fa-solid fa-image-portrait"),
StyledLink("Now", "/now.html", style="now", icon_style="fa-solid fa-clock"),
StyledLink(
"Tools", "/defaults.html", style="tools", icon_style="fa-solid fa-toolbox"
),
StyledLink(
"Projects",
"/projects.html",
style="projects",
icon_style="fa-solid fa-diagram-project",
),
]
# Social widget
SOCIAL = (
Social("Wandering.Shop", "https://wandering.shop/@offby1", network="mastodon"),
Social("Github", "https://github.com/offbyone"),
Social("Bluesky", "https://bsky.app/profile/offby1.net"),
)
OPEN_GRAPH_IMAGE = "/theme/images/dark/headshot.png"
DEFAULT_PAGINATION = 10
PLUGIN_PATHS = ["./plugins"]
PLUGINS = [
"extract_linked_metadata",
"myst_reader",
"pelican_edit_url",
"pelican_embed_microblog",
"pelican_gist",
"pelican_redirect",
"pelican.plugins.similar_posts",
"photos",
"simple_footnotes",
"sitemap",
"social_cards",
"tag_cloud",
"webassets",
]
ARTICLE_URL = "posts/{slug}.html"
ARTICLE_SAVE_AS = "posts/{slug}.html"
DISPLAY_PAGES_ON_MENU = False
TEMPLATE_EXTENSIONS = [".html.j2", ".html"]
# THEME = 'monospace'
# THEME = 'pelican-elegant-1.3'
# THEME = 'pure-single'
THEME = "themes/offby1"
# THEME = "twenty"
THEME_STATIC_PATHS = ["static"]
# set the SASS load path
WEBASSETS_SOURCE_PATHS = [
"static/css",
"sass",
"scss",
]
# Add node_modules to webassets search path for JS/CSS dependencies
WEBASSETS_SOURCE_PATHS.append(str(Path(__file__).parent / "node_modules"))
# find all node modules that contain min.js files and add those to the source paths
for p in Path("node_modules").resolve().glob("**/*min.js"):
WEBASSETS_SOURCE_PATHS.append(str(p.parent))
WEBASSETS_CONFIG = [
("SASS_LOAD_PATHS", [str(Path(__file__).parent.resolve() / "node_modules")]),
# Silence SASS deprecation warnings from dependencies like @primer/css
# These use deprecated @import syntax which we can't control
("SASS_BIN", "sass"),
(
"SASS_EXTRA_ARGS",
(
"--silence-deprecation=import",
"--silence-deprecation=global-builtin",
),
),
]
WEBASSETS_BUNDLES = [
(
"theme_js",
(
"js/fuji.js",
"js/bigfoot.js",
"jquery.magnific-popup.js",
"js/adblocker.js",
# We don't include federated-comments.js here because it's loaded conditionally
),
{
"output": "js/fuji.min.js",
"filters": ["jsmin"],
},
),
# Disabled - STILL - because for some reason this CSS doesn't apply in the site
# ... but the one in base.html.j2 _does_. Why? Who the hell knows?
# (
# "theme_css",
# ("fuji.scss", "bigfoot-default.scss", "magnific-popup.css"),
# {
# "output": "css/style.min.js",
# "filters": "scss",
# "depends": ("**/_*.scss",),
# },
# ),
]
STATIC_PATHS = ["images", "extra"]
EXTRA_PATH_METADATA = {
"extra/robots.txt": {
"path": "robots.txt",
},
"extra/favicon.ico": {
"path": "favicon.ico",
},
"extra/.well-known/webfinger": {
"path": ".well-known/webfinger",
},
"extra/js/federated-comments.js": {
"path": "js/federated-comments.js",
},
}
FLICKR_API_KEY = "b6948f5853252a6c1310523f2e3b1faa"
FLICKR_USER = "11217428@N00"
# PAGE_URL = "{slug}.html"
PAGE_SAVE_AS = "{slug}.html"
# PAGE_URL = "{slug}.html"
CONTENT_REDIRECT_CONFIGURATION = [
{
"PAGE_URL": "pages/{slug}.html",
}
]
THEMES_I_LIKE = [
"svtble",
"simple-bootstrap",
"pelican-bootstrap3",
"monospace",
"irfan",
"blueidea",
"basic",
]
IGNORE_FILES = [".#&", "flycheck_*", "flymake_*"]
REPOSITORY_ROOT = f"file://{Path(__file__).parent.resolve()}/{PATH}"
EDIT_CONTENT_URL = "https://github.com/offbyone/ideas/edit/main/{file_path}"
# MyST Reader configuration
MYST_DOCUTILS_SETTINGS = {
"myst_enable_extensions": [
"html_admonition", # Enable admonition syntax
"linkify", # Auto-detect links
"colon_fence", # Enable ::: directive syntax for dropdowns
"attrs_inline", # Enable {#id} and {.class} syntax for headings
"html_image", # Enable HTML img tags with attributes
],
"myst_disable_syntax": [], # Don't disable any syntax
"myst_heading_anchors": 3, # Add anchors to headings
}
if "IDEAS_EMIT_TIMING" in os.environ:
import sqlite3
import time
from pelican import signals
from pelican.generators import Generator
timing_db = "timings.sqlite3"
Path(timing_db).unlink(missing_ok=True)
con = sqlite3.connect(timing_db)
cur = con.cursor()
cur.execute("CREATE TABLE timings(path, start, end)")
@signals.article_generator_preread.connect
def start_time(generator: Generator):
with sqlite3.connect(timing_db) as con:
cur = con.cursor()
cur.execute(
"INSERT INTO timings (path, start) VALUES (?, ?)",
(generator.path, int(time.perf_counter() * 1000)),
)
@signals.article_generator_context.connect
def stop_time(generator: Generator, metadata):
with sqlite3.connect(timing_db) as con:
cur = con.cursor()
cur.execute(
"UPDATE timings SET end=? WHERE path = ?",
(int(time.perf_counter() * 1000), generator.path),
)