mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 08:09:18 +02:00
Export: add LINK.txt with PeerTube watch URLs to file ZIP export
This commit is contained in:
6
TODO.md
6
TODO.md
@@ -242,6 +242,12 @@
|
|||||||
- [x] Add `storage/tmp/filepond/*` to .gitignore + rsync exclude, with .gitkeep
|
- [x] Add `storage/tmp/filepond/*` to .gitignore + rsync exclude, with .gitkeep
|
||||||
- [ ] Deploy: `just deploy` to sync vendor JS files + updated CSP + .gitkeep to server
|
- [ ] Deploy: `just deploy` to sync vendor JS files + updated CSP + .gitkeep to server
|
||||||
|
|
||||||
|
## Export: LINK.txt for PeerTube files
|
||||||
|
- [x] Add `getPeerTubeInstanceUrl()` helper to ExportController
|
||||||
|
- [x] In `createExportZip()`: collect PeerTube files, generate LINK.txt per thesis directory
|
||||||
|
- [x] Augment manifest.json with `peertube_links` array per thesis
|
||||||
|
- [x] Update docs/export.md with LINK.txt and peertube_links documentation
|
||||||
|
|
||||||
# improvements_postlaunch — Année verrouillable dans partage + correction ID
|
# improvements_postlaunch — Année verrouillable dans partage + correction ID
|
||||||
|
|
||||||
## Implémentation
|
## Implémentation
|
||||||
|
|||||||
@@ -53,6 +53,16 @@ class ExportController
|
|||||||
return $this->db->getAllThesisFilesForExport($thesisIds);
|
return $this->db->getAllThesisFilesForExport($thesisIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the configured PeerTube instance URL, or empty string if not configured.
|
||||||
|
*/
|
||||||
|
private function getPeerTubeInstanceUrl(): string
|
||||||
|
{
|
||||||
|
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||||
|
$settings = PeerTubeService::getSettings($this->db);
|
||||||
|
return $settings['instance_url'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a JSON manifest describing every thesis and its files.
|
* Build a JSON manifest describing every thesis and its files.
|
||||||
*
|
*
|
||||||
@@ -153,17 +163,72 @@ class ExportController
|
|||||||
// Add every thesis file under files/
|
// Add every thesis file under files/
|
||||||
$addedCount = 0;
|
$addedCount = 0;
|
||||||
$skippedCount = 0;
|
$skippedCount = 0;
|
||||||
|
$peertubeLinks = []; // thesisId => [{uuid, watchUrl, fileType, label}]
|
||||||
|
$ptInstanceUrl = '';
|
||||||
foreach ($files as $f) {
|
foreach ($files as $f) {
|
||||||
$fullPath = $storageRoot . '/' . $f['file_path'];
|
$filePath = $f['file_path'];
|
||||||
|
|
||||||
|
// Collect PeerTube links per-thesis
|
||||||
|
if (str_starts_with($filePath, 'peertube_ids:')) {
|
||||||
|
$uuid = substr($filePath, strlen('peertube_ids:'));
|
||||||
|
if ($ptInstanceUrl === '') {
|
||||||
|
$ptInstanceUrl = $this->getPeerTubeInstanceUrl();
|
||||||
|
}
|
||||||
|
$tid = (int) $f['thesis_id'];
|
||||||
|
$peertubeLinks[$tid] = $peertubeLinks[$tid] ?? ['dirname' => '', 'links' => []];
|
||||||
|
$peertubeLinks[$tid]['links'][] = [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'url' => $ptInstanceUrl !== '' ? rtrim($ptInstanceUrl, '/') . '/videos/watch/' . $uuid : '',
|
||||||
|
'type' => $f['file_type'],
|
||||||
|
'label' => $f['display_label'] ?? '',
|
||||||
|
'name' => $f['file_name'],
|
||||||
|
];
|
||||||
|
$skippedCount++; // not a real file on disk
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track the directory for each thesis (for LINK.txt placement)
|
||||||
|
$tid = (int) $f['thesis_id'];
|
||||||
|
if (isset($peertubeLinks[$tid]) && $peertubeLinks[$tid]['dirname'] === '') {
|
||||||
|
$peertubeLinks[$tid]['dirname'] = dirname($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fullPath = $storageRoot . '/' . $filePath;
|
||||||
if (!is_file($fullPath) || !is_readable($fullPath)) {
|
if (!is_file($fullPath) || !is_readable($fullPath)) {
|
||||||
$skippedCount++;
|
$skippedCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$zipPath = $baseDir . '/' . $f['file_path'];
|
$zipPath = $baseDir . '/' . $filePath;
|
||||||
$zip->addFile($fullPath, $zipPath);
|
$zip->addFile($fullPath, $zipPath);
|
||||||
$addedCount++;
|
$addedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add LINK.txt in each thesis directory that has PeerTube files
|
||||||
|
foreach ($peertubeLinks as $info) {
|
||||||
|
if ($info['dirname'] === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$txt = "Liens PeerTube pour ce TFE\n"
|
||||||
|
. str_repeat('=', 40) . "\n\n";
|
||||||
|
foreach ($info['links'] as $link) {
|
||||||
|
$label = $link['label'] !== '' ? $link['label'] : $link['name'];
|
||||||
|
$txt .= ($label !== '' ? $label . "\n" : '');
|
||||||
|
$txt .= ($link['url'] !== '' ? $link['url'] . "\n" : '(instance PeerTube non configurée)' . "\n");
|
||||||
|
$txt .= "\n";
|
||||||
|
}
|
||||||
|
$txtPath = $baseDir . '/' . $info['dirname'] . '/LINK.txt';
|
||||||
|
$zip->addFromString($txtPath, $txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Augment manifest with PeerTube link info per thesis
|
||||||
|
foreach ($manifest['theses'] as &$entry) {
|
||||||
|
$tid = $entry['id'];
|
||||||
|
if (isset($peertubeLinks[$tid])) {
|
||||||
|
$entry['peertube_links'] = $peertubeLinks[$tid]['links'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($entry);
|
||||||
|
|
||||||
$zip->addFromString(
|
$zip->addFromString(
|
||||||
'manifest.json',
|
'manifest.json',
|
||||||
json_encode(array_merge($manifest, [
|
json_encode(array_merge($manifest, [
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ xamxam-files-2026-05-07.zip
|
|||||||
│ ├── 2025_LILA_DUBOIS_KARIM_NASSAR/
|
│ ├── 2025_LILA_DUBOIS_KARIM_NASSAR/
|
||||||
│ │ ├── nixing_the_fix_report_final.pdf
|
│ │ ├── nixing_the_fix_report_final.pdf
|
||||||
│ │ ├── bbb_sunflower_1080p_30fps_normal_mp4.zip
|
│ │ ├── bbb_sunflower_1080p_30fps_normal_mp4.zip
|
||||||
│ │ └── carte_loire_a_velo_france.pdf
|
│ │ ├── carte_loire_a_velo_france.pdf
|
||||||
|
│ │ └── LINK.txt ← si vidéos PeerTube présentes
|
||||||
│ └── …
|
│ └── …
|
||||||
└── 2026/
|
└── 2026/
|
||||||
└── …
|
└── …
|
||||||
@@ -69,6 +70,15 @@ xamxam-files-2026-05-07.zip
|
|||||||
"label": "Mémoire principal",
|
"label": "Mémoire principal",
|
||||||
"sort_order": 1
|
"sort_order": 1
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"peertube_links": [
|
||||||
|
{
|
||||||
|
"uuid": "abc123def",
|
||||||
|
"url": "https://videos.erg.be/videos/watch/abc123def",
|
||||||
|
"type": "video",
|
||||||
|
"label": "Vidéo de présentation",
|
||||||
|
"name": "presentation.mp4"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user