aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruser <user@node5.net>2024-02-27 19:05:31 +0100
committeruser <user@node5.net>2024-02-27 19:05:31 +0100
commit49f483c3cf45a844ca864444360cba02a19ebe6d (patch)
treef70364eb349ffb27f435ce90b542ddf36f11cce3
parent679d9081ed16f9f6f2041ec3d5bf2a928ec25347 (diff)
MOTD
-rw-r--r--Makefile2
-rw-r--r--blog.node5.net/motd.yml7
-rw-r--r--blog.node5.net/static/main.css2
-rw-r--r--blog.node5.net/templates/base.html2
-rw-r--r--src/blog_node5_net.py20
5 files changed, 22 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 150cd5a..bf30f7d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
.PHONY: live_reload
-output/pygmentize_code_highlight.css:
+blog.node5.net/static/pygmentize_code_highlight.css:
pygmentize -S fruity -f html -a .codehilite > output/pygmentize_code_highlight.css
debug_server:
flask --app src/blog_node5_net --debug run
diff --git a/blog.node5.net/motd.yml b/blog.node5.net/motd.yml
new file mode 100644
index 0000000..9b091ba
--- /dev/null
+++ b/blog.node5.net/motd.yml
@@ -0,0 +1,7 @@
+- Hosted in a bunker, no really
+- 100% Biodegradable, contains 0 JavaScript
+- Only available over legacy IP
+- BTW I run Arch
+- Hosted on Debian
+- Enriched by PostgreSQL
+- Running Python Flask \ No newline at end of file
diff --git a/blog.node5.net/static/main.css b/blog.node5.net/static/main.css
index c85aed3..4332df8 100644
--- a/blog.node5.net/static/main.css
+++ b/blog.node5.net/static/main.css
@@ -40,7 +40,7 @@ body {
}
.inline {
- display: inline;
+ display: inline-block;
}
hr {
diff --git a/blog.node5.net/templates/base.html b/blog.node5.net/templates/base.html
index 3210946..34c0eeb 100644
--- a/blog.node5.net/templates/base.html
+++ b/blog.node5.net/templates/base.html
@@ -12,7 +12,7 @@
<body>
<div id="root-container">
<a id="logo" href="/">
- <h1>{{ title }}</h1>
+ <h1 class="inline">{{ title }}</h1><h2 class="inline">{{ motd }}</h2>
</a>
<hr>
<br>
diff --git a/src/blog_node5_net.py b/src/blog_node5_net.py
index f59a899..e4bde5d 100644
--- a/src/blog_node5_net.py
+++ b/src/blog_node5_net.py
@@ -1,4 +1,5 @@
import logging
+import random
import os
import typing
import urllib
@@ -17,18 +18,21 @@ site_root_folder_path = 'blog.node5.net'
app = flask.Flask(__name__, template_folder=os.path.join('..', site_root_folder_path, 'templates'),
static_folder=os.path.join('..', site_root_folder_path, 'static'), static_url_path='')
+with open(os.path.join(site_root_folder_path, 'motd.yml'), 'r') as file:
+ motd_list = yaml.safe_load(file.read())
+
folders_by_url: typing.Dict[str, article_handler.Folder] = {}
articles_by_url: typing.Dict[str, article_handler.Article] = {}
-with open(os.path.join('configs', 'database.yml'), 'r') as file:
- db_con_params = yaml.safe_load(file.read())
- logger.debug(f'Database connection parameters: {db_con_params}')
-
-
@app.context_processor # Always inject site title to all render_templates
-def inject_title():
- comments = get_comments(strip_trailing_slash(flask.request.path))
- return {'title': site_root_folder_path, 'comments': comments}
+def inject_common():
+ args = {
+ 'comments': db_handler.get_comments(strip_trailing_slash(flask.request.path)),
+ 'title': site_root_folder_path,
+ 'motd': random.choice(motd_list)
+ }
+
+ return args
def strip_trailing_slash(path):