Add script to list album photos with original filename, add macro for single photo with caption

This commit is contained in:
2016-01-13 12:11:24 +00:00
parent 6c5141eb4f
commit c3c955d739
36 changed files with 87 additions and 57 deletions

View File

@@ -0,0 +1,20 @@
<?php
require __DIR__ . '/../_php/autoload.php';
use Symfony\Component\Yaml\Yaml;
foreach (glob('gallery/*') as $sAlbumPath) {
if (!is_dir($sAlbumPath)) continue;
$sAlbum = basename($sAlbumPath);
foreach (glob($sAlbumPath . '/*.md') as $sFile) {
$sPhoto = basename($sFile);
$sContents = file_get_contents($sFile);
$aContents = explode("\n", $sContents);
$aParts = explode('--', implode("\n", array_slice($aContents, 1)));
$aYaml = Yaml::parse(trim(str_replace(" - \n", null, current($aParts))));
if (isset($aYaml['file'])) {
$sOriginal = basename($aYaml['file'], '.JPG');
printf("[%s] %s = %s\n", $sAlbum, $sPhoto, $sOriginal);
}
}
}