From 4657d85dde0b1b54d8499332757951590d585d0d Mon Sep 17 00:00:00 2001 From: mi Date: Wed, 12 Nov 2025 10:48:35 +1000 Subject: [PATCH] :sparkles: markdown support --- app.py | 11 ++++++++++- content/about.md | 19 +++++++++++++++++++ requirements.txt | 3 ++- templates/about.html | 23 ----------------------- templates/page.html | 7 +++++++ 5 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 content/about.md delete mode 100644 templates/about.html create mode 100644 templates/page.html diff --git a/app.py b/app.py index b6e1597..111d095 100644 --- a/app.py +++ b/app.py @@ -2,6 +2,7 @@ import os from datetime import datetime from flask import Flask, render_template, abort, jsonify, request from comics_data import COMICS, FULL_WIDTH_DEFAULT, PLAIN_DEFAULT, HEADER_IMAGE, COMPACT_FOOTER +import markdown app = Flask(__name__) @@ -107,7 +108,15 @@ def archive(): @app.route('/about') def about(): """About page""" - return render_template('about.html', title='About') + # Read and render the markdown file + about_path = os.path.join(os.path.dirname(__file__), 'content', 'about.md') + try: + with open(about_path, 'r', encoding='utf-8') as f: + content = f.read() + html_content = markdown.markdown(content) + except FileNotFoundError: + html_content = '

About content not found.

' + return render_template('page.html', title='About', content=html_content) @app.route('/api/comics') diff --git a/content/about.md b/content/about.md new file mode 100644 index 0000000..415a0c0 --- /dev/null +++ b/content/about.md @@ -0,0 +1,19 @@ +# About Sunday Comics + +Welcome to Sunday Comics, a webcomic about life, humor, and everything in between. + +## About the Comic + +Sunday Comics is updated regularly with new strips. Each comic tells a story, shares a laugh, or offers a unique perspective on everyday situations. + +## About the Author + +Sunday Comics is created by [Your Name]. [Add your bio here] + +## Updates + +New comics are posted [specify your schedule, e.g., "every Monday and Thursday" or "weekly"]. + +## Support + +If you enjoy Sunday Comics, consider sharing it with friends or supporting the comic through [Patreon/Ko-fi/etc.]. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c204bef..8faa1fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Flask==3.0.0 \ No newline at end of file +Flask==3.0.0 +markdown==3.5.1 \ No newline at end of file diff --git a/templates/about.html b/templates/about.html deleted file mode 100644 index e2aa361..0000000 --- a/templates/about.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "base.html" %} - -{% block content %} - - -
-

Welcome to Sunday Comics, a webcomic about life, humor, and everything in between.

- -

About the Comic

-

Sunday Comics is updated regularly with new strips. Each comic tells a story, shares a laugh, or offers a unique perspective on everyday situations.

- -

About the Author

-

Sunday Comics is created by [Your Name]. [Add your bio here]

- -

Updates

-

New comics are posted [specify your schedule, e.g., "every Monday and Thursday" or "weekly"].

- -

Support

-

If you enjoy Sunday Comics, consider sharing it with friends or supporting the comic through [Patreon/Ko-fi/etc.].

-
-{% endblock %} \ No newline at end of file diff --git a/templates/page.html b/templates/page.html new file mode 100644 index 0000000..066fc55 --- /dev/null +++ b/templates/page.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block content %} +
+ {{ content|safe }} +
+{% endblock %} \ No newline at end of file