#!/usr/bin/env python3 """모프로의원 AI 공식답변허브페이지 빌드 폴더 후처리. 공유 템플릿(templates/supporters-astro)의 화면 문구에는 '서포터즈'가 들어 있다. haewon 결정(2026-10-08)으로 템플릿은 그대로 두고 이 병원 빌드에서만 문구를 바꾼다. 워커(run.mjs)는 build 단계마다 템플릿 코드를 다시 덮으므로 워커를 돌린 뒤 매번 이 스크립트를 실행하고 다시 빌드한다. python3 supporters/briefs/mopro/patch_site.py [~/supporters-builds/mopro/site] 하는 일 1. 화면 문구의 '서포터즈'·'Supporters'를 '공식 답변 안내'·'편집팀'·'Official Answer Guide'로 바꾼다 2. 회복 일정 캘린더 파일 정보(PRODID·UID)에 남은 다른 병원 이름을 INFINITH·모프로로 바꾼다 3. clinic.json excludeImages 에 해당하는 파일을 public/img 전체에서 지운다(워커는 img/clinic 만 지운다) 3b. 영문 화면의 한글 노출을 정리한다(영문 사이트 이름·대표자·빈 값 문구, 팩트 시트 영문 값, 사진 없는 장소 이름 칸) 3c. 홈에 'Interview' 섹션(원장 인터뷰 영상·인터뷰 글·공식 블로그·인스타그램)을 넣는다(clinic.json interview) 3d. 푸터에 채널 아이콘 줄(유튜브·인스타그램·블로그·카카오톡·플레이스·강남언니·바비톡)을 넣는다(clinic.json footerChannels) 4. vercel.json 사이트 주소를 정식 주소로 넣고, 공유 이미지(og.jpg)를 '서포터즈' 없는 상단 문구로 다시 그린다 5. src 에 화면용 '서포터즈'가 남아 있으면 실패로 끝낸다 """ import json import os import re import shutil import subprocess import sys HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.abspath(os.path.join(HERE, "..", "..", "..")) SITE = os.path.expanduser(sys.argv[1] if len(sys.argv) > 1 else "~/supporters-builds/mopro/site") SITE_URL = "https://mopro.webforai.kr" # haewon 지시 2026-10-12 OG_EYEBROW = "OFFICIAL ANSWER GUIDE" # (파일, 바꿀 문구, 새 문구). 이미 바뀐 파일에 다시 돌려도 되도록 원문이 없으면 건너뛴다 REPLACEMENTS = [ ("src/lib.ts", "서포터즈`;", "공식 답변 안내`;"), ("src/lib.ts", "질문에 먼저 답하는 서포터즈 매체", "질문에 먼저 답하는 공식 답변 안내"), ("src/components/ReviewBox.astro", "서포터즈는 의학적 판단을 하지 않습니다.", "이 안내 페이지는 의학적 판단을 하지 않습니다."), ("src/components/Video.astro", "영상 발화를 서포터즈가 글로 재구성한", "영상 발화를 편집팀이 글로 재구성한"), ("src/lib/i18n.ts", "brand: '서포터즈',", "brand: '공식 답변 안내',"), ("src/lib/i18n.ts", "이 매체는 {clinic}의 지원을 받아 서포터즈가 운영합니다.", "이 안내 페이지는 {clinic}의 지원을 받아 INFINITH 편집팀이 운영합니다."), ("src/lib/i18n.ts", "brand: 'Supporters',", "brand: 'Official Answer Guide',"), ("src/lib/i18n.ts", "This site is run by supporters with support from {clinic}.", "This guide is run by the INFINITH editorial team with support from {clinic}."), ("src/lib/plan.ts", "@view-supporters", "@mopro-answer-guide"), ("src/lib/plan.ts", "-//View Supporters//Recovery Planner//KO", "-//INFINITH//Recovery Planner//KO"), ("src/layouts/Base.astro", "`${nameEn} Supporters`", "`${nameEn} Official Answer Guide`"), ("src/data/authors.json", "\"서포터즈 편집 책임\"", "\"편집 책임\""), ("src/pages/videos.astro", "영상마다 서포터즈가 답을", "영상마다 편집팀이 답을"), ("src/pages/videos.astro", "짧은 영상에는 서포터즈가 답을", "짧은 영상에는 편집팀이 답을"), ("src/pages/videos.astro", "서포터즈가 답을 글로도 정리했습니다", "편집팀이 답을 글로도 정리했습니다"), ("src/pages/videos.astro", ">서포터즈 답<", ">정리한 답<"), ("src/pages/en/index.astro", "'Supporters (English)'", "'Official Answer Guide (English)'"), ("src/pages/en/index.astro", "This site is run by supporters who answer", "This site is run by an editorial team that answers"), ("src/pages/editorial.astro", "병원 담당자, 서포터즈, INFINITH 운영진이", "병원 담당자, 편집팀, INFINITH 운영진이"), ("src/pages/editorial.astro", "서포터즈. 확정 후", "편집팀. 확정 후"), ] def patch_copy(): changed = 0 for rel, old, new in REPLACEMENTS: path = os.path.join(SITE, rel) text = open(path, encoding="utf-8").read() if old in text: open(path, "w", encoding="utf-8").write(text.replace(old, new)) changed += 1 return changed # 영문 화면의 한글 노출 정리 (haewon 지시 2026-10-12). 템플릿은 영문 값이 없으면 한국어 값·'확인 대기'를 그대로 그린다 EN_PENDING = "To be confirmed" EN_REPLACEMENTS = [ # 탭 제목·푸터 사이트 이름: 영문 페이지는 site.siteTitleEn·taglineEn ("src/layouts/Base.astro", "{title} | {SITE_NAME}", "{title} | {lang === 'en' ? ((S as any).siteTitleEn || SITE_NAME) : SITE_NAME}"), ("src/layouts/Base.astro", "

