From a47ad949bd5c636f96e1a1d045d3ce611be2b9b1 Mon Sep 17 00:00:00 2001 From: m Date: Thu, 26 Mar 2026 16:07:05 +0100 Subject: [PATCH] preview --- app.py | 17 +++- content | 2 +- flask_logic/components.py | 32 +++++- static/animation.svg | 124 ----------------------- static/css/components/tree.css | 10 ++ static/css/simple-blog-template.css | 11 -- templates/base.html | 4 - templates/components/christmas_post.html | 5 - templates/components/code.html | 3 - templates/components/image.html | 3 - templates/components/post_preview.html | 20 ++-- templates/components/post_renderer.html | 11 -- templates/components/timeline.html | 9 -- 13 files changed, 63 insertions(+), 188 deletions(-) delete mode 100644 static/animation.svg create mode 100644 static/css/components/tree.css delete mode 100644 templates/components/christmas_post.html delete mode 100644 templates/components/code.html delete mode 100644 templates/components/image.html delete mode 100644 templates/components/post_renderer.html delete mode 100644 templates/components/timeline.html diff --git a/app.py b/app.py index 1024aac..f71213a 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,7 @@ from flask import Flask, render_template, request, redirect, url_for, send_from_directory from content.posts import BLOG_POSTS from flask_logic.logic import get_enriched_post, get_comments_for_post, save_comment -from flask_logic.renderer import process_post_content, collect_css +from flask_logic.renderer import process_post_content, collect_css, generate_preview # 🌟 IMPORT THE content from separate files. from content.posts import BLOG_POSTS from content.about_text import ABOUT, TITLE @@ -78,13 +78,26 @@ def calculate_pagination(posts, posts_per_page, page): 'total_posts': total_posts } + + + + + @app.route('/') def home(): + posts_with_preview = [] + for post in BLOG_POSTS: + preview = generate_preview(post.get("content", "")) + + post_copy = dict(post) + post_copy["preview"] = preview + + posts_with_preview.append(post_copy) """Home page with paginated blog posts.""" page = request.args.get('page', 1, type=int) blog_title = TITLE - pagination = calculate_pagination(BLOG_POSTS, POSTS_PER_PAGE, page) + pagination = calculate_pagination(posts_with_preview, POSTS_PER_PAGE, page) return render_template('index.html', posts=pagination['posts_to_show'], diff --git a/content b/content index 4b04188..cb53a98 160000 --- a/content +++ b/content @@ -1 +1 @@ -Subproject commit 4b041884ab37f220e04e3dbe5e843e0cc19e2a60 +Subproject commit cb53a98cca5bc452caa44f59d8ba0c2669f6d395 diff --git a/flask_logic/components.py b/flask_logic/components.py index 1d1ebff..5c12987 100644 --- a/flask_logic/components.py +++ b/flask_logic/components.py @@ -27,4 +27,34 @@ def render_code_block(value=None, code=None, context=None): return f"""
{code}
- """ \ No newline at end of file + """ + + +@register_component("tree", css="css/components/tree.css") +def render_tree_component(context=None): + if context: + context["used_components"].add("tree") + return f""" +
+ +
+

tree source: codepen @uchardon

+
""" + +@register_component("timeline", css="css/components/timeline.css") + +def render_timeline_component(timeline=None, value=None, context=None): + if context: + context["used_components"].add("timeline") + timeline = timeline or value or "" + return f""" +
+
    + {timeline} +
+
+ +
  • +""" \ No newline at end of file diff --git a/static/animation.svg b/static/animation.svg deleted file mode 100644 index 00b229a..0000000 --- a/static/animation.svg +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/static/css/components/tree.css b/static/css/components/tree.css new file mode 100644 index 0000000..94dc069 --- /dev/null +++ b/static/css/components/tree.css @@ -0,0 +1,10 @@ +/* --- Decoration --- */ +.background-svg { + position: fixed; + bottom: 100px; + right: 200px; + width: 200px; + z-index: -1; + pointer-events: none; + opacity: 0.6; +} diff --git a/static/css/simple-blog-template.css b/static/css/simple-blog-template.css index 8e19582..ed97099 100644 --- a/static/css/simple-blog-template.css +++ b/static/css/simple-blog-template.css @@ -221,17 +221,6 @@ nav { border-color: #ccc; } -/* --- Decoration --- */ -.background-svg { - position: fixed; - bottom: 100px; - right: 200px; - width: 200px; - z-index: -1; - pointer-events: none; - opacity: 0.6; -} - /* Login, Sign up, New post */ .login, .signup { diff --git a/templates/base.html b/templates/base.html index d07776e..c448cae 100644 --- a/templates/base.html +++ b/templates/base.html @@ -31,10 +31,6 @@ href="{{ url_for('static', filename='css/blog.css') }}" rel="stylesheet" /> -