render fn

This commit is contained in:
m
2026-03-25 12:42:26 +01:00
parent 0272ec3d07
commit 1c23c05cc7
6 changed files with 145 additions and 15 deletions

24
app.py
View File

@@ -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
# 🌟 IMPORT THE content from separate files.
from content.posts import BLOG_POSTS
from content.about_text import ABOUT, TITLE
@@ -106,6 +106,7 @@ def about():
return render_template('about.html', about_txt = about_txt, blog_title = TITLE)
@app.route('/post/<int:post_id>')
def post_detail(post_id):
context = {"used_components": set()}
@@ -113,28 +114,23 @@ def post_detail(post_id):
post = get_enriched_post(post_id, BLOG_POSTS)
if not post:
return "Post not found", 404
comments = get_comments_for_post(post_id)
context["used_components"].add("image")
context["used_components"].add("code")
processed_content = process_post_content(
post.get('content', ''), context=context
)
#processed_content = render_content(post['content'], context=context)
css_files = []
for comp in context["used_components"]:
css_files.append(f"css/components/{comp}.css")
css_files = collect_css(context)
return render_template(
"post_detail.html",
post=post,
comments=comments,
blog_title = TITLE,
content=processed_content,
comments=comments,
blog_title=TITLE,
component_css=css_files
)
@app.route('/content/image/<path:filename>')
def content_image_files(filename):
directory = 'content/image'