{SITE_NAME} · {SITE_TAGLINE}

", "

{lang === 'en' ? ((S as any).siteTitleEn || SITE_NAME) : SITE_NAME} · {lang === 'en' ? ((S as any).taglineEn || SITE_TAGLINE) : SITE_TAGLINE}

"), # 푸터 연락처: 빈 값은 영문 화면에서 'To be confirmed', 대표자는 영문 이름 ("src/layouts/Base.astro", "{u.foot_phone} {v(f.phone)} · {u.foot_fax} {v(f.fax)}
{u.foot_rep} {v(f.representative)} · {u.foot_biz} {v(f.businessNo)}", "{u.foot_phone} {v(f.phone, lang === 'en' ? '" + EN_PENDING + "' : undefined)} · {u.foot_fax} {v(f.fax, lang === 'en' ? '" + EN_PENDING + "' : undefined)}
{u.foot_rep} {lang === 'en' ? v((EN as any).representative, '" + EN_PENDING + "') : v(f.representative)} · {u.foot_biz} {v(f.businessNo, lang === 'en' ? '" + EN_PENDING + "' : undefined)}"), # 로고 이미지가 없을 때 헤더에 글자로 나오는 상호 ("src/layouts/Base.astro", "", ""), # 관광 데이터에 영문 주소가 없는 항목(한글만)은 영문 페이지에서 주소 줄을 비운다 ("src/pages/en/stay.astro", "

{p.address}

", "

{/[A-Za-z]/.test(p.address || '') ? p.address : ''}

"), ("src/pages/en/stay.astro", "

{e.address}

", "

{/[A-Za-z]/.test(e.address || '') ? e.address : ''}

