added description to all projekt

This commit is contained in:
2026-11-12 19:50:38 +01:00
parent 3f5438cb92
commit 7824ddb6dc
5 changed files with 110 additions and 4 deletions

View File

@@ -992,6 +992,7 @@ function matchesSearch(p) {
if (!term) return true
return p.name.toLowerCase().includes(term) ||
p.notes.toLowerCase().includes(term) ||
(p.description ?? '').toLowerCase().includes(term) ||
(p.tags ?? []).some((t) => t.toLowerCase().includes(term)) ||
(p.tech?.types ?? []).some((t) => t.toLowerCase().includes(term))
}
@@ -1969,8 +1970,29 @@ function renderInfo(name, d) {
<div class="hint">${genDir ? 'Mit ComfyGen erzeugen (Prompt „icon“ in prompts.py eintragen):' : 'Generator-Vorlage aus _Tools\\ComfyGen\\template kopieren, dann:'}</div>
<code class="cmd">cd "${escapeHtml(d.path)}\\${escapeHtml(genDir ? genDir.rel : 'sprite-generator')}" &amp;&amp; gen generate icon &amp;&amp; gen adopt icon</code>`
// description: own text (.dashboard.json), else the README's intro as a suggestion
const desc = p.description ?? ''
const descBody = desc
? `<div class="pdesc">${escapeHtml(desc)}</div>`
: d.readme
? `<div class="pdesc muted">${escapeHtml(d.readme)}</div>
<div class="hint">${ic('file-text', 'sm')} Aus der README – noch keine eigene Beschreibung.
<button class="btn ghost" type="button" id="btnDescTake">${ic('check', 'sm')}Übernehmen</button></div>`
: '<div class="hint" style="margin-top:0">Noch keine Beschreibung. Kurz notieren, was das für ein Projekt ist.</div>'
const descEdit = `<div class="pdesc-edit" hidden>
<textarea id="fDesc" rows="6" maxlength="4000" placeholder="Was ist das für ein Projekt? Idee, Stand, Besonderheiten …"></textarea>
<div class="actgroup" style="margin-top:8px">
<button class="btn primary" type="button" id="btnDescSave">${ic('check')}Speichern</button>
<button class="btn" type="button" id="btnDescCancel">Abbrechen</button>
${d.readme ? `<button class="btn ghost" type="button" id="btnDescReadme" title="Text aus der README einsetzen">${ic('file-text')}aus README</button>` : ''}
<span class="hint" style="margin:0 0 0 auto">Strg+Enter speichert</span>
</div>
</div>`
const el = document.getElementById('sec-info')
el.innerHTML =
section('notebook-text', 'Beschreibung', `<div class="pdesc-view">${descBody}</div>${descEdit}`,
{ id: 'info-desc', right: `<a href="#" class="jump" id="btnDescEdit">${ic('pencil', 'sm')}${desc ? 'Ändern' : 'Schreiben'}</a>` }) +
section('info', 'Übersicht', overview, { right: del >= 1 ? jumpLink('act-clean', 'Aufräumen') : '' }) +
section('git-branch', 'Git', gitBody, { right: jumpLink('act-git', g.isRepo ? 'Push &amp; Remote' : 'Einrichten') }) +
(name === '_Tools' ? '' : section('rocket', 'itch.io', itchBody, { right: jumpLink('act-itch', ip.exists ? 'Ansehen' : 'Erzeugen') })) +
@@ -1980,9 +2002,48 @@ function renderInfo(name, d) {
section('wand-sparkles', 'Generator', genBody) +
section('image', 'App-Icon', iconBody)
bindJumps(el)
bindDescription(name, d, el)
loadProjectActivity(name)
}
function bindDescription(name, d, el) {
const view = el.querySelector('.pdesc-view')
const edit = el.querySelector('.pdesc-edit')
const ta = document.getElementById('fDesc')
const link = document.getElementById('btnDescEdit')
const open = (text) => {
ta.value = text
view.hidden = true
edit.hidden = false
link.style.visibility = 'hidden'
ta.focus()
}
const close = () => { view.hidden = false; edit.hidden = true; link.style.visibility = '' }
const save = async (text) => {
try {
const res = await fetch(`/api/projects/${encodeURIComponent(name)}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ description: text }),
})
const r = await res.json().catch(() => ({}))
if (!res.ok) throw new Error(r.error ?? 'Speichern fehlgeschlagen')
for (const p of [editing, projects.find((x) => x.name === name)]) if (p) p.description = r.description
toast(r.description ? 'Beschreibung gespeichert' : 'Beschreibung entfernt', 'notebook-text')
if (editing?.name === name) renderInfo(name, d)
} catch (e) { toast(e.message, 'triangle-alert') }
}
link.onclick = (e) => { e.preventDefault(); open(editing?.description || '') }
document.getElementById('btnDescTake')?.addEventListener('click', () => save(d.readme))
document.getElementById('btnDescReadme')?.addEventListener('click', () => { ta.value = ta.value.trim() ? `${ta.value.trim()}\n\n${d.readme}` : d.readme; ta.focus() })
document.getElementById('btnDescCancel').onclick = close
document.getElementById('btnDescSave').onclick = () => save(ta.value)
ta.onkeydown = (e) => {
if (e.key === 'Enter' && e.ctrlKey) { e.preventDefault(); save(ta.value) }
if (e.key === 'Escape') { e.stopPropagation(); close() }
}
}
/* Aktionen tab: everything that does something, grouped */
function gitActionsHtml(name, d) {
const g = d.git