import html import json import shutil from pathlib import Path HERE = Path(__file__).parent TPL = HERE / "tpl-story" OUT = HERE / "build3" PAYLOAD = json.loads((HERE / "stay3-payload.json").read_text()) ORIGIN = "https://web4ai.o2osolution.ai" BASE = "/s/stay3" place = PAYLOAD["place"] narrative = PAYLOAD["narrative"] units = PAYLOAD["units"] media = PAYLOAD["media"] facts = {f["key"]: f for f in PAYLOAD["facts"]} faqs = PAYLOAD["faqs"] links = PAYLOAD["links"] local = PAYLOAD["local"] sections = {s["id"]: (json.loads(s["data"]) if isinstance(s.get("data"), str) else None) for s in PAYLOAD["theme"]["sections"]} NAME = place["name"] PHONE = place["phone"] BOOK_URL = next((l["url"] for l in links if l.get("channel") == 7), "#") INSTA_URL = next((l["url"] for l in links if l.get("channel") == 4), None) ABOUT = narrative["about"] PRICE_FROM = "198,000" def e(text): return html.escape(str(text or ""), quote=True) def unit_fact(unit, key): for f in unit["facts"]: if f["key"] == key: return f return None def unit_value(unit, key, default=""): f = unit_fact(unit, key) if not f: return default unit_text = f.get("unit") or "" joiner = "" if unit_text in ("명", "원") else " " return f["value"] + (joiner + unit_text if unit_text else "") def unit_title(unit): return unit["name"].split("(")[0].strip() def unit_subtitle(unit): raw = unit["name"] return raw[raw.find("(") + 1:raw.rfind(")")].strip() if "(" in raw else "" def pics(category=None, limit=None, skip=0): rows = [m for m in media if category is None or m.get("category") == category] rows = rows[skip:] return rows[:limit] if limit else rows def naver(query): from urllib.parse import quote return f"https://search.naver.com/search.naver?query={quote(query)}" HEAD = """ {title}
{name}
""" FOOT = """
{price_from}원주중 1박 기준 예약하기
""" FOOTER_SECTION = """ """ def page(path, title, desc, og, body): canonical = f"{ORIGIN}{BASE}{path}" head = HEAD.format(title=e(title), desc=e(desc), canonical=canonical, origin=ORIGIN, og=og, base=BASE, name=e(NAME), phone=PHONE) foot = FOOT.format(base=BASE, book=e(BOOK_URL), price_from=PRICE_FROM) insta = (f'
  • 인스타그램
  • ') if INSTA_URL else "" footer = FOOTER_SECTION.format(name=e(NAME), road=e(place["roadAddress"]), phone=PHONE, book=e(BOOK_URL), insta=insta) target = OUT / path.lstrip("/") / "index.html" if path else OUT / "index.html" target.parent.mkdir(parents=True, exist_ok=True) target.write_text(head + body + footer + foot) return target def banner(image, kicker, heading, lead, actions, extra_class="fullscreen cover"): action_html = f'' if actions else "" return f""" """ def spotlight(image, heading, paragraphs, orient="right", invert=False, actions=""): body = "".join(f"

    {p}

    " for p in paragraphs) klass = "spotlight style1 orient-%s content-align-left image-position-center onscroll-image-fade-in" % orient if invert: klass += " invert" return f"""

    {heading}

    {body} {f'' if actions else ''}
    {e(image['alt'])}
    """ def gallery(rows, style="style2 medium"): cells = "".join( f'
    ' f'

    {e(m.get("category") or "")}

    ' for m in rows) return f'' def spec_index(pairs): rows = "".join(f"

    {k}

    {v}

    " for k, v in pairs) return f'
    {rows}
    ' def build_home(): hero = media[0] actions = '
  • 머뭄 둘러보기
  • ' body = banner(hero, e(place["addressLocality"]), e(NAME), e(narrative["tagline"]), actions) body += f'
    ' body += spotlight(pics("외관", 1)[0] if pics("외관", 1) else media[3], "백 년 된 집 한 채", [e(ABOUT[0])], orient="right") body += spotlight(pics("카페", 1)[0] if pics("카페", 1) else media[7], "마당과 창고형 카페", [e(ABOUT[1]), e(ABOUT[2])], orient="left") unit_shots = [(pics("거실", 1, skip=1) or pics(limit=1))[0], (pics("침실", 1) or pics(limit=1, skip=4))[0]] cards = "" for i, u in enumerate(units): shot = unit_shots[i] chip_values = [f"기준 {unit_value(u, 'standard_capacity')}", f"최대 {unit_value(u, 'max_capacity')}", unit_value(u, "bed_type"), unit_value(u, "room_size")] chips = "".join(f"
  • {e(c)}
  • " for c in chip_values if c.strip()) cards += f"""
    {e(shot['alt'])}

    {e(unit_title(u))}

    {e(unit_subtitle(u))}

    주중 1박 {e(f"{int(unit_value(u, 'weekday_price').replace('원', '').strip()):,}")}원

    이 동 자세히 보기
    """ body += f"""

    두 동, 각각 한 팀만

    A동과 B동은 서로 보이지 않습니다. 한 동을 한 팀이 통째로 씁니다.

    {cards}
    """ fest = local["festivals"][0] spots = local["attractions"][:3] tiles = "".join( f'' f'{e(s[' f'{e(s["name"])}도보 {e(s["distanceText"])}' for s in spots) tiles += (f'' f'{e(fest[' f'{e(fest["name"])}{e(fest["month"])}') body += f"""

    군산에서 보낼 시간

    담을 나서면 근대 도심입니다. 걸어서 닿는 곳과 계절마다 열리는 축제, 하루를 통째로 짜 둔 일정 {len(sections['itinerary']['items'])}가지를 따로 모아 두었습니다.

    {tiles}
    """ lat, lng = place["latitude"], place["longitude"] body += f"""

    오시는 길

    {e(place['roadAddress'])}

    군산역에서 차로 약 20분 · 히로쓰 가옥 후문에서 걸어서 13m

    """ amen = [("체크인 / 체크아웃", f"{facts['check_in_time']['value']} / {facts['check_out_time']['value']}"), ("인원", "기준 2명 · 최대 4명 (추가 1인 20,000원)"), ("주차", "가능"), ("와이파이", "있음"), ("취사", "가능"), ("반려동물", "불가"), ("흡연", "불가"), ("바비큐", "불가"), ("픽업 서비스", "없음"), ("취소·환불", "입실 당일 취소·노쇼는 환불되지 않습니다")] faq_rows = "".join( f"
    {e(f['question'])}

    {e(f['answer'])}

    " for f in faqs[:5]) body += f"""

    기본 정보

    {spec_index(amen)}

    자주 묻는 질문

    {faq_rows}
    """ return page("", f"{NAME} · 전북 군산시 독채 펜션", narrative["summary"], media[0]["url"], body) def build_rooms(): body = banner(pics("침실", 1)[0] if pics("침실", 1) else media[5], "객실", "두 동, 각각 한 팀만", "A동은 일본집의 결을 그대로 두었고, B동은 현대식으로 꾸몄습니다.", f'
  • 예약하기
  • ', extra_class="cover compact") for i, u in enumerate(units): anchor = "a" if i == 0 else "b" shot = (pics("거실", 1, skip=1) if i == 0 else pics("침실", 1))[0] spec = [("기준 인원", unit_value(u, "standard_capacity")), ("최대 인원", unit_value(u, "max_capacity")), ("침대", unit_value(u, "bed_type")), ("면적", unit_value(u, "room_size")), ("주중 요금", f"{int(unit_value(u, 'weekday_price').replace('원', '').strip()):,}원"), ("요금 범위", unit_value(u, "price_range"))] rows = "".join(f"{k}{e(v)}" for k, v in spec if str(v).strip()) fac = unit_value(u, "room_facilities").split(" · ") chips = "".join(f"
  • {e(x)}
  • " for x in fac) body += f"""

    {e(unit_title(u))}

    {e(unit_subtitle(u))}

    {e(unit_value(u, 'room_intro'))}

    {e(shot['alt'])}
    {rows}
    """ body += f"""

    사진 {len(media)}장

    {gallery(media)}
    """ amen = [("체크인 / 체크아웃", f"{facts['check_in_time']['value']} / {facts['check_out_time']['value']}"), ("인원 추가", "1인 20,000원"), ("주차", "가능"), ("와이파이", "있음"), ("취사", "가능"), ("반려동물", "불가"), ("흡연", "불가"), ("바비큐", "불가")] faq_rows = "".join( f"
    {e(f['question'])}

    {e(f['answer'])}

    " for f in faqs[:14]) body += f"""

    이용 안내

    {spec_index(amen)}

    {e(facts['cancel_policy']['value'])}

    자주 묻는 질문

    {faq_rows}
    """ return page("rooms", f"객실과 요금 · {NAME}", "A동·B동 두 독채의 인원·침대·면적·요금과 사진 37장.", media[5]["url"], body) def build_gunsan(): fest = local["festivals"] spots = local["attractions"] rest = local["restaurants"][:8] itin = sections["itinerary"]["items"] reading = sections["reading"]["items"] songs = sections["songs"]["items"] body = banner(spots[0]["imageUrl"] and {"url": spots[0]["imageUrl"], "alt": spots[0]["name"]}, "군산", "담 너머의 도시", "걸어서 닿는 근대 도심과 계절마다 열리는 축제, 하루를 통째로 짜 둔 일정.", f'
  • 머뭄으로 돌아가기
  • ', extra_class="cover compact") def spot_cards(rows, meta_key): return "".join( f'' f'{e(s[' f'{e(s["name"])}{e(s.get(meta_key) or "")}' f'{e((s.get("description") or "")[:70])}' for s in rows if s.get("imageUrl")) body += f"""

    걸어서 닿는 곳

    도보 시간은 직선거리를 분속 80m로 환산한 값입니다.

    {spot_cards(spots, 'distanceText')}

    근처에서 먹을 곳

    {spot_cards(rest, 'distanceText')}

    계절마다 열리는 것

    한국관광공사 TourAPI 기준. 일정은 주최 측 사정으로 바뀔 수 있습니다.

    {spot_cards(fest, 'period')}
    """ plans = "".join( f"
    {e(i['name'])}{e(i['duration'])} · {e(i['audience'])}" f"

    {e(i['why'])}

    " + "".join( f"

    {e(d['label'])} {e(d['startTime'])} 출발

      " + "".join(f"
    1. {e(s['name'])}{('' + e(s['note']) + '') if s.get('note') else ''}
    2. " for s in d["stops"]) + "
    " for d in i["days"]) + "
    " for i in itin) body += f"""

    하루를 통째로

    머뭄에서 나서고 머뭄으로 돌아옵니다 — {len(itin)}가지

    {plans}
    """ reads = "".join( f"

    {e(r['title'])}

    {e(r['body'])}

    " f"{e(r['source']['name'])}
    " for r in reading) body += f"""

    이 도시를 쓴 사람과 그 자리

    {reads}
    """ def song_row(s): return (f"
  • " f"{e(s['title'])}{e(s['artist'])}{e(s['story'])}
  • ") head_rows = "".join(song_row(s) for s in songs[:8]) rest_rows = "".join(song_row(s) for s in songs[8:]) body += f"""

    군산을 노래한 {len(songs)}곡

      {head_rows}
    나머지 {len(songs) - 8}곡 보기
      {rest_rows}
    """ return page("gunsan", f"군산 둘러보기 · {NAME}", "걸어서 닿는 근대 도심, 계절 축제, 추천 일정 21가지, 군산을 쓴 글과 노래.", spots[0]["imageUrl"], body) OVERRIDE = """ :root { --ink: #16181a; --accent: #1f4a3f; --muted: #6a7178; } body, input, select, textarea, button { font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; font-size: 16px; line-height: 1.7; word-break: keep-all; color: var(--ink); } h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; } .serif { font-family: "Gowun Batang", serif; font-weight: 700; letter-spacing: -0.01em; } p { font-size: 16px; } .kicker { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; opacity: .8; margin-bottom: .4rem; } #footer .inner { padding-top: 3rem; padding-bottom: 3rem; } #footer h2 { font-size: 20px; } .tiny { font-size: 12.5px; color: var(--muted); line-height: 1.8; } .lead { max-width: 40rem; margin-left: auto; margin-right: auto; } input[type="submit"].primary, input[type="reset"].primary, input[type="button"].primary, button.primary, .button.primary { background-color: var(--accent); } input[type="submit"].primary:hover, button.primary:hover, .button.primary:hover { background-color: #2a6455; } a { color: var(--accent); } #topbar { position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: rgba(255,255,255,.88); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(0,0,0,.07); } #topbar .brand { font-weight: 700; font-size: 15px; text-decoration: none; color: var(--ink); letter-spacing: -.01em; } #topbar nav { display: flex; gap: 4px; } #topbar nav a { display: flex; align-items: center; min-height: 44px; padding: 0 10px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink); } #wrapper { padding-top: 48px; } #bookbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-top: 1px solid rgba(0,0,0,.09); } #bookbar .price { display: flex; flex-direction: column; line-height: 1.25; } #bookbar .price b { font-size: 18px; font-weight: 700; } #bookbar .price small { font-size: 12px; color: var(--muted); } #bookbar .button.primary { margin-left: auto; min-width: 9.5rem; min-height: 48px; line-height: 48px; } body { padding-bottom: 76px; } .banner.style1 .content > .kicker, .banner.style1 .content > .major { color: inherit; } .banner.style1 h1 { font-size: 2.6rem; line-height: 1.2; } .banner.style1 .content { padding: 3rem 1.5rem; } .units { display: grid; gap: 20px; margin: 2rem 0 1rem; text-align: left; } .unit { border: 1px solid rgba(0,0,0,.1); border-radius: 12px; overflow: hidden; background: #fff; } .unit .image { display: block; aspect-ratio: 4/3; } .unit .image img { width: 100%; height: 100%; object-fit: cover; } .unit .body { padding: 18px; } .unit h3 { font-size: 20px; margin: 0 0 2px; } .unit .sub { font-size: 14px; color: var(--muted); margin: 0 0 12px; } .unit .price { margin: 12px 0; font-size: 15px; } .unit .price b { font-size: 19px; } .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; } .chips li { padding: 5px 10px; border-radius: 999px; background: rgba(0,0,0,.05); font-size: 13px; font-weight: 500; line-height: 1.4; } .chips.wide { justify-content: center; margin-top: 1rem; } .invert .chips li { background: rgba(255,255,255,.14); } .tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 1.75rem 0 1rem; text-align: left; } .tiles.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } .tile { display: block; border-radius: 12px; overflow: hidden; text-decoration: none; background: rgba(0,0,0,.04); color: inherit; } .invert .tile { background: rgba(255,255,255,.08); } .tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; } .tile span { display: block; padding: 10px 12px 13px; } .tile b { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.4; } .tile small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; } .invert .tile small { color: rgba(255,255,255,.7); } .tile em { display: block; font-style: normal; font-size: 12.5px; line-height: 1.55; margin-top: 5px; opacity: .8; } .mapframe { width: 100%; height: 300px; border: 0; border-radius: 12px; margin: 1.5rem 0 1rem; } .address { font-size: 18px; font-weight: 600; } .index.align-left { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; max-width: 44rem; margin-inline: auto; } .index.align-left section { padding: 9px 0; border-bottom: 1px solid rgba(0,0,0,.07); } .invert .index.align-left section { border-bottom-color: rgba(255,255,255,.16); } .index.align-left header { margin: 0; padding: 0; } .index.align-left h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0; } .invert .index.align-left h3 { color: rgba(255,255,255,.7); } .index.align-left .content { padding: 0; } .index.align-left .content p { font-size: 15px; margin: 0; line-height: 1.5; } .faqhead { margin-top: 2.5rem; font-size: 18px; } .faq { text-align: left; max-width: 44rem; margin: 0 auto; } .faq details { border-bottom: 1px solid rgba(0,0,0,.1); } .invert .faq details { border-bottom-color: rgba(255,255,255,.18); } .faq summary { cursor: pointer; list-style: none; padding: 15px 28px 15px 0; position: relative; font-size: 15.5px; font-weight: 600; min-height: 44px; } .faq summary::-webkit-details-marker { display: none; } .faq summary::after { content: "+"; position: absolute; right: 4px; top: 13px; font-size: 20px; font-weight: 400; opacity: .55; } .faq details[open] summary::after { content: "\\2212"; } .faq details p { padding: 0 0 15px; margin: 0; font-size: 15px; } .faq .plans summary span { display: block; font-size: 13px; font-weight: 400; color: var(--muted); } .invert .faq .plans summary span { color: rgba(255,255,255,.7); } .plans .why { font-size: 15px; padding-bottom: 8px; } .plans .day { padding: 4px 0 14px; } .plans .day h4 { font-size: 14px; margin: 0 0 6px; } .plans .day h4 small { font-weight: 400; color: var(--muted); } .plans .day ol { margin: 0; padding-left: 1.2rem; } .plans .day li { padding: 4px 0; font-size: 14.5px; } .plans .day li b { font-weight: 600; } .plans .day li span { display: block; font-size: 13.5px; opacity: .78; line-height: 1.6; } .reads { display: grid; gap: 18px; text-align: left; max-width: 44rem; margin: 1.5rem auto 0; } .read { border-left: 2px solid var(--accent); padding-left: 16px; } .read h3 { font-size: 17px; margin: 0 0 6px; } .read p { font-size: 15px; margin: 0 0 8px; } .read a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13.5px; font-weight: 600; } .songs { list-style: none; margin: 1.5rem 0 0; padding: 0; text-align: left; max-width: 44rem; margin-inline: auto; } .songs li { border-top: 1px solid rgba(255,255,255,.16); } .songs li:last-child { border-bottom: 1px solid rgba(255,255,255,.16); } .songs a { display: block; padding: 14px 0; text-decoration: none; color: inherit; min-height: 44px; } .songs b { font-size: 16px; font-weight: 600; } .songs span { font-size: 13.5px; opacity: .72; margin-left: 8px; } .songs em { display: block; font-style: normal; font-size: 13.5px; opacity: .78; margin-top: 3px; line-height: 1.6; } .hero-shot { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 12px; margin: 1.25rem 0; } .table-wrapper table.alt th { width: 8rem; font-size: 14px; color: var(--muted); } .table-wrapper table.alt td { font-size: 15px; } .banner.style1.cover { position: relative; display: block; padding: 0; } .banner.style1.cover .image { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; max-width: none; } .banner.style1.cover .image img { width: 100%; height: 100%; object-fit: cover; } .banner.style1.cover .content { position: relative; z-index: 2; display: flex; flex-direction: column; justify-content: flex-end; min-height: 88svh; padding: 2rem 1.5rem 3rem; text-align: left; max-width: none; background: linear-gradient(to top, rgba(12,14,13,.86) 0%, rgba(12,14,13,.62) 32%, rgba(12,14,13,.22) 58%, rgba(12,14,13,0) 82%); } .banner.style1.cover.compact .content { min-height: 56svh; } .banner.style1.cover .content, .banner.style1.cover .content h1, .banner.style1.cover .content p { color: #fff; } .banner.style1.cover .content .kicker { opacity: .92; } .banner.style1.cover .content .major { font-size: 17px; max-width: 26rem; } .banner.style1.cover .actions { margin-top: 1.25rem; } .button, .button.large, input[type="submit"], button { letter-spacing: 0; font-weight: 600; min-height: 48px; line-height: 48px; } .button.large { min-height: 52px; line-height: 52px; font-size: 16px; } .button.ghost { background: rgba(255,255,255,.14); color: #fff !important; box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); } .button.ghost:hover { background: rgba(255,255,255,.24); } .tile em { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .tile b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .tiles.wide { align-items: stretch; } .tiles.wide .tile { display: flex; flex-direction: column; } #topbar .brand { display: flex; align-items: center; min-height: 44px; } .more { margin-top: 1.25rem; } .more > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 1.5rem; border-radius: 999px; font-size: 15px; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255,255,255,.45); } .more > summary::-webkit-details-marker { display: none; } @media (min-width: 737px) { .units { grid-template-columns: repeat(2, 1fr); } .tiles { grid-template-columns: repeat(4, 1fr); } .banner.style1 h1 { font-size: 3.4rem; } .banner.style1.cover .content { min-height: 82svh; padding: 3rem 4rem 4rem; width: 100%; max-width: none; flex-basis: auto; } .banner.style1.cover .content > * { max-width: 34rem; } .banner.style1.cover.compact .content { min-height: 46svh; } #topbar { height: 56px; padding: 0 28px; } #wrapper { padding-top: 56px; } } @media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } } """ def main(): if OUT.exists(): shutil.rmtree(OUT) OUT.mkdir(parents=True) shutil.copytree(TPL / "assets", OUT / "assets") (OUT / "assets" / "js" / "demo.js").unlink(missing_ok=True) (OUT / "assets" / "css" / "meomoom.css").write_text(OVERRIDE) shutil.copy(TPL / "LICENSE.txt", OUT / "assets" / "LICENSE-story.txt") made = [build_home(), build_rooms(), build_gunsan()] for path in made: print(path.relative_to(OUT), f"{path.stat().st_size:,} bytes") if __name__ == "__main__": main()