mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 23:39:58 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03a0c42795 | ||
|
|
1426a7ec95 | ||
|
|
2a759eed74 | ||
|
|
8980b78220 | ||
|
|
12b0a839e7 | ||
|
|
b4d570fd21 | ||
|
|
e60fd82400 | ||
|
|
a1abcfd067 | ||
|
|
7f90ad8474 | ||
|
|
e1d52181a3 | ||
|
|
d4494cb502 | ||
|
|
2f17b3fa7d | ||
|
|
afe72d0783 | ||
|
|
8e0e3e8718 | ||
|
|
30ff986603 |
@@ -1,3 +1,11 @@
|
|||||||
|
# v1.4.5
|
||||||
|
## 05/15/2018
|
||||||
|
|
||||||
|
1. [](#bugfix)
|
||||||
|
* Fixed an issue with some users getting **2FA** prompt after upgrade [admin#1442](https://github.com/getgrav/grav-plugin-admin/issues/1442)
|
||||||
|
* Do not crash when generating URLs with arrays as parameters [#2018](https://github.com/getgrav/grav/pull/2018)
|
||||||
|
* Utils::truncateHTML removes whitespace when generating summaries [#2004](https://github.com/getgrav/grav/pull/2004)
|
||||||
|
|
||||||
# v1.4.4
|
# v1.4.4
|
||||||
## 05/11/2018
|
## 05/11/2018
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
// Some standard defines
|
// Some standard defines
|
||||||
define('GRAV', true);
|
define('GRAV', true);
|
||||||
define('GRAV_VERSION', '1.4.4');
|
define('GRAV_VERSION', '1.4.5');
|
||||||
define('GRAV_TESTING', false);
|
define('GRAV_TESTING', false);
|
||||||
define('DS', '/');
|
define('DS', '/');
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class Truncator {
|
|||||||
|
|
||||||
// Iterate over words.
|
// Iterate over words.
|
||||||
$words = new DOMWordsIterator($body);
|
$words = new DOMWordsIterator($body);
|
||||||
|
$truncated = false;
|
||||||
foreach ($words as $word) {
|
foreach ($words as $word) {
|
||||||
|
|
||||||
// If we have exceeded the limit, we delete the remainder of the content.
|
// If we have exceeded the limit, we delete the remainder of the content.
|
||||||
@@ -70,12 +71,19 @@ class Truncator {
|
|||||||
self::insertEllipsis($curNode, $ellipsis);
|
self::insertEllipsis($curNode, $ellipsis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$truncated = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return original HTML if not truncated.
|
||||||
|
if ($truncated) {
|
||||||
return self::innerHTML($body);
|
return self::innerHTML($body);
|
||||||
|
} else {
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,6 +106,7 @@ class Truncator {
|
|||||||
|
|
||||||
// Iterate over letters.
|
// Iterate over letters.
|
||||||
$letters = new DOMLettersIterator($body);
|
$letters = new DOMLettersIterator($body);
|
||||||
|
$truncated = false;
|
||||||
foreach ($letters as $letter) {
|
foreach ($letters as $letter) {
|
||||||
|
|
||||||
// If we have exceeded the limit, we want to delete the remainder of this document.
|
// If we have exceeded the limit, we want to delete the remainder of this document.
|
||||||
@@ -111,11 +120,18 @@ class Truncator {
|
|||||||
self::insertEllipsis($currentText[0], $ellipsis);
|
self::insertEllipsis($currentText[0], $ellipsis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$truncated = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return original HTML if not truncated.
|
||||||
|
if ($truncated) {
|
||||||
return self::innerHTML($body);
|
return self::innerHTML($body);
|
||||||
|
} else {
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -536,7 +536,12 @@ class Medium extends Data implements RenderableInterface
|
|||||||
{
|
{
|
||||||
$qs = $method;
|
$qs = $method;
|
||||||
if (count($args) > 1 || (count($args) == 1 && !empty($args[0]))) {
|
if (count($args) > 1 || (count($args) == 1 && !empty($args[0]))) {
|
||||||
$qs .= '=' . implode(',', array_map(function ($a) { return rawurlencode($a); }, $args));
|
$qs .= '=' . implode(',', array_map(function ($a) {
|
||||||
|
if (is_array($a)) {
|
||||||
|
$a = '[' . implode(',', $a) . ']';
|
||||||
|
}
|
||||||
|
return rawurlencode($a);
|
||||||
|
}, $args));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($qs)) {
|
if (!empty($qs)) {
|
||||||
|
|||||||
@@ -95,11 +95,41 @@ class User extends Data
|
|||||||
public static function remove($username)
|
public static function remove($username)
|
||||||
{
|
{
|
||||||
$file_path = Grav::instance()['locator']->findResource('account://' . $username . YAML_EXT);
|
$file_path = Grav::instance()['locator']->findResource('account://' . $username . YAML_EXT);
|
||||||
if ($file_path && unlink($file_path)) {
|
|
||||||
return true;
|
return $file_path && unlink($file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
/**
|
||||||
|
* @param string $offset
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function offsetExists($offset)
|
||||||
|
{
|
||||||
|
$value = parent::offsetExists($offset);
|
||||||
|
|
||||||
|
// Handle special case where user was logged in before 'authorized' was added to the user object.
|
||||||
|
if (false === $value && $offset === 'authorized') {
|
||||||
|
$value = $this->offsetExists('authenticated');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $offset
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function offsetGet($offset)
|
||||||
|
{
|
||||||
|
$value = parent::offsetGet($offset);
|
||||||
|
|
||||||
|
// Handle special case where user was logged in before 'authorized' was added to the user object.
|
||||||
|
if (null === $value && $offset === 'authorized') {
|
||||||
|
$value = $this->offsetGet('authenticated');
|
||||||
|
$this->offsetSet($offset, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -296,10 +296,6 @@ abstract class Utils
|
|||||||
*/
|
*/
|
||||||
public static function truncateHtml($text, $length = 100, $ellipsis = '...')
|
public static function truncateHtml($text, $length = 100, $ellipsis = '...')
|
||||||
{
|
{
|
||||||
if (mb_strlen($text) <= $length) {
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Truncator::truncateLetters($text, $length, $ellipsis);
|
return Truncator::truncateLetters($text, $length, $ellipsis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||||||
$this->assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
|
$this->assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
|
||||||
$this->assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
|
$this->assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
|
||||||
$this->assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
|
$this->assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
|
||||||
$this->assertEquals('<input type="file" id="file" multiple>', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
|
$this->assertEquals('<input type="file" id="file" multiple />', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
|
||||||
$this->assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
|
$this->assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
|
||||||
$this->assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
|
$this->assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||||||
$this->assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
|
$this->assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
|
||||||
$this->assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
|
$this->assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
|
||||||
$this->assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
|
$this->assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
|
||||||
$this->assertEquals('<input type="file" id="file" multiple>', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
|
$this->assertEquals('<input type="file" id="file" multiple />', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
|
||||||
$this->assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
|
$this->assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user