diff --git a/.gitignore b/.gitignore
index 53a8c0e..751140e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
venv/
log.txt
src/rss.xml
+__pycache__/
diff --git a/main.py b/main.py
index 2fbb24f..f7ba6e0 100644
--- a/main.py
+++ b/main.py
@@ -1,29 +1,50 @@
import frmWrk.website as website
import feed_generator
-import markdown
import pathlib
from time import sleep
+article_base_html = ""
+with open("src/article.html") as article_html:
+ article_base_html = article_html.read()
+
+articles_base_html = ""
+with open("src/articles.html") as articles_html:
+ articles_base_html = articles_html.read()
+
+def article_list():
+ article_paths = (pathlib.Path.cwd() / "feed_articles").glob("[0-9]*")
+ article_paths_sorted = sorted(article_paths, key=lambda x: x.name, reverse=True)
+
+ metadatas = [feed_generator.convert_markdown_to_html(path)[1] for path in article_paths_sorted]
+
+ elements = ['
{title} ({guid}) '.format(title=metadata["title"][0], guid=metadata["guid"][0]) for metadata in metadatas]
+
+ return articles_base_html.format(elements="\n".join(elements))
+
def article(path):
+ if not "?" in path:
+ return article_list()
+
article_name = path.split("?")[1]
article_html = feed_generator.convert_markdown_to_html(pathlib.Path("feed_articles") / article_name)
- return article_html[0]
+ return article_base_html.format(body=article_html[0])
-webserver = website.WebServer("", 3000, "./src", overwrites={"/articles.html": article})
+if __name__ == "__main__":
+ webserver = website.WebServer("", 3000, "./src", overwrites={"/articles.html": article})
-webserver.start()
+ webserver.start()
-while True:
- feed = feed_generator.make_rss_feed("feed_articles", "Vantens", "https://vanten-s.com/", "Vantens personal feed")
- with open("src/rss.xml", "w") as f:
- f.write(feed)
+ while True:
+ feed = feed_generator.make_rss_feed("feed_articles", "Vantens", "https://vanten-s.com/", "Vantens personal feed")
+ with open("src/rss.xml", "w") as f:
+ f.write(feed)
- try:
- sleep(15)
+ try:
+ sleep(15)
- except KeyboardInterrupt:
- break
+ except KeyboardInterrupt:
+ break
-webserver.close()
+ webserver.close()
diff --git a/src/article.html b/src/article.html
new file mode 100644
index 0000000..031f710
--- /dev/null
+++ b/src/article.html
@@ -0,0 +1,61 @@
+
+
+
+ Article
+
+
+
+
+
+
+
+
+
+ {body}
+
+
+
+
\ No newline at end of file
diff --git a/src/articles.html b/src/articles.html
new file mode 100644
index 0000000..39c55a3
--- /dev/null
+++ b/src/articles.html
@@ -0,0 +1,60 @@
+
+
+
+ Articles
+
+
+
+
+
+
+
+
+Posts
+{elements}
+
+
+
\ No newline at end of file
diff --git a/src/index.html b/src/index.html
index 2b748ec..0d4869c 100644
--- a/src/index.html
+++ b/src/index.html
@@ -78,6 +78,12 @@
+
+
+
+
+
+