Expand gallery functionality to automatic generation of index, slideshow and map files
This commit is contained in:
23
_scripts/generate-gallery-yaml.php
Normal file
23
_scripts/generate-gallery-yaml.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
writeMetaYaml($argv[1]);
|
||||
|
||||
function writeMetaYaml($sDir) {
|
||||
$sDir = rtrim($sDir, '"\'/\\');
|
||||
$aMeta = [
|
||||
'gallery' => ['name' => '', 'title' => '', 'description' => ''],
|
||||
'files' => null
|
||||
];
|
||||
if (!is_dir($sDir)) {
|
||||
die('Directory does not exist');
|
||||
}
|
||||
$aFiles = glob($sDir . '/*.jpg');
|
||||
foreach ($aFiles as $sFile) {
|
||||
$aMeta['files'][basename($sFile)] = ['title' => '', 'comment' => ''];
|
||||
}
|
||||
$sYaml = str_replace("''", null, Yaml::dump($aMeta, 4, 2));
|
||||
file_put_contents($sDir . '/meta.yaml', $sYaml);
|
||||
}
|
||||
Reference in New Issue
Block a user