- Replace the plain textarea with EasyMDE (vendored locally, no CDN) for markdown authoring: syntax highlighting, smart list continuation, and a custom text-based toolbar (built-in EasyMDE toolbar icons require Font Awesome from a CDN, which this app doesn't use). unorderedListStyle is set to "-" to match the app's own template convention. - Add a preview/edit toggle button that swaps the editor for the exact same server-rendered markdown (via /journal/preview) shown after saving, instead of always showing both. - Fix create/edit entry routes to verify the submitted category_id actually belongs to the current user before inserting -- every other write path in this app already checked ownership; this one didn't (found while manually testing the new editor with a typo'd category id that happened to belong to someone else's category, which surfaced as an IntegrityError 500 instead of a clean 404-equivalent). - Fix the default "일상" category template: bare "-" bullet lines don't parse as list items in the markdown renderer (they need a trailing space), and the content_template validator was silently stripping that trailing space off on every save. Backfill migration updates any category still holding the old, broken template text. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
82 lines
3.3 KiB
Python
82 lines
3.3 KiB
Python
"""fix default 일상 template: bare "-" bullets don't render as list items
|
|
|
|
Revision ID: 0014_fix_template_bullets
|
|
Revises: 0013_journal_category_template
|
|
Create Date: 2026-08-05
|
|
|
|
0013에서 넣은 기본 틀의 "-" 줄들이 뒤에 공백이 없어서, markdown 렌더러가 목록으로 인식하지 못하고
|
|
그냥 문단 텍스트("-")로 렌더링됐다(제목 줄과 "-" 사이의 빈 줄 자체는 맞게 넣어서 제목이 밑줄로
|
|
오인되는 문제는 없었음). "- "(대시+공백)로 통일해야 실제 빈 목록 항목(<li></li>)이 된다.
|
|
아직 이 기본값을 커스터마이징하지 않은(즉 0013이 넣어준 원래 문구 그대로인) "일상" 카테고리만
|
|
갱신한다 — 이미 사용자가 직접 수정한 틀은 덮어쓰지 않는다.
|
|
|
|
(참고: revision id를 "0014_fix_category_template_bullets"로 처음 만들었다가 alembic_version.
|
|
version_num이 VARCHAR(32)라 34자짜리 id가 안 들어가서 DataError가 났다 — 25자로 줄여 다시 만든
|
|
파일이다. 실제 데이터 UPDATE 자체는 그때 이미 반영됐고 버전 기록만 실패한 상태였다.)
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0014_fix_template_bullets"
|
|
down_revision: Union[str, None] = "0013_journal_category_template"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
_BULLET = "- "
|
|
|
|
_OLD_TEMPLATE = "\n\n".join(
|
|
[
|
|
"**1. Story : 오늘 무슨 일이 있었나요?**",
|
|
"-",
|
|
"**2. Feelings : 오늘 들었던 생각과 나의 감정은?**",
|
|
"-",
|
|
"**3. Decisions : 오늘 내가 내린 결정이 있나요?**",
|
|
"-",
|
|
"**4. Insights : 나에 대해 새롭게 알게된 사실이 있나요?**",
|
|
"-",
|
|
"→ 나에 대한 인사이트는 메타인지를 키워주는 **소중한 기록**입니다. 꼭 보관하세요.",
|
|
"**5. Actions : 내가 다음에 할 행동은 무엇인가요?**",
|
|
_BULLET,
|
|
]
|
|
)
|
|
|
|
_NEW_TEMPLATE = "\n\n".join(
|
|
[
|
|
"**1. Story : 오늘 무슨 일이 있었나요?**",
|
|
_BULLET,
|
|
"**2. Feelings : 오늘 들었던 생각과 나의 감정은?**",
|
|
_BULLET,
|
|
"**3. Decisions : 오늘 내가 내린 결정이 있나요?**",
|
|
_BULLET,
|
|
"**4. Insights : 나에 대해 새롭게 알게된 사실이 있나요?**",
|
|
_BULLET,
|
|
"→ 나에 대한 인사이트는 메타인지를 키워주는 **소중한 기록**입니다. 꼭 보관하세요.",
|
|
"**5. Actions : 내가 다음에 할 행동은 무엇인가요?**",
|
|
_BULLET,
|
|
]
|
|
)
|
|
|
|
|
|
def upgrade() -> None:
|
|
journal_category = sa.table(
|
|
"journal_category", sa.column("name", sa.String), sa.column("content_template", sa.Text)
|
|
)
|
|
op.execute(
|
|
journal_category.update()
|
|
.where(journal_category.c.name == "일상", journal_category.c.content_template == _OLD_TEMPLATE)
|
|
.values(content_template=_NEW_TEMPLATE)
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
journal_category = sa.table(
|
|
"journal_category", sa.column("name", sa.String), sa.column("content_template", sa.Text)
|
|
)
|
|
op.execute(
|
|
journal_category.update()
|
|
.where(journal_category.c.name == "일상", journal_category.c.content_template == _NEW_TEMPLATE)
|
|
.values(content_template=_OLD_TEMPLATE)
|
|
)
|