From 5d5abedb7504a93bda52fc326e39255629e2c648 Mon Sep 17 00:00:00 2001
From: jwansek <eddie.atten.ea29@gmail.com>
Date: Sat, 8 Oct 2022 23:39:56 +0100
Subject: Added rendering diary posts, fixed git section

---
 app.py                  |  9 +++++++++
 database.py             |  3 ---
 static/style.css        | 14 ++++++++++++++
 templates/diary.html.j2 | 24 ++++++++++++++++++++++++
 templates/index.html.j2 |  2 +-
 5 files changed, 48 insertions(+), 4 deletions(-)
 create mode 100644 templates/diary.html.j2

diff --git a/app.py b/app.py
index e06ac8e..3e0c96b 100755
--- a/app.py
+++ b/app.py
@@ -67,6 +67,15 @@ def index():
 def robots():
     return flask.send_from_directory("static", "robots.txt")
 
+@app.route("/diary")
+def diary():
+    with database.Database() as db:
+        return flask.render_template(
+            "diary.html.j2",
+            **get_template_items("diary", db),
+            diary = db.get_diary()
+        )
+
 @app.route("/discord")
 def discord():
     with database.Database() as db:
diff --git a/database.py b/database.py
index 52cfe39..ff769a0 100755
--- a/database.py
+++ b/database.py
@@ -275,9 +275,6 @@ class Database:
                     self.append_diary_images(tweet_id, im)
 
         self.__connection.commit()
-        print("Fetch completed.")
-
-        
 
 def update_cache():
     # print("updating cache...")
diff --git a/static/style.css b/static/style.css
index cc6b460..6d18d62 100755
--- a/static/style.css
+++ b/static/style.css
@@ -129,6 +129,20 @@ aside {
     font-size: x-small;
 }
 
+#diaryentry {
+    list-style-type: none;
+}
+
+#diaryentry ul {
+    list-style-type: none;
+    display: inline-block;
+}
+
+#diaryentry ul li img {
+    max-height: 150px;
+    margin-top: 10px;
+}
+
 blockquote span {
     color: #789922;
 }
diff --git a/templates/diary.html.j2 b/templates/diary.html.j2
new file mode 100644
index 0000000..15cbe71
--- /dev/null
+++ b/templates/diary.html.j2
@@ -0,0 +1,24 @@
+{% extends "template.html.j2" %}
+{% block content %}
+    <dl>
+        {% for dt, entries in diary.items() %}
+            <dt><a href="{{ entries[0]['link'] }}">{{ dt }}</a></dt>
+            <dd>
+                <ol id="diaryentry">
+                    {% for entry in entries %}
+                        {% if entry["images"] != [] %}
+                            <ul>
+                                {% for img in entry["images"] %}
+                                    <li><a href="{{ img }}" target='_blank'><img src="{{ img }}"></a></li>
+                                {% endfor %}
+                            </ul>
+                        {% endif %}
+                        <li>
+                            <p>{{ entry["text"] }}</p>
+                        </li>
+                    {% endfor %}
+                </ol>
+            </dd>
+        {% endfor %}
+    </dl>
+{% endblock %}
\ No newline at end of file
diff --git a/templates/index.html.j2 b/templates/index.html.j2
index 31c6207..72bff7b 100755
--- a/templates/index.html.j2
+++ b/templates/index.html.j2
@@ -29,7 +29,7 @@
         <h3>recent git commits:</h3>
         <ul>
             {% for commit in commits %}
-                <li>[<a href="{{'https://git.eda.gay/' + commit['repo'] + '/about.html'}}">{{commit["repo"]}}</a>] {+{{commit["stats"]["additions"]}}; -{{commit["stats"]["deletions"]}}} <a href="{{commit['url'].replace('github.com/jwansek', 'git.eda.gay') + '.html'}}">{{commit["message"]}}</a> - <a href="{{commit['url']}}">backup link</a></li>
+                <li>[<a href="{{'https://git.eda.gay/' + commit['repo']}}">{{commit["repo"]}}</a>] {+{{commit["stats"]["additions"]}}; -{{commit["stats"]["deletions"]}}} <a href="{{commit['url'].replace('github.com/jwansek', 'git.eda.gay')}}">{{commit["message"]}}</a> - <a href="{{commit['url']}}">github mirror</a></li>
             {% endfor %}
         </ul>
     </section>
-- 
cgit v1.2.3