diff --git a/site/build.py b/site/build.py index 5842fa6..37cf7d8 100644 --- a/site/build.py +++ b/site/build.py @@ -483,13 +483,15 @@ def index_page(topics, policies, issues, datasets, projects=(), answers=(), line

그 정책, 진짜 먹혔을까?

뉴스에서 "효과 있었다", "실패했다"는 말이 나올 때, 공공데이터로 '받은 동네 vs 안 받은 동네'를 비교해 진짜 효과인지 확인하는 곳이에요. 데이터가 모른다고 하면 모른다고 말하는 것까지가 이 사이트의 규칙이에요.

- + + {flow} -
+
+검색으로 안 풀리면 대화로 물어보기 주제 · 데이터 · 분석 계획 초안까지 같이 정리해 드려요
@@ -510,7 +512,8 @@ def index_page(topics, policies, issues, datasets, projects=(), answers=(), line

로컬 Ollama는 OLLAMA_ORIGINS=https://causalinferencelab.github.io로 실행해야 브라우저에서 부를 수 있습니다. AI도 결과를 계산하지 않습니다. 주제·데이터·계획을 함께 정리할 뿐이고, 숫자는 레포의 분석 코드가 냅니다. 법률 자문이 아닙니다.

- + + {proj.personas(e, n_answers, len(datasets))} diff --git a/site/search.js b/site/search.js index 7c46831..cd97e08 100644 --- a/site/search.js +++ b/site/search.js @@ -13,7 +13,7 @@ const $ = (s) => document.querySelector(s); const esc = (s) => String(s == null ? "" : s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]); const norm = (s) => String(s || "").toLowerCase().replace(/\s+/g, ""); - const input = $("#sq"), res = $("#sres"), none = $("#snone"), verdict = $("#verdict"); + const input = $("#sq"), res = $("#sres"), none = $("#snone"), verdict = $("#verdict"), idle = $("#sidle"); const REPO = "https://github.com/CausalInferenceLab/policy-effect-analytics-agent"; let items = [], kind = "", logged = new Set(), timer = null; @@ -40,37 +40,59 @@ if (it.tk && it.tk.split(" ").some((k) => k.length >= 2 && qn.includes(norm(k)))) s += 3; return hit || s >= 3 ? s : 0; } - function row(it) { + const TYPE = { result: "결과", project: "진행 중", issue: "이슈", topic: "주제", law: "법령", lineage: "계보", dataset: "데이터" }; + function card(it) { // 분석 결과: 판정 + 95% 범위 그림 + return `` + + `${esc(it.badge)}${esc(it.title)}` + + `${esc(it.sub)}${esc(it.who)}` + + `${it.g || ""}`; + } + function row(it) { // 그 밖: 한 줄짜리 목록 const ext = /^https?:/.test(it.url); - const badge = it.badge ? `${esc(it.badge)}` : ""; - return `` + - `${badge}${it.who ? `${esc(it.who)}` : ""}` + - `${esc(it.title)}${esc(it.sub)}`; + return `` + + `${TYPE[it.t]}${esc(it.title)}` + + `${esc(it.sub)}${it.badge ? `${esc(it.badge)}` : ""}`; + } + function group(t, xs) { + const draw = t === "result" ? card : row, cls = t === "result" ? "r-list" : "s-rows"; + return `

${KO[t]}${xs.length}

${xs.slice(0, 8).map(draw).join("")}
` + + (xs.length > 8 ? `
${xs.length - 8}개 더 보기
${xs.slice(8).map(draw).join("")}
` : "") + + `
`; + } + function counts(hits) { + document.querySelectorAll(".sf").forEach((b) => { + const n = b.dataset.t ? hits.filter((it) => it.t === b.dataset.t).length : hits.length; + b.querySelector(".n").textContent = hits.length ? n : ""; + b.disabled = !!b.dataset.t && hits.length > 0 && n === 0; + }); } function render(q) { const qn = norm(q), tks = tokens(q); - if (!qn) { res.innerHTML = ""; none.hidden = true; verdict.hidden = true; return 0; } + idle.hidden = !!qn; + if (!qn) { res.innerHTML = ""; none.hidden = true; verdict.hidden = true; counts([]); return 0; } const hits = items.map((it) => [it, score(it, tks, qn)]).filter(([, s]) => s > 0).sort((a, b) => b[1] - a[1]).map(([it]) => it); + counts(hits); const shown = kind ? hits.filter((it) => it.t === kind) : hits; - const groups = ORDER.map((t) => [t, shown.filter((it) => it.t === t)]).filter(([, xs]) => xs.length); - res.innerHTML = groups.map(([t, xs]) => - `

${KO[t]} ${xs.length}

${xs.slice(0, 8).map(row).join("")}
` + - (xs.length > 8 ? `
${xs.length - 8}개 더 보기
${xs.slice(8).map(row).join("")}
` : "") + - `
`).join(""); + res.innerHTML = ORDER.map((t) => [t, shown.filter((it) => it.t === t)]).filter(([, xs]) => xs.length).map(([t, xs]) => group(t, xs)).join(""); const results = hits.filter((it) => it.t === "result"); const propose = `${REPO}/issues/new?template=case-proposal.yml&title=${encodeURIComponent("[작업] " + q.trim().slice(0, 60))}`; $("#snone-propose").href = propose; if (results.length) { const top = results[0]; - verdict.innerHTML = `

이 질문과 가장 가까운 분석

` + - `

${esc(top.title)}

` + - `

${esc(top.badge)} ${esc(top.sub)}

` + - `

판정은 '이 데이터와 이 비교로는' 이라는 조건이 붙은 답입니다. 결과 페이지에서 쓸 수 있는 문장과 한계를 함께 보세요.` + - (results.length > 1 ? ` 비슷한 분석 ${results.length - 1}개가 더 있어요.` : "") + `

`; + verdict.className = "v-panel v-" + top.cls; + verdict.innerHTML = `
가장 가까운 분석의 판정${esc(top.badge)}
` + + `

${esc(top.title)}

${esc(top.sub)}

` + + `
${top.g || ""}
` + + `
인용해도 되는 문장숫자가 나온 길` + + `직접 돌려 보기` + + (results.length > 1 ? `비슷한 분석 ${results.length - 1}개 더` : "") + `
` + + `

판정은 '이 데이터와 이 비교로는'이라는 조건이 붙은 답이에요.

`; verdict.hidden = false; } else if (hits.length) { - verdict.innerHTML = `

아직 이 정책의 효과를 잰 분석은 없어요. 대신 아래 이슈·데이터·계보로 시작할 수 있어요. ` + - `분석 요청하기

`; + verdict.className = "v-panel v-none"; + verdict.innerHTML = `
판정아직 분석 없음
` + + `

이 정책의 효과를 잰 분석은 아직 없어요. 아래 이슈·데이터·계보로 시작할 수 있어요.

` + + `
이 정책 분석 요청하기
`; verdict.hidden = false; } else verdict.hidden = true; none.hidden = hits.length > 0; @@ -94,8 +116,13 @@ const q = new URLSearchParams(location.search).get("q") || ""; input.value = q; if (q) run(q, true); - }).catch(() => { res.innerHTML = '

검색 목록을 불러오지 못했어요. 새로고침해 보세요.

'; }); + }).catch(() => { res.innerHTML = '

검색 목록을 불러오지 못했어요. 새로고침해 보세요.

'; }); input.addEventListener("input", () => run(input.value, false)); + document.addEventListener("keydown", (ev) => { // '/' 로 검색창에 바로 + if (ev.key === "/" && document.activeElement !== input && !/INPUT|TEXTAREA|SELECT/.test(document.activeElement.tagName)) { + ev.preventDefault(); input.focus(); input.select(); + } + }); $("#sform").addEventListener("submit", (ev) => { ev.preventDefault(); run(input.value, true); }); document.querySelectorAll("[data-q]").forEach((a) => a.addEventListener("click", (ev) => { ev.preventDefault(); input.value = a.dataset.q; run(a.dataset.q, true); diff --git a/site/search.py b/site/search.py index e93babe..a2d656a 100644 --- a/site/search.py +++ b/site/search.py @@ -36,7 +36,9 @@ def _j(*parts) -> str: def index(topics, issues, datasets, answers, projects, lineages) -> list[dict]: """검색 항목 목록. kw 는 찾는 데만 쓰는 글(화면에 안 보임).""" - from answers import DESCRIPTIVE_LABEL, VERDICT, card_line + from html import escape + + from answers import DESCRIPTIVE_LABEL, VERDICT, card_line, range_glyph from core.discovery.links import dataset_users, is_auto @@ -57,6 +59,7 @@ def index(topics, issues, datasets, answers, projects, lineages) -> list[dict]: "badge": lab, "cls": cls, "who": "멘토 예시" if a["mentor"] else f"@{a['owner']}", + "g": range_glyph(escape, a), "kw": _j(a["question"], tname.get(a["topic"]), a["owner"], a["case"]), } ) @@ -148,44 +151,48 @@ def write(out_dir, items: list[dict]) -> None: EXAMPLES = [ - "토지거래허가구역", - "기후동행카드", - "출산지원금", - "지역화폐", - "녹색교통", - "대형마트 의무휴업", + ("토허제 풍선효과", "토허제 뒤 옆 동네 집값은?"), + ("기후동행카드", "기후동행카드로 지하철 더 탔나?"), + ("출산지원금", "출산지원금 올리면 아이가 늘었나?"), + ("지역화폐", "상품권 할인 늘리면 결제가 늘었나?"), + ("녹색교통", "노후차 막으니 도심 공기가 좋아졌나?"), + ("대형마트 의무휴업", "마트 쉬는 날 바꾸니 동네 가게는?"), ] def body(e, n_items: int, n_results: int) -> str: chips = "".join( - f'{e(x)}' for x in EXAMPLES + f'{e(label)}' + for q, label in EXAMPLES ) filters = "".join( - f'' + f'' for k, v in TYPE_KO.items() ) return f""" -

그 정책, 진짜 효과였나?

-

뉴스에서 본 정책 이름·지역·키워드를 넣어 보세요. 이미 확인한 분석 결과와 판정, 쓸 수 있는 공공데이터, 데이터가 이어지는 길(계보)을 한 번에 찾아 드려요.

- +
+

그 정책, 진짜 효과였나?

+

뉴스에서 본 정책 이름이나 지역을 넣어 보세요. 이미 확인한 판정, 쓸 수 있는 공공데이터, 숫자가 나온 길까지 한 번에 보여 드려요.

+ + - - -
{chips}
- -
-
{filters}
- + + + +
{chips}
+ +
+
{filters}
+
-
""" diff --git a/site/style.css b/site/style.css index d2569a0..737f4b4 100644 --- a/site/style.css +++ b/site/style.css @@ -537,21 +537,105 @@ details.todo[open] summary { font-weight: 700; color: var(--ink) } @media (max-width: 960px) { ol.path { grid-template-columns: repeat(2, minmax(0, 1fr)) } } @media (max-width: 560px) { ol.path { grid-template-columns: minmax(0, 1fr) } } -/* 통합 검색 */ +/* 통합 검색 — 표지 요소는 판정 패널 하나. 나머지는 조용한 목록 */ .sbox { display: flex; gap: 8px; margin: 18px 0 10px; max-width: 760px } -.sbox input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 13px 16px; border: 2px solid var(--ink); border-radius: 12px; background: var(--surface); color: var(--ink) } -.sbox input:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px } -.sbox .btn { border: 0; cursor: pointer; white-space: nowrap } -.home-search { margin-top: 22px } -.s-verdict { margin: 16px 0; border-left: 5px solid var(--accent) } -.s-group { padding: 18px 0 4px } -.s-group h2 { font-size: 17px; margin: 0 0 10px } -.s-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 10px } -.s-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; text-decoration: none; color: inherit } -.s-item:hover { border-color: var(--ink2) } -.s-item b { color: var(--ink); line-height: 1.45 } -.s-item .s-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 4px } -.s-result { border-left: 4px solid var(--accent) } +.sbox input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 13px 16px; border: 1px solid var(--hair); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 28px -20px rgba(20, 23, 28, .45) } +.sbox input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft) } +.sbox .btn { border: 0; cursor: pointer; white-space: nowrap; border-radius: 14px; padding: 0 22px } +.home-search { max-width: 760px; margin: 26px 0 6px } +details.ask { margin-top: 26px; border-top: 1px solid var(--hair); padding-top: 4px } +details.ask > summary { cursor: pointer; list-style: none; padding: 14px 0; font-weight: 700; color: var(--ink); display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: baseline } +details.ask > summary::-webkit-details-marker { display: none } +details.ask > summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--sunk); font-weight: 700 } +details.ask[open] > summary::before { content: "−" } +details.ask > summary span { font-weight: 400; font-size: 14px; color: var(--muted) } +@media (max-width: 560px) { .sbox { flex-direction: column } .sbox .btn { padding: 12px 22px } } + +.s-hero { padding: 64px 0 4px; max-width: 820px } +.s-hero h1 { font-size: clamp(34px, 6.2vw, 58px); line-height: 1.08; letter-spacing: -.045em; font-weight: 800; margin: 0 0 16px } +.s-hero .lede { font-size: 17px; max-width: 54ch } +.qbar { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; align-items: center; margin: 28px 0 14px; + background: var(--surface); border: 1px solid var(--hair); border-radius: 20px; padding: 6px; min-height: 68px; + box-shadow: 0 1px 0 var(--hair), 0 22px 44px -30px rgba(20, 23, 28, .55); transition: border-color .15s, box-shadow .15s } +.qbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft), 0 22px 44px -30px rgba(20, 23, 28, .55) } +.qbar-icon { width: 22px; height: 22px; justify-self: center; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round } +.qbar input { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: clamp(17px, 2.4vw, 21px); font-weight: 700; letter-spacing: -.02em; padding: 12px 6px; min-width: 0 } +.qbar input::placeholder { color: var(--muted); font-weight: 400 } +.qbar input:focus { outline: none } +.qbar input::-webkit-search-cancel-button { cursor: pointer } +.qbar-key { font: 12px var(--mono); color: var(--muted); border: 1px solid var(--hair); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; margin-right: 10px } +.qbar:focus-within .qbar-key { visibility: hidden } +.qbar-go { border: 0; border-radius: 14px; background: var(--ink); color: var(--paper); font: inherit; font-weight: 700; font-size: 15px; padding: 0 22px; align-self: stretch; cursor: pointer } +.qbar-go:hover { background: var(--accent); color: #fff } +.qbar-go:focus-visible, .q-chip:focus-visible, .sf:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px } +.q-examples { display: flex; flex-wrap: wrap; gap: 8px } +.q-chip { font-size: 14px; color: var(--ink2); text-decoration: none; background: var(--sunk); border-radius: 10px; padding: 7px 12px; line-height: 1.4 } +.q-chip:hover { background: var(--ink); color: var(--paper) } +@media (max-width: 640px) { + .q-examples { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none } + .q-chip { flex: none } + .qbar { grid-template-columns: 40px minmax(0, 1fr) auto auto; min-height: 60px } + .qbar-go { padding: 0 16px } +} + +.s-body { padding-top: 34px } +.s-filters { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--hair); margin-bottom: 22px; scrollbar-width: none } +.sf { flex: none; border: 0; background: none; font: inherit; font-size: 14.5px; color: var(--muted); padding: 10px 12px 11px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px } +.sf .n { font-size: 12px; margin-left: 5px; color: var(--muted); font-variant-numeric: tabular-nums } +.sf:hover { color: var(--ink) } +.sf[aria-pressed=true] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink) } +.sf:disabled { opacity: .35; cursor: default } + +.v-panel { --v: var(--warn); --v-bg: var(--warn-bg); position: relative; background: var(--surface); border: 1px solid var(--hair); border-radius: 20px; + padding: 22px 26px 18px 34px; margin: 0 0 26px; overflow: hidden; animation: v-in .22s ease-out } +.v-panel::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--v) } +.v-panel.v-go { --v: var(--go); --v-bg: var(--go-bg) } .v-panel.v-stop { --v: var(--stop); --v-bg: var(--stop-bg) } +.v-panel.v-info { --v: var(--accent); --v-bg: var(--accent-soft) } .v-panel.v-none { --v: var(--hair); --v-bg: var(--sunk) } +.v-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap } +.v-label { font-size: 13.5px; color: var(--muted) } +.v-stamp { font-size: clamp(24px, 3.6vw, 34px); font-weight: 800; letter-spacing: -.04em; color: var(--v); line-height: 1.15 } +.v-panel.v-none .v-stamp { color: var(--ink2) } +.v-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 26px; align-items: center; margin-top: 10px } +.v-body h2 { font-size: 19px; line-height: 1.45; margin: 0 0 6px } .v-body h2 a { color: var(--ink); text-decoration: none } .v-body h2 a:hover { text-decoration: underline } +.v-body p, .v-msg { margin: 0; color: var(--ink2); font-size: 15px } +.v-glyph { background: var(--v-bg); border-radius: 14px; padding: 16px 16px 10px } +.v-glyph:empty { display: none } +.v-glyph .glyph svg { height: 46px } +.v-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hair); font-size: 14.5px; align-items: baseline } +.v-foot a { font-weight: 700; color: var(--ink); text-underline-offset: 3px } +.v-foot span { color: var(--muted); margin-left: auto } +.v-note { margin: 10px 0 0; font-size: 13px; color: var(--muted) } +@keyframes v-in { from { opacity: 0; transform: translateY(6px) } } +@media (prefers-reduced-motion: reduce) { .v-panel { animation: none } } +@media (max-width: 720px) { .v-body { grid-template-columns: 1fr } .v-panel { padding: 20px 18px 16px 26px } .v-foot span { margin-left: 0 } } + +.s-group { padding: 6px 0 22px } +.s-group h2 { font-size: 15px; font-weight: 700; color: var(--ink2); margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline } +.s-group h2 .n { font-size: 13px; color: var(--muted); font-weight: 400 } +.r-list { display: flex; flex-direction: column; gap: 8px } +.r-card { --v: var(--warn); display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; align-items: center; padding: 14px 18px 14px 20px; + background: var(--surface); border: 1px solid var(--hair); border-left: 4px solid var(--v); border-radius: 14px; text-decoration: none; color: inherit } +.r-card.v-go { --v: var(--go) } .r-card.v-stop { --v: var(--stop) } .r-card.v-info { --v: var(--accent) } +.r-card:hover { border-color: var(--ink2); border-left-color: var(--v) } +.r-main { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0 } +.r-main b { color: var(--ink); line-height: 1.45 } +.r-line { color: var(--ink2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden } +.r-who { color: var(--muted); font-size: 13px } +@media (max-width: 640px) { .r-card { grid-template-columns: 1fr } } +.s-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); column-gap: 28px; border-top: 1px solid var(--hair) } +.s-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--hair); text-decoration: none; color: inherit } +.s-row:hover b { color: var(--accent) } +.s-kind { font-size: 12px; color: var(--muted); text-align: center; background: var(--sunk); border-radius: 6px; padding: 2px 0 } +.t-issue .s-kind { background: var(--r-treat-bg); color: var(--r-treat) } .t-dataset .s-kind { background: var(--r-out-bg); color: var(--r-out) } +.t-lineage .s-kind { background: var(--go-bg); color: var(--go) } .t-project .s-kind { background: var(--warn-bg); color: var(--warn) } +.s-txt { min-width: 0; display: flex; flex-direction: column } +.s-txt b { font-size: 15px; line-height: 1.45; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap } +.s-txt span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap } +.s-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap } +.s-more summary { cursor: pointer; font-size: 14px; color: var(--ink2); padding: 10px 4px } +.s-empty { background: var(--surface); border: 1px dashed var(--hair); border-radius: 20px; padding: 26px } +.s-empty h2 { font-size: 20px; margin: 0 0 6px } +.s-idle p { color: var(--muted); font-size: 15px; margin: 0 } +.s-privacy { color: var(--muted); font-size: 13px; max-width: 74ch; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--hair) } .search-terms { display: flex; flex-wrap: wrap; gap: 6px } .search-terms .chip b { font-weight: 700; margin-left: 4px } -@media (max-width: 560px) { .sbox { flex-direction: column } }