Extract common code from scripts, add script to process post links, put links in list in top of post to allow links in excerpts

This commit is contained in:
2016-01-30 16:02:49 +00:00
parent 098debb80d
commit f503e8be6c
3 changed files with 94 additions and 69 deletions

View File

@@ -33,20 +33,15 @@ $oConsole
$sGallery = $oInput->getArgument('name');
$sDir = realpath(rtrim($oInput->getArgument('dir'), '/\\'));
$sAssetPath = $oInput->getArgument('assetdir') . '/' . $sGallery;
$sRenderPath = $oInput->getArgument('mdowndir') . '/' . $sGallery;
$sLayout = $oInput->getOption('layout');
$sExports = $oInput->getOption('export');
$bSkipResize = $oInput->getOption('skip-resize');
$oImagine = new Imagine\Gd\Imagine();
// Initialize directories
// Initialize directory
if (!is_dir($sAssetPath)) {
mkdir($sAssetPath, 0700, true);
}
if (!is_dir($sRenderPath)) {
mkdir($sRenderPath, 0700, true);
}
// Check directory and presence of YAML file
if (!is_dir($sDir)) {
@@ -87,11 +82,6 @@ $oConsole
$aPhoto['id'] .= '-' . preg_replace('/(-| )+/', '-', preg_replace('/[^a-z0-9 ]/i', '-', preg_replace('/\'/', '', strtolower(preg_replace('/\p{Mn}/u', '', Normalizer::normalize($aPhoto['title'], Normalizer::FORM_KD))))));
}
// Check if photo is highlighted
if (empty($sHighlight) && isset($aMeta[$sFile]['highlight'])) {
$sHighlight = $aPhoto['id'];
}
// Parse selected EXIF data
$aPhoto['exif'] = exif_read_data($aPhoto['path']);
if (isset($aPhoto['exif']['GPSLongitude'])) {
@@ -286,21 +276,15 @@ $oConsole
: (($iSurfaceA > $iSurfaceB) ? -1 : 1);
}
);
// Write photo Markdown file
file_put_contents(
$sRenderPath . '/' . $aPhoto['id'] . '.md',
'---' . "\n" . yamlDump($aMatter) . '---' . "\n" . (empty($aPhoto['comment']) ? '' : $aPhoto['comment'] . "\n")
);
// yamlDump($aMatter)
$oOutput->writeln(' done');
}
// Write gallery index
// Write datafile
$oOutput->write('<comment>index</comment>');
$aMatter = [
'layout' => 'gallery-list',
'title' => empty($aGallery['title']) ? '' : $aGallery['title'],
'highlight_photo' => empty($sHighlight) ? $aPhotos[0]['id'] : $sHighlight,
'date' => $oDate->format('Y-m-d')
];
$bSlideshow = isset($aGallery['slideshow']) ? $aGallery['slideshow'] : true;
@@ -320,13 +304,8 @@ $oConsole
if ($oDate->diff($oEndDate)->d > 0) {
$aMatter['end_date'] = $oEndDate->format('Y-m-d');
}
$sContents = empty($aGallery['description']) ? '' : $aGallery['description'];
file_put_contents(
$sRenderPath . '/index.html',
'---' . "\n" . yamlDump($aMatter) . '---' . "\n" . $sContents
);
$oOutput->writeln(' done');
// yamlDump($aMatter)
}
);