diff --git a/PyPost.py b/PyPost.py
index dd59477..384687e 100644
--- a/PyPost.py
+++ b/PyPost.py
@@ -1,18 +1,19 @@
#!/usr/bin/env python3
import os
import sys
-import time
import subprocess
import platform
from pathlib import Path
+from jinja2 import Environment, FileSystemLoader
+import base64
+import random
import marko
from marko.ext.gfm import GFM
from watchdog.observers import Observer
-from watchdog.events import FileSystemEventHandler
from log.Logger import *
-from hashes.obfuscation.Obfuscator import Obfuscator
+from hashes.hashes import hash_list
from htmlhandler import htmlhandler as Handler
# Use absolute paths
@@ -28,7 +29,7 @@ RUST_PARSER_PATH = ROOT / "fastmd" / "target" / "release" / f"fastmd{exe_ext}"
if not RUST_PARSER_PATH.exists():
RUST_PARSER_PATH = ROOT / "fastmd" / "target" / "debug" / f"fastmd{exe_ext}"
-# Create Python markdown parser with table support (fallback for small files)
+# Create Python Markdown parser with table support (fallback for small files)
markdown_parser = marko.Markdown(extensions=[GFM])
# Threshold for switching to Rust parser (number of lines)
@@ -100,96 +101,41 @@ def render_markdown(md_path: Path):
html_body = markdown_parser.convert(text)
else:
html_body = markdown_parser.convert(text)
-
+
# Extract title from filename or first H1
title = md_path.stem
for line in text.splitlines():
if line.startswith("# "):
title = line[2:].strip()
break
-
- import base64
- import random
- from hashes.hashes import hash_list
+
# Create clean HTML structure
# Pick two different hashes from hash_list
+ env = Environment(loader=FileSystemLoader("html/base"))
+ template = env.get_template("template.html")
hash1, hash2 = random.sample(hash_list, 2)
- clean_html = f"""
-
-
-
-
- {title}
-
-
-
+ # Load these variable for Jinja to use.
+ clean_jinja_html = template.render(
+ title=title,
+ html_body=html_body,
+ now=time.asctime(time.localtime()),
+ hash1 = base64.b64encode(hash1.encode("utf-8")).decode("utf-8"),
+ hash2 = base64.b64encode(hash2.encode("windows-1252")).decode("utf-8"),
+ timestamp=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
+ )
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {title}
-
-
- Written @{time.asctime(time.localtime())}
-
-
-
- {html_body}
-
-
-
-
-
-"""
-
-
- # Obfuscate the HTML for browser output
- obfuscated_html = Obfuscator.obfuscate_html(clean_html)
-
# Ensure html directory exists
HTML_DIR.mkdir(exist_ok=True)
-
+
# Maintain relative directory structure in html/
relative_path = md_path.relative_to(MARKDOWN_DIR)
out_path = HTML_DIR / relative_path.with_suffix(".html")
-
+
# Create parent directories if needed
out_path.parent.mkdir(parents=True, exist_ok=True)
-# if obfuscate:
-# out_path.write_text(obfuscated_html, encoding="utf-8")
-# else:
-# out_path.write_text(clean_html, encoding="utf-8")
- out_path.write_text(clean_html, encoding="utf-8")
+ out_path.write_text(clean_jinja_html, encoding="utf-8")
Logger.log_debug(f"Rendered: {md_path} -> {out_path}")
def remove_html(md_path: Path):
diff --git a/html/base/template.html b/html/base/template.html
new file mode 100644
index 0000000..c6ecaed
--- /dev/null
+++ b/html/base/template.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ title }}
+
+
+
+ Written @{{ now }}
+
+
+
+ {{ html_body | safe }}
+
+
+
+
+
+
diff --git a/requirements.txt b/requirements.txt
index 1c776d7..9dd55ed 100644
Binary files a/requirements.txt and b/requirements.txt differ
diff --git a/webserver.py b/webserver.py
index 605516e..714b2ed 100644
--- a/webserver.py
+++ b/webserver.py
@@ -5,11 +5,9 @@ import subprocess
from http.server import BaseHTTPRequestHandler, HTTPServer
import mimetypes
from jsmin import jsmin # pip install jsmin
-import time
from log.Logger import *
logger = Logger()
-import PyPost
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
HTML_DIR = os.path.join(PROJECT_ROOT, "html")
@@ -58,6 +56,7 @@ H2 = random.choice(H2_CANDIDATES) if H2_CANDIDATES else H1
# cahcing was a bad, idea, servertime got stuck. it is now a variable ;)
def index_footer():
+ tor_link = "http://7uhuxits7qfmiagkmpazxvh3rtk6aijs6pbawge3fl77y4xqjixlhkqd.onion/"
return f"""
- View Git-Repository
+ View Git-Repository
+
+ View Tor Site
"""