From ba62e82f1b4b404f990f6b087a3ddd8f2d71d2f7 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Thu, 8 Oct 2026 09:10:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B3=84=EC=A0=88=20=EC=9D=B4=EC=95=BC?= =?UTF-8?q?=EA=B8=B0=EC=97=90=20=EC=82=AC=EC=A7=84=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?(=EB=9D=A0=C2=B7=EB=AA=A9=EB=A1=9D=C2=B7=EC=83=81=EC=84=B8?= =?UTF-8?q?=C2=B7=ED=94=BC=EB=93=9C,=20CC=20BY=20=EA=B3=84=EC=97=B4=20?= =?UTF-8?q?=EC=B6=9C=EC=B2=98=20=ED=91=9C=EA=B8=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 5 +++-- backend/common/database/model/models.py | 2 ++ backend/postgres-init/init.sql | 6 +++++- backend/router/v1/feed/protocol.py | 2 ++ backend/router/v1/season/protocol.py | 2 ++ backend/router/v1/season/season.py | 3 ++- backend/scripts/load_seed.py | 3 ++- backend/seed/article.json | 17 +++++++++++++++++ backend/services/feed_service.py | 6 ++++-- backend/tests/test_season.py | 14 ++++++++++++++ frontend/src/api/client/types.gen.ts | 16 ++++++++++++++++ frontend/src/b/SeasonPage.tsx | 6 ++---- frontend/src/b/Sheets.tsx | 6 ++---- frontend/src/b/TodayPage.tsx | 4 +--- frontend/src/b/ui.tsx | 6 +++--- 15 files changed, 77 insertions(+), 21 deletions(-) diff --git a/TODO.md b/TODO.md index b90f8b6..1b971d8 100644 --- a/TODO.md +++ b/TODO.md @@ -51,7 +51,7 @@ | [x] | 각 상세 창 점수 칸을 오늘/내일/토/일로 — 단기예보(시간별)는 약 4일 뒤까지라 월~수엔 주말 점수를 같은 방식으로 못 냄. 안: 범위 밖 주말은 중기예보(기온·비 확률)로 대략 점수 + "예상" 표시, 오늘·내일이 주말이면 다음 주말 표시 | 사용자 요청 | `backend/services/index_service.py` (`DAYS = 3`), `frontend/src/b/Sheets.tsx` | | [x] | 그날 밤 달 모양 — 밤 히어로에 달 모양·밝기, 보름·삭인 밤엔 '오늘 밤 달' 포스트 (사용자 결정 1·4안). 보름·삭 시각은 Meeus 계산(오차 2분 안) — 계산은 `moon.py`로 외부 API 없이 가능 | 사용자 질문 | `backend/services/calc/moon.py` | | [ ] | **[결정 필요]** 각과 상관없는 요소 비중 — 김서림각 바람, 택시대란·배달폭주·넷플릭스각 습도가 '상관없음'인데 비중 5%라 항상 50점으로 섞임. 0으로 할지 / 짬뽕·배달폭주각에 '공기 맑음' 5%가 좋은 쪽으로 들어가는 게 맞는지 | 6각 차트 수정 중 발견 | `backend/seed/index_definition.json` | -| [ ] | **[결정 필요]** 계절 이야기 사진 — CC BY-SA 등 8장은 저작자·라이선스 표시 필요(표시 위치 정하기), `howgak` 글은 맞는 사진 없음(일러스트/아이콘), `tangerine`(퍼블릭 도메인) 사용 여부, `di`(매미)·`peanut_new`(일본 삶은 땅콩) 주제 적합성 | 사진 수집 중 발견 | `frontend/public/season/sources.json` | +| [x] | **[결정 필요]** 계절 이야기 사진 — CC BY-SA 등 8장은 저작자·라이선스 표시 필요(표시 위치 정하기), `howgak` 글은 맞는 사진 없음(일러스트/아이콘), `tangerine`(퍼블릭 도메인) 사용 여부, `di`(매미)·`peanut_new`(일본 삶은 땅콩) 주제 적합성 | 사진 수집 중 발견 | `frontend/public/season/sources.json` | | [x] | 포스트 본문이 슬라이드 내용 반복 — 축제("N월 N일부터…까지예요" = 기간 줄), 오늘 날씨, 생활 알림, 내일 미리보기, 한 문장, 각, 노을. 본문엔 슬라이드에 없는 한 줄만 | 전체 검수 | `backend/services/feed_service.py` | | [x] | 아이콘 오용 — 밤 '한 문장' 카드에 망원경(`stars`), 폭염·한파 특보에도 우산 아이콘·"☔ 우산 챙겨!", 흐린 날 노을 시간대 칸에 노을 그림, 데이터 없는 칸에 해·구름 그림, 흐려도 "맑음"·해 그림(주말 플랜·주말 화면), 행사 아이콘 `calendar`/`fireworks` 혼용 | 전체 검수 | `backend/seed/article.json:103,117`, `backend/services/feed_service.py:420`, `backend/services/weather_service.py:85,94`, `backend/services/weekend_plan.py:52,95,116`, `frontend/src/b/WeekPage.tsx:85` | | [x] | 뜻 모를 표시 — "출처: 날씨각 (검수 전 예시)" 노출, "41번째 주", "해 지는 쪽 263°", 점수 뒤 "점" 없음, "추천: 피크닉각 추천", 노을 시각 18:12/6:12 이중 표기, 날짜 "10.04"/"10.4" 혼용, "구름많음"/"구름 많음" 혼용 | 전체 검수 | `backend/seed/article.json`, `frontend/src/b/SeasonPage.tsx:32`, `frontend/src/b/SkyPage.tsx`, `frontend/src/b/WeekPage.tsx:69` | @@ -64,7 +64,8 @@ | [ ] | 문화정보 API 승인 후 실제 응답 확인 — 지금 `SERVICE_KEY_IS_NOT_REGISTERED_ERROR`(403). 날짜 형식, `gpsX`/`gpsY` 순서, 썸네일 https 여부 확인. 승인 직후 바로 보려면 Redis `event:{sido}:{날짜}` 키 삭제 | 전시 연결 중 발견 | `backend/services/external/culture_api.py` | | [ ] | **[결정 필요]** 두 달 넘는 전시가 `MAX_EVENT_DAYS = 60` 필터에 걸려 빠짐 — 전시는 기준을 따로 둘지 | 전시 연결 중 발견 | `backend/services/week_service.py` | | [ ] | 전시 썸네일 저작권 확인 — 데이터셋은 '이용허락범위 제한 없음'이나 원저작권이 주최 기관에 있을 수 있음 | 전시 연결 중 발견 | `backend/services/week_service.py` (`image_credit`) | -| [ ] | 계절 이야기 사진 연결 — 받은 13장(`frontend/public/season/`)을 `article`에 사진 칸 추가해 띠·목록·상세·피드에 표시, CC BY 계열은 저작자·라이선스 표시. 스켈레톤 작업 끝난 뒤 진행 | 사용자 요청 | `backend/common/database/model/models.py`, `backend/seed/article.json`, `frontend/src/b/SeasonPage.tsx`, `frontend/src/b/Sheets.tsx`, `frontend/src/b/TodayPage.tsx` | +| [x] | 계절 이야기 사진 연결 — 받은 13장(`frontend/public/season/`)을 `article`에 사진 칸 추가해 띠·목록·상세·피드에 표시, CC BY 계열은 저작자·라이선스 표시. 스켈레톤 작업 끝난 뒤 진행 | 사용자 요청 | `backend/common/database/model/models.py`, `backend/seed/article.json`, `frontend/src/b/SeasonPage.tsx`, `frontend/src/b/Sheets.tsx`, `frontend/src/b/TodayPage.tsx` | +| [ ] | **[결정 필요]** 계절 이야기 사진 2장 안 씀 — `di.jpg`(매미)는 불쾌지수 글과 주제가 다르고, `peanut_new.jpg`(일본 가토리시 삶은 땅콩, 왼쪽은 일본 대립종)는 '국산 햇땅콩' 글과 맞지 않아 아이콘 유지. 맞는 사진을 새로 구할지 | 계절 이야기 사진 연결 중 판단 | `frontend/public/season/sources.json`, `backend/seed/article.json` | | [x] | (로컬 반영함, 운영 DB는 배포 때 같은 ALTER 필요) 로컬 DB 칼럼 추가 후 백엔드·워커 컨테이너 다시 빌드 — 지금 9810 백엔드는 이미지로 떠 있어 이번 백엔드 수정이 화면에 안 보임. 필요한 ALTER: `weather_daily.rain_prob_am`/`rain_prob_pm SMALLINT NULL`, `index_score.estimated BOOLEAN NOT NULL DEFAULT false`. 진행 중인 백엔드 작업이 끝난 뒤 실행 | 오늘/내일/토/일 작업 중 발견 | `backend/postgres-init/init.sql`, `compose.yaml` | | [ ] | **[결정 필요]** 확정 시안(`docs/시안_B_확정.html` 489·585행, `.trend3`)에 각 점수 칸이 아직 "오늘·내일·모레" 3칸 — 실제는 오늘/내일/토/일 4칸. 시안도 고칠지 | 오늘/내일/토/일 작업 중 발견 | `docs/시안_B_확정.html` | | [x] | (로컬 반영함, 운영은 배포 때) 행사 아이콘 `calendar`→`fireworks` 기존 DB 반영 — 코드·`init.sql` 기본값만 바뀌어 이미 들어간 행사는 그대로. 필요한 명령: `UPDATE event SET icon='fireworks' WHERE icon='calendar'; ALTER TABLE event ALTER COLUMN icon SET DEFAULT 'fireworks';` (운영은 확인 받고) | 아이콘 오용 수정 중 발견 | `backend/postgres-init/init.sql`, `backend/common/database/model/models.py` | diff --git a/backend/common/database/model/models.py b/backend/common/database/model/models.py index 59cd010..6c9aa43 100644 --- a/backend/common/database/model/models.py +++ b/backend/common/database/model/models.py @@ -280,6 +280,8 @@ class Article(Base): show_from: Mapped[Optional[date]] = mapped_column(Date, nullable=True) show_until: Mapped[Optional[date]] = mapped_column(Date, nullable=True) sort_order: Mapped[int] = mapped_column(SmallInteger, default=0) + image_url: Mapped[Optional[str]] = mapped_column(String(200), nullable=True) + image_credit: Mapped[Optional[str]] = mapped_column(String(60), nullable=True) class Post(Base): diff --git a/backend/postgres-init/init.sql b/backend/postgres-init/init.sql index 7963676..07f1c07 100644 --- a/backend/postgres-init/init.sql +++ b/backend/postgres-init/init.sql @@ -374,5 +374,9 @@ CREATE TABLE IF NOT EXISTS public.article ( body JSONB NOT NULL, -- 문단 목록 show_from DATE NULL, -- 계절 소식이 보이는 기간 (NULL = 늘) show_until DATE NULL, - sort_order SMALLINT NOT NULL DEFAULT 0 + sort_order SMALLINT NOT NULL DEFAULT 0, + image_url VARCHAR(200) NULL, -- 사진 (frontend/public/season/, NULL = 아이콘) + image_credit VARCHAR(60) NULL -- 사진 출처 표기 ("ⓒ저작자 · CC BY-SA 4.0"), 표기가 필요 없으면 NULL ); +ALTER TABLE public.article ADD COLUMN IF NOT EXISTS image_url VARCHAR(200) NULL; +ALTER TABLE public.article ADD COLUMN IF NOT EXISTS image_credit VARCHAR(60) NULL; diff --git a/backend/router/v1/feed/protocol.py b/backend/router/v1/feed/protocol.py index a59c76d..032d6e8 100644 --- a/backend/router/v1/feed/protocol.py +++ b/backend/router/v1/feed/protocol.py @@ -171,6 +171,8 @@ class BandArticle(WebPacketProtocol): title: str meta: str icon: str + image: Optional[str] = None + image_credit: Optional[str] = None class Bands(WebPacketProtocol): diff --git a/backend/router/v1/season/protocol.py b/backend/router/v1/season/protocol.py index 0e47f4b..240b824 100644 --- a/backend/router/v1/season/protocol.py +++ b/backend/router/v1/season/protocol.py @@ -17,6 +17,8 @@ class ArticleSummary(WebPacketProtocol): title: str read_minutes: int icon: str + image: Optional[str] = None # 있으면 아이콘 대신 사진 + image_credit: Optional[str] = None # 사진 출처 표기 ("ⓒ저작자 · CC BY-SA 4.0") class Res_SeasonWeek(Res_WebPacketProtocol): diff --git a/backend/router/v1/season/season.py b/backend/router/v1/season/season.py index d0a0cb8..6d7dd36 100644 --- a/backend/router/v1/season/season.py +++ b/backend/router/v1/season/season.py @@ -12,7 +12,8 @@ router = APIRouter(prefix="/v1/season", tags=["season"]) def _summary(a: Article) -> ArticleSummary: - return ArticleSummary(article_id=a.article_id, code=a.code, category=ArticleCategory(a.category), title=a.title, read_minutes=a.read_minutes, icon=a.icon) + return ArticleSummary(article_id=a.article_id, code=a.code, category=ArticleCategory(a.category), title=a.title, read_minutes=a.read_minutes, icon=a.icon, + image=a.image_url, image_credit=a.image_credit) @router.get("/week", response_model=Res_SeasonWeek, response_model_exclude_none=True, summary="이번 주 계절 책: 시, 절기, 계절 소식") diff --git a/backend/scripts/load_seed.py b/backend/scripts/load_seed.py index a212e0e..5050725 100644 --- a/backend/scripts/load_seed.py +++ b/backend/scripts/load_seed.py @@ -70,7 +70,8 @@ async def main() -> int: ] articles = [ {**a, "show_from": date.fromisoformat(a["show_from"]) if a["show_from"] else None, - "show_until": date.fromisoformat(a["show_until"]) if a["show_until"] else None} + "show_until": date.fromisoformat(a["show_until"]) if a["show_until"] else None, + "image_url": a.get("image_url"), "image_credit": a.get("image_credit")} for a in _json("article.json") ] weeks = _json("season_week.json") diff --git a/backend/seed/article.json b/backend/seed/article.json index 106b180..d990e7e 100644 --- a/backend/seed/article.json +++ b/backend/seed/article.json @@ -5,6 +5,8 @@ "title": "설악산 첫 단풍, 절정은 언제?", "read_minutes": 3, "icon": "maple", + "image_url": "/season/maple.jpg", + "image_credit": "ⓒJoycekim77 · CC BY-SA 3.0", "show_from": "2026-09-20", "show_until": "2026-10-25", "body": [ @@ -20,6 +22,8 @@ "title": "하늘공원 억새가 반짝이는 시간", "read_minutes": 2, "icon": "sheaf", + "image_url": "/season/reed.jpg", + "image_credit": "ⓒJocelyndurrey · CC BY-SA 4.0", "show_from": "2026-09-25", "show_until": "2026-10-31", "body": [ @@ -34,6 +38,8 @@ "title": "대관령 첫서리, 서울은 한 달 뒤", "read_minutes": 2, "icon": "snow", + "image_url": "/season/frost.jpg", + "image_credit": "ⓒSally V · CC BY-SA 4.0", "show_from": "2026-10-01", "show_until": "2026-11-15", "body": [ @@ -77,6 +83,7 @@ "title": "노을은 왜 해 지고 15분 뒤가 더 붉을까?", "read_minutes": 3, "icon": "sunset", + "image_url": "/season/sunset.jpg", "show_from": null, "show_until": null, "body": [ @@ -91,6 +98,7 @@ "title": "비 확률 30%면 우산을 챙겨야 할까?", "read_minutes": 2, "icon": "umbrella", + "image_url": "/season/umbrella.jpg", "show_from": null, "show_until": null, "body": [ @@ -251,6 +259,7 @@ "title": "햇밤, 바로 먹을까 두었다 먹을까?", "read_minutes": 2, "icon": "chestnut", + "image_url": "/season/chestnut_new.jpg", "show_from": "2026-09-15", "show_until": "2026-10-31", "body": [ @@ -281,6 +290,8 @@ "title": "은행 냄새 나는 길, 언제까지일까", "read_minutes": 2, "icon": "fallen_leaf", + "image_url": "/season/ginkgo.jpg", + "image_credit": "ⓒKorea.net · CC BY-SA 2.0", "show_from": "2026-10-10", "show_until": "2026-11-15", "body": [ @@ -296,6 +307,8 @@ "title": "군고구마가 생각나는 첫 추위", "read_minutes": 2, "icon": "sweet_potato", + "image_url": "/season/sweet_potato.jpg", + "image_credit": "ⓒ국립국어원 · CC BY-SA 2.0 KR", "show_from": "2026-10-15", "show_until": "2026-12-31", "body": [ @@ -311,6 +324,7 @@ "title": "노지 귤이 나오기 시작해요", "read_minutes": 2, "icon": "tangerine", + "image_url": "/season/tangerine.jpg", "show_from": "2026-10-20", "show_until": "2026-12-31", "body": [ @@ -326,6 +340,8 @@ "title": "부사 사과가 나오는 때", "read_minutes": 2, "icon": "apple", + "image_url": "/season/apple_fuji.jpg", + "image_credit": "ⓒAomorikuma · CC BY-SA 4.0", "show_from": "2026-10-20", "show_until": "2026-11-30", "body": [ @@ -341,6 +357,7 @@ "title": "김장, 언제 하면 좋을까?", "read_minutes": 2, "icon": "kimchi", + "image_url": "/season/kimjang.jpg", "show_from": "2026-11-01", "show_until": "2026-12-15", "body": [ diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index c7ff345..110320d 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -362,7 +362,8 @@ class FeedService: image=e.event.image_url, image_credit=image_credit(e.event)) for e in mix_kinds(events)[:4]], top5=[_top(i) for i in items[:5]], season=[ - BandArticle(article_id=a.article_id, title=a.title, meta=f"{_CATEGORY_META[a.category]} · {a.read_minutes}분", icon=a.icon) + BandArticle(article_id=a.article_id, title=a.title, meta=f"{_CATEGORY_META[a.category]} · {a.read_minutes}분", icon=a.icon, + image=a.image_url, image_credit=a.image_credit) for a in articles or [] if a.category == ArticleCategory.SEASON.value ], ), @@ -450,7 +451,8 @@ class FeedService: if t in (PostType.SEASON, PostType.TIP) and p.ref_id in c.articles: a = c.articles[p.ref_id] return PostData(**base, title=a.title, icon=a.icon, caption=" ".join(a.body[1:2]) or a.body[0], - slides=[RowsSlide(kind="rows", eyebrow=_CATEGORY_META[a.category], line=a.body[0], icon=a.icon)], share_messages=[a.title]) + slides=[RowsSlide(kind="rows", eyebrow=_CATEGORY_META[a.category], line=a.body[0], icon=a.icon, image=a.image_url, image_credit=a.image_credit)], + share_messages=[a.title]) if t is PostType.EVENT: soon = mix_kinds([e for e in c.events if e.event.start_date <= c.now.date() + timedelta(days=7) and e.event.end_date >= c.now.date()]) rank = p.index_rank or 1 diff --git a/backend/tests/test_season.py b/backend/tests/test_season.py index 9e2817f..51f151c 100644 --- a/backend/tests/test_season.py +++ b/backend/tests/test_season.py @@ -2,8 +2,10 @@ from datetime import timedelta import pytest from httpx import ASGITransport, AsyncClient +from sqlalchemy import text import services.season_service as season_service +from common.database.db_session_manager import DB_SESSION_MNG from common.utils.kma_time import now_kst from router.router import app @@ -38,3 +40,15 @@ async def test_article_detail_and_not_found(): missing = (await client.get("/v1/season/article/9999")).json() assert first["body"] and first["article"]["title"] == listed[0]["title"] assert missing["result"]["desc"] == "NOT_FOUND" + + +@pytest.mark.anyio +async def test_article_photo_only_when_seeded(): + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + listed = {a["code"]: a for a in (await client.get("/v1/season/article/list")).json()["articles"]} + umbrella = (await client.get(f"/v1/season/article/{listed['umbrella']['article_id']}")).json()["article"] + _, maple_id = await DB_SESSION_MNG.execute_lambda(lambda s: s.scalar(text("SELECT article_id FROM article WHERE code = 'maple'"))) + maple = (await client.get(f"/v1/season/article/{maple_id}")).json()["article"] + assert umbrella["image"] == "/season/umbrella.jpg" and "image_credit" not in umbrella + assert maple["image"] == "/season/maple.jpg" and maple["image_credit"] == "ⓒJoycekim77 · CC BY-SA 3.0" + assert "image" not in listed["howgak"] and "image" not in listed["di"] diff --git a/frontend/src/api/client/types.gen.ts b/frontend/src/api/client/types.gen.ts index d33a082..0d6fc2a 100644 --- a/frontend/src/api/client/types.gen.ts +++ b/frontend/src/api/client/types.gen.ts @@ -110,6 +110,14 @@ export type ArticleSummary = { * Icon */ icon: string; + /** + * Image + */ + image?: string | null; + /** + * Image Credit + */ + image_credit?: string | null; }; /** @@ -148,6 +156,14 @@ export type BandArticle = { * Icon */ icon: string; + /** + * Image + */ + image?: string | null; + /** + * Image Credit + */ + image_credit?: string | null; }; /** diff --git a/frontend/src/b/SeasonPage.tsx b/frontend/src/b/SeasonPage.tsx index bbfa7da..4a3a320 100644 --- a/frontend/src/b/SeasonPage.tsx +++ b/frontend/src/b/SeasonPage.tsx @@ -5,7 +5,7 @@ import { ArticleCategory } from '../api/client/types.gen' import { cx } from '../lib/utils' import { ARTICLE_CAT, cardBg, dateRange, fall, loadOf, shortDay } from './lib' import { useSheet } from './sheetContext' -import { Chips, Ic, Skel, StateBox } from './ui' +import { Chips, Ic, Skel, StateBox, Thumb } from './ui' const CATS = [ ['all', '전체'], @@ -126,9 +126,7 @@ export function SeasonPage() { {a.title} {a.read_minutes}분 읽기 - - - + ))} diff --git a/frontend/src/b/Sheets.tsx b/frontend/src/b/Sheets.tsx index 0623302..ff02d78 100644 --- a/frontend/src/b/Sheets.tsx +++ b/frontend/src/b/Sheets.tsx @@ -28,7 +28,7 @@ import { useSky } from './skyContext' import { SHARE_SIZES, shareImage, type ShareSize } from './storyImage' import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext' import { HeartIcon } from './svg' -import { Avatar, Ic, Skel, StateBox } from './ui' +import { Avatar, Ic, Skel, StateBox, Thumb } from './ui' export function SheetProvider({ children }: { children: ReactNode }) { const [state, setState] = useState(null) @@ -397,9 +397,7 @@ function ArticleSheet({ articleId, onTitle }: { articleId: number; onTitle: (t: if (!a) return {load === 'loading' ? : q.refetch()} empty="글을 찾지 못했어요." hold={} className="inset-0" />} return ( -
- -
+

{articleMeta(a)}

{a.title}

{(q.data?.body ?? []).map((t) => ( diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index f89a3de..5bb3de9 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -284,9 +284,7 @@ function SeasonBand({ news }: { news: BandArticle[] }) { {news.map((a) => (