1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-04 21:27:41 +02:00

Version 1.5.1: Lazy loading images and ping sitemap

This commit is contained in:
trendschau
2021-10-22 23:58:01 +02:00
parent d1d7d61b4e
commit 2e12e184d3
10 changed files with 78 additions and 20 deletions

1
cache/securitylog.txt vendored Normal file
View File

@@ -0,0 +1 @@
127.0.0.1;2021-10-21 16:41:00;wrong captcha http://localhost/typemill/tm/login

View File

@@ -8,3 +8,5 @@ Do you need professional help, an individual theme or a special plugin? You can
[Contributions](https://github.com/typemill/typemill#contributors--supporters), [donations](https://www.paypal.me/typemill) and [feedback](https://github.com/typemill/typemill/issues) for this open source project are always welcome.
![alt](media/live/youtube-6i2-uv88gke.jpeg){.center loading="lazy"}

View File

@@ -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));

View File

@@ -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;

View File

@@ -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)

View File

@@ -200,6 +200,20 @@ class ParsedownExtension extends \ParsedownExtra
return $block;
}
protected function inlineImage($excerpt)
{
$image = parent::inlineImage($excerpt);
if ( ! isset($image))
{
return null;
}
$image['element']['attributes']['loading'] = "lazy";
return $image;
}
protected function blockTable($Line, array $Block = null)
{

View File

@@ -193,6 +193,7 @@ class Settings
'securitylog' => true,
'oldslug' => true,
'refreshcache' => true,
'pingsitemap' => true,
];
# cleanup the existing usersettings

View File

@@ -1604,7 +1604,7 @@ const imageComponent = Vue.component('image-component', {
imgmarkdown = imgmarkdown + '(' + this.imgfile + ')';
}
var imgattr = '';
var imgattr = 'loading="lazy" ';
if(this.imgid != '')
{
if(this.imgid.length < 100)

View File

@@ -1,19 +1,10 @@
meta:
fields:
fieldsetnavi:
type: fieldset
legend: Navigation
fields:
navtitle:
type: text
label: Navigation Title
class: medium
maxlength: 60
hide:
type: checkbox
label: Hide
checkboxlabel: Hide page from navigation
class: medium
navtitle:
type: text
label: Navigation Title
class: large
maxlength: 60
fieldsetcontent:
type: fieldset
legend: Meta-Content
@@ -36,6 +27,20 @@ meta:
heroimagealt:
type: text
label: Alternative Text for the hero image
fieldsetvisibility:
type: fieldset
legend: Visibility
fields:
hide:
type: checkbox
label: Hide
checkboxlabel: Hide page from navigation
class: medium
nofollow:
type: checkbox
label: Nofollow
checkboxlabel: Add no-follow and exclude from sitemap
class: medium
fieldsetauthor:
type: fieldset
legend: Author

View File

@@ -20,7 +20,7 @@
</header>
<div id="typemill" class="fc-system-version update-banner">{{ settings.version ? settings.version : 'Unknown' }}</div>
<fieldset>
<div class="medium{{ errors.settings.title ? ' error' : '' }}">
@@ -71,6 +71,13 @@
</div><div class="medium">
<label for="settings[sitemap]">{{ __('Google Sitemap') }} <small>({{ __('Readonly') }})</small></label>
<input type="text" name="settings[sitemap]" id="sitemap" readonly value="{{ base_url }}/cache/sitemap.xml" />
<div class="description">You can ping the sitemap with the following links to <a target="_blank" href="https://www.google.com/ping?sitemap={{ (base_url ~ '/cache/sitemap.xml')|url_encode }}">google</a> and <a target="_blank" href="http://www.bing.com/ping?sitemap={{ (base_url ~ '/cache/sitemap.xml')|url_encode }}">bing</a>.</div>
</div><div class="medium{{ errors.settings.pingsitemap ? ' error' : '' }}">
<label for="settings[pingsitemap]">{{ __('Ping sitemap automatically') }}</label>
<label class="control-group">{{ __('Ping sitemap automatically after publishing a page.') }}
<input name="settings[pingsitemap]" type="checkbox" {% if (settings.pingsitemap or old.settings.pingsitemap) %} checked {% endif %}>
<span class="checkmark"></span>
</label>
</div>
<hr>
<header class="headline">