diff --git a/mkht.php b/mkht.php index 2b6f61c..c856988 100755 --- a/mkht.php +++ b/mkht.php @@ -94,12 +94,6 @@ foreach($nodes_cache as $node) { $path_parts_src = pathinfo($src); $path_parts_target = pathinfo($target); - if (preg_match('#/\.(?!htaccess|well-known)#', $src) !== 0) // Skip hidden nodes other than .htaccess and .well-known - continue; - if ($node_info->getType() !== 'file') - continue; - if (in_array('draft', explode('.', $path_parts_target['basename']), true)) - continue; if (!file_exists($path_parts_target['dirname'])) // Create parent directory if needed mkdir($path_parts_target['dirname'], 0755, true); copy($src, $target); @@ -125,17 +119,24 @@ foreach ($pages as $node) { $target = str_replace(SITE . 'cache/', SITE . 'target/', $src); $path_parts_src = pathinfo($src); $path_parts_target = pathinfo($target); + $lang = $files_langs[$src]; + $file_timestamped = str_replace(SITE . 'cache/', SITE, $src); + if (!file_exists($file_timestamped)) { + foreach ($pages_langs[$path_parts_src['dirname'] . '/' . $page_names[$src]] as $page_lang) { + if (file_exists($file_timestamped = str_replace('.' . $lang . '.', '.' . $page_lang . '.', $file_timestamped))) + break; + } + } $last_update = match (preg_match("/^(?[0-9]{4})-(?[0-9]{2})-(?[0-9]{2})-/D", $path_parts_src['basename'], $date)) { 1 => (new DateTime())->setDate($date['year'], $date['month'], $date['day'])->format('U'), - 0 => (new SplFileInfo(str_replace(SITE . 'cache/', SITE, $src)))->getMTime(), + 0 => (new SplFileInfo($file_timestamped))->getMTime(), }; $base_filepath_src = $path_parts_src['dirname'] . '/' . $path_parts_src['filename']; $base_filepath_target = $path_parts_target['dirname'] . '/' . $path_parts_target['filename']; $content = file_get_contents($src); - $lang = $files_langs[$src]; preg_match('/^# (?.*)$/Dm', $content, $matches); $title = $matches['title'] ?? NULL;