some visual changes
This commit is contained in:
32
PyPost.py
32
PyPost.py
@@ -47,6 +47,9 @@ def render_markdown(md_path: Path):
|
||||
import random
|
||||
from hashes.hashes import hash_list
|
||||
# Create clean HTML structure
|
||||
# Pick two different hashes from hash_list
|
||||
hash1, hash2 = random.sample(hash_list, 2)
|
||||
|
||||
clean_html = f"""<!doctype html>
|
||||
<html lang="en" style="height:100%; margin:0;">
|
||||
<head>
|
||||
@@ -62,7 +65,7 @@ def render_markdown(md_path: Path):
|
||||
<img src="../css/icons/back.png" width="32" height="32" alt="Back" style="display:block;" />
|
||||
{title}
|
||||
</h1>
|
||||
<img src="../css/icons/written.png" width="32" height="32" alt="write_img" loading="lazy" style="vertical-align: middle;" />
|
||||
<img src="../css/icons/written.png" width="32" height="32" alt="write_img" loading="lazy" style="vertical-align: middle;padding-left:12px; padding-left:40px;" />
|
||||
<div class="meta" style="display: inline;">Written @{time.asctime(time.localtime())}</div>
|
||||
<hr style="margin:10px 0;" />
|
||||
{html_body}
|
||||
@@ -73,10 +76,9 @@ def render_markdown(md_path: Path):
|
||||
<img src="../css/icons/date.png" width="16" height="16" alt="date" loading="lazy" style="vertical-align: middle;" />
|
||||
{time.strftime("%Y-%m-%d %H:%M:%S")}<br/>
|
||||
<img src="../css/icons/magnifier.png" width="16" height="16" alt="Hash1" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(random.choice(hash_list).encode("utf-8")).decode("utf-8")}</i><br />
|
||||
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(hash1.encode("utf-8")).decode("utf-8")}</i><br />
|
||||
<img src="../css/icons/magnifier.png" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 2 (<b>ASCII</b>)<i>:{base64.b64encode(random.choice(hash_list).encode("ascii")).decode("ascii")}</i><br />
|
||||
<i>Decode Hashes to identify pages</i>
|
||||
Hash 2 (<b>Windows-1252</b>)<i>:{base64.b64encode(hash2.encode("windows-1252")).decode("windows-1252")}</i><br />
|
||||
</footer>
|
||||
</body>
|
||||
</html>"""
|
||||
@@ -116,28 +118,6 @@ def initial_scan(markdown_dir: Path):
|
||||
for md in markdown_dir.rglob("*.md"):
|
||||
render_markdown(md)
|
||||
|
||||
"""
|
||||
class Handler(FileSystemEventHandler):
|
||||
def on_created(self, event):
|
||||
if not event.is_directory and event.src_path.endswith(".md"):
|
||||
render_markdown(Path(event.src_path))
|
||||
|
||||
def on_modified(self, event):
|
||||
if not event.is_directory and event.src_path.endswith(".md"):
|
||||
render_markdown(Path(event.src_path))
|
||||
|
||||
def on_deleted(self, event):
|
||||
if not event.is_directory and event.src_path.endswith(".md"):
|
||||
remove_html(Path(event.src_path))
|
||||
|
||||
def on_moved(self, event):
|
||||
src = Path(event.src_path)
|
||||
dest = Path(event.dest_path)
|
||||
if src.suffix.lower() == ".md":
|
||||
remove_html(src)
|
||||
if dest.suffix.lower() == ".md":
|
||||
render_markdown(dest)
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not MARKDOWN_DIR.exists():
|
||||
|
||||
Reference in New Issue
Block a user