From ee89735cb3714dc7c3ec8bbd0643cf279ee9a1ef Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 17 Mar 2024 00:00:29 +0100
Subject: [PATCH] Add rump Days module.

---
 scripts/pre-commit      | 6 +++---
 task.py                 | 6 +++++-
 templates/calendar.html | 9 +++++++++
 templates/index.html    | 5 -----
 4 files changed, 17 insertions(+), 9 deletions(-)
 create mode 100644 templates/calendar.html
 delete mode 100644 templates/index.html

diff --git a/scripts/pre-commit b/scripts/pre-commit
index a053262..e1cfb73 100755
--- a/scripts/pre-commit
+++ b/scripts/pre-commit
@@ -1,6 +1,6 @@
 #!/bin/sh
 set -e
-python3 -m mypy task.py
-python3 -m flake8 task.py
-python3 -m pylint --good-names 'do_GET,do_POST' task.py
+python3 -m mypy *.py
+python3 -m flake8 *.py
+python3 -m pylint --good-names 'do_GET,do_POST' *.py
 exit 0
diff --git a/task.py b/task.py
index 2a6c699..d6128ee 100755
--- a/task.py
+++ b/task.py
@@ -5,6 +5,7 @@ plom's task manager
 from http.server import BaseHTTPRequestHandler
 from http.server import HTTPServer
 from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader
+from days import Day
 
 HTTP_PORT = 8082
 TEMPLATES_DIR = 'templates'
@@ -21,7 +22,10 @@ class TaskHandler(BaseHTTPRequestHandler):
         """Handle any GET request."""
         self.send_response(200)
         self.end_headers()
-        html = self.server.jinja.get_template('index.html').render()
+        days = [Day('2024-01-03'), Day('2024-01-01'), Day('2024-01-02')]
+        days.sort()
+        html = self.server.jinja.get_template('calendar.html').render(
+                days=days)
         self.wfile.write(bytes(html, 'utf-8'))
 
 
diff --git a/templates/calendar.html b/templates/calendar.html
new file mode 100644
index 0000000..0f18203
--- /dev/null
+++ b/templates/calendar.html
@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+
+{% block content %}
+<ul>
+{% for day in days %}
+<li>{{day.date}} ({{day.weekday}})
+{% endfor %}
+</ul>
+{% endblock %}
diff --git a/templates/index.html b/templates/index.html
deleted file mode 100644
index 72d81d4..0000000
--- a/templates/index.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{% extends 'base.html' %}
-
-{% block content %}
-Hi there!
-{% endblock %}
-- 
2.30.2