Compare commits
9 Commits
d4cb947df0
...
main
Author | SHA1 | Date | |
---|---|---|---|
97dd5e0bd7 | |||
cdf1377019 | |||
b5fad3d59c | |||
5ede1cdcdf | |||
8c49ef1e7a | |||
a321798b37 | |||
184d003e55 | |||
011a3306df | |||
2360e76965 |
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
venv
|
||||
dist
|
||||
feedback
|
||||
backup
|
||||
*.sh
|
||||
|
@ -12,15 +12,15 @@ Compile the content into a static site using
|
||||
python app.py
|
||||
```
|
||||
|
||||
This creates the "dist" directory, with all of the HTML in there.
|
||||
This creates the "dist" directory, with all of the HTML in there.
|
||||
At the moment, `dist` is part of the `.gitignore`!
|
||||
|
||||
|
||||
### Writing Content
|
||||
Within the `content` directory, you can create/edit markdown files. When compiling the markdown content, `app.py` will look for jinja templates in the `templates` directory. If the markdown file is in the root of `content`, it will try to load a template with the same filename as the markdown file. For instance, `about.md` will look for `about.jinja`.
|
||||
Within the `content` directory, you can create/edit markdown files. When compiling the markdown content, `app.py` will look for jinja templates in the `templates` directory. If the markdown file is in the root of `content`, it will try to load a template with the same filename as the markdown file. For instance, `about.md` will look for `about.jinja`.
|
||||
If the markdown file is in a subdirectory, it will look for a template with the same name as the subdirectory. At the moment, there is no functionality for deep nested folders. So, `recipes/tomato-soup.md` wants `recipes.jinja`. If the template does not exist, the default template is `post.jinja`.
|
||||
|
||||
The project uses [Jinja](https://jinja.palletsprojects.com/), which allows for extending templates, using variables, looping trough variables, and other funky features!
|
||||
The project uses [Jinja](https://jinja.palletsprojects.com/), which allows for extending templates, using variables, looping through variables, and other funky features!
|
||||
|
||||
Additionally, `component-inventory.csv` is loaded as a dataset.
|
||||
|
||||
|
29
app.py
@ -16,28 +16,13 @@ from slugify import slugify
|
||||
env = Environment(loader=PackageLoader("src"), autoescape=select_autoescape())
|
||||
|
||||
CONTENT_D = os.path.abspath("src/content")
|
||||
OUTPUT_D = "dist"
|
||||
OUT_ASSETS = "dist/assets"
|
||||
SRC_ASSETS = "src/assets"
|
||||
OUTPUT_D = "publication"
|
||||
|
||||
documents = {}
|
||||
now = datetime.now()
|
||||
word_count = 0
|
||||
ins_count = 0
|
||||
|
||||
def imageSpread(params):
|
||||
global documents
|
||||
param = params.split(" ")
|
||||
print(param[1])
|
||||
for item in documents[param[0]]:
|
||||
print(item.get("filename"))
|
||||
|
||||
d = [item for item in documents[param[0]] if item.get("filename") == param[1]]
|
||||
print(d)
|
||||
template = env.select_template(["snippets/spread-images.jinja"])
|
||||
html = template.render(documents=documents, content=d[0], type=param[1])
|
||||
|
||||
return html
|
||||
|
||||
# jinja filter that can list documents
|
||||
def listDocuments(params):
|
||||
param = params.split(" ")
|
||||
@ -91,7 +76,7 @@ def get_ins_count(html_string):
|
||||
# jinja filter to replace shortcodes in HTML
|
||||
def shortcode_filter(value):
|
||||
|
||||
shortcode_callbacks = {"show": listDocuments, "showImages": imageSpread}
|
||||
shortcode_callbacks = {"show": listDocuments}
|
||||
|
||||
def shortcode_replacer(match):
|
||||
|
||||
@ -236,7 +221,7 @@ def preload_documents():
|
||||
.strip()
|
||||
)
|
||||
|
||||
documents["meta"] = {"now": now.strftime("%d %B %Y - %H:%M:%S"), "version": version}
|
||||
documents["meta"] = {"now": now.strftime("%d %B %Y"), "version": version}
|
||||
|
||||
for subdir in os.listdir(CONTENT_D):
|
||||
path = os.path.join(CONTENT_D, subdir)
|
||||
@ -270,7 +255,7 @@ def get_inventory():
|
||||
|
||||
def get_wordcount():
|
||||
global word_count, ins_count
|
||||
word_count += count_words_in_markdown(documents["thesis"].body)
|
||||
word_count += count_words_in_markdown(documents["index"].body)
|
||||
|
||||
for section in ["chapters", "components", "recipes"]:
|
||||
for c in documents[section]:
|
||||
@ -304,10 +289,6 @@ def main():
|
||||
elif Path(path).suffix in [".csv"]:
|
||||
print("Compile: not compiling ", Path(path).name)
|
||||
|
||||
if os.path.exists(OUT_ASSETS):
|
||||
shutil.rmtree(OUT_ASSETS)
|
||||
|
||||
shutil.copytree(SRC_ASSETS, OUT_ASSETS)
|
||||
global ins_count
|
||||
print(f"total words: {word_count}")
|
||||
print(f"total ins left: {ins_count}")
|
||||
|
934
library.bib
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 157 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 211 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 679 B After Width: | Height: | Size: 679 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B |
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 226 B |
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 470 B After Width: | Height: | Size: 470 B |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 469 B After Width: | Height: | Size: 469 B |
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 202 B After Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 274 B After Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 373 B |
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 449 B |
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
Before Width: | Height: | Size: 263 B After Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 405 B |
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 937 B After Width: | Height: | Size: 937 B |
Before Width: | Height: | Size: 699 B After Width: | Height: | Size: 699 B |
Before Width: | Height: | Size: 698 B After Width: | Height: | Size: 698 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 859 B After Width: | Height: | Size: 859 B |
Before Width: | Height: | Size: 619 B After Width: | Height: | Size: 619 B |