Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ node_modules/
/badges/
__pycache__/
/sitemap.xml
# screenshots taken while checking the site belong outside the repo
/*.png
/library/
11 changes: 11 additions & 0 deletions assets/css/hub.css
Original file line number Diff line number Diff line change
Expand Up @@ -2913,3 +2913,14 @@ body.has-helper .site-footer { padding-bottom: calc(96px + env(safe-area-inset-b
.lt.on .lt-n { background: var(--l-main); border-color: var(--l-main); color: #fff; }
.lt[data-shelf="exp"].on .lt-n { background: var(--l-exp); border-color: var(--l-exp); }
.lt-started { font-weight: 700; color: var(--ink); }
/* library topics: videos and other materials as two groups; in the video group the kind column says nothing new */
.lib-group { display: flex; align-items: baseline; gap: 6px; margin: 16px 0 0; font-size: 13px; font-weight: 800; color: var(--ink); }
.lib-group span { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lib-group + .lib-items { margin-top: 6px; }
.lib-items.is-video .lib-item { grid-template-columns: minmax(0, 1fr); }
.lib-items.is-video .lib-kind { display: none; }
/* hero materials: videos first, then the rest, with a hairline between the two groups */
.starts li.docs-start { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, .14); border-radius: 0; }
.starts li.docs-start:hover { border-radius: 0 0 12px 12px; }
@media (min-width: 861px) { .starts a.sm { padding-top: 5px; padding-bottom: 5px; } }
@media (max-width: 860px) { .starts a.sm { padding-top: 6px; padding-bottom: 6px; } }
3 changes: 2 additions & 1 deletion assets/js/ga.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
(Until November 2026 the hub loaded the web book's tag, G-BEBVKYH8HL, which sent every page to both the
web book's property and the hub's first stream, G-C5V0X2SGD3. That stream now only keeps the history.) */
const ID = "G-CS9K0E86LR";
if (location.hostname === "causalinferencelab.github.io") {
/* counted on the live hub only: its github.io address and the pseudo-lab.com address it can move to */
if (["causalinferencelab.github.io", "causalinference.pseudo-lab.com"].includes(location.hostname)) {
const s = document.createElement("script");
s.async = true;
s.src = `https://www.googletagmanager.com/gtag/js?id=${ID}`;
Expand Down
16 changes: 14 additions & 2 deletions assets/js/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
const norm = (s) => String(s || "").toLowerCase().replace(/[\s·\-_/()?!.,~'"]/g, "");
const track = (n, p) => window.hubTrack && window.hubTrack(n, p);
const SITE = "https://causalinferencelab.github.io/";
const SITE = `${window.hubSite || "https://causalinferencelab.github.io"}/`;
const BOOK = SITE + "Causal-Inference-with-Python/";
const SAID = "cil-helper-said", QUIET = "cil-helper-quiet";
const reduced = () => matchMedia("(prefers-reduced-motion: reduce)").matches;
Expand Down Expand Up @@ -484,7 +484,19 @@
sayEl.querySelector(".hp-say-acts").innerHTML = line.acts.map(([label, q]) => `<button type="button" data-say-ask="${esc(q)}">${esc(label)}</button>`).join("");
});
clearTimeout(sayTimer);
sayTimer = setTimeout(() => { if (!sayEl.matches(":hover, :focus-within")) hush(false); }, 14000);
/* on a phone the bubble covers a third of the screen, so it stays briefly and steps aside once the reader
scrolls on; on a wider screen it sits beside the content and stays longer */
const phone = matchMedia("(max-width: 760px)").matches;
sayTimer = setTimeout(() => { if (!sayEl.matches(":hover, :focus-within")) hush(false); }, phone ? 8000 : 14000);
if (phone) {
const from = scrollY, since = Date.now();
const away = () => {
if (sayEl.hidden) { removeEventListener("scroll", away); return; }
if (Date.now() - since < 1500 || Math.abs(scrollY - from) < 160 || sayEl.matches(":focus-within")) return;
removeEventListener("scroll", away); hush(false);
};
addEventListener("scroll", away, { passive: true });
}
track("helper_say", { line: line.as || line.id, page });
}
function hush(forGood) {
Expand Down
14 changes: 9 additions & 5 deletions assets/js/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
const fmt = (n) => Number(n).toLocaleString("ko-KR");
/* the address printed on share cards: the live hub's host (track.js sets hubSite) */
const siteHost = () => { try { return new URL(window.hubSite).host; } catch (e) { return "causalinferencelab.github.io"; } };
const $ = (sel, root = document) => root.querySelector(sel);
const dot = (d) => esc(String(d ?? "").replace(/-/g, "."));
/* Data files come from pull requests: links must be http(s) or a site path, ids plain tokens,
Expand Down Expand Up @@ -647,7 +649,7 @@
<p class="fc-tier">${esc(lv.tier || lv.name)}</p>
${interest ? `<p class="fc-in"><span>관심</span>${esc(interest)}</p>` : ""}
<label class="fc-name"><span>이름이나 닉네임 (선택, 저장하지 않음)</span><input type="text" maxlength="16" autocomplete="nickname" placeholder="예: 진수"></label>
<p class="fc-foot">인과추론 Hub에서 3분 진단 · causalinferencelab.github.io</p>
<p class="fc-foot">인과추론 Hub에서 3분 진단 · ${esc(siteHost())}</p>
</div>
<p class="lt-sub">같은 레벨이나 같은 관심 분야인 사람과 이야기를 시작해 보세요. 화면을 켜 둔 채 보여 주면 됩니다.</p></div>
<div class="sh-foot"><button type="button" class="btn ghost" data-forum-back>결과로 돌아가기</button><button type="button" class="btn" data-goto-level="${lv.id}" data-test-go>${LV(lv.id)} 코스로 이동</button></div>`;
Expand Down Expand Up @@ -1113,12 +1115,14 @@
function renderStarts() {
const box = $("#starts");
if (!box) return;
box.innerHTML = (state.starts || []).map((f) => {
const list = state.starts || [], firstDoc = list.findIndex((f) => f.icon !== "youtube");
box.innerHTML = list.map((f, i) => {
const split = i > 0 && i === firstDoc;
const r = f.repo && state.repos.get(f.repo);
const ext = !/^https:\/\/causalinferencelab\.github\.io\//.test(f.url);
const ev = (target) => `data-event="start_click" data-event-params='${esc(JSON.stringify({ target, placement: "hero" }))}'`;
const star = r && r.stars ? `<a class="gh" href="https://github.com/CausalInferenceLab/${esc(r.repo)}" target="_blank" rel="noopener" aria-label="${esc(f.title)} GitHub 저장소, 별 ${fmt(r.stars)}개" ${ev(`${f.target}_github`)}>${icons.star}${fmt(r.stars)}</a>` : "";
return `<li><a class="sm" href="${esc(f.url)}"${ext ? ' target="_blank" rel="noopener"' : ""} ${ev(f.target)}>${START_ICON[f.icon] || ""}<span class="tx"><span class="t">${esc(f.title)}</span><span class="d">${esc(f.desc)}</span></span></a>${star}</li>`;
return `<li${split ? ' class="docs-start"' : ""}><a class="sm" href="${esc(f.url)}"${ext ? ' target="_blank" rel="noopener"' : ""} ${ev(f.target)}>${START_ICON[f.icon] || ""}<span class="tx"><span class="t">${esc(f.title)}</span><span class="d">${esc(f.desc)}</span></span></a>${star}</li>`;
}).join("");
}
/* the team's open-source projects in the hero: name, what kind of project, GitHub stars */
Expand Down Expand Up @@ -1626,7 +1630,7 @@
if (name) { c.fillStyle = "#fff"; c.font = font(700, 34); c.fillText(name, 80, H - 104); }
c.fillStyle = "rgba(255,255,255,.7)"; c.font = font(500, 24);
const d = new Date(), date = `${d.getFullYear()}.${pad2(d.getMonth() + 1)}.${pad2(d.getDate())}`;
c.fillText(`${date} · causalinferencelab.github.io`, 80, H - 60);
c.fillText(`${date} · ${siteHost()}`, 80, H - 60);
const mark = $(".banner-mark");
if (mark && mark.complete && mark.naturalWidth) c.drawImage(mark, W - 300, 70, 210, 210);
}
Expand Down Expand Up @@ -1670,7 +1674,7 @@
c.fillStyle = "#fff"; c.font = font(700, 24); c.fillText(m.name, x + 56, y + 9);
});
c.fillStyle = "rgba(255,255,255,.7)"; c.font = font(500, 22);
c.fillText(`causalinferencelab.github.io/builders/${info.slug || ""}`, 80, H - 56);
c.fillText(`${siteHost()}/builders/${info.slug || ""}`, 80, H - 56);
drawMedal(c, 930, 330, 150, t, p.cohorts.length);
}
async function openMedalCard(name) {
Expand Down
28 changes: 21 additions & 7 deletions assets/js/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
const norm = (s) => String(s || "").toLowerCase().replace(/[\s·\-_/()]/g, "");
const BOOK = "https://causalinferencelab.github.io/Causal-Inference-with-Python/";
const KIND_ORDER = ["video", "read", "code", "slides", "case", "post"];
const FIRST = 3;
const FIRST_EACH = 2;
/* a topic lists its videos together and its other materials (writing, code, slides) together */
const isVideo = (x) => x.kind === "video";
function groupsHTML(items, t) {
const vids = items.filter(isVideo), docs = items.filter((x) => !isVideo(x));
const pool = t.items.filter(itemOk);
const count = (list, all) => (st.q ? list.length : all);
const group = (name, cls, list, all) => (list.length ? `<p class="lib-group">${name}<span>${count(list, all)}</span></p><ol class="lib-items ${cls}">${list.map((x) => itemHTML(x, t)).join("")}</ol>` : "");
return group("영상", "is-video", vids, pool.filter(isVideo).length) + group("자료", "is-doc", docs, pool.filter((x) => !isVideo(x)).length);
}
/* the sources in the order a newcomer meets them, with what each one is */
const SOURCES = [
["causal-studio", "Causal Studio", "짧은 입문 영상과 노트북"],
Expand Down Expand Up @@ -145,8 +154,13 @@
items = st.open.has(t.id) && hit.length ? pool : hit;
}
}
/* three items per topic at first; the rest open on request, so a topic never reads as a wall of links */
if (!q && !st.open.has(t.id) && items.length > FIRST) { partial = true; items = items.slice(0, FIRST); }
/* two videos and two other materials per topic at first; the rest open on request, so a topic never
reads as a wall of links */
if (!q && !st.open.has(t.id)) {
const vids = items.filter(isVideo), docs = items.filter((x) => !isVideo(x));
const shown = [...vids.slice(0, FIRST_EACH), ...docs.slice(0, FIRST_EACH)];
if (shown.length < items.length) { partial = true; items = shown; }
}
return { t, items, partial, total: pool.length, n: q ? items.length : pool.length };
}).filter((v) => v.items.length);
}
Expand All @@ -166,7 +180,7 @@
function projectsHTML(list) {
if (!list.length) return "";
return `<section class="lib-pjs" aria-labelledby="lib-pjs-h"><h2 class="lib-pjs-h" id="lib-pjs-h">팀 프로젝트<span>저장소째 살펴보기</span></h2><ul>${list.map((r) => {
const url = r.site ? (/^https?:/.test(r.site) ? r.site : `https://causalinferencelab.github.io/${String(r.site).replace(/^\//, "")}`) : `https://github.com/CausalInferenceLab/${r.repo}`;
const url = r.site ? (/^https?:/.test(r.site) ? r.site : `${window.hubSite}/${String(r.site).replace(/^\//, "")}`) : `https://github.com/CausalInferenceLab/${r.repo}`;
const lv = /^L[0-4]$/.test(r.level || "") ? `<b class="lib-lv lv-${r.level}">${r.level} ${LV_NAME[r.level]}</b>` : "";
return `<li class="lib-pj" id="pj-${esc(r.repo)}" tabindex="-1"><a href="${esc(url)}" target="_blank" rel="noopener" data-event="library_click" data-event-params='${esc(JSON.stringify({ topic: "project", kind: "project", repo: r.repo, target: "project" }))}'>
<span class="lib-pj-t">${esc(r.title)}<span class="lib-out" aria-hidden="true"> ↗</span></span><span class="lib-pj-s">${esc(r.summary || "")}</span><span class="lib-src">${lv}${r.site ? "사이트" : "GitHub"} · ${esc(r.repo)}</span></a></li>`;
Expand Down Expand Up @@ -218,10 +232,10 @@
const terms = termsFor(t).slice(0, 3);
return `${head}<article class="lib-topic s-${esc(t.shelf)}" id="${esc(t.id)}" tabindex="-1" aria-labelledby="t-${esc(t.id)}">
<header><h3 id="t-${esc(t.id)}">${esc(t.name)}</h3><span class="lib-en" lang="en">${esc(t.en)}</span>
<button type="button" class="lib-link" data-copy="${esc(`https://causalinferencelab.github.io/library.html#${t.id}`)}" data-share="library_topic" aria-label="${esc(t.name)} 링크 복사">링크 복사</button></header>
<button type="button" class="lib-link" data-copy="${esc(`${window.hubSite}/library.html#${t.id}`)}" data-share="library_topic" aria-label="${esc(t.name)} 링크 복사">링크 복사</button></header>
<p class="lib-about">${esc(t.about)}</p>
${terms.length ? `<p class="lib-terms"><span>먼저 알아 둘 용어</span>${terms.map((x) => `<a href="#${esc(x.id)}" data-term="${esc(x.id)}">${esc(x.ko)}</a>`).join("")}</p>` : ""}
<ol class="lib-items">${v.items.map((x) => itemHTML(x, t)).join("")}</ol>
${groupsHTML(v.items, t)}
${v.partial ? `<button type="button" class="lib-all" data-lib-open="${esc(t.id)}">${v.total - v.items.length}개 더 보기</button>` : ""}
</article>`;
}).join("");
Expand Down Expand Up @@ -280,7 +294,7 @@
<section class="gl-col"><h4>팀 자료에서</h4>${team ? `<ul class="gl-team">${team}</ul>` : '<p class="gl-none">이 용어를 주로 다룬 팀 자료를 아직 찾지 못했습니다.</p>'}</section>
</div>
<p class="gl-acts">${tp ? `<span class="gl-tps"><span>자료실 주제</span>${tp}</span>` : ""}
<span class="gl-btns"><button type="button" class="lib-link" data-copy="${esc(`https://causalinferencelab.github.io/library.html#${x.id}`)}" data-share="library_term" aria-label="${esc(x.ko)} 링크 복사">링크 복사</button>
<span class="gl-btns"><button type="button" class="lib-link" data-copy="${esc(`${window.hubSite}/library.html#${x.id}`)}" data-share="library_term" aria-label="${esc(x.ko)} 링크 복사">링크 복사</button>
<button type="button" class="lib-link" data-helper-ask="${esc(x.ko)} 알려 주세요">Pseudo에게 묻기</button>
<a class="lib-link" href="${BOOK}glossary.html#${encodeURIComponent(x.id)}">웹북 용어집</a></span></p>
</div>`;
Expand Down
6 changes: 5 additions & 1 deletion assets/js/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
dictionary in the PM doc; keep them in snake_case and the params flat. */
(() => {
"use strict";
const SITE = "https://causalinferencelab.github.io";
/* the hub's own address for links people copy and share: wherever the live hub is served (github.io, or
the pseudo-lab.com address it can move to); a local preview shares links to the live hub */
const LIVE = ["causalinferencelab.github.io", "causalinference.pseudo-lab.com"];
const SITE = LIVE.includes(location.hostname) ? location.origin : "https://causalinferencelab.github.io";
window.hubSite = SITE;
window.hubTrack = (name, params = {}) => {
try {
if (typeof window.gtag === "function") window.gtag("event", name, params);
Expand Down
22 changes: 15 additions & 7 deletions data/starts.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"url": "https://www.youtube.com/@CausalStudio",
"target": "youtube"
},
{
"icon": "youtube",
"title": "인과추론 실무 영상",
"desc": "인과추론의 데이터과학 채널 · 실무자 특강 17강",
"url": "https://www.youtube.com/@causaldatascience",
"target": "youtube_causaldatascience"
},
{
"icon": "team",
"title": "인과추론 웹북 25장",
Expand All @@ -22,19 +29,20 @@
"repo": "awesome-causal-inference-python",
"target": "awesome"
},
{
"icon": "youtube",
"title": "인과추론 실무 영상",
"desc": "인과추론의 데이터과학 채널 · 실무자 특강 17강",
"url": "https://www.youtube.com/@causaldatascience",
"target": "youtube_causaldatascience"
},
{
"icon": "team",
"title": "온라인 통제 실험 강의 자료",
"desc": "OCE 스터디 · A/B 테스트 16회 발표",
"url": "https://github.com/CausalInferenceLab/OCE-Materials",
"repo": "OCE-Materials",
"target": "oce"
},
{
"icon": "team",
"title": "마케팅 사이언스",
"desc": "마케팅 인과추론 · MMM·CLV 발표 자료",
"url": "https://github.com/CausalInferenceLab/Marketing_Science",
"repo": "Marketing_Science",
"target": "marketing_science"
}
]
Binary file removed hero_1024.png
Binary file not shown.
Binary file removed hero_1440.png
Binary file not shown.
Binary file removed hero_390.png
Binary file not shown.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1 id="hero-title">Causal Inference Hub</h1>
<a class="lv-card" href="?level" data-test-open="hero" data-event="start_click" data-event-params='{"target":"level_test","placement":"hero"}'>
<span class="lv-card-k">처음이라면 여기서 시작</span>
<span class="lv-card-t">내 레벨 진단하기</span>
<span class="lv-card-s">실무 문제 10개, 3분이면 시작할 Level과 첫 자료를 알려 드립니다.</span>
<span class="lv-card-s">실무 문제 10개, 3분이면 시작할 Level을 알려 드립니다.</span>
<span class="lv-card-go">진단 시작<svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="M7 4l6 6-6 6" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg></span>
</a>
<div class="banner-side">
Expand Down
Binary file removed library/h_chat_1440.png
Binary file not shown.
Binary file removed library/h_chat_390.png
Binary file not shown.
Binary file removed library/h_closed_1440.png
Binary file not shown.
Binary file removed library/h_closed_390.png
Binary file not shown.
Binary file removed library/h_open_1440.png
Binary file not shown.
Binary file removed library/h_open_390.png
Binary file not shown.
Binary file removed loose.png
Binary file not shown.
Binary file removed proj.png
Binary file not shown.