summaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
authoryuzu-eva <cafebabe@disroot.org>2025-03-11 03:04:37 +0100
committeryuzu-eva <cafebabe@disroot.org>2025-03-11 03:04:37 +0100
commite2d1d421e422790b956e57e40522630221eae02c (patch)
tree5a0fe6d84a845c2d70bed1f47d17fc259df71021 /parser.py
parent1d1383ce943cf6b1ddb32b031a9c9a10e29f98fe (diff)
got website working; final touches are needed
Diffstat (limited to 'parser.py')
-rwxr-xr-xparser.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/parser.py b/parser.py
index 41ff65b..db363f3 100755
--- a/parser.py
+++ b/parser.py
@@ -45,9 +45,9 @@ class MyRenderer(mistune.HTMLRenderer):
)
def get_thought_from_id(db, id_):
- title, datetime, markdown, redirect = db.get_thought(id_)
+ title, datetime, markdown, redirect, category_name = db.get_thought(id_)
html, headers = parse_text(markdown)
- return title, datetime, html, headers, redirect
+ return title, datetime, redirect, category_name, html, headers
def parse_file(path):
with open(path, "r") as f:
@@ -114,6 +114,12 @@ def main():
type = str,
required = True
)
+ s.add_argument(
+ "-c", "--category",
+ help = "Article category",
+ type = str,
+ required = True
+ )
for s in [export_parser, update_parser]:
s.add_argument(
@@ -142,8 +148,10 @@ def main():
with database.Database() as db:
match verb:
case "save":
+ if db.add_category(args["category"]):
+ print("Added category.")
with open(args["markdown"], "r") as f:
- db.add_thought(args["title"], f.read())
+ db.add_thought(args["title"], f.read(), args["category"])
print("Added thought.")
case "export":
with open(args["out"], "w") as f:
@@ -154,8 +162,8 @@ def main():
db.update_thought_markdown(args["id"], f.read())
print("Updated thought.")
case "list":
- for id_, title, datetime in db.get_all_thoughts():
- print(f"{id_}, {title}, {datetime}")
+ for id_, title, datetime, category in db.get_all_thoughts():
+ print(f"{id_}, {title}, {datetime}, {category}")
case _:
print("Error! Unknown verb... Exiting...")
exit()