fix force refresh bug

This commit is contained in:
2026-05-27 11:23:23 +02:00
parent 5c170a195e
commit 7f5b144cff
6 changed files with 281 additions and 15 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ from watchdog.observers import Observer
from log.Logger import * from log.Logger import *
from hashes.hashes import hash_list from hashes.hashes import hash_list
from htmlhandler import htmlhandler as Handler from htmlhandler import htmlhandler
from lua import plugin_manager from lua import plugin_manager
# Import your LaTeX extension # Import your LaTeX extension
@@ -259,7 +259,7 @@ if __name__ == "__main__":
Logger.log_warning("Using Python parser for all files") Logger.log_warning("Using Python parser for all files")
initial_scan(MARKDOWN_DIR) initial_scan(MARKDOWN_DIR)
event_handler = Handler() event_handler = htmlhandler(render_markdown, remove_html)
observer = Observer() observer = Observer()
observer.schedule(event_handler, str(MARKDOWN_DIR), recursive=True) observer.schedule(event_handler, str(MARKDOWN_DIR), recursive=True)
observer.start() observer.start()
+245
View File
@@ -0,0 +1,245 @@
<!doctype html>
<html lang="en" style="height:100%;margin:0;">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Rotation eines Würfels mit Matrizen</title>
<!-- Load main stylesheet asynchronously -->
<link rel="preload" as="style" href="/css/main.css" onload="this.rel='stylesheet'">
<link rel="preload" as="style" href="/css/prism.css" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="/css/main.css"></noscript>
<link rel="icon" type="image/x-icon" href="/css/favicon/favicon.ico">
<!-- Local JS -->
<script src="/js/shared/theme.js"></script>
<script src="/js/post/download.js" defer></script>
<!-- Prism (code highlighting) -->
<script src="/js/post/prism.js" defer></script>
<!-- Dynamic MathJax loader -->
<script>
document.addEventListener('DOMContentLoaded', () => {
const hasMath = /\$\$(.|[\r\n])*?\$\$|\$(?!\$)(.*?)\$/.test(document.body.innerHTML);
if (hasMath) {
const mj = document.createElement('script');
mj.src = '/package/js/mathjax.js';
mj.defer = true;
document.head.appendChild(mj);
}
});
</script>
<!-- Service worker registration -->
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/js/post/sw.js').catch(console.error);
}
</script>
</head>
<body>
<main class="container">
<h1 onclick="window.location.href=window.location.origin" style="cursor:pointer;display:flex;align-items:center;gap:8px;font-size:1.5em;margin:0;">
<img src="/css/icons/back.webp" width="32" height="32" alt="⬅" loading="lazy">
Rotation eines Würfels mit Matrizen <noscript>(Enable JavaScript!)</noscript>
</h1>
<img src="/css/icons/written.webp" width="32" height="32" alt="📄" loading="lazy" style="vertical-align:middle;margin-left:40px;cursor:pointer;" onclick="toggleDarkMode();" />
<div class="meta" style="display:inline;cursor:pointer;" onclick="toggleDarkMode();">
Written @Wed May 27 11:21:22 2026
</div>
<hr style="margin:10px 0;">
<div class="html-content">
<h1>Rotation eines Würfels mit Matrizen</h1>
<h2>1. Der Würfel im Raum</h2>
<p>Ein Würfel im Ursprung des Koordinatensystems (Mittelpunkt bei ( (0,0,0) )) und der Kantenlänge 2 besitzt die Eckpunkte:</p>
<div class="math-block">$$
\begin{aligned}
A &amp;= (1, 1, 1), &amp; B &amp;= (1, 1, -1), &amp; C &amp;= (1, -1, 1), \\
D &amp;= (1, -1, -1), &amp; E &amp;= (-1, 1, 1), &amp; F &amp;= (-1, 1, -1), \\
G &amp;= (-1, -1, 1), &amp; H &amp;= (-1, -1, -1)
\end{aligned}
$$</div>
<p>Jeder Punkt kann als Spaltenvektor dargestellt werden:</p>
<div class="math-block">$$
\mathbf{v} =
\begin{pmatrix}
x \\
y \\
z
\end{pmatrix}.
$$</div>
<p>Eine Drehung des Würfels im Raum kann mathematisch durch <strong>Multiplikation mit einer Rotationsmatrix</strong> beschrieben werden.</p>
<hr />
<h2>2. Rotationsmatrizen im 3D-Raum</h2>
<p>Eine Rotationsmatrix beschreibt eine Drehung um eine bestimmte Achse. Dabei bleibt die Länge der Vektoren unverändert, ebenso die Winkel zwischen ihnen.
Es gibt drei elementare Rotationen: um die <strong>x-Achse</strong>, die <strong>y-Achse</strong> und die <strong>z-Achse</strong>.</p>
<hr />
<h3>a) Rotation um die x-Achse</h3>
<div class="math-block">$$
\mathbf{v}' = R_x(\theta)\mathbf{v} =
\begin{pmatrix}
x \\
y \cos\theta - z \sin\theta \\
y \sin\theta + z \cos\theta
\end{pmatrix}
$$</div>
<p>Die x-Koordinate bleibt bei dieser Drehung unverändert. Der Punkt</p>
<div class="math-block">$$
\mathbf{v}' = R_x(\theta)\mathbf{v} =
\begin{pmatrix}
x \\
y \cos\theta - z \sin\theta \\
y \sin\theta + z \cos\theta
\end{pmatrix}
$$</div>
<hr />
<h3>b) Rotation um die y-Achse</h3>
<div class="math-block">$$
R_y(\theta) =
\begin{pmatrix}
\cos\theta &amp; 0 &amp; \sin\theta \\
0 &amp; 1 &amp; 0 \\
-\sin\theta &amp; 0 &amp; \cos\theta
\end{pmatrix}
$$</div>
<p>Dabei bleibt die y-Koordinate gleich, x und z verändern sich.</p>
<div class="math-block">$$
\mathbf{v}' = R_y(\theta)\mathbf{v} =
\begin{pmatrix}
x \cos\theta + z \sin\theta \\
y \\
- x \sin\theta + z \cos\theta
\end{pmatrix}
$$</div>
<hr />
<h3>c) Rotation um die z-Achse</h3>
<div class="math-block">$$
R_z(\theta) =
\begin{pmatrix}
\cos\theta &amp; -\sin\theta &amp; 0 \\
\sin\theta &amp; \cos\theta &amp; 0 \\
0 &amp; 0 &amp; 1
\end{pmatrix}
$$</div>
<p>Hier bleibt z unverändert, während x und y rotieren.</p>
<div class="math-block">$$
\mathbf{v}' = R_z(\theta)\mathbf{v} =
\begin{pmatrix}
x \cos\theta - y \sin\theta \\
x \sin\theta + y \cos\theta \\
z
\end{pmatrix}
$$</div>
<hr />
<h2>3. Kombination mehrerer Rotationen</h2>
<p>Oft wird ein Objekt nacheinander um mehrere Achsen gedreht.
Die Gesamtrotation ergibt sich durch <strong>Multiplikation der einzelnen Rotationsmatrizen</strong>.</p>
<p>Beispiel:</p>
<div class="math-block">$$
R_{\text{gesamt}} = R_x(\alpha) \cdot R_y(\beta) \cdot R_z(\gamma).
$$</div>
<p>Ein Punkt \(v\) wird dann abgebildet auf:</p>
<div class="math-block">$$
\mathbf{v}' = R_{\text{gesamt}}\mathbf{v}.
$$</div>
<p>Die Reihenfolge ist dabei wesentlich, da die Matrixmultiplikation <strong>nicht kommutativ</strong> ist:</p>
<div class="math-block">$$
R_x R_y \neq R_y R_x.
$$</div>
<p>Das bedeutet: Zuerst um die x-Achse und danach um die y-Achse zu drehen führt zu einem anderen Ergebnis, als die Reihenfolge umzukehren.</p>
<hr />
<h2>4. Matrixmultiplikation</h2>
<p>Die Multiplikation zweier Matrizen (A) und (B) (jeweils 3×3) ergibt eine neue Matrix (C = A \cdot B) mit den Einträgen:</p>
<div class="math-block">$$
c_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + a_{i3}b_{3j}.
$$</div>
<p>Allgemein gilt:</p>
<ul>
<li>Jede Zeile von (A) wird mit jeder Spalte von (B) multipliziert.</li>
<li>Die Summe dieser Produkte ergibt das jeweilige Element von (C).</li>
</ul>
<p>So kann man Schritt für Schritt die Gesamtrotationsmatrix berechnen.</p>
<hr />
<h2>5. Beispiel für (\(\theta = 45^\circ\))</h2>
<p>Für den Winkel \(\theta = 45^\circ = \frac{\pi}{4}\) gilt:</p>
<div class="math-block">$$
\cos\theta = \sin\theta = \frac{\sqrt{2}}{2}.
$$</div>
<p>Damit lautet die Rotationsmatrix um die x-Achse:</p>
<div class="math-block">$$
R_x(45^\circ) =
\begin{pmatrix}
1 &amp; 0 &amp; 0 \\
0 &amp; \tfrac{\sqrt{2}}{2} &amp; -\tfrac{\sqrt{2}}{2} \\
0 &amp; \tfrac{\sqrt{2}}{2} &amp; \tfrac{\sqrt{2}}{2}
\end{pmatrix}
$$</div>
<p>Wendet man diese Matrix auf den Punkt \(\mathbf{A} = (1, 1, 1)\) an, ergibt sich:</p>
<div class="math-block">$$
\begin{aligned}
x' &amp;= 1, \\
y' &amp;= 1 \cdot \tfrac{\sqrt{2}}{2} - 1 \cdot \tfrac{\sqrt{2}}{2} = 0, \\
z' &amp;= 1 \cdot \tfrac{\sqrt{2}}{2} + 1 \cdot \tfrac{\sqrt{2}}{2} = \sqrt{2}.
\end{aligned}
$$</div>
<p>Der neue Punkt ist also:</p>
<div class="math-block">$$
\mathbf{A}' = (1, 0, \sqrt{2}).
$$</div>
<p>Der Punkt wurde damit um die x-Achse um 45° gedreht.</p>
<hr />
<h2>6. Zusammenfassung</h2>
<ul>
<li>Eine <strong>Rotationsmatrix</strong> beschreibt eine Drehung im Raum.</li>
<li>Die Länge eines Vektors bleibt bei der Rotation unverändert.</li>
<li>Es gibt drei Grundmatrizen: \(R_x(\theta)\), \(R_y(\theta)\) und \(R_z(\theta)\).</li>
<li>Durch <strong>Multiplikation</strong> kann man mehrere Drehungen kombinieren.</li>
<li>Die Reihenfolge der Rotationen ist <strong>nicht vertauschbar</strong>.</li>
<li>Bei \(45^\circ\) erscheinen häufig die Werte \(\frac{\sqrt{2}}{2}\) und \(\frac{1}{2}\).</li>
</ul>
</div>
</main>
<footer style="margin-top:auto;width:100%;">
<hr style="margin:10px 0;">
<img src="/css/icons/date.webp" width="16" height="16" alt="date" loading="lazy">
2026-05-27 11:21:22<br>
<img src="/css/icons/magnifier.webp" width="16" height="16" alt="Hash1" loading="lazy">
Hash 1 (<b>UTF-8</b>)<i>:dG9tYm95IHRvdWNhbg==</i><br>
<img src="/css/icons/magnifier.webp" width="16" height="16" alt="Hash2" loading="lazy">
Hash 2 (<b>Windows-1252</b>)<i>:ZmVtYm95IGZsYW1pbmdv</i><br>
<span style="display:inline-flex;align-items:center;gap:8px;">
<img src="/css/icons/save.webp" width="16" height="16" alt="Save" loading="lazy">
<a id="download-md">Download as Markdown</a>
<span style="border-left:1px solid #888;height:16px;"></span>
<img src="/css/icons/script.webp" width="16" height="16" alt="Script" loading="lazy">
<a id="download-html">Download as HTML</a>
</span>
</footer>
</body>
</html>
+9 -11
View File
@@ -1,29 +1,27 @@
from pathlib import Path from pathlib import Path
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
# this has to be like this. idk why. its ass
class htmlhandler(FileSystemEventHandler): class htmlhandler(FileSystemEventHandler):
def __init__(self, render_func, remove_func):
self.render_func = render_func
self.remove_func = remove_func
def on_created(self, event): def on_created(self, event):
if not event.is_directory and event.src_path.endswith(".md"): if not event.is_directory and event.src_path.endswith(".md"):
import PyPost self.render_func(Path(event.src_path))
PyPost.render_markdown(Path(event.src_path))
def on_modified(self, event): def on_modified(self, event):
if not event.is_directory and event.src_path.endswith(".md"): if not event.is_directory and event.src_path.endswith(".md"):
import PyPost self.render_func(Path(event.src_path))
PyPost.render_markdown(Path(event.src_path))
def on_deleted(self, event): def on_deleted(self, event):
if not event.is_directory and event.src_path.endswith(".md"): if not event.is_directory and event.src_path.endswith(".md"):
import PyPost self.remove_func(Path(event.src_path))
PyPost.remove_html(Path(event.src_path))
def on_moved(self, event): def on_moved(self, event):
src = Path(event.src_path) src = Path(event.src_path)
dest = Path(event.dest_path) dest = Path(event.dest_path)
import PyPost
if src.suffix.lower() == ".md": if src.suffix.lower() == ".md":
PyPost.remove_html(src) self.remove_func(src)
if dest.suffix.lower() == ".md": if dest.suffix.lower() == ".md":
PyPost.render_markdown(dest) self.render_func(dest)
+9
View File
@@ -0,0 +1,9 @@
register_hook("pre_template", function(md_path, html_body)
-- Check if the current markdown path is for test.md
if md_path and md_path:match("test%.md$") then
local banner = "<div class='plugin-banner' style='padding:10px;background:white;border:1px solid #f99;margin-bottom:12px;color:black;'>Note: served via Lua plugin banner</div>"
return banner .. html_body
end
-- For other pages, return the original HTML body unchanged
return html_body
end)
+14
View File
@@ -0,0 +1,14 @@
certifi==2026.5.20
charset-normalizer==3.4.7
colorama==0.4.6
idna==3.16
Jinja2==3.1.6
jsmin==3.0.1
lupa==2.5
marko==2.2.0
MarkupSafe==3.0.3
pillow==11.3.0
PyYAML==6.0.3
requests==2.32.5
urllib3==2.7.0
watchdog==6.0.0
+2 -2
View File
@@ -279,7 +279,7 @@ def get_html_files(directory=HTML_DIR):
return html_files return html_files
_index_cache = {"content": None, "timestamp": 0} _index_cache = {"content": None, "timestamp": 0}
INDEX_CACHE_TTL = 300 # 300/60 = 5min INDEX_CACHE_TTL = 10 # 300/60 = 5min
def build_index_page(force_refresh: bool = False) -> str: def build_index_page(force_refresh: bool = False) -> str:
"""Build index page with caching""" """Build index page with caching"""
@@ -460,7 +460,7 @@ class WebServerHTTPRequestHandler(BaseHTTPRequestHandler):
# Handle root/index with caching # Handle root/index with caching
if req_path == "" or req_path == "index.html": if req_path == "" or req_path == "index.html":
content = build_index_page() content = build_index_page(True)
self._send_compressed_response( self._send_compressed_response(
content.encode("utf-8"), content.encode("utf-8"),
"text/html", "text/html",