self-upgrade
This commit is contained in:
@@ -279,11 +279,7 @@ class Debugger
|
||||
->withHeader('X-Clockwork-Id', $clockworkRequest->id)
|
||||
->withHeader('X-Clockwork-Version', $clockwork::VERSION);
|
||||
|
||||
$grav = Grav::instance();
|
||||
$basePath = $this->grav['base_url_relative'] . $grav['pages']->base();
|
||||
if ($basePath) {
|
||||
$response = $response->withHeader('X-Clockwork-Path', $basePath . '/__clockwork/');
|
||||
}
|
||||
$response = $response->withHeader('X-Clockwork-Path', Utils::url('/__clockwork/'));
|
||||
|
||||
return $response->withHeader('Server-Timing', ServerTiming::fromRequest($clockworkRequest)->value());
|
||||
}
|
||||
@@ -307,7 +303,7 @@ class Debugger
|
||||
}
|
||||
|
||||
$id = $matches['id'] ?? null;
|
||||
$direction = $matches['direction'] ?? null;
|
||||
$direction = $matches['direction'] ?? 'latest';
|
||||
$count = $matches['count'] ?? null;
|
||||
|
||||
$storage = $clockwork->getStorage();
|
||||
@@ -316,7 +312,7 @@ class Debugger
|
||||
$data = $storage->previous($id, $count);
|
||||
} elseif ($direction === 'next') {
|
||||
$data = $storage->next($id, $count);
|
||||
} elseif ($id === 'latest') {
|
||||
} elseif ($direction === 'latest' || $id === 'latest') {
|
||||
$data = $storage->latest();
|
||||
} else {
|
||||
$data = $storage->find($id);
|
||||
@@ -403,8 +399,16 @@ class Debugger
|
||||
|
||||
// Clockwork specific assets
|
||||
if ($this->clockwork) {
|
||||
$assets->addCss('/system/assets/debugger/clockwork.css', ['loading' => 'inline']);
|
||||
$assets->addJs('/system/assets/debugger/clockwork.js', ['loading' => 'inline']);
|
||||
if ($this->config->get('plugins.clockwork-web.enabled')) {
|
||||
$route = Utils::url($this->grav['config']->get('plugins.clockwork-web.route'));
|
||||
} else {
|
||||
$route = 'https://github.com/getgrav/grav-plugin-clockwork-web';
|
||||
}
|
||||
$assets->addCss('/system/assets/debugger/clockwork.css');
|
||||
$assets->addJs('/system/assets/debugger/clockwork.js', [
|
||||
'id' => 'clockwork-script',
|
||||
'data-route' => $route
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -49,7 +49,7 @@ class RecursiveDirectoryFilterIterator extends RecursiveFilterIterator
|
||||
*
|
||||
* @return bool true if the current element is acceptable, otherwise false.
|
||||
*/
|
||||
public function accept()
|
||||
public function accept() :bool
|
||||
{
|
||||
/** @var SplFileInfo $file */
|
||||
$file = $this->current();
|
||||
@@ -72,7 +72,7 @@ class RecursiveDirectoryFilterIterator extends RecursiveFilterIterator
|
||||
/**
|
||||
* @return RecursiveDirectoryFilterIterator|RecursiveFilterIterator
|
||||
*/
|
||||
public function getChildren()
|
||||
public function getChildren() :RecursiveFilterIterator
|
||||
{
|
||||
/** @var RecursiveDirectoryFilterIterator $iterator */
|
||||
$iterator = $this->getInnerIterator();
|
||||
|
@@ -45,7 +45,7 @@ class RecursiveFolderFilterIterator extends \RecursiveFilterIterator
|
||||
*
|
||||
* @return bool true if the current element is acceptable, otherwise false.
|
||||
*/
|
||||
public function accept()
|
||||
public function accept() :bool
|
||||
{
|
||||
/** @var SplFileInfo $current */
|
||||
$current = $this->current();
|
||||
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav\Common\Media
|
||||
* @author Pedro Moreno https://github.com/pmoreno-rodriguez
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Common\Media\Traits;
|
||||
|
||||
use Grav\Common\Grav;
|
||||
|
||||
/**
|
||||
* Trait ImageFetchPriorityTrait
|
||||
* @package Grav\Common\Media\Traits
|
||||
*/
|
||||
|
||||
trait ImageFetchPriorityTrait
|
||||
{
|
||||
/**
|
||||
* Allows to set the fetchpriority attribute from Markdown or Twig
|
||||
*
|
||||
* @param string|null $value
|
||||
* @return $this
|
||||
*/
|
||||
public function fetchpriority($value = null)
|
||||
{
|
||||
if (null === $value) {
|
||||
$value = Grav::instance()['config']->get('system.images.defaults.fetchpriority', 'auto');
|
||||
}
|
||||
|
||||
// Validate the provided value (similar to loading and decoding attributes)
|
||||
if ($value !== null && $value !== 'auto') {
|
||||
$this->attributes['fetchpriority'] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
@@ -179,7 +179,7 @@ class ImageFile extends Image
|
||||
throw new RuntimeException('You need to EXIF PHP Extension to use this function');
|
||||
}
|
||||
|
||||
if (!in_array(exif_imagetype($this->source->getInfos()), [IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM], true)) {
|
||||
if (!file_exists($this->source->getInfos()) || !in_array(exif_imagetype($this->source->getInfos()), [IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM], true)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ use Grav\Common\Media\Interfaces\ImageMediaInterface;
|
||||
use Grav\Common\Media\Interfaces\MediaLinkInterface;
|
||||
use Grav\Common\Media\Traits\ImageLoadingTrait;
|
||||
use Grav\Common\Media\Traits\ImageDecodingTrait;
|
||||
use Grav\Common\Media\Traits\ImageFetchPriorityTrait;
|
||||
use Grav\Common\Media\Traits\ImageMediaTrait;
|
||||
use Grav\Common\Utils;
|
||||
use Gregwar\Image\Image;
|
||||
@@ -32,6 +33,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
use ImageMediaTrait;
|
||||
use ImageLoadingTrait;
|
||||
use ImageDecodingTrait;
|
||||
use ImageFetchPriorityTrait;
|
||||
|
||||
/**
|
||||
* @var mixed|string
|
||||
|
@@ -613,7 +613,15 @@ class Page implements PageInterface
|
||||
|
||||
// Set Last-Modified header
|
||||
if ($this->lastModified()) {
|
||||
$last_modified_date = gmdate('D, d M Y H:i:s', $this->modified()) . ' GMT';
|
||||
$last_modified = $this->modified();
|
||||
foreach ($this->children()->modular() as $cpage) {
|
||||
$modular_mtime = $cpage->modified();
|
||||
if ($modular_mtime > $last_modified) {
|
||||
$last_modified = $modular_mtime;
|
||||
}
|
||||
}
|
||||
|
||||
$last_modified_date = gmdate('D, d M Y H:i:s', $last_modified) . ' GMT';
|
||||
$headers['Last-Modified'] = $last_modified_date;
|
||||
}
|
||||
|
||||
@@ -1774,7 +1782,7 @@ class Page implements PageInterface
|
||||
'content' => $escape ? htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8') : $value
|
||||
];
|
||||
|
||||
if ($hasSeparator && !Utils::startsWith($key, ['twitter', 'flattr'])) {
|
||||
if ($hasSeparator && !Utils::startsWith($key, ['twitter', 'flattr','fediverse'])) {
|
||||
$entry['property'] = $key;
|
||||
} else {
|
||||
$entry['name'] = $key;
|
||||
|
@@ -1407,14 +1407,13 @@ class Uri
|
||||
*/
|
||||
public function getContentType($short = true)
|
||||
{
|
||||
if (isset($_SERVER['CONTENT_TYPE'])) {
|
||||
$content_type = $_SERVER['CONTENT_TYPE'];
|
||||
$content_type = $_SERVER['CONTENT_TYPE'] ?? $_SERVER['HTTP_CONTENT_TYPE'] ?? $_SERVER['HTTP_ACCEPT'] ?? null;
|
||||
if ($content_type) {
|
||||
if ($short) {
|
||||
return Utils::substrToString($content_type, ';');
|
||||
}
|
||||
return $content_type;
|
||||
}
|
||||
return null;
|
||||
return $content_type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1888,6 +1888,14 @@ abstract class Utils
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function toAscii(String $string): String
|
||||
{
|
||||
return strtr(utf8_decode($string),
|
||||
utf8_decode(
|
||||
'ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),
|
||||
'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the subnet of an ip with CIDR prefix size
|
||||
*
|
||||
|
@@ -57,6 +57,14 @@ class PluginCommandLoader implements CommandLoaderInterface
|
||||
$command = new $command_class();
|
||||
if ($command instanceof Command) {
|
||||
$this->commands[$command->getName()] = $command;
|
||||
|
||||
// If the command has an alias, add that as a possible command name.
|
||||
$aliases = $this->commands[$command->getName()]->getAliases();
|
||||
if (isset($aliases)) {
|
||||
foreach ($aliases as $alias) {
|
||||
$this->commands[$alias] = $command;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -440,7 +440,8 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
] + $context
|
||||
);
|
||||
|
||||
if ($debugger->enabled()) {
|
||||
if ($debugger->enabled() &&
|
||||
!($grav['uri']->getContentType() === 'application/json' || $grav['uri']->extension() === 'json')) {
|
||||
$output = "\n<!–– START {$type} collection ––>\n{$output}\n<!–– END {$type} collection ––>\n";
|
||||
}
|
||||
|
||||
|
@@ -627,7 +627,8 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
||||
] + $context
|
||||
);
|
||||
|
||||
if ($debugger->enabled()) {
|
||||
if ($debugger->enabled() &&
|
||||
!($grav['uri']->getContentType() === 'application/json' || $grav['uri']->extension() === 'json')) {
|
||||
$name = $this->getKey() . ' (' . $type . ')';
|
||||
$output = "\n<!–– START {$name} object ––>\n{$output}\n<!–– END {$name} object ––>\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user