feat: initialize blog app with blueprints and templates
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Extract blog-specific code from the coop monolith into a standalone repository. Includes auth, blog, post, admin, menu_items, snippets blueprints, associated templates, Dockerfile (APP_MODULE=app:app), entrypoint, and Gitea CI workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
42
bp/post/services/post_data.py
Normal file
42
bp/post/services/post_data.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from ...blog.ghost_db import DBClient # adjust import path
|
||||
from sqlalchemy import select
|
||||
from models.ghost_content import PostLike
|
||||
from quart import g
|
||||
|
||||
async def post_data(slug, session, include_drafts=False):
|
||||
client = DBClient(session)
|
||||
posts = (await client.posts_by_slug(slug, include_drafts=include_drafts))
|
||||
|
||||
if not posts:
|
||||
# 404 page (you can make a template for this if you want)
|
||||
return None
|
||||
post, original_post = posts[0]
|
||||
|
||||
# Check if current user has liked this post
|
||||
is_liked = False
|
||||
if g.user:
|
||||
liked_record = await session.scalar(
|
||||
select(PostLike).where(
|
||||
PostLike.user_id == g.user.id,
|
||||
PostLike.post_id == post["id"],
|
||||
PostLike.deleted_at.is_(None),
|
||||
)
|
||||
)
|
||||
is_liked = liked_record is not None
|
||||
|
||||
# Add is_liked to post dict
|
||||
post["is_liked"] = is_liked
|
||||
|
||||
tags=await client.list_tags(
|
||||
limit=50000
|
||||
) # <-- new
|
||||
authors=await client.list_authors(
|
||||
limit=50000
|
||||
)
|
||||
|
||||
return {
|
||||
"post": post,
|
||||
"original_post": original_post,
|
||||
"tags": tags,
|
||||
"authors": authors,
|
||||
}
|
||||
Reference in New Issue
Block a user