-
Notifications
You must be signed in to change notification settings - Fork 1
/
pelicanconf.py
executable file
·225 lines (186 loc) · 5.71 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
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
import os
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import Optional
import pytz
@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 = "Close Enough"
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 = pytz.timezone(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", "/pages/cv.html", style="cv", icon_style="fa-solid fa-image-portrait"
),
StyledLink(
"Tools", "/pages/defaults.html", style="tools", icon_style="fa-solid fa-toolbox"
),
]
# Social widget
SOCIAL = (
Social("Wandering.Shop", "https://wandering.shop/@offby1", network="mastodon"),
Social("Twitter", "https://twitter.com/offby1"),
Social("Github", "https://github.com/offbyone"),
)
DEFAULT_PAGINATION = 10
PLUGIN_PATHS = ["./plugins"]
PLUGINS = [
"link_toot",
"pelican_edit_url",
"pelican_embed_microblog",
"pelican_gist",
"photos",
"simple_footnotes",
"sitemap",
"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",
]
# find all node modules that contain min.js files and add thoes 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")])
]
WEBASSETS_BUNDLES = [
(
"theme_js",
(
"js/fuji.js",
"js/bigfoot.js",
"jquery.magnific-popup.js",
"js/adblocker.js",
),
{
"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",
},
}
FLICKR_API_KEY = "b6948f5853252a6c1310523f2e3b1faa"
FLICKR_USER = "11217428@N00"
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}"
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),
)