vault backup: 2025-12-07 17:19:42
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m48s
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
@@ -36,11 +36,3 @@ PMCID: PMC389671
|
||||
PMID: 4342968
|
||||
|
||||
→ Nobelpriset 1980 till Paul Berg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
𝛼-sl
|
||||
@@ -68,8 +68,6 @@ def markdown_filter(text):
|
||||
return md.convert(text)
|
||||
|
||||
env.filters["markdown"] = markdown_filter
|
||||
|
||||
template = env.get_template("base.html")
|
||||
output_dir = root_dir / "output"
|
||||
|
||||
|
||||
@@ -96,62 +94,75 @@ def build_tree(vault: Vault):
|
||||
if note:
|
||||
item["title"] = note.title
|
||||
# TODO: for search add tags, modified time, content etc
|
||||
|
||||
cur[filename] = item
|
||||
return tree
|
||||
|
||||
|
||||
def write_note(item, tree_json):
|
||||
def write_note(item):
|
||||
if "children" in item:
|
||||
for child in item["children"].values():
|
||||
write_note(child, tree_json)
|
||||
write_note(child)
|
||||
else:
|
||||
path = pathlib.Path(item["folder"]) / item["filename"]
|
||||
note = vault.get_note(path)
|
||||
if note:
|
||||
out_path = output_dir / item["folder"] / (item["title"] + ".html")
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
context = {
|
||||
"filename": item["filename"],
|
||||
"folder": item["folder"],
|
||||
"path": path,
|
||||
}
|
||||
|
||||
# Calculate relative base_path based on folder depth
|
||||
folder = item["folder"]
|
||||
if folder == ".":
|
||||
base_path = ""
|
||||
else:
|
||||
depth = len(pathlib.Path(folder).parts)
|
||||
base_path = "../" * depth
|
||||
|
||||
with out_path.open("w", encoding="utf-8") as f:
|
||||
data = template.render(note=note, vault=vault, base_path=base_path, index_json=tree_json)
|
||||
f.write(data)
|
||||
folder = output_dir / item["folder"]
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
link = False
|
||||
if note := vault.get_note(path):
|
||||
template_name = "note.jinja2"
|
||||
context["note"] = note
|
||||
context["title"] = note.title
|
||||
elif item["filename"].endswith(".pdf"):
|
||||
template_name = "pdf.jinja2"
|
||||
context["title"] = item["filename"]
|
||||
link = True
|
||||
elif item["filename"].lower().endswith((".png", ".jpg", ".jpeg", ".gif", ".webp")):
|
||||
template_name = "image.jinja2"
|
||||
context["title"] = item["filename"]
|
||||
link = True
|
||||
else:
|
||||
print(f"Note not found for {path}")
|
||||
return
|
||||
|
||||
if link:
|
||||
os.link(
|
||||
vault.path / item["folder"] / item["filename"],
|
||||
output_dir / item["folder"] / item["filename"],
|
||||
)
|
||||
|
||||
out_path = folder / (context["title"] + ".html")
|
||||
with out_path.open("w", encoding="utf-8") as f:
|
||||
template = env.get_template(template_name)
|
||||
data = template.render(**context)
|
||||
f.write(data)
|
||||
|
||||
|
||||
def build():
|
||||
"""Build the static site."""
|
||||
print("Building...")
|
||||
|
||||
# 1. Create output dir
|
||||
shutil.rmtree(output_dir, ignore_errors=True)
|
||||
output_dir.mkdir(exist_ok=True)
|
||||
|
||||
# 1b. Symlink CSS/JS to output root
|
||||
(output_dir / "style.css").symlink_to(root_dir / "style.css")
|
||||
(output_dir / "script.js").symlink_to(root_dir / "script.js")
|
||||
|
||||
# 1c. Symlink attachments directory
|
||||
attachments_src = root_dir.parent / "content" / "attachments"
|
||||
attachments_dst = output_dir / "attachments"
|
||||
attachments_dst.symlink_to(attachments_src)
|
||||
|
||||
# 2. Build tree and write index json
|
||||
tree = build_tree(vault)
|
||||
tree_json = json.dumps(tree)
|
||||
with (output_dir / "index.json").open("w") as f:
|
||||
f.write(tree_json)
|
||||
|
||||
# 3. Write out each note as html
|
||||
write_note({"children": tree}, tree_json)
|
||||
write_note({"children": tree})
|
||||
|
||||
print(f"Built to {output_dir}")
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<meta charset="utf-8">
|
||||
<base href="{{base_path}}">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<title>{% block title %}WIP{% endblock %}</title>
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{% extends "base.jinja2" %}
|
||||
{% block title %}{{ filename }}{% endblock %}
|
||||
{% block content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<div class="image-container">
|
||||
<img src="{{ filename }}" alt="{{ title }}" class="preview-image">
|
||||
</div>
|
||||
<style>
|
||||
.image-container {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.preview-image {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'base.html' %}
|
||||
{% extends 'base.jinja2' %}
|
||||
{% block title %}{{note.title}}{% endblock %}
|
||||
{% block content %}
|
||||
<h1>{{note.title}}</h1>
|
||||
|
||||
@@ -1,5 +1,52 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{filename}}{% endblock %}
|
||||
{% extends "base.jinja2" %}
|
||||
{% block title %}{{ filename }}{% endblock %}
|
||||
{% block content %}
|
||||
TODO: pdf.js
|
||||
<h1>{{ title }}</h1>
|
||||
<a id="download-btn" href="{{ filename }}" download class="download-button">Download PDF</a>
|
||||
<canvas id="pdf-render"></canvas>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
const url = "{{ filename }}";
|
||||
const pdfjsLib = window['pdfjs-dist/build/pdf'];
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js';
|
||||
const loadingTask = pdfjsLib
|
||||
.getDocument(url)
|
||||
.promise
|
||||
.then(function (pdf) {
|
||||
console.log('PDF loaded');
|
||||
pdf.getPage(1).then(function (page) {
|
||||
console.log('Page loaded');
|
||||
const scale = 1.5;
|
||||
const viewport = page.getViewport({scale: scale});
|
||||
const canvas = document.getElementById('pdf-render');
|
||||
const context = canvas.getContext('2d');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
const renderContext = {
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
};
|
||||
page.render(renderContext).promise.then(function () {
|
||||
console.log('Page rendered');
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(function (reason) {
|
||||
console.error(reason);
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.download-button {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.download-button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||