commit 08cb8f4cc9690295a4a2308a165bd8e06fe65961 Author: Rasmus Date: Mon Dec 22 06:29:13 2025 +0100 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61f212b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +pages/ +venv/ +static/ \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..9f05a80 --- /dev/null +++ b/app.py @@ -0,0 +1,29 @@ +from flask import Flask, render_template +from flask_flatpages import FlatPages + +DEBUG = True +FLATPAGES_AUTO_RELOAD = DEBUG +FLATPAGES_EXTENSION = '.md' + +app = Flask(__name__) +app.config.from_object(__name__) +pages = FlatPages(app) +FLATPAGES_MARKDOWN_EXTENSIONS = ['fenced_code', 'tables'] +app.config['FLATPAGES_MARKDOWN_EXTENSIONS'] = FLATPAGES_MARKDOWN_EXTENSIONS + +@app.route('/') +def index(): + posts = sorted(pages, key=lambda p: p.meta.get('date'), reverse=True) + return render_template('index.html', posts=posts) + +@app.route('//') +def post(path): + page = pages.get_or_404(path) + return render_template('post.html', page=page) + +@app.route('/about') +def about(): + return render_template('about.html') + +if __name__ == "__main__": + app.run(port=5001) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3d8e868 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +flask-flatpages diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000..a8b1ef2 --- /dev/null +++ b/templates/about.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block content %} +
+

What is this site?

+
+I write articles about Arduino, STM32 and self-hosting. The articles are short and conceptual. It is not tutorials but more high level descriptions and general guidelines for reproducing the various things i tinker with. +{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..c04b9cf --- /dev/null +++ b/templates/base.html @@ -0,0 +1,34 @@ + + + + + + + + + {% block title %}RasmusBendtsen.dk{% endblock %} + + + + +
+ +
+ +
+ {% block content %}{% endblock %} +
+ +
+
+ + + + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..f8df270 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} + +{% block content %} +
+

I write about Self-hosting, Arduino, STM32 and various tech stupidity.

+
+ +
+ {% for post in posts %} +
+

{{ post.title }}

+ {{ post.date }} +

{{ post.meta.get('description', 'Read more...') }}

+

{{ post.meta.get('tag', 'no tag') }}

+
+ {% else %} +

No posts yet. Time to write something!

+ {% endfor %} +
+{% endblock %} \ No newline at end of file diff --git a/templates/post.html b/templates/post.html new file mode 100644 index 0000000..faec6f0 --- /dev/null +++ b/templates/post.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block content %} +
+

{{ page.title }}

+

{{ page.date }}

+
+ {{ page.html|safe }}
+
+{% endblock %} \ No newline at end of file