"), # 사진 없는 장소의 이름 칸: 괄호 안이 한글이면 앞쪽 영문 이름을 쓴다 ("src/pages/en/stay.astro", " const m = t.match(/\\(([^)]+)\\)\\s*$/);\n return (m ? m[1] : t).replace(/\\s*\\[.*\\]\\s*/g, '').trim();", " const m = t.match(/^(.*?)\\s*\\(([^)]+)\\)\\s*$/);\n return (m ? (/[가-힣]/.test(m[2]) ? m[1] : m[2]) : t).replace(/\\s*\\[.*\\]\\s*/g, '').trim();"), ] def patch_english(): clinic = json.load(open(os.path.join(HERE, "clinic.json"), encoding="utf-8")) changed = 0 for rel, old, new in EN_REPLACEMENTS: path = os.path.join(SITE, rel) text = open(path, encoding="utf-8").read() if old in text: open(path, "w", encoding="utf-8").write(text.replace(old, new)) changed += 1 # 영문 홈: 빈 값 기본 문구를 영어로 (v() 기본값은 '확인 대기') path = os.path.join(SITE, "src/pages/en/index.astro") text = open(path, encoding="utf-8").read() if "const vEn" not in text: text = re.sub(r"(?;", "const f = fact as Record;\nconst vEn = (x: unknown) => v(x, '" + EN_PENDING + "');", 1) open(path, "w", encoding="utf-8").write(text) changed += 1 # 팩트 시트: 워커가 얕게 병합하므로 중첩 값(주소 영문·강남언니 수치)은 여기서 깊게 병합한다 fp = os.path.join(SITE, "src/data/factSheet.json") fact = json.load(open(fp, encoding="utf-8")) def deep(dst, src): for k, v in src.items(): if isinstance(v, dict) and isinstance(dst.get(k), dict): deep(dst[k], v) else: dst[k] = v deep(fact, clinic.get("factSheetPatch", {})) json.dump(fact, open(fp, "w", encoding="utf-8"), ensure_ascii=False, indent=2) ep = os.path.join(SITE, "src/data/factSheetEn.json") en = json.load(open(ep, encoding="utf-8")) deep(en, clinic.get("factSheetEn", {})) json.dump(en, open(ep, "w", encoding="utf-8"), ensure_ascii=False, indent=2) # 회복 일정 플래너 기준점 영문 이름(planner 단계가 inputs 단계보다 먼저 돌아 영문 상호를 못 받는다) pp = os.path.join(SITE, "src/data/places.json") if os.path.exists(pp) and en.get("shortName"): places = json.load(open(pp, encoding="utf-8")) places.setdefault("origin", {}).setdefault("label", {})["en"] = en["shortName"] json.dump(places, open(pp, "w", encoding="utf-8"), ensure_ascii=False, indent=2) return changed # 홈 'Interview' 섹션 (haewon 지시 2026-10-19). 원장 인터뷰 영상(외부 채널)과 인터뷰 글·공식 블로그·인스타그램 링크 카드 INTERVIEW_ANCHOR = "
\n
\n
Inside
" INTERVIEW_SECTION = """
Interview

Meet The Doctor

문건학 원장 인터뷰와 {clinic} 공식 채널입니다.

{interview.video &&
} {interview.links.map((l) => ( ))}
""" # VideoLite 캡션은 병원 유튜브 핸들을 고정으로 붙인다. 외부 채널 영상은 channel 로 바꿔 쓴다 VIDEOLITE_REPLACEMENTS = [ ("note?: string; compact?: boolean }", "note?: string; compact?: boolean; channel?: string }"), ("const { id, title, speaker, published, note, compact = false } = Astro.props;", "const { id, title, speaker, published, note, compact = false, channel } = Astro.props;"), ("{handle}{note ?", "{channel ?? handle}{note ?"), ] def patch_home_interview(): interview = json.load(open(os.path.join(HERE, "clinic.json"), encoding="utf-8")).get("interview") if not interview: return 0 json.dump(interview, open(os.path.join(SITE, "src/data/interview.json"), "w", encoding="utf-8"), ensure_ascii=False, indent=2) vp = os.path.join(SITE, "src/components/VideoLite.astro") text = open(vp, encoding="utf-8").read() for old, new in VIDEOLITE_REPLACEMENTS: text = text.replace(old, new) open(vp, "w", encoding="utf-8").write(text) ip = os.path.join(SITE, "src/pages/index.astro") text = open(ip, encoding="utf-8").read() if "data/interview.json" in text: return 0 if INTERVIEW_ANCHOR not in text: sys.exit("index.astro 에서 Inside 섹션을 찾지 못해 Interview 섹션을 넣지 못함") text = text.replace("import Gallery from '../components/Gallery.astro';", "import Gallery from '../components/Gallery.astro';\nimport interview from '../data/interview.json';", 1) text = text.replace(INTERVIEW_ANCHOR, INTERVIEW_SECTION + INTERVIEW_ANCHOR, 1) open(ip, "w", encoding="utf-8").write(text) return 1 # 푸터 채널 아이콘 (haewon 지시 2026-10-19). 유튜브·강남언니 글자 링크는 아이콘 줄로 옮기고 홈페이지 링크만 남긴다 FOOTER_LINKS_OLD = "{has(surface('youtube').url) && <> · {u.foot_youtube}}{has(surface('gangnamunni').url) && <> · {u.foot_gu}}

" FOOTER_CHANNELS = """

    {footerChannels.map((c) => (
  • {lang
  • ))}
""" FOOTER_CSS = """ /* 푸터 채널 아이콘 (patch_site.py 가 넣음) */ .site-footer .foot-channels { list-style: none; display: flex; flex-wrap: wrap; gap: 0.55rem; margin: 0.9rem 0 0; padding: 0; } .site-footer .foot-channels a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; background: #fff; transition: transform .2s, box-shadow .2s; } .site-footer .foot-channels a:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); } .site-footer .foot-channels img { width: 20px; height: 20px; display: block; } """ def patch_footer_channels(): channels = json.load(open(os.path.join(HERE, "clinic.json"), encoding="utf-8")).get("footerChannels") if not channels: return 0 dst = os.path.join(SITE, "public", "img", "channels") os.makedirs(dst, exist_ok=True) for c in channels: shutil.copyfile(os.path.join(HERE, "channel-icons", c["icon"]), os.path.join(dst, c["icon"])) json.dump(channels, open(os.path.join(SITE, "src/data/footerChannels.json"), "w", encoding="utf-8"), ensure_ascii=False, indent=2) changed = 0 cp = os.path.join(SITE, "src/styles/global.css") css = open(cp, encoding="utf-8").read() if ".foot-channels" not in css: open(cp, "w", encoding="utf-8").write(css.rstrip("\n") + "\n" + FOOTER_CSS) changed += 1 bp = os.path.join(SITE, "src/layouts/Base.astro") text = open(bp, encoding="utf-8").read() if "data/footerChannels.json" not in text: if FOOTER_LINKS_OLD not in text: sys.exit("Base.astro 에서 푸터 유튜브·강남언니 링크 줄을 찾지 못해 채널 아이콘을 넣지 못함") text = text.replace("import EN from '../data/factSheetEn.json';", "import EN from '../data/factSheetEn.json';\nimport footerChannels from '../data/footerChannels.json';", 1) text = text.replace(FOOTER_LINKS_OLD, FOOTER_CHANNELS, 1) open(bp, "w", encoding="utf-8").write(text) changed += 1 return changed def remove_excluded_images(): prefixes = json.load(open(os.path.join(HERE, "clinic.json"), encoding="utf-8")).get("excludeImages", []) removed = [] for root, _, files in os.walk(os.path.join(SITE, "public", "img")): for f in files: if any(f.startswith(p) for p in prefixes): os.remove(os.path.join(root, f)) removed.append(f) return removed def set_site_url_and_share_image(): vp = os.path.join(SITE, "vercel.json") vj = json.load(open(vp, encoding="utf-8")) vj.setdefault("build", {}).setdefault("env", {})["SITE_URL"] = SITE_URL json.dump(vj, open(vp, "w", encoding="utf-8"), ensure_ascii=False, indent=2) subprocess.run([sys.executable, os.path.join(ROOT, "scripts", "make_share_assets.py"), "supporters", "--site", SITE, "--eyebrow", OG_EYEBROW], check=True) def leftovers(): """화면에 나갈 수 있는 '서포터즈'·'Supporters'. 주석·데이터 키(authors.supporters)·내부 규칙 경로는 뺀다.""" hits = [] for root, _, files in os.walk(os.path.join(SITE, "src")): for f in files: path = os.path.join(root, f) for n, line in enumerate(open(path, encoding="utf-8", errors="ignore"), 1): code = re.sub(r"//.*$", "", line) code = code.replace("authors.supporters", "").replace("INFINITH_Supporters_Image_Rules", "") if '"supporters"' in code or "_comment" in code: continue if re.search(r"서포터즈|Supporters", code): hits.append(f"{os.path.relpath(path, SITE)}:{n}: {line.strip()[:120]}") return hits if __name__ == "__main__": n = patch_copy() n_en = patch_english() print(f"영문 처리 {n_en}곳") print(f"홈 인터뷰 섹션 {patch_home_interview()}곳") print(f"푸터 채널 아이콘 {patch_footer_channels()}곳") removed = remove_excluded_images() set_site_url_and_share_image() left = leftovers() print(f"문구 교체 {n}곳 · 제외 이미지 삭제 {len(removed)}개 {removed}") if left: print("화면용 '서포터즈'가 남아 있음:\n " + "\n ".join(left)) sys.exit(1)