From 0cb8e0664e62dc50a265242c093ede12c602c747 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 18 Oct 2017 16:35:27 -0400 Subject: [PATCH 1/9] Prepare for release --- CHANGELOG.md | 8 ++++---- system/defines.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61ece18ff1..d0b09cbf6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # v1.3.7 -## mm/dd/2017 +## 10/18/2017 1. [](#bugfix) - * Regressionin Uri: `base_url_absolute` always has the port number (#1690) - * Uri: Prefer using REQUEST_SCHEME instead of HTTPS (#1698) - * Fixed routing paths with urlencoded spaces and non-latin letters (#1688) + * Regression Uri: `base_url_absolute` always has the port number [#1690](https://github.com/getgrav/grav-plugin-admin/issues/1690) + * Uri: Prefer using REQUEST_SCHEME instead of HTTPS [#1698](https://github.com/getgrav/grav-plugin-admin/issues/1698) + * Fixed routing paths with urlencoded spaces and non-latin letters [#1688](https://github.com/getgrav/grav-plugin-admin/issues/1688) # v1.3.6 ## 10/12/2017 diff --git a/system/defines.php b/system/defines.php index dbe18d45a2..d8cf6a0a2c 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.3.6'); +define('GRAV_VERSION', '1.3.7'); //define('GRAV_TESTING', true); define('DS', '/'); From dd166ce25cf36972a23d4261b09fed3ccdb8e0b7 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 19 Oct 2017 22:19:03 +0900 Subject: [PATCH 2/9] Update CONTRIBUTING.md copywriting (#1706) --- CONTRIBUTING.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b187cdd24..da8896f693 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ patches and features. ## Grav, Plugins, Themes and Skeletons -Grav is a large open source project—it's made up of over 100 repositories. When you initially consider contributing to Grav, you might be unsure about which of those 200 repositories implements the functionality you want to change or report a bug for. +Grav is a large open source project — it's made up of over 100 repositories. When you initially consider contributing to Grav, you might be unsure about which of those 200 repositories implements the functionality you want to change or report a bug for. [https://github.com/getgrav/grav](https://github.com/getgrav/grav) is the main Grav repository. The core of Grav is provided by this repo. @@ -60,20 +60,20 @@ Guidelines for bug reports: A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. -What is your environment? Is it localhost, OSX, Linux, on a remote server? Same happening locally and or the server, or just locally or just on Linux? +- What is your environment? Is it localhost, OSX, Linux, on a remote server? Same happening locally and or the server, or just locally or just on Linux? -What steps will reproduce the issue? What browser(s) and OS experience the problem? +- What steps will reproduce the issue? What browser(s) and OS experience the problem? -What would you expect to be the outcome? +- What would you expect to be the outcome? -Did the problem start happening recently (e.g. after updating to a new version of Grav) or was this always a problem? +- Did the problem start happening recently (e.g. after updating to a new version of Grav) or was this always a problem? -If the problem started happening recently, can you reproduce the problem in an older version of Grav? What's the most recent version in which the problem doesn't happen? You can download older versions of Grav from the releases page on Github. +- If the problem started happening recently, can you reproduce the problem in an older version of Grav? What's the most recent version in which the problem doesn't happen? You can download older versions of Grav from the releases page on Github. -Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens. +- Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens. -All these details will help people to fix any potential bugs. +All these details will help contributors to fix any potential bugs. Important: [include Code Samples in triple backticks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) so that Github will provide a proper indentation. [Add the language name after the backticks](https://help.github.com/articles/github-flavored-markdown/#syntax-highlighting) to add syntax highlighting to the code snippets. From eb52f670b93842d45152e9625cde0fbff2093efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Rouleau?= Date: Thu, 19 Oct 2017 16:53:31 -0400 Subject: [PATCH 3/9] fix nonsense logic (#1709) --- system/src/Grav/Common/Grav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 3bbf857d00..2353e2ecc5 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -148,7 +148,7 @@ public function setLocale() // Initialize Locale if set and configured. if ($this['language']->enabled() && $this['config']->get('system.languages.override_locale')) { $language = $this['language']->getLanguage(); - setlocale(LC_ALL, count($language < 3) ? ($language . '_' . strtoupper($language)) : $language); + setlocale(LC_ALL, strlen($language) < 3 ? ($language . '_' . strtoupper($language)) : $language); } elseif ($this['config']->get('system.default_locale')) { setlocale(LC_ALL, $this['config']->get('system.default_locale')); } From 173a70c0178d4839004c3f3ccb134afda51e0201 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Thu, 19 Oct 2017 17:39:10 -0400 Subject: [PATCH 4/9] Updated default yaml with media order --- system/blueprints/pages/default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml index 929a067c3d..8472b3b1a3 100644 --- a/system/blueprints/pages/default.yaml +++ b/system/blueprints/pages/default.yaml @@ -32,7 +32,7 @@ form: validate: type: textarea - uploads: + header.media_order: type: pagemedia label: PLUGIN_ADMIN.PAGE_MEDIA From b5c8b7016388064bd566cf857360dc47f7b3baf6 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Thu, 19 Oct 2017 18:01:37 -0400 Subject: [PATCH 5/9] More media order changes --- system/blueprints/pages/external.yaml | 2 +- system/blueprints/pages/modular.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/blueprints/pages/external.yaml b/system/blueprints/pages/external.yaml index 3148c62e70..3db205f438 100644 --- a/system/blueprints/pages/external.yaml +++ b/system/blueprints/pages/external.yaml @@ -25,7 +25,7 @@ form: content: unset@: true - uploads: + header.media_order: unset@: true header.external_url: diff --git a/system/blueprints/pages/modular.yaml b/system/blueprints/pages/modular.yaml index 2331ebf3ea..b1e32c1b51 100644 --- a/system/blueprints/pages/modular.yaml +++ b/system/blueprints/pages/modular.yaml @@ -42,6 +42,6 @@ form: type: ignore content: type: ignore - uploads: + header.media_orider: type: ignore From 3ff5f795617697e0ece0f2c8252a6f0aafb6e5ec Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 19 Oct 2017 22:10:12 -0400 Subject: [PATCH 6/9] Added manual order capability to Page media --- .../Grav/Common/Page/Medium/AbstractMedia.php | 32 ++++++++++++++++--- system/src/Grav/Common/Utils.php | 18 +++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php index f4e8674463..cc428b9923 100644 --- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php +++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php @@ -9,6 +9,8 @@ namespace Grav\Common\Page\Medium; use Grav\Common\Getters; +use Grav\Common\Grav; +use Grav\Common\Utils; abstract class AbstractMedia extends Getters { @@ -49,7 +51,8 @@ public function __invoke($filename) */ public function all() { - ksort($this->instances, SORT_NATURAL | SORT_FLAG_CASE); + $this->instances = $this->orderMedia($this->instances); + return $this->instances; } @@ -60,7 +63,7 @@ public function all() */ public function images() { - ksort($this->images, SORT_NATURAL | SORT_FLAG_CASE); + $this->images = $this->orderMedia($this->images); return $this->images; } @@ -71,7 +74,7 @@ public function images() */ public function videos() { - ksort($this->videos, SORT_NATURAL | SORT_FLAG_CASE); + $this->videos = $this->orderMedia($this->videos); return $this->videos; } @@ -82,7 +85,7 @@ public function videos() */ public function audios() { - ksort($this->audios, SORT_NATURAL | SORT_FLAG_CASE); + $this->audios = $this->orderMedia($this->audios); return $this->audios; } @@ -93,7 +96,7 @@ public function audios() */ public function files() { - ksort($this->files, SORT_NATURAL | SORT_FLAG_CASE); + $this->files = $this->orderMedia($this->files); return $this->files; } @@ -119,6 +122,25 @@ protected function add($name, $file) } } + /** + * Order the media based on the page's media_order + * + * @param $media + * @return array + */ + protected function orderMedia($media) + { + $page = Grav::instance()['pages']->get($this->path); + + if ($page && isset($page->header()->media_order)) { + $media_order = array_map('trim', explode(',', $page->header()->media_order)); + $media = Utils::sortArrayByArray($media, $media_order); + } else { + ksort($media, SORT_NATURAL | SORT_FLAG_CASE); + } + return $media; + } + /** * Get filename, extension and meta part. * diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 6e383c343a..5de969b628 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -852,6 +852,24 @@ public static function isApache() { return strpos($_SERVER["SERVER_SOFTWARE"], 'Apache') !== false; } + /** + * Sort a multidimensional array by another array of ordered keys + * + * @param array $array + * @param array $orderArray + * @return array + */ + public static function sortArrayByArray(array $array, array $orderArray) { + $ordered = array(); + foreach ($orderArray as $key) { + if (array_key_exists($key, $array)) { + $ordered[$key] = $array[$key]; + unset($array[$key]); + } + } + return $ordered + $array; + } + /** * Get's path based on a token * From ca645ef476a8abf00f3b354b59aa91e86c3f4d16 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 19 Oct 2017 22:13:36 -0400 Subject: [PATCH 7/9] updated changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0b09cbf6d..d86130cd39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.3.8 +## xx/xx/2017 + +1. [](#new) + * Added Page `media_order` capability to manually order page media via a page header + # v1.3.7 ## 10/18/2017 From 0668a47758abebcbcd00778d71bc9664f35ba9a0 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 23 Oct 2017 16:13:22 -0600 Subject: [PATCH 8/9] Fixed GPM update issue with filtered slugs #1711 --- CHANGELOG.md | 2 ++ system/src/Grav/Console/Gpm/UpdateCommand.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d86130cd39..8ff7c5cb90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ 1. [](#new) * Added Page `media_order` capability to manually order page media via a page header +1. [](#bugfix) + * Fixed GPM update issue with filtered slugs [#1711](https://github.com/getgrav/grav/issues/1711) # v1.3.7 ## 10/18/2017 diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index 6bc8790b35..1fb07134b3 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -182,7 +182,7 @@ protected function serve() $index = 0; foreach ($this->data as $packages) { foreach ($packages as $slug => $package) { - if (count($limit_to) && !array_key_exists($slug, $limit_to)) { + if (count($only_packages) && !array_key_exists($slug, $limit_to)) { continue; } @@ -276,6 +276,7 @@ private function userInputPackages($only_packages) $this->output->writeln(''); $this->output->writeln("Packages not found or not requiring updates: " . implode(', ', $ignore) . ""); + } } From d3695b2faa914748f5ffaec84d252f314203f03c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 23 Oct 2017 16:19:08 -0600 Subject: [PATCH 9/9] Fixed missing image file not throwing 404 p#1713 --- CHANGELOG.md | 1 + system/src/Grav/Common/Grav.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff7c5cb90..e9778372d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added Page `media_order` capability to manually order page media via a page header 1. [](#bugfix) * Fixed GPM update issue with filtered slugs [#1711](https://github.com/getgrav/grav/issues/1711) + * Fixed issue with missing image file not throwing 404 properly [#1713](https://github.com/getgrav/grav/issues/1713) # v1.3.7 ## 10/18/2017 diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 2353e2ecc5..99566c8970 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -499,6 +499,9 @@ public function fallbackUrl($path) } Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download); } + + // Nothing found + return false; } return $page;