mirror of
https://github.com/typemill/typemill.git
synced 2025-08-05 21:57:31 +02:00
Version 1.5.1: Lazy loading images and ping sitemap
This commit is contained in:
@@ -98,7 +98,7 @@ class ControllerAuthorArticleApi extends ControllerAuthor
|
||||
$this->setFreshNavigation();
|
||||
|
||||
# update the sitemap
|
||||
$this->updateSitemap();
|
||||
$this->updateSitemap($ping = true);
|
||||
|
||||
# complete the page meta if title or description not set
|
||||
$writeMeta = new WriteMeta();
|
||||
@@ -518,7 +518,7 @@ class ControllerAuthorArticleApi extends ControllerAuthor
|
||||
$this->setFreshStructureDraft();
|
||||
$this->setFreshStructureLive();
|
||||
$this->setFreshNavigation();
|
||||
$this->updateSitemap();
|
||||
$this->updateSitemap($ping = true);
|
||||
|
||||
$newUrlRel = str_replace($this->item->slug, $this->params['slug'], $this->item->urlRelWoF);
|
||||
|
||||
@@ -591,6 +591,9 @@ class ControllerAuthorArticleApi extends ControllerAuthor
|
||||
# if the item has been moved within the same folder
|
||||
if($this->params['parent_id_from'] == $this->params['parent_id_to'])
|
||||
{
|
||||
# no need to ping search engines
|
||||
$ping = false;
|
||||
|
||||
# get key of item
|
||||
$itemKey = end($itemKeyPath);
|
||||
reset($itemKeyPath);
|
||||
@@ -600,6 +603,9 @@ class ControllerAuthorArticleApi extends ControllerAuthor
|
||||
}
|
||||
else
|
||||
{
|
||||
# let us ping search engines
|
||||
$ping = true;
|
||||
|
||||
# rename links in extended file
|
||||
$this->renameExtended($item, $newFolder);
|
||||
|
||||
@@ -644,7 +650,7 @@ class ControllerAuthorArticleApi extends ControllerAuthor
|
||||
$this->setFreshNavigation();
|
||||
|
||||
# update the sitemap
|
||||
$this->updateSitemap();
|
||||
$this->updateSitemap($ping);
|
||||
|
||||
# dispatch event
|
||||
$this->c->dispatcher->dispatch('onPageSorted', new OnPageSorted($this->params));
|
||||
|
@@ -120,6 +120,7 @@ class ControllerSettings extends ControllerShared
|
||||
'securitylog' => isset($newSettings['securitylog']) ? true : null,
|
||||
'oldslug' => isset($newSettings['oldslug']) ? true : null,
|
||||
'refreshcache' => isset($newSettings['refreshcache']) ? true : null,
|
||||
'pingsitemap' => isset($newSettings['pingsitemap']) ? true : null,
|
||||
);
|
||||
|
||||
# https://www.slimframework.com/docs/v3/cookbook/uploading-files.html;
|
||||
|
@@ -275,7 +275,7 @@ abstract class ControllerShared
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateSitemap()
|
||||
public function updateSitemap($ping = false)
|
||||
{
|
||||
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$sitemap .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
||||
@@ -284,6 +284,27 @@ abstract class ControllerShared
|
||||
$sitemap .= '</urlset>';
|
||||
|
||||
$this->writeCache->writeFile('cache', 'sitemap.xml', $sitemap);
|
||||
|
||||
if($ping && isset($this->settings['pingsitemap']) && $this->settings['pingsitemap'])
|
||||
{
|
||||
$sitemapUrl = $this->uri->getBaseUrl() . '/cache/sitemap.xml';
|
||||
|
||||
$pingGoogleUrl = 'http://www.google.com/ping?sitemap=' . urlencode($sitemapUrl);
|
||||
$pingBingUrl = 'http://www.bing.com/ping?sitemap=' . urlencode($sitemapUrl);
|
||||
|
||||
$opts = array(
|
||||
'http'=>array(
|
||||
'method'=>"GET",
|
||||
'timeout' => 5
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
$resultBing = file_get_contents($pingBingUrl, false, $context);
|
||||
$resultGoogle = file_get_contents($pingGoogleUrl, false, $context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function generateUrlSets($structureLive)
|
||||
|
Reference in New Issue
Block a user