mirror of
https://github.com/getgrav/grav.git
synced 2026-03-18 02:21:11 +01:00
Various tweaks and hopefully improvements to file change detection
This commit is contained in:
@@ -60,13 +60,10 @@ abstract class Folder
|
||||
|
||||
/** @var \RecursiveDirectoryIterator $file */
|
||||
foreach ($itr as $file) {
|
||||
if (!$file->isDir()) {
|
||||
$file_modified = $file->getMTime();
|
||||
if ($file_modified > $last_modified) {
|
||||
$last_modified = $file_modified;
|
||||
}
|
||||
$file_modified = $file->getMTime();
|
||||
if ($file_modified > $last_modified) {
|
||||
$last_modified = $file_modified;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $last_modified;
|
||||
@@ -277,7 +274,7 @@ abstract class Folder
|
||||
class GravRecursiveFilterIterator extends \RecursiveFilterIterator
|
||||
{
|
||||
public static $FILTERS = array(
|
||||
'.', '..', '.DS_Store'
|
||||
'..', '.DS_Store'
|
||||
);
|
||||
|
||||
public function accept()
|
||||
|
||||
@@ -750,33 +750,36 @@ class Page
|
||||
$this->metadata = array();
|
||||
$page_header = $this->header;
|
||||
|
||||
|
||||
// Set the Generator tag
|
||||
$this->metadata['generator'] = array('name'=>'generator', 'content'=>'Grav ' . GRAV_VERSION);
|
||||
|
||||
// Merge any site.metadata settings in with page metadata
|
||||
$defaults = (array) self::$grav['config']->get('site.metadata');
|
||||
if (isset($page_header->metadata)) {
|
||||
$page_header->metadata = array_merge($defaults, $page_header->metadata);
|
||||
} else {
|
||||
$page_header->metadata = $defaults;
|
||||
}
|
||||
// Safety check to ensure we have a header
|
||||
if ($page_header) {
|
||||
// Merge any site.metadata settings in with page metadata
|
||||
$defaults = (array) self::$grav['config']->get('site.metadata');
|
||||
|
||||
// Build an array of meta objects..
|
||||
foreach((array)$page_header->metadata as $key => $value) {
|
||||
|
||||
// If this is a property type metadata: "og", "twitter", "facebook" etc
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $property => $prop_value) {
|
||||
$prop_key = $key.":".$property;
|
||||
$this->metadata[$prop_key] = array('property'=>$prop_key, 'content'=>$prop_value);
|
||||
}
|
||||
// If it this is a standard meta data type
|
||||
if (isset($page_header->metadata)) {
|
||||
$page_header->metadata = array_merge($defaults, $page_header->metadata);
|
||||
} else {
|
||||
if (in_array($key, $header_tag_http_equivs)) {
|
||||
$this->metadata[$key] = array('http_equiv'=>$key, 'content'=>$value);
|
||||
$page_header->metadata = $defaults;
|
||||
}
|
||||
|
||||
// Build an array of meta objects..
|
||||
foreach((array)$page_header->metadata as $key => $value) {
|
||||
|
||||
// If this is a property type metadata: "og", "twitter", "facebook" etc
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $property => $prop_value) {
|
||||
$prop_key = $key.":".$property;
|
||||
$this->metadata[$prop_key] = array('property'=>$prop_key, 'content'=>$prop_value);
|
||||
}
|
||||
// If it this is a standard meta data type
|
||||
} else {
|
||||
$this->metadata[$key] = array('name'=>$key, 'content'=>$value);
|
||||
if (in_array($key, $header_tag_http_equivs)) {
|
||||
$this->metadata[$key] = array('http_equiv'=>$key, 'content'=>$value);
|
||||
} else {
|
||||
$this->metadata[$key] = array('name'=>$key, 'content'=>$value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,13 +465,18 @@ class Pages
|
||||
// set current modified of page
|
||||
$last_modified = $page->modified();
|
||||
|
||||
// flat for content availability
|
||||
$content_exists = false;
|
||||
|
||||
/** @var \DirectoryIterator $file */
|
||||
foreach ($iterator as $file) {
|
||||
$name = $file->getFilename();
|
||||
$modified = $file->getMTime();
|
||||
|
||||
if ($file->isFile() && Utils::endsWith($name, CONTENT_EXT)) {
|
||||
|
||||
$page->init($file);
|
||||
$content_exists = true;
|
||||
|
||||
if ($config->get('system.pages.events.page')) {
|
||||
$this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
|
||||
@@ -494,24 +499,23 @@ class Pages
|
||||
|
||||
// set the modified time if not already set
|
||||
if (!$page->date()) {
|
||||
$page->date($file->getMTime());
|
||||
$page->date($modified);
|
||||
}
|
||||
|
||||
// set the last modified time on pages
|
||||
$this->lastModified($file->getMTime());
|
||||
|
||||
if ($config->get('system.pages.events.page')) {
|
||||
$this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page]));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the last modified if it's newer than already found
|
||||
$date = $file->getMTime();
|
||||
if ($date > $last_modified) {
|
||||
$last_modified = $date;
|
||||
if ($modified > $last_modified) {
|
||||
$last_modified = $modified;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set routability to false if no page found
|
||||
if (!$content_exists) {
|
||||
$page->routable(false);
|
||||
}
|
||||
|
||||
// Override the modified and ID so that it takes the latest change into account
|
||||
|
||||
Reference in New Issue
Block a user