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
|
import random
|
||||||
from hashes.hashes import hash_list
|
from hashes.hashes import hash_list
|
||||||
# Create clean HTML structure
|
# Create clean HTML structure
|
||||||
|
# Pick two different hashes from hash_list
|
||||||
|
hash1, hash2 = random.sample(hash_list, 2)
|
||||||
|
|
||||||
clean_html = f"""<!doctype html>
|
clean_html = f"""<!doctype html>
|
||||||
<html lang="en" style="height:100%; margin:0;">
|
<html lang="en" style="height:100%; margin:0;">
|
||||||
<head>
|
<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;" />
|
<img src="../css/icons/back.png" width="32" height="32" alt="Back" style="display:block;" />
|
||||||
{title}
|
{title}
|
||||||
</h1>
|
</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>
|
<div class="meta" style="display: inline;">Written @{time.asctime(time.localtime())}</div>
|
||||||
<hr style="margin:10px 0;" />
|
<hr style="margin:10px 0;" />
|
||||||
{html_body}
|
{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;" />
|
<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/>
|
{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;" />
|
<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;" />
|
<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 />
|
Hash 2 (<b>Windows-1252</b>)<i>:{base64.b64encode(hash2.encode("windows-1252")).decode("windows-1252")}</i><br />
|
||||||
<i>Decode Hashes to identify pages</i>
|
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>"""
|
</html>"""
|
||||||
@@ -116,28 +118,6 @@ def initial_scan(markdown_dir: Path):
|
|||||||
for md in markdown_dir.rglob("*.md"):
|
for md in markdown_dir.rglob("*.md"):
|
||||||
render_markdown(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 __name__ == "__main__":
|
||||||
if not MARKDOWN_DIR.exists():
|
if not MARKDOWN_DIR.exists():
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
h1 { color: #333; }
|
h1 { color: #333; }
|
||||||
li { list-style: none; background: url("../../css/icons/item.png") no-repeat left center; background-size: 15px 20px; padding-left: 25px; transition: font-size 0.5s cubic-bezier(0.075, 0.82, 0.165, 1); }
|
li { list-style: none; background: url("../../css/icons/item.png") no-repeat left center; background-size: 15px 20px; padding-left: 25px; transition: font-size 0.5s cubic-bezier(0.075, 0.82, 0.165, 1); }
|
||||||
li:hover { font-size: larger; }
|
li:hover { font-size: larger; }
|
||||||
|
#available { padding-left: 40px;}
|
||||||
|
ul { padding-left: 100px;}
|
||||||
#nojs { display: inline-block;color: red;transition: transform 0.7s cubic-bezier(0.215, 0.610, 0.355, 1); }
|
#nojs { display: inline-block;color: red;transition: transform 0.7s cubic-bezier(0.215, 0.610, 0.355, 1); }
|
||||||
#nojs:hover { transform: skewX(-12deg);}
|
#nojs:hover { transform: skewX(-12deg);}
|
||||||
#nonenormalul { list-style: disc inside; margin: 1em 0; padding-left: 40px; background: none; }
|
#nonenormalul { list-style: disc inside; margin: 1em 0; padding-left: 40px; background: none; }
|
||||||
@@ -33,7 +35,7 @@
|
|||||||
console.log("javascript is enabled! good!")
|
console.log("javascript is enabled! good!")
|
||||||
document.write('<h1 id="nojs" style="color:black; display: flex; align-items: center;"><img src="../../css/icons/folder.png" width="45" height="45" style="vertical-align: middle; margin-right: 8px;" />Index of PyPost</h1>');
|
document.write('<h1 id="nojs" style="color:black; display: flex; align-items: center;"><img src="../../css/icons/folder.png" width="45" height="45" style="vertical-align: middle; margin-right: 8px;" />Index of PyPost</h1>');
|
||||||
</script>
|
</script>
|
||||||
<p>
|
<p id="available">
|
||||||
<img src="../../css/icons/available.png" width="32" height="32" style="vertical-align: middle; display: inline; margin-right: 8px;" />
|
<img src="../../css/icons/available.png" width="32" height="32" style="vertical-align: middle; display: inline; margin-right: 8px;" />
|
||||||
Available pages:
|
Available pages:
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
13
webserver.py
13
webserver.py
@@ -4,6 +4,7 @@ import threading
|
|||||||
import subprocess
|
import subprocess
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
from functools import lru_cache
|
||||||
from jsmin import jsmin # pip install jsmin
|
from jsmin import jsmin # pip install jsmin
|
||||||
|
|
||||||
from log.Logger import *
|
from log.Logger import *
|
||||||
@@ -37,7 +38,13 @@ import random
|
|||||||
|
|
||||||
from hashes.hashes import hash_list
|
from hashes.hashes import hash_list
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def index_footer():
|
def index_footer():
|
||||||
|
h1 = random.choice(hash_list)
|
||||||
|
# Ensure h2 is different from h1
|
||||||
|
h2_candidates = [h for h in hash_list if h != h1]
|
||||||
|
h2 = random.choice(h2_candidates) if h2_candidates else h1
|
||||||
|
|
||||||
return f"""
|
return f"""
|
||||||
<footer style="
|
<footer style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -46,9 +53,9 @@ def index_footer():
|
|||||||
">
|
">
|
||||||
<hr style="border: 1px solid #ccc;" />
|
<hr style="border: 1px solid #ccc;" />
|
||||||
<p>
|
<p>
|
||||||
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(random.choice(hash_list).encode("utf-8")).decode("utf-8")}</i><br />
|
Server-Time (CET): <i>{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}</i><br />
|
||||||
Hash 2 (<b>ASCII</b>)<i>:{base64.b64encode(random.choice(hash_list).encode("ascii")).decode("ascii")}</i><br />
|
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(h1.encode("utf-8")).decode("utf-8")}</i><br />
|
||||||
<i>Decode Hashes to identify pages</i>
|
Hash 2 (<b>Windows-1252</b>)<i>:{base64.b64encode(h2.encode("windows-1252")).decode("windows-1252")}</i><br />
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user