nice visual improvments
This commit is contained in:
92
webserver.py
92
webserver.py
@@ -9,6 +9,8 @@ from pathlib import Path
|
||||
|
||||
from log.Logger import *
|
||||
from lua import plugin_manager
|
||||
from PyPost import extract_summary
|
||||
|
||||
logger = Logger()
|
||||
plugin_manager = plugin_manager.PluginManager()
|
||||
plugin_manager.load_all() # load all plugins
|
||||
@@ -27,28 +29,45 @@ def get_html_files(directory=HTML_DIR):
|
||||
html_files.append(entry)
|
||||
return html_files
|
||||
|
||||
def get_markdown_files():
|
||||
"""Get list of .md files from the markdown directory."""
|
||||
if not os.path.exists(MARKDOWN_DIR):
|
||||
return []
|
||||
|
||||
markdown_files = []
|
||||
for entry in os.listdir(MARKDOWN_DIR):
|
||||
full_path = os.path.join(MARKDOWN_DIR, entry)
|
||||
if os.path.isfile(full_path) and entry.endswith(".md"):
|
||||
markdown_files.append(entry)
|
||||
return markdown_files
|
||||
|
||||
def build_index_page():
|
||||
with open(BASE_FILE, "r", encoding="utf-8") as f:
|
||||
base_html = f.read()
|
||||
html_files = get_html_files(HTML_DIR)
|
||||
links = "\n".join(f'<li><a href="/html/{fname}">{fname}</a></li>' for fname in html_files)
|
||||
content = f"<ul>{links}</ul>"
|
||||
# Insert footer after content
|
||||
full_content = content + index_footer()
|
||||
|
||||
articles = []
|
||||
for md_path in Path(MARKDOWN_DIR).rglob("*.md"):
|
||||
try:
|
||||
summary_data = extract_summary(md_path)
|
||||
if summary_data:
|
||||
html_name, summary = summary_data
|
||||
else:
|
||||
html_name = md_path.stem + ".html"
|
||||
summary = "No Summary for this Article!"
|
||||
|
||||
text = md_path.read_text(encoding="utf-8")
|
||||
title = md_path.stem
|
||||
for line in text.splitlines():
|
||||
if line.startswith("# "):
|
||||
title = line[2:].strip()
|
||||
break
|
||||
|
||||
article_html = f"""
|
||||
<article>
|
||||
<h3><a href="/html/{html_name}">{title}</a></h3>
|
||||
<p>{summary}</p>
|
||||
</article>
|
||||
"""
|
||||
articles.append(article_html)
|
||||
|
||||
except Exception as e:
|
||||
logger.log_warning(f"Exception with summary: {e} at {md_path}")
|
||||
continue
|
||||
|
||||
full_content = "\n".join(articles) + "</main>" + index_footer()
|
||||
return base_html.replace("<!-- CONTENT -->", full_content)
|
||||
|
||||
|
||||
|
||||
import base64
|
||||
import random
|
||||
|
||||
@@ -66,28 +85,25 @@ def index_footer():
|
||||
<!-- Footer styling doesnt need to work with
|
||||
flex, or anything else, because pagnation.
|
||||
-->
|
||||
<footer style="
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
">
|
||||
<hr style="border: 1px solid #ccc;" />
|
||||
<p>
|
||||
<!-- Server Time -->
|
||||
<img src="../css/icons/date.webp" width="16" height="16" alt="date" loading="lazy" style="vertical-align: middle;" />
|
||||
Server-Time (CET ; GMT+2): <i>{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}</i><br />
|
||||
<!-- Hashes -->
|
||||
<img src="../css/icons/magnifier.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(H1.encode("utf-8")).decode("utf-8")}</i><br />
|
||||
<img src="../css/icons/magnifier.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 2 (<b>Windows-1252</b>)<i>:{base64.b64encode(H2.encode("windows-1252")).decode("windows-1252")}</i><br />
|
||||
<!-- Git Repository Link -->
|
||||
<img src="../css/icons/written.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
<a style="text-decoration:none;color:#0066cc;font-style:italic;padding-top:5px;" href="https://rattatwinko.servecounterstrike.com/gitea/rattatwinko/PyPost">View Git-Repository</a><br />
|
||||
<img src="../css/icons/script.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
<a style="text-decoration:none;color:#0066cc;font-style:italic;padding-top:5px;" href="{tor_link}">View Tor Site</a>
|
||||
</p>
|
||||
</footer>
|
||||
<div class="footer">
|
||||
<footer>
|
||||
<p>
|
||||
<!-- Server Time -->
|
||||
<img src="../css/icons/date.webp" width="16" height="16" alt="date" loading="lazy" style="vertical-align: middle;" />
|
||||
Server-Time (CET ; GMT+2): <i>{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}</i><br />
|
||||
<!-- Hashes -->
|
||||
<img src="../css/icons/magnifier.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 1 (<b>UTF-8</b>)<i>:{base64.b64encode(H1.encode("utf-8")).decode("utf-8")}</i><br />
|
||||
<img src="../css/icons/magnifier.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
Hash 2 (<b>Windows-1252</b>)<i>:{base64.b64encode(H2.encode("windows-1252")).decode("windows-1252")}</i><br />
|
||||
<!-- Git Repository Link -->
|
||||
<img src="../css/icons/written.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
<a style="text-decoration:none;color:#0066cc;font-style:italic;padding-top:5px;" href="https://rattatwinko.servecounterstrike.com/gitea/rattatwinko/PyPost">View Git-Repository</a><br />
|
||||
<img src="../css/icons/script.webp" width="16" height="16" alt="Hash2" loading="lazy" style="display:inline; vertical-align:middle;" />
|
||||
<a style="text-decoration:none;color:#0066cc;font-style:italic;padding-top:5px;" href="{tor_link}">View Tor Site</a>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
"""
|
||||
|
||||
class MyHandler(BaseHTTPRequestHandler):
|
||||
|
||||
Reference in New Issue
Block a user