Spaces:
Running
Running
Download Protokoll/api/list_md.php from GermanDarkDEV/lndwrtshft: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/GermanDarkDEV/lndwrtshft/resolve/main/Protokoll/api/list_md.php
- Command line
-
hf download hf://spaces/GermanDarkDEV/lndwrtshft/Protokoll/api/list_md.php
-
curl -L -o list_md.php https://huggingface.co/spaces/GermanDarkDEV/lndwrtshft/resolve/main/Protokoll/api/list_md.php
1.27 kB
| // Listet alle .md Dateien im Ordner Protokoll/ | |
| declare(strict_types=1); | |
| header('Content-Type: application/json; charset=utf-8'); | |
| $dir = realpath(dirname(__DIR__)); | |
| if ($dir === false) { | |
| http_response_code(500); | |
| echo json_encode(['status' => 'error', 'error' => 'Pfadfehler']); | |
| exit; | |
| } | |
| $files = []; | |
| $dh = opendir($dir); | |
| if ($dh) { | |
| while (($f = readdir($dh)) !== false) { | |
| if ($f === '.' || $f === '..') continue; | |
| if (preg_match('/\.md$/i', $f)) { | |
| $files[] = [ 'name' => $f, 'path' => './' . $f ]; | |
| } | |
| } | |
| closedir($dh); | |
| } | |
| // Sortierung: bekannte Kern-Dateien zuerst, dann alphabetisch | |
| $priority = [ | |
| 'PROJEKTBESCHREIBUNG.md', | |
| 'REGELN.md', | |
| 'ARCHITEKTUR.md', | |
| 'WEBLINKS.md', | |
| 'OFFENEAUFGABEN.md', | |
| 'FERTIGEAUFGABEN.md', | |
| 'DEVNOTIZEN.md', | |
| ]; | |
| usort($files, function($a, $b) use ($priority) { | |
| $ai = array_search($a['name'], $priority, true); | |
| $bi = array_search($b['name'], $priority, true); | |
| $aw = $ai === false ? PHP_INT_MAX : $ai; | |
| $bw = $bi === false ? PHP_INT_MAX : $bi; | |
| if ($aw === $bw) return strcmp($a['name'], $b['name']); | |
| return $aw <=> $bw; | |
| }); | |
| echo json_encode([ 'status' => 'ok', 'files' => $files ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | |