devcoach 2.8.0-next.712.gda0b1a4 → 2.8.0-next.713.g726e9ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-YX6LSJM2.js → app-VHU3W3NF.js} +104 -104
- package/dist/bin.js +1 -1
- package/dist/chunk-2F7M7IRR.js +2 -0
- package/dist/{chunk-DYT5EZOC.js → chunk-3HWAJCII.js} +1 -1
- package/dist/{chunk-K3BUZMZU.js → chunk-ISRR2ZQ7.js} +1 -1
- package/dist/{chunk-RGZ6DF6G.js → chunk-KKT36WIU.js} +1 -1
- package/dist/{chunk-SDIK7HUX.js → chunk-TDXOMDX2.js} +1 -1
- package/dist/{chunk-ENZJ5CJ3.js → chunk-XQ73NT5F.js} +1 -1
- package/dist/{commands-DGTJLMG3.js → commands-OQWVVY5I.js} +2 -2
- package/dist/{hooks-5X2QMD4I.js → hooks-7MSQTLRP.js} +1 -1
- package/dist/{server-FILCKV5R.js → server-DAVYE5JX.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-ILDBPNYJ.js +0 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a as a$3,e as e$1}from'./chunk-
|
|
2
|
+
import {a as a$3,e as e$1}from'./chunk-KKT36WIU.js';import {p,q,h as h$1,m,a as a$1,e,g,j as j$1,l,n}from'./chunk-ISRR2ZQ7.js';import {z as z$1,E,A,y,G,X as X$1,Ea,Ia,Fa,R as R$1,V as V$1,S,W as W$1,Ga,T,U as U$1,L,Ja,ra,va,N,M,P,H,K as K$1,Ha,J as J$1,O,Y as Y$1,w,Aa,za,b as b$1,c,a as a$2,oa,qa,r,ta,sa,ua,xa,wa}from'./chunk-TDXOMDX2.js';import {a}from'./chunk-2F7M7IRR.js';import {existsSync,readFileSync,mkdirSync,writeFileSync}from'fs';import {dirname,join,extname}from'path';import {fileURLToPath}from'url';import {serve}from'@hono/node-server';import {Hono}from'hono';import {html,raw}from'hono/html';function j(t){return JSON.stringify(t??"").replace(/[<>&\u2028\u2029]/g,e=>String.raw`\u`+(e.codePointAt(0)??0).toString(16).padStart(4,"0"))}function Ve(t,e){return t+e.replace(/[^A-Za-z0-9_-]/g,g=>`_${(g.codePointAt(0)??0).toString(16)}`)}var lt=html`<svg class="w-4 h-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><circle cx="4" cy="10" r="1.75"/><circle cx="10" cy="10" r="1.75"/><circle cx="16" cy="10" r="1.75"/></svg>`;function K(t,e="",g=""){return html`<div class="relative ${e}" ${raw(g)} x-data="{ open: false }" @click.outside="open = false" @keydown.escape="open = false">
|
|
3
3
|
<button type="button" @click="open = !open" :aria-expanded="open" aria-label="More actions" title="More actions" class="w-8 h-8 inline-flex items-center justify-center rounded-lg border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:border-accent-400 hover:text-gray-800 dark:hover:text-gray-100">${lt}</button>
|
|
4
4
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute right-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-56 p-1" style="display:none">
|
|
5
|
-
${
|
|
5
|
+
${t}
|
|
6
6
|
</div>
|
|
7
|
-
</div>`}function
|
|
7
|
+
</div>`}function Y(t,e,g,d,r){return html`<div x-show="${t}" style="display:none" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" class="fixed inset-0 z-[80] flex items-center justify-center px-4">
|
|
8
8
|
<div class="absolute inset-0 bg-gray-900/50 dark:bg-black/60" @click="${e}"></div>
|
|
9
9
|
<div role="alertdialog" aria-modal="true" class="relative w-full max-w-md bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-xl p-5">
|
|
10
10
|
<div class="flex items-start gap-3">
|
|
@@ -14,16 +14,16 @@ import {a as a$3,e as e$1}from'./chunk-RGZ6DF6G.js';import {p,q,h as h$1,m,a as
|
|
|
14
14
|
<div class="mt-1 text-sm text-gray-500 dark:text-gray-400 space-y-2">${d}</div>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
<div class="mt-5 flex justify-end gap-2">${
|
|
17
|
+
<div class="mt-5 flex justify-end gap-2">${r}</div>
|
|
18
18
|
</div>
|
|
19
|
-
</div>`}function
|
|
19
|
+
</div>`}function R(t){let e=(g,d,r)=>html`<a href="${g}" class="text-gray-500 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition ${r?"text-gray-900 dark:text-white font-semibold":""}">${d}</a>`;return html`<!DOCTYPE html>
|
|
20
20
|
<html lang="en">
|
|
21
21
|
<head>
|
|
22
22
|
<meta charset="UTF-8" />
|
|
23
23
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
24
|
-
<title>${
|
|
24
|
+
<title>${t.title}</title>
|
|
25
25
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg" />
|
|
26
|
-
<meta name="devcoach-theme" content="${
|
|
26
|
+
<meta name="devcoach-theme" content="${t.uiTheme}" />
|
|
27
27
|
<script>
|
|
28
28
|
// Before first paint: the nav toggle's choice (this browser) wins over the saved setting;
|
|
29
29
|
// "system" follows the OS. Saving Settings clears the toggle's choice.
|
|
@@ -54,7 +54,7 @@ import {a as a$3,e as e$1}from'./chunk-RGZ6DF6G.js';import {p,q,h as h$1,m,a as
|
|
|
54
54
|
<script src="/static/vendor/htmx.min.js"></script>
|
|
55
55
|
<script src="/static/vendor/alpinejs.min.js" defer></script>
|
|
56
56
|
<link rel="stylesheet" href="/static/style.css" />
|
|
57
|
-
${
|
|
57
|
+
${t.head??""}
|
|
58
58
|
<script>
|
|
59
59
|
// Pages with code blocks ship the dark highlighter stylesheet: point it at the light one
|
|
60
60
|
// before first paint when the page is light.
|
|
@@ -82,18 +82,18 @@ import {a as a$3,e as e$1}from'./chunk-RGZ6DF6G.js';import {p,q,h as h$1,m,a as
|
|
|
82
82
|
<a href="/" class="font-extrabold text-lg tracking-tight text-gray-900 dark:text-gray-100 hover:opacity-80 transition"
|
|
83
83
|
>🎓 dev<span class="text-teal-600 dark:text-teal-300">coach</span></a
|
|
84
84
|
>
|
|
85
|
-
${e("/knowledge","Profile",
|
|
86
|
-
${e("/lessons","Lessons",
|
|
87
|
-
${e("/courses","Courses",
|
|
85
|
+
${e("/knowledge","Profile",t.currentPath==="/knowledge")}
|
|
86
|
+
${e("/lessons","Lessons",t.currentPath.includes("/lessons"))}
|
|
87
|
+
${e("/courses","Courses",t.currentPath.includes("/courses"))}
|
|
88
88
|
<div class="ml-auto flex items-center gap-1.5">
|
|
89
|
-
<a href="/settings" title="Settings" ${
|
|
89
|
+
<a href="/settings" title="Settings" ${t.currentPath==="/settings"?raw('aria-current="page"'):""} class="h-8 px-2.5 inline-flex items-center gap-1.5 rounded-lg border text-sm font-medium transition ${t.currentPath==="/settings"?"bg-white dark:bg-gray-900 border-accent-400 text-gray-900 dark:text-white":"bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:border-accent-400 hover:text-gray-800 dark:hover:text-gray-100"}"><svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z"/><path d="M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1.03 1.56V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1.11-1.56 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.7 1.7 0 0 0 4.6 15a1.7 1.7 0 0 0-1.56-1.03H3a2 2 0 1 1 0-4h.09A1.7 1.7 0 0 0 4.65 8.9a1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.7 1.7 0 0 0 9 4.6h.09A1.7 1.7 0 0 0 10.1 3.1V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1.03 1.56 1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.7 1.7 0 0 0 19.4 9v.09a1.7 1.7 0 0 0 1.56 1.03H21a2 2 0 1 1 0 4h-.09A1.7 1.7 0 0 0 19.4 15Z"/></svg><span>Settings</span></a>
|
|
90
90
|
<!-- Shows the CURRENT scheme (both glyphs ship, the .dark class picks one: right from the
|
|
91
91
|
first paint, no script needed); the label says what a click does. -->
|
|
92
92
|
<button id="theme-toggle" onclick="toggleTheme()" title="Switch theme" aria-label="Switch theme"
|
|
93
93
|
class="w-8 h-8 inline-flex items-center justify-center rounded-lg border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:border-accent-400 text-base leading-none"><span class="dark:hidden" aria-hidden="true">☀️</span><span class="hidden dark:inline" aria-hidden="true">🌙</span></button>
|
|
94
94
|
</div>
|
|
95
95
|
</nav>
|
|
96
|
-
<main class="${
|
|
96
|
+
<main class="${t.wide?"max-w-none":"max-w-7xl"} mx-auto px-4 sm:px-6 py-8">${t.body}</main>
|
|
97
97
|
<script>
|
|
98
98
|
function isDark() { return document.documentElement.classList.contains('dark'); }
|
|
99
99
|
function updateHljsTheme() {
|
|
@@ -128,9 +128,9 @@ import {a as a$3,e as e$1}from'./chunk-RGZ6DF6G.js';import {p,q,h as h$1,m,a as
|
|
|
128
128
|
applyTheme(isDark());
|
|
129
129
|
})();
|
|
130
130
|
</script>
|
|
131
|
-
${
|
|
131
|
+
${t.scripts??""}
|
|
132
132
|
</body>
|
|
133
|
-
</html>`}function
|
|
133
|
+
</html>`}function We(t){let e=d=>t.allGroups.filter(r=>r!=="Other").map(r=>html`<option value="${r}" ${r===d?"selected":""}>${r}</option>`),g=html`
|
|
134
134
|
<div id="knowledge-map" x-data="{ editMode: JSON.parse(localStorage.getItem('km-edit-mode') || 'false'), toggle() { this.editMode = !this.editMode; localStorage.setItem('km-edit-mode', this.editMode); } }">
|
|
135
135
|
|
|
136
136
|
<div class="flex items-center justify-between mb-6">
|
|
@@ -180,16 +180,16 @@ import {a as a$3,e as e$1}from'./chunk-RGZ6DF6G.js';import {p,q,h as h$1,m,a as
|
|
|
180
180
|
</div>
|
|
181
181
|
|
|
182
182
|
<div class="mb-6 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-gray-500 dark:text-gray-400">
|
|
183
|
-
<span><span class="font-semibold text-gray-800 dark:text-gray-100">${Number(
|
|
183
|
+
<span><span class="font-semibold text-gray-800 dark:text-gray-100">${Number(t.stats.total_lessons??0)}</span> lessons total</span>
|
|
184
184
|
<span class="text-gray-300 dark:text-gray-600">·</span>
|
|
185
|
-
<span><span class="font-semibold text-gray-800 dark:text-gray-100">${Number(
|
|
185
|
+
<span><span class="font-semibold text-gray-800 dark:text-gray-100">${Number(t.stats.lessons_today??0)}</span> / ${t.maxPerDay} today</span>
|
|
186
186
|
<span class="text-gray-300 dark:text-gray-600">·</span>
|
|
187
|
-
<span><span class="font-semibold text-gray-800 dark:text-gray-100">${Number(
|
|
187
|
+
<span><span class="font-semibold text-gray-800 dark:text-gray-100">${Number(t.stats.lessons_this_week??0)}</span> this week</span>
|
|
188
188
|
<span class="text-gray-300 dark:text-gray-600">·</span>
|
|
189
|
-
${
|
|
189
|
+
${t.rateLimit.allowed?html`<span class="text-green-600 dark:text-green-400 font-medium">Available now</span>`:html`<span class="text-yellow-600 dark:text-yellow-400">${t.rateLimit.reason}</span>`}
|
|
190
190
|
</div>
|
|
191
191
|
|
|
192
|
-
${Object.entries(
|
|
192
|
+
${Object.entries(t.categorised).map(([d,r])=>html`
|
|
193
193
|
<section class="mb-6 group/section">
|
|
194
194
|
<div class="flex items-center gap-2 mb-2 border-b border-gray-200 dark:border-gray-800 pb-1">
|
|
195
195
|
<div class="flex items-center gap-1 flex-1 min-w-0">
|
|
@@ -214,7 +214,7 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
214
214
|
</div>
|
|
215
215
|
</div>
|
|
216
216
|
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-x-8 gap-y-0">
|
|
217
|
-
${
|
|
217
|
+
${r.map(a=>{let n=Ve("topic-row-",a.topic),i=a.confidence,s=Math.trunc(i/10*100),c=i>=7?"bg-green-500":i>=4?"bg-yellow-500":"bg-red-500",u=i>=7?"text-green-600 dark:text-green-400":i>=4?"text-yellow-600 dark:text-yellow-400":"text-red-600 dark:text-red-400";return html`
|
|
218
218
|
<div id="${n}" class="flex items-center gap-2 py-1.5 border-b border-gray-100 dark:border-gray-800/50 group/row">
|
|
219
219
|
<div x-show="editMode" style="display:none" x-data="{ open: false }" class="relative shrink-0 flex items-center">
|
|
220
220
|
<button type="button" @click="open = !open" class="text-xs text-gray-200 dark:text-gray-700 hover:text-accent-500 dark:hover:text-accent-400 transition w-4 text-center opacity-0 group-hover/row:opacity-100" title="Move to group">⇄</button>
|
|
@@ -249,9 +249,9 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
249
249
|
</div>`})}
|
|
250
250
|
</div>
|
|
251
251
|
</section>`)}
|
|
252
|
-
</div>`;return
|
|
252
|
+
</div>`;return R({title:"Profile \u2014 devcoach",currentPath:"/knowledge",uiTheme:t.uiTheme,body:g})}var ze={all:"All time",today:"Today",week:"Last 7 days",month:"Last 30 days",year:"Last year"},Ke={know:"\u2713 Knew it",understood:"\u{1F4A1} Understood",dont_know:"\u2717 Couldn't follow",none:"\u2014 No response"},Ye={junior:"\u{1F7E2}",mid:"\u{1F7E1}",senior:"\u{1F534}"};function h(t,e={}){let g={period:t.period,category:t.category,level:t.level,project:t.project,repository:t.repository,branch:t.branch,commit:t.commit,feedback:t.feedback,imported:t.imported,shared_by:t.shared_by,search:t.search,date_from:t.date_from,date_to:t.date_to,sort:t.sort,order:t.order};t.starred&&(g.starred="1"),Object.assign(g,e);let d=new URLSearchParams;for(let[r,a]of Object.entries(g))a&&d.set(r,a);return `?${d.toString()}`}function Ze(t){let e=t.s,g=!!(e.date_from||e.date_to),d=e.period!=="all"&&!g||g||!!(e.category||e.level||e.project||e.repository||e.branch||e.commit||e.starred||e.imported||e.shared_by||e.search||e.feedback),r=g?e.date_from&&e.date_to?`${e.date_from} \u2192 ${e.date_to}`:e.date_from?`From ${e.date_from}`:`Until ${e.date_to}`:ze[e.period]??"All time",a=e.feedback?Ke[e.feedback]??"Feedback":"Feedback",n=e.shared_by?`\u{1F91D} from ${e.shared_by}`:e.imported==="1"?"\u{1F91D} Shared with me":e.imported==="0"?"\u{1F464} My own":"\u{1F91D} Shared",i=[["","","All lessons"],["0","","\u{1F464} My own"],["1","","\u{1F91D} Shared with me"],...t.allSharedBy.map(l=>["1",l,`\u{1F91D} from ${l}`])],s={junior:"text-teal-600 dark:text-teal-400 bg-teal-50 dark:bg-teal-900/20",mid:"text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20",senior:"text-rose-600 dark:text-rose-400 bg-rose-50 dark:bg-rose-900/20"},c=(l,x)=>html`<span class="inline-flex items-center gap-1 pl-2.5 pr-1 py-0.5 rounded-full text-xs bg-accent-50 dark:bg-accent-900/20 text-accent-700 dark:text-accent-300 border border-accent-200 dark:border-accent-800">${l}<a href="${x}" class="ml-0.5 w-4 h-4 flex items-center justify-center rounded-full hover:bg-accent-200 dark:hover:bg-accent-700 transition">×</a></span>`,u=(l,x,$="")=>{let _=e.sort===x,k=_&&e.order==="desc"?"asc":"desc";return html`<th class="px-3 py-3 whitespace-nowrap relative overflow-hidden text-ellipsis ${$}">
|
|
253
253
|
<a href="${h(e,{sort:x,order:k})}" class="hover:text-gray-700 dark:hover:text-gray-200 transition group/sort">${l}
|
|
254
|
-
${
|
|
254
|
+
${_?html`<span class="text-accent-400">${e.order==="asc"?"\u2191":"\u2193"}</span>`:html`<span class="text-gray-200 dark:text-gray-700 group-hover/sort:text-gray-400 dark:group-hover/sort:text-gray-500 transition">↕</span>`}
|
|
255
255
|
</a></th>`},p=html`<svg class="w-3 h-3 opacity-60" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"/></svg>`,m=html`<link rel="stylesheet" href="/static/vendor/flatpickr.min.css" />
|
|
256
256
|
<style>
|
|
257
257
|
.dark .flatpickr-calendar { background:rgb(var(--dc-gray-900)); border-color:rgb(var(--dc-gray-700)); }
|
|
@@ -263,7 +263,7 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
263
263
|
.dark .flatpickr-current-month, .dark .flatpickr-monthDropdown-months { color:rgb(var(--dc-gray-200)); background:rgb(var(--dc-gray-900)); }
|
|
264
264
|
.dark .flatpickr-weekday { color:rgb(var(--dc-gray-400)); background:rgb(var(--dc-gray-900)); }
|
|
265
265
|
.dark .flatpickr-prev-month svg, .dark .flatpickr-next-month svg { fill:rgb(var(--dc-gray-400)); }
|
|
266
|
-
</style>`,v=
|
|
266
|
+
</style>`,v=t.total===0?"No lessons":t.totalPages===1?`${t.total} lesson${t.total!==1?"s":""}`:`${(t.page-1)*t.perPage+1}\u2013${Math.min(t.page*t.perPage,t.total)} of ${t.total}`,T=JSON.stringify(t.lessons.map(l=>l.id)),P=html`
|
|
267
267
|
<div :class="selectMode && 'dc-selecting'" x-data="{ selectMode: false, selected: [], confirmOpen: false, shareOpen: false, sharePos: { left: 0, top: null, bottom: null }, openShare(btn) { const r = btn.getBoundingClientRect(); const w = 320; const left = Math.max(8, Math.min(r.right - w, innerWidth - w - 8)); const below = innerHeight - r.bottom > 380; this.sharePos = { left, top: below ? r.bottom + 6 : null, bottom: below ? null : innerHeight - r.top + 6 }; this.shareOpen = true }, toggle(id) { const i = this.selected.indexOf(id); if (i < 0) this.selected.push(id); else this.selected.splice(i, 1) }, setAll(ids, on) { this.selected = on ? ids.slice() : [] }, selectedTitles() { const rows = Array.from(document.querySelectorAll('tr[data-id]')); return this.selected.map((id) => { const r = rows.find((x) => x.dataset.id === id); return r ? r.dataset.title : id }) }, leave() { this.selectMode = false; this.selected = []; this.shareOpen = false; this.confirmOpen = false } }" @keydown.escape.window="leave()">
|
|
268
268
|
<form id="filter-form" method="get" action="/lessons">
|
|
269
269
|
<input type="hidden" name="period" id="h-period" value="${e.period}">
|
|
@@ -296,17 +296,17 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
296
296
|
<div class="relative" x-data="{ open: false }" @click.outside="open = false" @keydown.escape="open = false">
|
|
297
297
|
<button type="button" @click="open = !open" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition ${e.imported||e.shared_by?"bg-accent-600 text-white border-accent-600":"bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400"}">${n}${p}</button>
|
|
298
298
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute left-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-52 p-1 overflow-hidden" style="display:none">
|
|
299
|
-
${i.map(([l,x,$])=>{let
|
|
299
|
+
${i.map(([l,x,$])=>{let _=e.imported===l&&e.shared_by===x;return html`<button type="button" data-imported="${l}" data-shared-by="${x}" onclick="var d=this.dataset; document.getElementById('h-imported').value=d.imported; document.getElementById('h-shared-by').value=d.sharedBy; document.getElementById('filter-form').submit()" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center justify-between ${_?"bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 font-medium":"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"}"><span class="truncate">${$}</span>${_?html`<span class="text-accent-500 ml-auto">✓</span>`:""}</button>`})}
|
|
300
300
|
</div>
|
|
301
301
|
</div>
|
|
302
302
|
|
|
303
303
|
<div class="relative" x-data="periodPicker()" @keydown.escape="close()">
|
|
304
304
|
<button type="button" @click="toggle()" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition ${g||e.period!=="all"?"bg-accent-600 text-white border-accent-600":"bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400"}">
|
|
305
|
-
<span>📅</span><span x-text="label">${
|
|
305
|
+
<span>📅</span><span x-text="label">${r}</span>${p}
|
|
306
306
|
</button>
|
|
307
307
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-95" @click.outside="close()" class="absolute left-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-64 overflow-hidden" style="display:none">
|
|
308
308
|
<div class="p-1">
|
|
309
|
-
${Object.entries(
|
|
309
|
+
${Object.entries(ze).map(([l,x])=>{let $=e.period===l&&!g;return html`<button type="button" @click="selectPreset('${l}', '${x}')" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center justify-between ${$?"bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 font-medium":"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"}">${x}${$?html`<span class="text-accent-500">✓</span>`:""}</button>`})}
|
|
310
310
|
</div>
|
|
311
311
|
<div class="border-t border-gray-100 dark:border-gray-800 p-1">
|
|
312
312
|
<button type="button" @click="showCustom = !showCustom" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center justify-between ${g?"bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 font-medium":"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"}">
|
|
@@ -328,34 +328,34 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
328
328
|
</div>
|
|
329
329
|
|
|
330
330
|
<div class="relative" x-data="{ open: false }" @click.outside="open = false" @keydown.escape="open = false">
|
|
331
|
-
<button type="button" @click="open = !open" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition ${e.level?"bg-accent-600 text-white border-accent-600":"bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400"}">${e.level?`${
|
|
331
|
+
<button type="button" @click="open = !open" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition ${e.level?"bg-accent-600 text-white border-accent-600":"bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400"}">${e.level?`${Ye[e.level]??""} ${e.level}`:"Level"}${p}</button>
|
|
332
332
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute left-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-40 p-1 overflow-hidden" style="display:none">
|
|
333
333
|
${[["","All levels"],["junior","\u{1F7E2} Junior"],["mid","\u{1F7E1} Mid"],["senior","\u{1F534} Senior"]].map(([l,x])=>html`<button type="button" onclick="document.getElementById('h-level').value='${l}'; document.getElementById('filter-form').submit()" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center justify-between ${e.level===l?"bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 font-medium":"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"}">${x}${e.level===l?html`<span class="text-accent-500 ml-auto">✓</span>`:""}</button>`)}
|
|
334
334
|
</div>
|
|
335
335
|
</div>
|
|
336
336
|
|
|
337
|
-
${
|
|
337
|
+
${t.allCategories.length||t.allProjects.length||t.allRepositories.length||t.allBranches.length||t.allCommits.length?html`<div class="relative" x-data="{ open: false }" @click.outside="open = false" @keydown.escape="open = false">
|
|
338
338
|
<button type="button" @click="open = !open" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition ${e.category||e.project||e.repository||e.branch||e.commit?"bg-accent-600 text-white border-accent-600":"bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400"}">Filters${p}</button>
|
|
339
339
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute left-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-64 p-3 space-y-2.5" style="display:none">
|
|
340
|
-
${
|
|
341
|
-
${
|
|
342
|
-
${
|
|
343
|
-
${
|
|
344
|
-
${
|
|
340
|
+
${t.allCategories.length?html`<div><label class="block text-xs text-gray-400 dark:text-gray-500 mb-1">Category</label><select name="category" onchange="this.form.submit()" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-accent-500"><option value="">All categories</option>${t.allCategories.map(l=>html`<option value="${l}" ${e.category===l?"selected":""}>${l}</option>`)}</select></div>`:""}
|
|
341
|
+
${t.allProjects.length?html`<div><label class="block text-xs text-gray-400 dark:text-gray-500 mb-1">Project</label><select name="project" onchange="this.form.submit()" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-accent-500"><option value="">All projects</option>${t.allProjects.map(l=>html`<option value="${l}" ${e.project===l?"selected":""}>${l}</option>`)}</select></div>`:""}
|
|
342
|
+
${t.allRepositories.length?html`<div><label class="block text-xs text-gray-400 dark:text-gray-500 mb-1">Repository</label><select name="repository" onchange="this.form.submit()" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-accent-500"><option value="">All repositories</option>${t.allRepositories.map(l=>html`<option value="${l}" ${e.repository===l?"selected":""}>${l}</option>`)}</select></div>`:""}
|
|
343
|
+
${t.allBranches.length?html`<div><label class="block text-xs text-gray-400 dark:text-gray-500 mb-1">Branch</label><input type="text" name="branch" value="${e.branch}" placeholder="e.g. main" list="branch-list" autocomplete="off" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-accent-500" /><datalist id="branch-list">${t.allBranches.map(l=>html`<option value="${l}">`)}</datalist></div>`:""}
|
|
344
|
+
${t.allCommits.length?html`<div><label class="block text-xs text-gray-400 dark:text-gray-500 mb-1">Commit</label><input type="text" name="commit" value="${e.commit}" placeholder="hash prefix…" list="commit-list" autocomplete="off" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-accent-500" /><datalist id="commit-list">${t.allCommits.map(l=>html`<option value="${l.slice(0,7)}">`)}</datalist></div>`:""}
|
|
345
345
|
<button type="submit" class="w-full bg-accent-600 hover:bg-accent-500 text-white rounded-lg px-3 py-1.5 text-xs font-medium transition">Apply</button>
|
|
346
346
|
</div>
|
|
347
347
|
</div>`:""}
|
|
348
348
|
|
|
349
349
|
${d?html`<a href="/lessons" class="ml-auto text-xs text-gray-400 hover:text-gray-700 dark:hover:text-white transition">Clear all</a>`:""}
|
|
350
350
|
|
|
351
|
-
${
|
|
351
|
+
${K(html`<button type="button" @click="selectMode = true; open = false" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center gap-2 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"><span class="w-4 h-4 inline-flex items-center justify-center shrink-0 text-[13px] leading-none" aria-hidden="true">🗑</span>Delete lessons…</button>
|
|
352
352
|
<button type="button" @click="window.resetLessonColumns && window.resetLessonColumns(); open = false" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center gap-2 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"><svg class="w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><rect x="2.5" y="4" width="15" height="12" rx="2"/><path d="M7.5 4v12M12.5 4v12"/></svg>Reset column widths</button>`,d?"":"ml-auto",'x-show="!selectMode"')}
|
|
353
353
|
<button type="button" x-show="selectMode" style="display:none" @click="leave()" class="${d?"":"ml-auto"} inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-rose-400 hover:text-rose-600 dark:hover:text-rose-400">✕ Cancel</button>
|
|
354
|
-
<div class="relative" x-data="{ open: ${String(
|
|
354
|
+
<div class="relative" x-data="{ open: ${String(t.importOpen)} }" @click.outside="open = false" @keydown.escape="open = false">
|
|
355
355
|
<button type="button" @click="open = !open" title="Import a lesson someone shared" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400">+ Import</button>
|
|
356
356
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute right-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-80 p-3 space-y-2.5" style="display:none">
|
|
357
357
|
<p class="text-xs text-gray-500 dark:text-gray-400">Paste the lesson code, the link, a URL or the whole text — or drop a <code>.devcoach.md</code> anywhere on this page.</p>
|
|
358
|
-
${
|
|
358
|
+
${t.importError==="invalid"?html`<p class="text-xs text-rose-600 dark:text-rose-400">That doesn't look like a devcoach lesson — copy the whole text again.</p>`:""}
|
|
359
359
|
<textarea name="text" form="import-form" rows="4" placeholder="devcoach:lesson:1:…" autocomplete="off" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-accent-500 font-mono" x-ref="importText" x-effect="if (open) $nextTick(() => $refs.importText.focus())"></textarea>
|
|
360
360
|
<div class="flex items-center gap-2">
|
|
361
361
|
<label class="cursor-pointer text-xs text-gray-500 dark:text-gray-400 hover:text-accent-600 dark:hover:text-accent-400 transition">📄 Choose file<input id="import-file" type="file" name="file" form="import-form" accept=".md,.json,.txt" class="hidden" onchange="document.getElementById('import-form').submit()" /></label>
|
|
@@ -366,14 +366,14 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
366
366
|
</div>
|
|
367
367
|
|
|
368
368
|
${d?html`<div class="flex flex-wrap gap-1.5 mb-4">
|
|
369
|
-
${g?c(`\u{1F4C5} ${
|
|
370
|
-
${e.period!=="all"&&!g?c(`\u{1F550} ${
|
|
371
|
-
${e.feedback?c(
|
|
369
|
+
${g?c(`\u{1F4C5} ${r}`,h(e,{date_from:"",date_to:""})):""}
|
|
370
|
+
${e.period!=="all"&&!g?c(`\u{1F550} ${r}`,h(e,{period:"all"})):""}
|
|
371
|
+
${e.feedback?c(Ke[e.feedback]??e.feedback,h(e,{feedback:""})):""}
|
|
372
372
|
${e.starred?html`<span class="inline-flex items-center gap-1 pl-2.5 pr-1 py-0.5 rounded-full text-xs bg-yellow-50 dark:bg-yellow-900/20 text-yellow-700 dark:text-yellow-300 border border-yellow-200 dark:border-yellow-800">★ Starred<a href="${h({...e,starred:false})}" class="ml-0.5 w-4 h-4 flex items-center justify-center rounded-full hover:bg-yellow-200 dark:hover:bg-yellow-700 transition">×</a></span>`:""}
|
|
373
373
|
${e.imported||e.shared_by?c(n,h(e,{imported:"",shared_by:""})):""}
|
|
374
374
|
${e.search?c(`\u{1F50D} "${e.search}"`,h(e,{search:""})):""}
|
|
375
375
|
${e.category?c(e.category,h(e,{category:""})):""}
|
|
376
|
-
${e.level?c(`${
|
|
376
|
+
${e.level?c(`${Ye[e.level]??""} ${e.level}`,h(e,{level:""})):""}
|
|
377
377
|
${e.project?c(`\u{1F4C1} ${e.project}`,h(e,{project:""})):""}
|
|
378
378
|
${e.repository?c(`\u2387 ${e.repository}`,h(e,{repository:""})):""}
|
|
379
379
|
${e.branch?c(`\u2387 ${e.branch}`,h(e,{branch:""})):""}
|
|
@@ -383,7 +383,7 @@ ${Object.entries(r.categorised).map(([d,t])=>html`
|
|
|
383
383
|
<form id="import-form" method="post" action="/lessons/import" enctype="multipart/form-data" class="hidden"><input type="hidden" name="from" value="lessons" /></form>
|
|
384
384
|
<div id="drop-hint" class="hidden fixed inset-0 z-[60] bg-accent-500/10 border-4 border-dashed border-accent-400 pointer-events-none items-center justify-center"><p class="bg-white dark:bg-gray-900 text-accent-700 dark:text-accent-300 font-semibold rounded-xl px-6 py-3 shadow-lg">Drop to import the lesson</p></div>
|
|
385
385
|
|
|
386
|
-
${
|
|
386
|
+
${t.lessons.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-hidden">
|
|
387
387
|
<table class="w-full text-sm table-fixed" data-resizable="lessons">
|
|
388
388
|
<colgroup>
|
|
389
389
|
<col data-col="star" style="width:2.75rem" />
|
|
@@ -408,7 +408,7 @@ ${r.lessons.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
408
408
|
</tr>
|
|
409
409
|
</thead>
|
|
410
410
|
<tbody class="divide-y divide-gray-100 dark:divide-gray-800">
|
|
411
|
-
${
|
|
411
|
+
${t.lessons.map(l=>{let x=Ve("lesson-row-",l.id),$=l.timestamp.slice(0,10),_=l.timestamp.slice(0,16).replace("T"," ");return html`<tr id="${x}" data-id="${l.id}" data-title="${l.title}" data-href="/lessons/${encodeURIComponent(l.id)}" class="hover:bg-gray-50 dark:hover:bg-gray-800/40 transition-colors group cursor-pointer" tabindex="0" role="link" @click="if (selectMode) toggle($el.dataset.id); else if (!$event.target.closest('a, button, input, label')) window.location = $el.dataset.href" @keydown.enter="if (selectMode) toggle($el.dataset.id); else if ($event.target === $el) window.location = $el.dataset.href" @keydown.space.prevent="selectMode && toggle($el.dataset.id)" :class="selected.includes($el.dataset.id) && 'bg-accent-50 dark:bg-accent-900/20'">
|
|
412
412
|
<td class="px-3 py-3">
|
|
413
413
|
<form x-show="!selectMode" method="post" action="/lessons/${encodeURIComponent(l.id)}/star" hx-post="/lessons/${encodeURIComponent(l.id)}/star" hx-target="#${x}" hx-select="#${x}" hx-swap="outerHTML">
|
|
414
414
|
<input type="hidden" name="starred" value="${l.starred?"0":"1"}" />
|
|
@@ -419,7 +419,7 @@ ${r.lessons.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
419
419
|
</td>
|
|
420
420
|
<td class="px-3 py-3 whitespace-nowrap tabular-nums relative group/date">
|
|
421
421
|
<span class="text-gray-400 dark:text-gray-500 cursor-default" data-ts="${l.timestamp}">${$}</span>
|
|
422
|
-
<div class="absolute z-10 bottom-full left-0 mb-1 px-2 py-1 rounded bg-gray-800 dark:bg-gray-700 text-white text-xs whitespace-nowrap pointer-events-none opacity-0 group-hover/date:opacity-100 transition-opacity duration-150">${
|
|
422
|
+
<div class="absolute z-10 bottom-full left-0 mb-1 px-2 py-1 rounded bg-gray-800 dark:bg-gray-700 text-white text-xs whitespace-nowrap pointer-events-none opacity-0 group-hover/date:opacity-100 transition-opacity duration-150">${_}</div>
|
|
423
423
|
</td>
|
|
424
424
|
<td class="px-3 py-3 hidden sm:table-cell"><span class="block truncate text-xs font-mono text-cyan-600 dark:text-cyan-400">${l.topic_id}</span>${l.imported?html`<span class="block text-[11px] text-gray-400 dark:text-gray-500 truncate max-w-[10rem]" title="This lesson was shared with you">🤝 ${l.shared_by??"anonymous"}</span>`:""}</td>
|
|
425
425
|
<td class="px-3 py-3"><a href="/lessons/${encodeURIComponent(l.id)}" class="font-semibold text-[15px] leading-snug text-gray-800 dark:text-gray-100 hover:text-accent-600 dark:hover:text-accent-400 transition line-clamp-2">${l.title}</a></td>
|
|
@@ -431,12 +431,12 @@ ${r.lessons.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
431
431
|
</tbody>
|
|
432
432
|
</table>
|
|
433
433
|
</div>
|
|
434
|
-
${
|
|
435
|
-
<p class="text-xs text-gray-400 dark:text-gray-500">Page ${
|
|
434
|
+
${t.totalPages>1?html`<div class="flex items-center justify-between mt-4">
|
|
435
|
+
<p class="text-xs text-gray-400 dark:text-gray-500">Page ${t.page} of ${t.totalPages}</p>
|
|
436
436
|
<div class="flex items-center gap-1">
|
|
437
|
-
${
|
|
438
|
-
${ct(
|
|
439
|
-
${
|
|
437
|
+
${t.page>1?html`<a href="${h(e,{page:String(t.page-1)})}" class="inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-medium bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-300 hover:border-accent-400 transition">← Prev</a>`:html`<span class="inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-medium border border-gray-100 dark:border-gray-800 text-gray-300 dark:text-gray-600 cursor-not-allowed">← Prev</span>`}
|
|
438
|
+
${ct(t.page,t.totalPages).map(l=>l===0?html`<span class="text-gray-400 dark:text-gray-600 text-xs px-1">…</span>`:l===t.page?html`<span class="inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-medium bg-accent-600 text-white border border-accent-600">${l}</span>`:html`<a href="${h(e,{page:String(l)})}" class="inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-medium bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-300 hover:border-accent-400 transition">${l}</a>`)}
|
|
439
|
+
${t.page<t.totalPages?html`<a href="${h(e,{page:String(t.page+1)})}" class="inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-medium bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-300 hover:border-accent-400 transition">Next →</a>`:html`<span class="inline-flex items-center px-3 py-1.5 rounded-lg text-xs font-medium border border-gray-100 dark:border-gray-800 text-gray-300 dark:text-gray-600 cursor-not-allowed">Next →</span>`}
|
|
440
440
|
</div>
|
|
441
441
|
</div>`:""}`:html`<div class="flex flex-col items-center justify-center py-16 text-center">
|
|
442
442
|
<p class="text-3xl mb-3">📭</p>
|
|
@@ -453,14 +453,14 @@ ${r.totalPages>1?html`<div class="flex items-center justify-between mt-4">
|
|
|
453
453
|
</div>
|
|
454
454
|
</div>
|
|
455
455
|
</div>
|
|
456
|
-
${
|
|
456
|
+
${Y("confirmOpen","confirmOpen = false",html`<span x-text="selected.length === 1 ? 'Delete this lesson?' : 'Delete ' + selected.length + ' lessons?'"></span>`,html`<ul class="max-h-40 overflow-y-auto space-y-1 text-gray-700 dark:text-gray-200">
|
|
457
457
|
<template x-for="t in selectedTitles().slice(0, 6)" :key="t"><li class="truncate">· <span x-text="t"></span></li></template>
|
|
458
458
|
</ul>
|
|
459
459
|
<p x-show="selected.length > 6" style="display:none" x-text="'…and ' + (selected.length - 6) + ' more'"></p>
|
|
460
460
|
<p>They will be removed from your log. This cannot be undone.</p>`,html`<button type="button" @click="confirmOpen = false" class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400">Cancel</button>
|
|
461
461
|
<form method="post" action="/lessons/delete" class="contents">
|
|
462
462
|
<template x-for="id in selected" :key="id"><input type="hidden" name="id" :value="id" /></template>
|
|
463
|
-
<input type="hidden" name="next" value="/lessons${h(e,{page:String(
|
|
463
|
+
<input type="hidden" name="next" value="/lessons${h(e,{page:String(t.page)})}" />
|
|
464
464
|
<button type="submit" :disabled="!selected.length" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-rose-600 text-white border-rose-600 hover:bg-rose-500" x-text="selected.length === 1 ? '🗑 Delete lesson' : '🗑 Delete ' + selected.length + ' lessons'">🗑 Delete</button>
|
|
465
465
|
</form>`)}
|
|
466
466
|
<div x-show="shareOpen" style="display:none" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" class="fixed inset-0 z-[70] pointer-events-none">
|
|
@@ -469,7 +469,7 @@ ${J("confirmOpen","confirmOpen = false",html`<span x-text="selected.length === 1
|
|
|
469
469
|
<div id="share-modal-body" class="space-y-3"><p class="text-xs text-gray-400 dark:text-gray-500">Loading…</p></div>
|
|
470
470
|
</div>
|
|
471
471
|
</div>
|
|
472
|
-
</div>`,
|
|
472
|
+
</div>`,E=html`<script src="/static/vendor/flatpickr.min.js"></script>
|
|
473
473
|
<script src="/static/relative-time.js"></script>
|
|
474
474
|
<script src="/static/table-resize.js"></script>
|
|
475
475
|
<script src="/static/share.js"></script>
|
|
@@ -478,7 +478,7 @@ function periodPicker() {
|
|
|
478
478
|
return {
|
|
479
479
|
open: false,
|
|
480
480
|
showCustom: ${raw(g?"true":"false")},
|
|
481
|
-
label: ${raw(j(
|
|
481
|
+
label: ${raw(j(r))},
|
|
482
482
|
fp: null,
|
|
483
483
|
init() {
|
|
484
484
|
const self = this;
|
|
@@ -509,17 +509,17 @@ function periodPicker() {
|
|
|
509
509
|
},
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
|
-
</script>`;return
|
|
512
|
+
</script>`;return R({title:"Lessons \u2014 devcoach",currentPath:"/lessons",uiTheme:t.uiTheme,head:m,body:P,scripts:E})}function ct(t,e){let g=[],d=0;for(let r=1;r<=e;r++)(r===1||r===e||r>=t-2&&r<=t+2)&&(d&&r-d>1&&g.push(0),g.push(r),d=r);return g}var z={github:"github.com",gitlab:"gitlab.com",bitbucket:"bitbucket.org"};function J(t){let e=`/lessons/${encodeURIComponent(t.id)}/share?format=md&name=${encodeURIComponent(t.name)}&include_context=${t.includeContext?"1":"0"}`;return html`<div id="share-payloads" data-text="${t.text}" data-link="${t.link}" class="space-y-2">
|
|
513
513
|
<div class="flex flex-wrap gap-2">
|
|
514
514
|
<button type="button" onclick="copyShare('text', this)" class="inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium bg-gray-100 dark:bg-gray-800 hover:bg-accent-100 dark:hover:bg-accent-900/40 text-gray-700 dark:text-gray-200 hover:text-accent-700 dark:hover:text-accent-300 transition">📋 Copy text</button>
|
|
515
515
|
<button type="button" onclick="copyShare('link', this)" class="inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium bg-gray-100 dark:bg-gray-800 hover:bg-accent-100 dark:hover:bg-accent-900/40 text-gray-700 dark:text-gray-200 hover:text-accent-700 dark:hover:text-accent-300 transition">🔗 Copy link</button>
|
|
516
516
|
<a href="${e}" class="inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium bg-gray-100 dark:bg-gray-800 hover:bg-accent-100 dark:hover:bg-accent-900/40 text-gray-700 dark:text-gray-200 hover:text-accent-700 dark:hover:text-accent-300 transition">⬇ Download .md</a>
|
|
517
517
|
</div>
|
|
518
|
-
<p class="text-[11px] text-gray-400 dark:text-gray-500">${
|
|
519
|
-
</div>`}function
|
|
518
|
+
<p class="text-[11px] text-gray-400 dark:text-gray-500">${t.name?html`Shared by <span class="text-gray-600 dark:text-gray-300">${t.name}</span>`:"Shared anonymously"} · ${t.includeContext?"includes project, branch and commit":"only the lesson travels \u2014 no paths, no project"}.</p>
|
|
519
|
+
</div>`}function V(t,e,g=null){return html`
|
|
520
520
|
<p class="text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500">Share this lesson</p>
|
|
521
521
|
${g?html`<p class="text-sm font-semibold text-gray-800 dark:text-gray-100 leading-snug">${g}</p>`:""}
|
|
522
|
-
<form method="post" action="/lessons/${encodeURIComponent(
|
|
522
|
+
<form method="post" action="/lessons/${encodeURIComponent(t)}/share" hx-post="/lessons/${encodeURIComponent(t)}/share" hx-target="#share-payloads" hx-swap="outerHTML" hx-trigger="input delay:300ms, change" onsubmit="return false" class="space-y-2.5">
|
|
523
523
|
<input type="hidden" name="persist" value="0" x-ref="persist" />
|
|
524
524
|
<div>
|
|
525
525
|
<label for="share-name" class="block text-xs text-gray-400 dark:text-gray-500 mb-1">Your name</label>
|
|
@@ -527,11 +527,11 @@ function periodPicker() {
|
|
|
527
527
|
</div>
|
|
528
528
|
<label class="flex items-start gap-2 text-xs text-gray-600 dark:text-gray-300 cursor-pointer"><input type="checkbox" name="include_context" value="1" ${e.includeContext?"checked":""} class="mt-0.5" /><span>Include where it happened <span class="text-gray-400 dark:text-gray-500">(project, branch, commit — never local paths)</span></span></label>
|
|
529
529
|
</form>
|
|
530
|
-
${
|
|
531
|
-
`}function
|
|
530
|
+
${J(e)}
|
|
531
|
+
`}function Qe(t){let e=t.lesson,g=t.share,d=e.level==="junior"?"text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-900/30 border-green-300 dark:border-green-700":e.level==="mid"?"text-yellow-700 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700":"text-red-700 dark:text-red-400 bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-700",r=e.repository_platform==="local",a=null;r&&e.repository?a=`vscode://file/${e.repository}`:e.repository_platform&&z[e.repository_platform]&&e.repository&&(a=`https://${z[e.repository_platform]}/${e.repository}`);let n=null;a&&e.commit_hash&&!r&&(n=e.repository_platform==="gitlab"?`${a}/-/commit/${e.commit_hash}`:e.repository_platform==="bitbucket"?`${a}/commits/${e.commit_hash}`:`${a}/commit/${e.commit_hash}`);let i=!!(e.project||e.repository||e.branch||e.commit_hash||e.folder),s=e.timestamp.slice(0,10),c=e.timestamp.slice(0,16).replace("T"," "),u=`hx-post="/lessons/${encodeURIComponent(e.id)}/feedback" hx-target="#lesson-meta" hx-select="#lesson-meta" hx-swap="outerHTML" hx-select-oob="#lesson-feedback:outerHTML"`,p=html`
|
|
532
532
|
<div x-data="{ confirmOpen: false }" @keydown.escape.window="confirmOpen = false">
|
|
533
533
|
<div class="mb-4"><a href="/lessons" class="text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-white text-sm transition">← Back to lessons</a></div>
|
|
534
|
-
${
|
|
534
|
+
${t.imported?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-700 text-green-700 dark:text-green-300">${t.imported==="new"?html`✓ Imported “${e.title}”${e.shared_by?html`, shared by ${e.shared_by}`:""}. It's in your log now — feedback works as usual and it never counts against your daily limit.`:html`“${e.title}” was already in your log — nothing changed.`}</div>`:""}
|
|
535
535
|
<div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6">
|
|
536
536
|
<div class="flex flex-wrap items-center gap-3 mb-2">
|
|
537
537
|
<form id="lesson-star" method="post" action="/lessons/${encodeURIComponent(e.id)}/star" hx-post="/lessons/${encodeURIComponent(e.id)}/star" hx-target="#lesson-star" hx-select="#lesson-star" hx-swap="outerHTML">
|
|
@@ -541,11 +541,11 @@ ${r.imported?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm bg-green-
|
|
|
541
541
|
</form>
|
|
542
542
|
<h1 class="text-xl font-bold text-gray-900 dark:text-white flex-1 min-w-0">${e.title}</h1>
|
|
543
543
|
<a href="/lessons?level=${e.level}" class="text-xs font-semibold px-2 py-0.5 rounded-full border ${d} shrink-0 hover:ring-2 hover:ring-current hover:ring-offset-1 transition-shadow">${e.level}</a>
|
|
544
|
-
${
|
|
544
|
+
${K(html`<button type="button" @click="confirmOpen = true; open = false" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center gap-2 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 hover:!bg-rose-50 dark:hover:!bg-rose-900/30 hover:text-rose-700 dark:hover:text-rose-300"><span class="w-4 h-4 inline-flex items-center justify-center shrink-0 text-[13px] leading-none" aria-hidden="true">🗑</span>Delete lesson…</button>`,"shrink-0")}
|
|
545
545
|
<div class="relative shrink-0" x-data="{ open: ${String(g.open)} }" @click.outside="open = false" @keydown.escape="open = false">
|
|
546
546
|
<button type="button" @click="open = !open" title="Share this lesson" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400">↗ Share</button>
|
|
547
547
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute right-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-80 p-4 space-y-3" style="display:none">
|
|
548
|
-
${
|
|
548
|
+
${V(e.id,g)}
|
|
549
549
|
</div>
|
|
550
550
|
</div>
|
|
551
551
|
</div>
|
|
@@ -555,7 +555,7 @@ ${r.imported?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm bg-green-
|
|
|
555
555
|
</span>
|
|
556
556
|
<span>🏷 <span class="text-cyan-600 dark:text-cyan-400">${e.topic_id}</span></span>
|
|
557
557
|
${e.imported?html`<span title="This lesson was shared with you">🤝 shared by <span class="text-gray-700 dark:text-gray-200">${e.shared_by??"anonymous"}</span></span>`:""}
|
|
558
|
-
${
|
|
558
|
+
${t.course?html`<a href="/courses/${encodeURIComponent(t.course.id)}" title="${t.course.title}" class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 border border-accent-200 dark:border-accent-700 hover:border-accent-400 transition">🎓 Course · ${t.course.done}/${t.course.total}${t.course.status==="completed"?" \u2713":""}</a>`:""}
|
|
559
559
|
${e.categories.map(T=>html`<a href="/lessons?category=${encodeURIComponent(T)}" class="inline-block bg-gray-100 dark:bg-gray-800 hover:bg-accent-50 dark:hover:bg-accent-900/50 text-gray-600 dark:text-gray-300 text-xs rounded px-2 py-0.5 transition border border-gray-200 dark:border-gray-700 hover:border-accent-400 dark:hover:border-accent-600">${T}</a>`)}
|
|
560
560
|
${e.feedback?html`${e.feedback==="know"?html`<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 border border-green-200 dark:border-green-700">✓ I knew this</span>`:e.feedback==="understood"?html`<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 border border-accent-200 dark:border-accent-700">💡 Understood</span>`:html`<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 border border-red-200 dark:border-red-700">✗ Couldn't follow</span>`}
|
|
561
561
|
<form method="post" action="/lessons/${encodeURIComponent(e.id)}/feedback" ${raw(u)}><input type="hidden" name="feedback" value="clear" /><input type="hidden" name="next" value="/lessons/${encodeURIComponent(e.id)}" /><button type="submit" class="text-xs text-gray-400 dark:text-gray-600 hover:text-gray-600 dark:hover:text-gray-400 transition">Clear</button></form>`:""}
|
|
@@ -567,8 +567,8 @@ ${r.imported?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm bg-green-
|
|
|
567
567
|
<div id="body-content" class="markdown-body"></div>
|
|
568
568
|
${e.task_context?html`<div class="mt-6 pt-4 border-t border-gray-100 dark:border-gray-800 text-sm text-gray-500 dark:text-gray-400"><span class="text-gray-400 dark:text-gray-500">Context:</span> ${e.task_context}</div>`:""}
|
|
569
569
|
${i?html`<div class="mt-4 pt-4 border-t border-gray-100 dark:border-gray-800"><div class="flex flex-wrap gap-x-5 gap-y-1.5 text-xs text-gray-400 dark:text-gray-500 font-mono">
|
|
570
|
-
${e.project?html`<span><span class="text-gray-400 dark:text-gray-600">project</span> ${a?html`<a href="${a}" ${
|
|
571
|
-
${e.repository?html`<span class="inline-flex items-center gap-1"><span class="text-gray-400 dark:text-gray-600">repo</span>${e.repository_platform&&
|
|
570
|
+
${e.project?html`<span><span class="text-gray-400 dark:text-gray-600">project</span> ${a?html`<a href="${a}" ${r?"":raw('target="_blank" rel="noopener"')} class="text-gray-600 dark:text-gray-300 hover:text-accent-600 dark:hover:text-accent-400 transition">${e.project}</a>`:html`<span class="text-gray-600 dark:text-gray-300">${e.project}</span>`}</span>`:""}
|
|
571
|
+
${e.repository?html`<span class="inline-flex items-center gap-1"><span class="text-gray-400 dark:text-gray-600">repo</span>${e.repository_platform&&z[e.repository_platform]?html`<img src="/static/vendor/icons/${e.repository_platform}.svg" class="w-3 h-3 dark:invert opacity-60 shrink-0" alt="" />`:""}${a?html`<a href="${a}" ${r?"":raw('target="_blank" rel="noopener"')} class="text-gray-600 dark:text-gray-300 hover:text-accent-600 dark:hover:text-accent-400 transition">${e.repository}</a>`:html`<span class="text-gray-600 dark:text-gray-300">${e.repository}</span>`}</span>`:""}
|
|
572
572
|
${e.branch?html`<span><span class="text-gray-400 dark:text-gray-600">branch</span> <span class="text-accent-600 dark:text-accent-400">${e.branch}</span></span>`:""}
|
|
573
573
|
${e.commit_hash?html`<span><span class="text-gray-400 dark:text-gray-600">commit</span> ${n?html`<a href="${n}" target="_blank" rel="noopener" class="text-cyan-600 dark:text-cyan-400 hover:text-accent-600 dark:hover:text-accent-400 transition">${e.commit_hash.slice(0,7)}</a>`:html`<span class="text-cyan-600 dark:text-cyan-400">${e.commit_hash.slice(0,7)}</span>`}</span>`:""}
|
|
574
574
|
${e.folder?html`<span class="inline-flex items-center gap-1"><span class="text-gray-400 dark:text-gray-600">folder</span><a href="vscode://file/${e.folder}" class="inline-flex items-center gap-1 text-gray-600 dark:text-gray-300 hover:text-accent-600 dark:hover:text-accent-400 transition"><img src="/static/vendor/icons/vscode.svg" class="w-3.5 h-3.5 shrink-0" alt="" />${e.folder}</a></span>`:""}
|
|
@@ -580,7 +580,7 @@ ${r.imported?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm bg-green-
|
|
|
580
580
|
</div>`}</div>
|
|
581
581
|
<div class="mt-4 pt-4 border-t border-gray-100 dark:border-gray-800 text-xs text-gray-300 dark:text-gray-600">ID: ${e.id}</div>
|
|
582
582
|
</div>
|
|
583
|
-
${
|
|
583
|
+
${Y("confirmOpen","confirmOpen = false",html`Delete this lesson?`,html`<p class="text-gray-700 dark:text-gray-200 font-medium">“${e.title}”</p>
|
|
584
584
|
<p>${e.imported?html`It was shared with you${e.shared_by?html` by ${e.shared_by}`:""}; you can import it again later. `:""}It will be removed from your log. This cannot be undone.</p>`,html`<button type="button" @click="confirmOpen = false" class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400">Cancel</button>
|
|
585
585
|
<form method="post" action="/lessons/delete" class="contents">
|
|
586
586
|
<input type="hidden" name="id" value="${e.id}" />
|
|
@@ -603,7 +603,7 @@ ${J("confirmOpen","confirmOpen = false",html`Delete this lesson?`,html`<p class=
|
|
|
603
603
|
});
|
|
604
604
|
document.getElementById('summary-content').innerHTML = DOMPurify.sanitize(marked.parse(${raw(j(e.summary))}));
|
|
605
605
|
document.getElementById('body-content').innerHTML = DOMPurify.sanitize(marked.parse(${raw(j(e.body))}));
|
|
606
|
-
</script>`;return
|
|
606
|
+
</script>`;return R({title:`${e.title} \u2014 devcoach`,currentPath:"/lessons",uiTheme:t.uiTheme,head:m,body:p,scripts:v})}var gt={junior:"text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-900/30 border-green-300 dark:border-green-700",mid:"text-yellow-700 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700",senior:"text-red-700 dark:text-red-400 bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-700"};function Xe(t){let e=t.preview,g=html`<form id="import-form" method="post" action="/lessons/import" enctype="multipart/form-data" class="space-y-3">
|
|
607
607
|
<input type="hidden" name="from" value="lessons" />
|
|
608
608
|
<textarea name="text" rows="5" placeholder="devcoach:lesson:1:… — or the link, a URL, or the whole card" autocomplete="off" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 rounded-lg px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-accent-500 font-mono"></textarea>
|
|
609
609
|
<div class="flex items-center gap-3">
|
|
@@ -615,7 +615,7 @@ ${J("confirmOpen","confirmOpen = false",html`Delete this lesson?`,html`<p class=
|
|
|
615
615
|
<div class="mb-4"><a href="/lessons" class="text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-white text-sm transition">← Back to lessons</a></div>
|
|
616
616
|
<div class="${e?"max-w-5xl":"max-w-3xl"} mx-auto bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6">
|
|
617
617
|
<p class="text-xs font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500 mb-4">${e?"Someone shared a lesson with you":"Import a shared lesson"}</p>
|
|
618
|
-
${
|
|
618
|
+
${t.error?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm bg-rose-50 dark:bg-rose-900/20 border-rose-200 dark:border-rose-700 text-rose-700 dark:text-rose-300">${t.error}</div>`:""}
|
|
619
619
|
${e?html`<div class="flex flex-wrap items-center gap-3 mb-2">
|
|
620
620
|
<h1 class="text-xl font-bold text-gray-900 dark:text-white flex-1 min-w-0">${e.lesson.title}</h1>
|
|
621
621
|
<span class="text-xs font-semibold px-2 py-0.5 rounded-full border ${gt[e.lesson.level]??""} shrink-0">${e.lesson.level}</span>
|
|
@@ -636,11 +636,11 @@ ${J("confirmOpen","confirmOpen = false",html`Delete this lesson?`,html`<p class=
|
|
|
636
636
|
${e.lesson.task_context?html`<div class="mt-6 pt-4 border-t border-gray-100 dark:border-gray-800 text-sm text-gray-500 dark:text-gray-400"><span class="text-gray-400 dark:text-gray-500">Context:</span> ${e.lesson.task_context}</div>`:""}
|
|
637
637
|
<form method="post" action="/lessons/import" class="mt-6 pt-4 border-t border-gray-100 dark:border-gray-800 flex flex-wrap items-center gap-3">
|
|
638
638
|
<input type="hidden" name="from" value="lessons" />
|
|
639
|
-
<input type="hidden" name="text" value="${
|
|
639
|
+
<input type="hidden" name="text" value="${t.code}" />
|
|
640
640
|
<button type="submit" class="bg-accent-600 hover:bg-accent-500 text-white font-semibold rounded-lg px-4 py-2 text-sm transition">+ Add to my lessons</button>
|
|
641
641
|
<p class="text-xs text-gray-400 dark:text-gray-500">Nothing is saved until you click. It joins your log like your own lessons and never counts against the daily limit.</p>
|
|
642
642
|
</form>`:g}
|
|
643
|
-
</div>`,
|
|
643
|
+
</div>`,r=html`<link id="hljs-theme" rel="stylesheet" href="/static/vendor/hljs-dark.min.css" />`,a=html`<script src="/static/vendor/highlight.min.js"></script>
|
|
644
644
|
<script src="/static/vendor/marked.min.js"></script>
|
|
645
645
|
<script src="/static/vendor/purify.min.js"></script>
|
|
646
646
|
<script src="/static/share.js"></script>
|
|
@@ -655,12 +655,12 @@ ${J("confirmOpen","confirmOpen = false",html`Delete this lesson?`,html`<p class=
|
|
|
655
655
|
});
|
|
656
656
|
${e?raw(`document.getElementById('summary-content').innerHTML = DOMPurify.sanitize(marked.parse(${j(e.lesson.summary)}));
|
|
657
657
|
document.getElementById('body-content').innerHTML = DOMPurify.sanitize(marked.parse(${j(e.lesson.body??"")}));`):""}
|
|
658
|
-
</script>`;return
|
|
658
|
+
</script>`;return R({title:e?`${e.lesson.title} \u2014 devcoach`:"Import a lesson \u2014 devcoach",currentPath:"/lessons",uiTheme:t.uiTheme,head:r,body:d,scripts:a})}var pt=[[0,"No cooldown"],[15,"15 minutes"],[30,"30 minutes"],[60,"1 hour"],[90,"1 hour 30 min"],[120,"2 hours"],[180,"3 hours"],[240,"4 hours"],[360,"6 hours"],[480,"8 hours"],[720,"12 hours"],[1440,"24 hours"]],Je={active:"bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 border-accent-200 dark:border-accent-700",completed:"bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 border-green-200 dark:border-green-700",abandoned:"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 border-gray-200 dark:border-gray-700"},ut={todo:"\u25CB",done:"\u25CF",skipped:"\u25CC"};function et(t){return html`<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${Je[t]??Je.abandoned}">${t}</span>`}function tt(t){let e=html`
|
|
659
659
|
<div class="flex items-center justify-between mb-6">
|
|
660
660
|
<h1 class="text-2xl font-bold text-accent-600 dark:text-accent-400">Courses</h1>
|
|
661
|
-
<p class="text-sm text-gray-400 dark:text-gray-500">${
|
|
661
|
+
<p class="text-sm text-gray-400 dark:text-gray-500">${t.courses.length} course${t.courses.length!==1?"s":""}</p>
|
|
662
662
|
</div>
|
|
663
|
-
${
|
|
663
|
+
${t.courses.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-hidden">
|
|
664
664
|
<table class="w-full text-sm table-fixed">
|
|
665
665
|
<colgroup><col style="width:46%" /><col style="width:22%" /><col style="width:14%" /><col style="width:8rem" /></colgroup>
|
|
666
666
|
<thead>
|
|
@@ -669,15 +669,15 @@ ${r.courses.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
669
669
|
</tr>
|
|
670
670
|
</thead>
|
|
671
671
|
<tbody class="divide-y divide-gray-100 dark:divide-gray-800">
|
|
672
|
-
${
|
|
672
|
+
${t.courses.map(d=>{let r=d.steps.filter(n=>n.status!=="todo").length,a=d.steps.length?Math.round(r/d.steps.length*100):0;return html`<tr class="hover:bg-gray-50 dark:hover:bg-gray-800/40 transition-colors cursor-pointer" tabindex="0" role="link" data-href="/courses/${encodeURIComponent(d.id)}" @click="if (!$event.target.closest('a, button')) window.location = $el.dataset.href" @keydown.enter="window.location = $el.dataset.href">
|
|
673
673
|
<td class="px-4 py-3">
|
|
674
674
|
<a href="/courses/${encodeURIComponent(d.id)}" class="font-semibold text-gray-800 dark:text-gray-100 hover:text-accent-600 dark:hover:text-accent-400 transition line-clamp-2">${d.title}</a>
|
|
675
675
|
${d.lesson_id?html`<span class="block text-[11px] text-gray-400 dark:text-gray-500 truncate">from <a href="/lessons/${encodeURIComponent(d.lesson_id)}" class="hover:text-accent-500 hover:underline">${d.lesson_title??d.lesson_id}</a></span>`:""}
|
|
676
676
|
</td>
|
|
677
677
|
<td class="px-3 py-3">
|
|
678
|
-
<div class="flex items-center gap-2"><div class="flex-1 h-1.5 rounded-full bg-gray-100 dark:bg-gray-800 overflow-hidden"><div class="h-full bg-accent-500" style="width:${a}%"></div></div><span class="text-xs tabular-nums text-gray-500 dark:text-gray-400 shrink-0">${
|
|
678
|
+
<div class="flex items-center gap-2"><div class="flex-1 h-1.5 rounded-full bg-gray-100 dark:bg-gray-800 overflow-hidden"><div class="h-full bg-accent-500" style="width:${a}%"></div></div><span class="text-xs tabular-nums text-gray-500 dark:text-gray-400 shrink-0">${r}/${d.steps.length}</span></div>
|
|
679
679
|
</td>
|
|
680
|
-
<td class="px-3 py-3">${
|
|
680
|
+
<td class="px-3 py-3">${et(d.status)}</td>
|
|
681
681
|
<td class="px-3 py-3 whitespace-nowrap text-gray-400 dark:text-gray-500 tabular-nums"><span data-ts="${d.updated_at}">${d.updated_at.slice(0,10)}</span></td>
|
|
682
682
|
</tr>`})}
|
|
683
683
|
</tbody>
|
|
@@ -686,20 +686,20 @@ ${r.courses.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
686
686
|
<p class="text-3xl mb-3">🎓</p>
|
|
687
687
|
<p class="text-gray-700 dark:text-gray-200 font-medium">No courses yet.</p>
|
|
688
688
|
<p class="text-sm text-gray-500 dark:text-gray-400 mt-2 max-w-md mx-auto">A course starts in your agent: answer <span class="font-mono">n</span> (couldn't follow) under a lesson card and say yes to the offer, or run <span class="font-mono">/devcoach:course</span> on any lesson or concept. The AI first asks what you already know, then writes the course here.</p>
|
|
689
|
-
</div>`}`,g=html`<script src="/static/relative-time.js"></script>`;return
|
|
689
|
+
</div>`}`,g=html`<script src="/static/relative-time.js"></script>`;return R({title:"Courses \u2014 devcoach",currentPath:"/courses",uiTheme:t.uiTheme,body:e,scripts:g})}function rt(t){return html`<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><title>Read-only — devcoach</title>
|
|
690
690
|
<link rel="stylesheet" href="/static/style.css" /></head>
|
|
691
691
|
<body style="font-family: ui-monospace, monospace; max-width: 40rem; margin: 4rem auto; padding: 0 1rem; line-height: 1.5">
|
|
692
692
|
<h1 style="font-size: 1.25rem">This devcoach is older than your database</h1>
|
|
693
|
-
<p>${
|
|
693
|
+
<p>${t}</p>
|
|
694
694
|
<p><a href="javascript:history.back()">← Back</a></p>
|
|
695
|
-
</body></html>`}function
|
|
695
|
+
</body></html>`}function at(t){let e=t.course,g=e.steps.filter(s=>s.status!=="todo").length,d=e.steps.find(s=>s.position===t.selected)??e.steps[0],r=`/courses/${encodeURIComponent(e.id)}/index.html${d?`#${d.anchor}`:""}`,a=(s,c,u,p)=>html`<form method="post" action="/courses/${encodeURIComponent(e.id)}/steps/${s}" class="inline"><input type="hidden" name="status" value="${c}" /><input type="hidden" name="next" value="/courses/${encodeURIComponent(e.id)}?step=${s}" /><button type="submit" class="${p}">${u}</button></form>`,n="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400",i=html`
|
|
696
696
|
<div x-data="{ confirmOpen: false }" @keydown.escape.window="confirmOpen = false">
|
|
697
697
|
<div class="sticky top-0 z-20 -mx-4 sm:-mx-6 -mt-8 mb-5 px-4 sm:px-6 h-12 flex items-center gap-3 bg-gray-50/95 dark:bg-gray-950/95 backdrop-blur border-b border-gray-200 dark:border-gray-800">
|
|
698
698
|
<a href="/courses" title="Back to courses" class="text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-white text-sm transition shrink-0">←</a>
|
|
699
699
|
<span class="text-sm font-semibold text-gray-900 dark:text-white truncate min-w-0">${e.title}</span>
|
|
700
|
-
${
|
|
700
|
+
${et(e.status)}
|
|
701
701
|
<span class="text-xs text-gray-500 dark:text-gray-400 shrink-0">${g}/${e.steps.length} steps</span>
|
|
702
|
-
${
|
|
702
|
+
${K(html`<button type="button" @click="confirmOpen = true; open = false" class="w-full text-left px-3 py-2 rounded-lg text-sm transition flex items-center gap-2 text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 hover:!bg-rose-50 dark:hover:!bg-rose-900/30 hover:text-rose-700 dark:hover:text-rose-300"><span class="w-4 h-4 inline-flex items-center justify-center shrink-0 text-[13px] leading-none" aria-hidden="true">🗑</span>Delete course…</button>`,"ml-auto shrink-0")}
|
|
703
703
|
</div>
|
|
704
704
|
<div class="grid grid-cols-1 lg:grid-cols-[15rem_minmax(0,1fr)] gap-6 lg:gap-8">
|
|
705
705
|
<aside id="course-steps" class="lg:sticky lg:top-16 self-start">
|
|
@@ -718,7 +718,7 @@ ${r.courses.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
718
718
|
<summary class="cursor-pointer font-semibold uppercase tracking-wide text-gray-400 dark:text-gray-500 select-none">About this course</summary>
|
|
719
719
|
<div class="mt-2 space-y-2">
|
|
720
720
|
<p>🏷 <span class="text-cyan-600 dark:text-cyan-400">${e.topic_id}</span></p>
|
|
721
|
-
${e.lesson_id?html`<p>from <a href="/lessons/${encodeURIComponent(e.lesson_id)}" class="text-gray-700 dark:text-gray-200 hover:text-accent-500 hover:underline">${
|
|
721
|
+
${e.lesson_id?html`<p>from <a href="/lessons/${encodeURIComponent(e.lesson_id)}" class="text-gray-700 dark:text-gray-200 hover:text-accent-500 hover:underline">${t.lessonTitle??e.lesson_id}</a></p>`:""}
|
|
722
722
|
${e.goal?html`<p class="text-gray-600 dark:text-gray-300">${e.goal}</p>`:""}
|
|
723
723
|
${e.prerequisites.length?html`<div class="flex flex-wrap items-center gap-1" title="The prerequisite chain explored before writing the course">
|
|
724
724
|
${e.prerequisites.map(s=>html`<span class="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border ${s.known?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800":"bg-rose-50 dark:bg-rose-900/20 text-rose-700 dark:text-rose-300 border-rose-200 dark:border-rose-800"}">${s.known?"\u2713":"\u2717"} ${s.concept}</span>`)}
|
|
@@ -727,19 +727,19 @@ ${r.courses.length?html`<div class="bg-white dark:bg-gray-900 rounded-xl border
|
|
|
727
727
|
</details>
|
|
728
728
|
</aside>
|
|
729
729
|
<div class="min-w-0">
|
|
730
|
-
${
|
|
730
|
+
${t.hasDocument?html`<iframe id="course-frame" src="${r}" title="${e.title}" sandbox="allow-scripts allow-forms" referrerpolicy="no-referrer" scrolling="no" class="w-full block min-h-[40vh]"></iframe>`:html`<div class="p-8 text-center text-sm text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl"><p class="text-3xl mb-3">✍️</p>The course document hasn't been written yet. Ask your agent to continue the course — it writes <span class="font-mono">index.html</span> in the course folder, and it appears here.</div>`}
|
|
731
731
|
</div>
|
|
732
732
|
</div>
|
|
733
|
-
${
|
|
733
|
+
${Y("confirmOpen","confirmOpen = false",html`Delete this course?`,html`<p class="text-gray-700 dark:text-gray-200 font-medium">“${e.title}”</p>
|
|
734
734
|
<p>The course, its steps and its document folder will be removed. This cannot be undone.${e.lesson_id?" The lesson it grew from stays.":""}</p>`,html`<button type="button" @click="confirmOpen = false" class="inline-flex items-center px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-200 hover:border-accent-400">Cancel</button>
|
|
735
735
|
<form method="post" action="/courses/delete" class="contents">
|
|
736
736
|
<input type="hidden" name="id" value="${e.id}" />
|
|
737
737
|
<button type="submit" class="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium border transition bg-rose-600 text-white border-rose-600 hover:bg-rose-500">🗑 Delete course</button>
|
|
738
738
|
</form>`)}
|
|
739
|
-
</div>`;return
|
|
739
|
+
</div>`;return R({title:`${e.title} \u2014 devcoach`,currentPath:"/courses",uiTheme:t.uiTheme,body:i,scripts:html`<script src="/static/course-viewer.js"></script>`,wide:true})}function ot(t){let e=t.settings.min_gap_minutes,g=[["system","System","\u{1F313}"],["light","Light","\u2600\uFE0F"],["dark","Dark","\u{1F319}"]],d=[["auto","Auto","\u{1F3E0}"],["lessons","Lessons","\u{1F4DA}"],["knowledge","Knowledge map","\u{1F9ED}"]],r=t.flash,a=html`
|
|
740
740
|
<h1 class="text-2xl font-bold mb-6 text-accent-600 dark:text-accent-400">Settings</h1>
|
|
741
|
-
${
|
|
742
|
-
${
|
|
741
|
+
${r?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm ${r.invalid?"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-700 text-yellow-800 dark:text-yellow-300":"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-700 text-green-700 dark:text-green-300"}">
|
|
742
|
+
${r.imported} lesson${r.imported!==1?"s":""} imported.${r.skipped?` ${r.skipped} skipped (already in DB).`:""}${r.invalid?` ${r.invalid} rejected (failed validation).`:""}${r.groups?` ${r.groups} group${r.groups!==1?"s":""} added.`:""}${r.notebook?" Notebook restored.":""}
|
|
743
743
|
</div>`:""}
|
|
744
744
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
745
745
|
<div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl p-6">
|
|
@@ -748,7 +748,7 @@ ${t?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm ${t.invalid?"bg-ye
|
|
|
748
748
|
<div class="grid grid-cols-2 gap-4">
|
|
749
749
|
<div>
|
|
750
750
|
<label for="max-per-day" class="block text-sm text-gray-600 dark:text-gray-400 mb-1">Max lessons per day</label>
|
|
751
|
-
<input id="max-per-day" type="number" name="max_per_day" min="1" max="20" value="${
|
|
751
|
+
<input id="max-per-day" type="number" name="max_per_day" min="1" max="20" value="${t.settings.max_per_day}" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white rounded px-3 py-2 text-sm focus:outline-none focus:border-accent-500" />
|
|
752
752
|
<p class="text-xs text-gray-400 dark:text-gray-500 mt-1">Lessons in a 24h window.</p>
|
|
753
753
|
</div>
|
|
754
754
|
<div>
|
|
@@ -762,28 +762,28 @@ ${t?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm ${t.invalid?"bg-ye
|
|
|
762
762
|
<div class="grid grid-cols-2 gap-4">
|
|
763
763
|
<div>
|
|
764
764
|
<label for="nudge-every" class="block text-sm text-gray-600 dark:text-gray-400 mb-1">Interactions between lessons</label>
|
|
765
|
-
<input id="nudge-every" type="number" name="nudge_every" min="0" max="1000" value="${
|
|
765
|
+
<input id="nudge-every" type="number" name="nudge_every" min="0" max="1000" value="${t.settings.nudge_every}" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white rounded px-3 py-2 text-sm focus:outline-none focus:border-accent-500" />
|
|
766
766
|
<p class="text-xs text-gray-400 dark:text-gray-500 mt-1">Cue at most once every N (0 = every turn).</p>
|
|
767
767
|
</div>
|
|
768
768
|
<div>
|
|
769
769
|
<label for="nudge-scope" class="block text-sm text-gray-600 dark:text-gray-400 mb-1">Count interactions</label>
|
|
770
770
|
<select id="nudge-scope" name="nudge_scope" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white rounded px-3 py-2 text-sm focus:outline-none focus:border-accent-500">
|
|
771
|
-
<option value="session" ${
|
|
772
|
-
<option value="global" ${
|
|
771
|
+
<option value="session" ${t.settings.nudge_scope==="session"?"selected":""}>Per chat session</option>
|
|
772
|
+
<option value="global" ${t.settings.nudge_scope==="global"?"selected":""}>Globally</option>
|
|
773
773
|
</select>
|
|
774
774
|
<p class="text-xs text-gray-400 dark:text-gray-500 mt-1">Per-chat or across all sessions.</p>
|
|
775
775
|
</div>
|
|
776
776
|
</div>
|
|
777
777
|
<div>
|
|
778
778
|
<label for="share-name" class="block text-sm text-gray-600 dark:text-gray-400 mb-1">Your name (for sharing)</label>
|
|
779
|
-
<input id="share-name" type="text" name="share_name" maxlength="80" value="${
|
|
779
|
+
<input id="share-name" type="text" name="share_name" maxlength="80" value="${t.settings.share_name??""}" placeholder="git user.name when empty" autocomplete="off" class="w-full bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-700 text-gray-900 dark:text-white rounded px-3 py-2 text-sm focus:outline-none focus:border-accent-500" />
|
|
780
780
|
<p class="text-xs text-gray-400 dark:text-gray-500 mt-1">Proposed as the sender when you share a lesson. Empty → your git name.</p>
|
|
781
781
|
</div>
|
|
782
782
|
<fieldset class="border-0 p-0 m-0">
|
|
783
783
|
<legend class="block text-sm text-gray-600 dark:text-gray-400 mb-1">UI theme</legend>
|
|
784
784
|
<div class="flex gap-2">
|
|
785
785
|
${g.map(([i,s,c])=>html`<label class="flex-1 cursor-pointer">
|
|
786
|
-
<input type="radio" name="ui_theme" value="${i}" ${
|
|
786
|
+
<input type="radio" name="ui_theme" value="${i}" ${t.settings.ui_theme===i?"checked":""} class="sr-only peer" />
|
|
787
787
|
<span class="flex flex-col items-center justify-center gap-1 px-3 py-2 rounded border border-gray-300 dark:border-gray-700 peer-checked:border-accent-500 peer-checked:bg-accent-50 dark:peer-checked:bg-accent-900/30 peer-checked:text-accent-700 dark:peer-checked:text-accent-300 text-gray-500 dark:text-gray-400 text-xs font-medium transition select-none"><span class="text-base leading-none">${c}</span>${s}</span>
|
|
788
788
|
</label>`)}
|
|
789
789
|
</div>
|
|
@@ -793,7 +793,7 @@ ${t?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm ${t.invalid?"bg-ye
|
|
|
793
793
|
<legend class="block text-sm text-gray-600 dark:text-gray-400 mb-1">Home page</legend>
|
|
794
794
|
<div class="flex gap-2">
|
|
795
795
|
${d.map(([i,s,c])=>html`<label class="flex-1 cursor-pointer">
|
|
796
|
-
<input type="radio" name="ui_home" value="${i}" ${
|
|
796
|
+
<input type="radio" name="ui_home" value="${i}" ${t.settings.ui_home===i?"checked":""} class="sr-only peer" />
|
|
797
797
|
<span class="flex flex-col items-center justify-center gap-1 px-3 py-2 rounded border border-gray-300 dark:border-gray-700 peer-checked:border-accent-500 peer-checked:bg-accent-50 dark:peer-checked:bg-accent-900/30 peer-checked:text-accent-700 dark:peer-checked:text-accent-300 text-gray-500 dark:text-gray-400 text-xs font-medium transition select-none"><span class="text-base leading-none">${c}</span>${s}</span>
|
|
798
798
|
</label>`)}
|
|
799
799
|
</div>
|
|
@@ -846,11 +846,11 @@ ${t?html`<div class="mb-4 px-4 py-2 rounded-lg border text-sm ${t.invalid?"bg-ye
|
|
|
846
846
|
<button type="button" @click="nbMode = 'source'" :class="nbMode === 'source' ? 'bg-accent-600 text-white' : 'bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700'" class="px-3 py-1.5 transition border-l border-gray-200 dark:border-gray-700">Source</button>
|
|
847
847
|
</div>
|
|
848
848
|
<a href="/settings/notebook/download" class="inline-flex items-center gap-1.5 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 font-medium rounded px-3 py-1.5 text-xs transition">↓ Download</a>
|
|
849
|
-
<a href="vscode://file/${
|
|
849
|
+
<a href="vscode://file/${t.notebookPath}" title="Open in VS Code" class="inline-flex items-center gap-1.5 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-200 font-medium rounded px-3 py-1.5 text-xs transition"><img src="/static/vscode.svg" class="w-4 h-4" alt="VS Code" />Open in VS Code</a>
|
|
850
850
|
</div>
|
|
851
851
|
</div>
|
|
852
852
|
<div x-show="nbMode === 'preview'" id="notebook-preview-settings" class="markdown-body min-h-24"></div>
|
|
853
|
-
<pre x-show="nbMode === 'source'" style="display:none" class="text-xs font-mono bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded p-3 overflow-x-auto whitespace-pre-wrap text-gray-700 dark:text-gray-200 min-h-24">${
|
|
853
|
+
<pre x-show="nbMode === 'source'" style="display:none" class="text-xs font-mono bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded p-3 overflow-x-auto whitespace-pre-wrap text-gray-700 dark:text-gray-200 min-h-24">${t.notebookContent}</pre>
|
|
854
854
|
</div>
|
|
855
855
|
</div>`,n=html`<script src="/static/vendor/marked.min.js"></script>
|
|
856
856
|
<script src="/static/vendor/purify.min.js"></script>
|
|
@@ -861,11 +861,11 @@ function updateLabel(inputId, labelId, submitId) {
|
|
|
861
861
|
document.getElementById(submitId).disabled = !input.files.length;
|
|
862
862
|
}
|
|
863
863
|
marked.setOptions({ breaks: true, gfm: true });
|
|
864
|
-
document.getElementById('notebook-preview-settings').innerHTML = DOMPurify.sanitize(marked.parse(${raw(j(
|
|
865
|
-
</script>`;return
|
|
866
|
-
<script>${readFileSync(join(
|
|
867
|
-
`}catch{return ""}})();return e$1.get("/courses",
|
|
868
|
-
${a$2()??""}`:"",u=Buffer.concat([i,Buffer.from(d+c$1)]);return new Response(new Uint8Array(u),{headers:new Headers(g$1)})}catch{return
|
|
869
|
-
${a$3.dim("Open it there, start another with --port <n>, or stop it with: devcoach ui --stop")}`}}return {exitCode:1,message:`${a$3.red(`\u2717 Port ${
|
|
870
|
-
${a$3.dim("Pick another port: devcoach ui --port <n>")}`}}return e.code==="EACCES"?{exitCode:1,message:a$3.red(`\u2717 Port ${
|
|
871
|
-
export{
|
|
864
|
+
document.getElementById('notebook-preview-settings').innerHTML = DOMPurify.sanitize(marked.parse(${raw(j(t.notebookContent))}));
|
|
865
|
+
</script>`;return R({title:"Settings \u2014 devcoach",currentPath:"/settings",uiTheme:t.uiTheme,body:a,scripts:n})}var W=25;function U(t,e="/lessons"){return t?.startsWith("/")&&!t.startsWith("//")?t:e}function b(t,e,g=""){let d=t[e];return typeof d=="string"?d:g}var Z=dirname(fileURLToPath(import.meta.url)),Q=[join(Z,"../assets/static"),join(Z,"../../assets/static")].find(t=>existsSync(t))??join(Z,"../assets/static"),kt={".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".woff2":"font/woff2",".woff":"font/woff",".ico":"image/x-icon"},vt="https://ultimaphoenix.github.io",st={"access-control-allow-origin":vt,"access-control-allow-methods":"GET, OPTIONS","access-control-allow-private-network":"true","cache-control":"no-store",vary:"Origin"};function dt(t){let e=t.req.header("sec-fetch-site");return e!==void 0&&e!=="same-origin"&&e!=="none"}var wt=new Set(["127.0.0.1","localhost","[::1]"]),$t=new Set(["GET","HEAD","OPTIONS"]);function St(t){return wt.has(new URL(t.req.url).hostname)?!$t.has(t.req.method)&&dt(t)?"Forbidden: another website cannot change your devcoach dashboard.":null:"Forbidden: the devcoach dashboard answers on 127.0.0.1 and localhost only."}var X;function _t(){return X===void 0&&(X=n()),X}function nt(t,e,g){let d=ta({explicit:g.name??null,setting:e,gitUserName:_t()}),r=g.includeContext??false,a=sa(t,{includeContext:r,sharedBy:d}),n=ua(a);return {payload:a,state:{id:t.id,open:g.open??false,name:d??"",includeContext:r,text:wa(a,n),link:xa(a,n)}}}function Ct(t,e){return t==="lessons"?"/lessons":t==="knowledge"?"/knowledge":e?"/lessons":"/knowledge"}function Tt(){try{return E(t=>X$1(t).ui_theme)}catch{return "system"}}function It(t={}){let e$1=new Hono;e$1.onError((r,a)=>r instanceof z$1?a.html(rt(r.message),503):(console.error(r),a.text("Internal Server Error",500))),e$1.use(async(r,a)=>{let n=St(r);if(n)return r.text(n,403);await a();}),e$1.get("/static/*",r=>{let a=decodeURIComponent(r.req.path.slice(8)),n=join(Q,a);if(!n.startsWith(Q))return r.notFound();try{let i=readFileSync(n);return new Response(new Uint8Array(i),{headers:{"content-type":kt[extname(n)]??"application/octet-stream","cache-control":"no-cache"}})}catch{return r.notFound()}}),e$1.get("/ping",r=>{let a$1=null;try{a$1=E(n=>{let i=A(n);return i?{...i,message:y(i)}:null});}catch{}return r.json({ok:true,version:a,compat:a$1},200,st)}),e$1.options("/ping",r=>r.body(null,204,st)),e$1.post("/shutdown",r=>(setTimeout(()=>t.onShutdown?.(),50),r.json({ok:true}))),e$1.get("/shutdown",r=>r.text("Method Not Allowed",405)),e$1.get("/",r=>{let{home:a,hasLessons:n}=E(i=>({home:X$1(i).ui_home,hasLessons:G(i)>0}));return r.redirect(Ct(a,n),302)}),e$1.get("/knowledge",r=>{let{profile:a,stats:n,rateLimit:i,settings:s}=E(p=>({profile:Fa(p),stats:Ia(p),rateLimit:Ea(p),settings:X$1(p)})),c=new Map;for(let p of a.groups)for(let m of p.topics)c.set(m,p.name);let u={};for(let p of a.groups)u[p.name]=[];for(let p of a.knowledge){let m=c.get(p.topic)??"Other",v=u[m]??[];v.push(p),u[m]=v;}return r.html(We({categorised:u,allGroups:a.groups.map(p=>p.name),stats:n,rateLimit:i,maxPerDay:s.max_per_day,uiTheme:s.ui_theme}))}),e$1.post("/knowledge",async r=>{let a=await r.req.parseBody(),n=b(a,"topic").trim();if(n){let i=Number.parseInt(b(a,"confidence","5"),10)||5,s=b(a,"group").trim();E(c=>{R$1(c,n,i),s&&s!=="Other"&&V$1(c,n,s);});}return r.redirect("/knowledge",303)}),e$1.post("/knowledge/:topic/delete",r=>(E(a=>S(a,r.req.param("topic"))),r.redirect("/knowledge",303))),e$1.post("/knowledge/:topic/group",async r=>{let a=b(await r.req.parseBody(),"group").trim(),n=r.req.param("topic");return E(i=>{a&&a!=="Other"?V$1(i,n,a):W$1(i,n);}),r.redirect("/knowledge",303)}),e$1.post("/knowledge/:topic",async r=>{let a=Number.parseInt(b(await r.req.parseBody(),"delta","0"),10)||0;return E(n=>Ga(n,r.req.param("topic"),a)),r.redirect("/knowledge",303)}),e$1.post("/groups",async r=>{let a=b(await r.req.parseBody(),"group_name").trim();return a&&a!=="Other"&&E(n=>T(n,a)),r.redirect("/knowledge",303)}),e$1.post("/groups/:group_name/delete",r=>(E(a=>U$1(a,r.req.param("group_name"))),r.redirect("/knowledge",303))),e$1.get("/lessons/export",()=>{let r=E(a=>L(a));return new Response(JSON.stringify(r,null,2),{headers:{"content-type":"application/json","content-disposition":"attachment; filename=devcoach-lessons.json"}})}),e$1.post("/lessons/import",async r=>{let a=await r.req.parseBody(),n=b(a,"from")==="lessons",i=()=>r.redirect(n?"/lessons?import=1&error=invalid":"/settings?imported=0&skipped=0&invalid=1",303),s=a.file,u=(s instanceof File&&s.size>0?await s.text():null)??b(a,"text").trim();try{p(u)&&!u.includes("#devcoach:lesson:")&&(u=await q(u));let p$1=E(m=>Ja(m,u));return p$1.kind==="lessons"||!p$1.lesson?r.redirect(`/settings?imported=${p$1.inserted}&skipped=${p$1.duplicated}&invalid=${p$1.invalid}`,303):r.redirect(`/lessons/${encodeURIComponent(p$1.lesson.id)}?imported=${p$1.inserted?"1":"dup"}`,303)}catch(p){if(p instanceof ra)return i();throw p}}),e$1.get("/lessons/import",r=>{let a=(r.req.query("code")??"").trim(),n=null,i=null;if(a)try{n=va(a);}catch(s){i=s instanceof ra?s.message:"That code could not be read.";}return r.html(Xe({code:a,preview:n,error:i,uiTheme:Tt()}))}),e$1.get("/lessons",r=>{let a=r.req.query(),n=new Set(["junior","mid","senior"]),i=a.level&&n.has(a.level)?a.level:"",s=a.date_from||"",c=a.date_to||"",u=a.starred==="1",p=a.imported==="1"?"1":a.imported==="0"?"0":"",m=a.shared_by||null,v=a.sort||"timestamp",T=a.order==="asc"?"asc":"desc",P$1=Math.max(1,Number.parseInt(a.page??"1",10)||1),E$1=a.period||"all",l={period:s||c?null:E$1!=="all"?E$1:null,category:a.category||null,level:i||null,project:a.project||null,repository:a.repository||null,branch:a.branch||null,commit:a.commit||null,starred:u?true:null,imported:m||p==="1"?true:p==="0"?false:null,shared_by:m,search:a.search||null,feedback:a.feedback||null,date_from:s||null,date_to:c||null},x=E(k=>{let te=G(k,l),re=Math.max(1,Math.ceil(te/W));return P$1=Math.min(P$1,re),{total:te,totalPages:re,lessons:H(k,{...l,sort:v,order:T,page:P$1,per_page:W}),allCategories:P(k),allProjects:M(k,"project"),allRepositories:M(k,"repository"),allBranches:M(k,"branch"),allCommits:M(k,"commit_hash"),allSharedBy:N(k),theme:X$1(k).ui_theme}}),$={period:E$1,category:a.category||"",level:i,project:a.project||"",repository:a.repository||"",branch:a.branch||"",commit:a.commit||"",starred:u,imported:m?"1":p,shared_by:m??"",search:a.search||"",feedback:a.feedback||"",date_from:s,date_to:c,sort:v,order:T},_=a.error==="invalid"?"invalid":null;return r.html(Ze({importOpen:a.import==="1",importError:_,lessons:x.lessons,allCategories:x.allCategories,allProjects:x.allProjects,allRepositories:x.allRepositories,allBranches:x.allBranches,allCommits:x.allCommits,allSharedBy:x.allSharedBy,s:$,page:P$1,perPage:W,total:x.total,totalPages:x.totalPages,uiTheme:x.theme}))}),e$1.post("/lessons/:lesson_id/star",async r=>{let a=await r.req.parseBody();return E(n=>K$1(n,r.req.param("lesson_id"),a.starred==="1")),r.redirect(U(b(a,"next")||void 0),303)}),e$1.post("/lessons/:lesson_id/feedback",async r=>{let a=await r.req.parseBody(),n=b(a,"feedback");if(!["","clear","know","understood","dont_know"].includes(n))return r.text("Unknown feedback value",400);let i=n===""||n==="clear"?null:n;return E(s=>Ha(s,r.req.param("lesson_id"),i)),r.redirect(U(b(a,"next")||void 0),303)}),e$1.post("/lessons/delete",async r=>{let a=await r.req.parseBody({all:true}),n=a.id,i=(Array.isArray(n)?n:[n]).filter(s=>typeof s=="string"&&s!=="");return E(s=>J$1(s,i)),r.redirect(U(b(a,"next")||void 0),303)}),e$1.on(["GET","POST"],"/lessons/:lesson_id/share",async r=>{if(dt(r))return r.text("Forbidden",403);let a,n,i=false;if(r.req.method==="POST"){let m=await r.req.parseBody();a=b(m,"name"),n=b(m,"include_context")==="1",i=b(m,"persist")==="1";}else a=r.req.query("name"),n=r.req.query("include_context")==="1";let s=E(m=>{let v=O(m,r.req.param("lesson_id")??"");return v?(i&&a!==void 0&&Y$1(m,"share_name",w(a)),{lesson:v,settingName:X$1(m).share_name}):null});if(!s)return r.text("Lesson not found",404);let{state:c,payload:u}=nt(s.lesson,s.settingName,{name:a,includeContext:n}),p=r.req.query("format");return p==="text"?r.text(c.text):p==="link"?r.text(c.link):p==="md"?new Response(Aa(u),{headers:{"content-type":"text/markdown; charset=utf-8","content-disposition":`attachment; filename="${za(u)}"`}}):p==="panel"?r.html(V(s.lesson.id,c,s.lesson.title)):r.html(J(c))}),e$1.get("/lessons/:lesson_id",r=>{let a=E(s=>{let c=O(s,r.req.param("lesson_id"));if(!c)return null;let u=X$1(s),p=h$1(s,{lesson_id:c.id})[0],m$1=p?{id:p.id,title:p.title,status:p.status,...m(p)}:null;return {lesson:c,course:m$1,settingName:u.share_name,uiTheme:u.ui_theme}});if(!a)return r.html("<h1>Lesson not found</h1>",404);let n=r.req.query(),i=n.imported==="1"?"new":n.imported==="dup"?"dup":null;return r.html(Qe({lesson:a.lesson,uiTheme:a.uiTheme,share:nt(a.lesson,a.settingName,{open:n.share==="1"}).state,imported:i,course:a.course}))});let g$1={"content-type":"text/html; charset=utf-8","content-security-policy":"sandbox allow-scripts allow-forms; default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data:; font-src data:; form-action 'none'; base-uri 'none'; frame-ancestors 'self'","referrer-policy":"no-referrer","x-content-type-options":"nosniff","cache-control":"no-cache"},d=(()=>{try{return `
|
|
866
|
+
<script>${readFileSync(join(Q,"course-frame.js"),"utf8")}</script>
|
|
867
|
+
`}catch{return ""}})();return e$1.get("/courses",r=>{let a=E(n=>({courses:h$1(n).map(i=>({...i,lesson_title:i.lesson_id?O(n,i.lesson_id)?.title??null:null})),uiTheme:X$1(n).ui_theme}));return r.html(tt(a))}),e$1.get("/courses/:course_id/index.html",r=>{let a=r.req.param("course_id");if(!a$1.test(a))return r.notFound();let n=e(a);if(!n)return r.notFound();try{let i=readFileSync(n),s=i.toString("utf8"),c$1=!b$1(s)&&c(s)?`
|
|
868
|
+
${a$2()??""}`:"",u=Buffer.concat([i,Buffer.from(d+c$1)]);return new Response(new Uint8Array(u),{headers:new Headers(g$1)})}catch{return r.notFound()}}),e$1.get("/courses/:course_id",r=>{let a=r.req.param("course_id"),n=E(c=>{let u=g(c,a);return u?{course:u,lessonTitle:u.lesson_id?O(c,u.lesson_id)?.title??null:null,uiTheme:X$1(c).ui_theme}:null});if(!n)return r.html("<h1>Course not found</h1>",404);let i=n.course.steps.find(c=>c.status==="todo")?.position??1,s=Number.parseInt(r.req.query("step")??"",10)||i;return r.html(at({...n,selected:s,hasDocument:e(a)!==null}))}),e$1.post("/courses/:course_id/steps/:position",async r=>{let a=await r.req.parseBody(),n=b(a,"status");if(!["todo","done","skipped"].includes(n))return r.text("Unknown status",400);let i=Number.parseInt(r.req.param("position"),10),s=r.req.param("course_id");return E(u=>Number.isFinite(i)?j$1(u,s,i,n):null)?r.redirect(U(b(a,"next")||void 0,`/courses/${encodeURIComponent(s)}`),303):r.text("Step not found",404)}),e$1.post("/courses/delete",async r=>{let a=await r.req.parseBody();return E(n=>l(n,b(a,"id"))),r.redirect("/courses",303)}),e$1.get("/settings/export",()=>{let r=E(a=>oa(a));return new Response(new Uint8Array(r),{headers:{"content-type":"application/zip","content-disposition":"attachment; filename=devcoach-backup.zip"}})}),e$1.post("/settings/import",async r=>{let a=(await r.req.parseBody()).file;if(!(a instanceof File))return r.redirect("/settings?imported=0&skipped=0&invalid=1",303);let n=new Uint8Array(await a.arrayBuffer()),i=E(s=>qa(s,n));return r.redirect(`/settings?imported=${i.lessons}&skipped=${i.skipped}&invalid=${i.invalid}&groups=${i.groups}¬ebook=${i.learning_state}`,303)}),e$1.get("/settings/notebook/download",()=>{let r$1=existsSync(r)?readFileSync(r,"utf8"):"";return new Response(r$1,{headers:{"content-type":"text/markdown","content-disposition":"attachment; filename=devcoach-notebook.md"}})}),e$1.post("/settings/notebook",async r$1=>{let a=await r$1.req.parseBody();return mkdirSync(dirname(r),{recursive:true}),writeFileSync(r,b(a,"content"),"utf8"),r$1.redirect(U(b(a,"next")||void 0,"/settings?notebook_saved=1"),303)}),e$1.post("/settings",async r=>{let a=await r.req.parseBody(),n=Number.parseInt(b(a,"max_per_day","2"),10)||2,i=Number.parseInt(b(a,"min_gap_minutes","240"),10),s=b(a,"ui_theme","system");["system","dark","light"].includes(s)||(s="system");let c=b(a,"ui_home","auto");["auto","lessons","knowledge"].includes(c)||(c="auto");let u=Math.max(0,Number.parseInt(b(a,"nudge_every","10"),10)||0),p=b(a,"nudge_scope","session");return p!=="session"&&p!=="global"&&(p="session"),E(m=>{Y$1(m,"max_per_day",String(n)),Y$1(m,"min_gap_minutes",String(Number.isNaN(i)?240:i)),Y$1(m,"ui_theme",s),Y$1(m,"ui_home",c),Y$1(m,"nudge_every",String(u)),Y$1(m,"nudge_scope",p),Y$1(m,"share_name",w(b(a,"share_name")));}),r.redirect("/settings",303)}),e$1.get("/settings",r$1=>{let a=E(c=>X$1(c)),n=existsSync(r)?readFileSync(r,"utf8"):"",i=r$1.req.query(),s=i.imported!==void 0?{imported:Number(i.imported??0),skipped:Number(i.skipped??0),invalid:Number(i.invalid??0),groups:Number(i.groups??0),notebook:Number(i.notebook??0)}:null;return r$1.html(ot({settings:a,notebookContent:n,notebookPath:r,uiTheme:a.ui_theme,flash:s}))}),e$1}function jt(t,e=2e3){let g=t;return new Promise(d=>{let r=setTimeout(()=>{g.closeAllConnections?.();},e),a=setInterval(()=>g.closeIdleConnections?.(),100);t.close(()=>{clearTimeout(r),clearInterval(a),d();}),g.closeIdleConnections?.();})}async function Rt(t,e=fetch){try{let g=await e(`http://127.0.0.1:${t}/ping`,{signal:AbortSignal.timeout(1500)});if(!g.ok)return null;let d=await g.json();return d.ok===!0?{version:String(d.version??"")}:null}catch{return null}}async function Pt(t,e,g=Rt){if(e.code==="EADDRINUSE"){let d=await g(t);if(d){let r=`http://localhost:${t}`,a=d.version?` (v${d.version})`:"";return {existingUrl:r,exitCode:0,message:`${a$3.yellow("devcoach UI is already running at")} ${a$3.cyan(e$1(r))}${a}
|
|
869
|
+
${a$3.dim("Open it there, start another with --port <n>, or stop it with: devcoach ui --stop")}`}}return {exitCode:1,message:`${a$3.red(`\u2717 Port ${t} is already in use by another process`)}
|
|
870
|
+
${a$3.dim("Pick another port: devcoach ui --port <n>")}`}}return e.code==="EACCES"?{exitCode:1,message:a$3.red(`\u2717 Port ${t} is not allowed (permission denied) \u2014 use a port \u2265 1024`)}:{exitCode:1,message:a$3.red(`\u2717 Could not start the devcoach UI on port ${t}: ${e.message}`)}}function Vt(t,e={}){let g=false,d=(s,c)=>{if(g){c&&process.exit(130);return}g=true,process.stdout.isTTY&&console.log(a$3.dim(`devcoach UI stopping (${s})\u2026`)),jt(a).then(()=>{c&&process.exit(0);});},r=It({onShutdown:()=>d("stop requested",false)}),a=serve({fetch:r.fetch,port:t,hostname:"127.0.0.1"},s=>{let c=`http://localhost:${s.port}`;console.log(`devcoach UI running at ${a$3.cyan(e$1(c))}`),process.stdout.isTTY&&console.log(a$3.dim("Press Ctrl+C to stop")),e.onReady?.(c);}),n=["SIGINT","SIGTERM","SIGHUP"],i={SIGINT:()=>d("SIGINT",true),SIGTERM:()=>d("SIGTERM",true),SIGHUP:()=>d("SIGHUP",true)};if(e.handleSignals!==false)for(let s of n)process.on(s,i[s]);return a.once("error",s=>{for(let c of n)process.off(c,i[c]);Pt(t,s).then(c=>{if(e.onListenError){e.onListenError(c);return}console.error(c.message),process.exit(c.exitCode);});}),a}async function Wt(t,e=fetch){try{return (await e(`http://127.0.0.1:${t}/shutdown`,{method:"POST",signal:AbortSignal.timeout(3e3)})).ok}catch{return false}}
|
|
871
|
+
export{It as createApp,Pt as explainListenError,jt as gracefulShutdown,Rt as pingUi,Ct as resolveHomePath,Vt as startUi,Wt as stopUi};
|