4 blog website setup#14
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a blog website setup by replacing a simple yes/no answer system with a full blog post management system. The changes include creating new blog post models, API endpoints for CRUD operations, and frontend components for creating and displaying blog posts.
- Replaces YesNo model with BlogPost model supporting titles, content, slugs, and cover images
- Adds comprehensive blog post API endpoints (create, read, update, delete)
- Refactors frontend to use separate PostEditor and PostList components
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/routes/+page.svelte | Updates main page to use new PostEditor and PostList components |
| frontend/src/lib/components/TinyEditor.svelte | Removes form submission logic and styling, keeping only the editor functionality |
| frontend/src/lib/components/PostList.svelte | New component for fetching and displaying blog posts from the API |
| frontend/src/lib/components/PostEditor.svelte | New component containing the post creation form with title, cover image, and content fields |
| backend/app/models/yesno.py | Removes the YesNo model (deleted file) |
| backend/app/models/blog_post.py | Adds new BlogPost model with associated Pydantic schemas |
| backend/app/main.py | Simplifies CORS configuration to allow all origins |
| backend/app/api/data.py | Replaces YesNo endpoints with comprehensive blog post CRUD operations |
| from pydantic import BaseModel | ||
|
|
||
|
|
||
| from typing import Optional |
There was a problem hiding this comment.
Duplicate import statement. The typing.Optional import on line 8 is redundant as it's already imported on line 4.
| from typing import Optional |
|
|
||
| from typing import Optional | ||
| from sqlmodel import SQLModel, Field | ||
| from pydantic import BaseModel |
There was a problem hiding this comment.
Duplicate import statement. The pydantic.BaseModel import on line 10 is redundant as it's already imported on line 5.
| from pydantic import BaseModel |
| from typing import Optional | ||
| from sqlmodel import SQLModel, Field | ||
| from pydantic import BaseModel | ||
| import time |
There was a problem hiding this comment.
Duplicate import statement. The time import on line 11 is redundant as it's already imported on line 3.
| import time |
| answer = answer.decode("utf-8") | ||
| db.add(YesNo(timestamp=datetime.datetime.now(), answer=answer)) | ||
|
|
||
| def sanitise_html(html: str) -> str: |
There was a problem hiding this comment.
The sanitise_html function returns the input unchanged, providing no HTML sanitization. This creates a security risk as unsanitized HTML content could lead to XSS vulnerabilities when rendered in the frontend.
| if updated_post.cover_image is not None: | ||
| db_post.cover_image = updated_post.cover_image | ||
|
|
||
| # db_post.timestamp = int(time.time()) |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase to maintain code cleanliness.
| # db_post.timestamp = int(time.time()) |
| {:else} | ||
| {#each posts as post} | ||
| <article> | ||
| <h1>{post.id}</h1> |
There was a problem hiding this comment.
Using <h1> tag to display the post ID is semantically incorrect. The post ID should use a less prominent heading tag or span element, as <h1> should represent the main heading of the page or section.
| <h1>{post.id}</h1> | |
| <span>{post.id}</span> |
No description provided.