Spaces:
Paused
Paused
Polish history cards and hide empty file box
Browse files
app.py
CHANGED
|
@@ -244,12 +244,11 @@ def verlauf_laden():
|
|
| 244 |
lokal = hf_hub_download(DATEN_REPO, f, repo_type="dataset", token=HF_TOKEN)
|
| 245 |
with open(lokal, encoding="utf-8") as fh:
|
| 246 |
fm, _ = _frontmatter(fh.read())
|
| 247 |
-
datum = str(fm.get("datum", ""))[:16].replace("T", " ")
|
| 248 |
titel = fm.get("titel", f)
|
| 249 |
karten += (f'<div class="sa-card"><div class="sa-card-title">{titel}</div>'
|
| 250 |
-
f'<div class="sa-card-meta">
|
| 251 |
-
f'👥 {fm.get("sprecher", "?")}
|
| 252 |
-
f'🕒 {_zeit(fm.get("dauer_s", 0))} min</div></div>')
|
| 253 |
auswahl.append((f"{titel}", f))
|
| 254 |
if not karten:
|
| 255 |
karten = '<div class="sa-card">Noch keine Aufzeichnungen.</div>'
|
|
@@ -258,14 +257,14 @@ def verlauf_laden():
|
|
| 258 |
|
| 259 |
def eintrag_anzeigen(pfad):
|
| 260 |
if not pfad:
|
| 261 |
-
return "", None
|
| 262 |
lokal = hf_hub_download(DATEN_REPO, pfad, repo_type="dataset", token=HF_TOKEN)
|
| 263 |
with open(lokal, encoding="utf-8") as fh:
|
| 264 |
text = fh.read()
|
| 265 |
fm, body = _frontmatter(text)
|
| 266 |
vorschau = (f"```yaml\n{yaml.safe_dump(fm, allow_unicode=True, sort_keys=False).strip()}\n```\n"
|
| 267 |
+ body)
|
| 268 |
-
return vorschau, lokal
|
| 269 |
|
| 270 |
|
| 271 |
CSS = """
|
|
@@ -305,7 +304,8 @@ button.primary {width: 100%; min-height: 52px; font-size: 1.05rem;
|
|
| 305 |
.sa-card {padding: 12px 14px; border-radius: 12px;
|
| 306 |
background: rgba(128,128,128,.08); margin: 8px 0}
|
| 307 |
.sa-card-title {font-weight: 600}
|
| 308 |
-
.sa-card-meta {font-size: .85rem; opacity: .7; margin-top: 2px
|
|
|
|
| 309 |
|
| 310 |
@media (max-width: 640px) {
|
| 311 |
.gradio-container {padding: 8px !important}
|
|
@@ -331,7 +331,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Sprecher-Analyse", css=CSS) as dem
|
|
| 331 |
eintrag = gr.Dropdown(label="Eintrag öffnen", choices=[],
|
| 332 |
interactive=True)
|
| 333 |
vorschau = gr.Markdown()
|
| 334 |
-
datei = gr.File(label="Markdown-Datei")
|
| 335 |
|
| 336 |
start.click(analysieren, [audio, num_speakers], [ergebnis, status]) \
|
| 337 |
.then(verlauf_laden, None, [verlauf_html, eintrag])
|
|
|
|
| 244 |
lokal = hf_hub_download(DATEN_REPO, f, repo_type="dataset", token=HF_TOKEN)
|
| 245 |
with open(lokal, encoding="utf-8") as fh:
|
| 246 |
fm, _ = _frontmatter(fh.read())
|
|
|
|
| 247 |
titel = fm.get("titel", f)
|
| 248 |
karten += (f'<div class="sa-card"><div class="sa-card-title">{titel}</div>'
|
| 249 |
+
f'<div class="sa-card-meta">'
|
| 250 |
+
f'<span>👥 {fm.get("sprecher", "?")} Sprecher</span>'
|
| 251 |
+
f'<span>🕒 {_zeit(fm.get("dauer_s", 0))} min</span></div></div>')
|
| 252 |
auswahl.append((f"{titel}", f))
|
| 253 |
if not karten:
|
| 254 |
karten = '<div class="sa-card">Noch keine Aufzeichnungen.</div>'
|
|
|
|
| 257 |
|
| 258 |
def eintrag_anzeigen(pfad):
|
| 259 |
if not pfad:
|
| 260 |
+
return "", gr.update(value=None, visible=False)
|
| 261 |
lokal = hf_hub_download(DATEN_REPO, pfad, repo_type="dataset", token=HF_TOKEN)
|
| 262 |
with open(lokal, encoding="utf-8") as fh:
|
| 263 |
text = fh.read()
|
| 264 |
fm, body = _frontmatter(text)
|
| 265 |
vorschau = (f"```yaml\n{yaml.safe_dump(fm, allow_unicode=True, sort_keys=False).strip()}\n```\n"
|
| 266 |
+ body)
|
| 267 |
+
return vorschau, gr.update(value=lokal, visible=True)
|
| 268 |
|
| 269 |
|
| 270 |
CSS = """
|
|
|
|
| 304 |
.sa-card {padding: 12px 14px; border-radius: 12px;
|
| 305 |
background: rgba(128,128,128,.08); margin: 8px 0}
|
| 306 |
.sa-card-title {font-weight: 600}
|
| 307 |
+
.sa-card-meta {font-size: .85rem; opacity: .7; margin-top: 2px;
|
| 308 |
+
display: flex; gap: 14px; flex-wrap: wrap}
|
| 309 |
|
| 310 |
@media (max-width: 640px) {
|
| 311 |
.gradio-container {padding: 8px !important}
|
|
|
|
| 331 |
eintrag = gr.Dropdown(label="Eintrag öffnen", choices=[],
|
| 332 |
interactive=True)
|
| 333 |
vorschau = gr.Markdown()
|
| 334 |
+
datei = gr.File(label="Markdown-Datei", visible=False)
|
| 335 |
|
| 336 |
start.click(analysieren, [audio, num_speakers], [ergebnis, status]) \
|
| 337 |
.then(verlauf_laden, None, [verlauf_html, eintrag])
|