Merge branch 'release/0.9.11'

This commit is contained in:
Andy Miller
2014-12-21 20:56:38 -07:00
6 changed files with 67 additions and 36 deletions

View File

@@ -1,4 +1,16 @@
# v0.9.10 beta
# v0.9.11
## 12/21/2014
1. [](#new)
* Added support for simple redirects as well as routes
2. [](#improved)
* Handle Twig errors more cleanly
3. [](#bugfix)
* Fix for error caused by invalid or missing user agent string
* Fix for directory relative links and URL fragments (#pagelink)
* Fix for relative links with no subfolder in `base_url`
# v0.9.10
## 12/12/2014
1. [](#new)
@@ -8,7 +20,7 @@
3. [](#bugfix)
* Fix for undefined index with previous/next buttons
# v0.9.9 beta
# v0.9.9
## 12/05/2014
1. [](#new)
@@ -22,7 +34,7 @@
3. [](#bugfix)
* Fix for over-escaped apostrophes in YAML
# v0.9.8 beta
# v0.9.8
## 12/01/2014
1. [](#new)
@@ -38,7 +50,7 @@
3. [](#bugfix)
* Fix issue with miscalculation of blog separator location `===`
# v0.9.7 beta
# v0.9.7
## 11/24/2014
1. [](#improved)
@@ -51,7 +63,7 @@
* Fix for JS asset pipeline and scripts that don't end in `;`
* Fix for schema-based markdown URLs broken routes (eg `mailto:`)
# v0.9.6 beta
# v0.9.6
## 11/17/2014
1. [](#improved)
@@ -66,7 +78,7 @@
* Fix for relative URLs in markdown on installs with no base_url
* Fix for page media images with uppercase extension
# v0.9.5 beta
# v0.9.5
## 11/09/2014
1. [](#new)
@@ -89,7 +101,7 @@
* Fix for Data URLs in CSS being badly formed
* Fix Markdown links with fragment and query elements
# v0.9.4 beta
# v0.9.4
## 10/29/2014
1. [](#new)
@@ -114,7 +126,7 @@
* Fix potential double // in assets
* Load debugger as early as possible
# v0.9.3 beta
# v0.9.3
## 10/09/2014
1. [](#new)
@@ -142,7 +154,7 @@
* Switched debugger to PRODUCTION mode by default
* Various fixes in URI class for increased reliability
# v0.9.2 beta
# v0.9.2
## 09/15/2014
1. [](#new)
@@ -175,7 +187,7 @@
* Fix broken password validation
* Back to proper PSR-4 Autoloader
# v0.9.1 beta
# v0.9.1
## 09/02/2014
1. [](#new)
@@ -196,7 +208,7 @@
* Fixed template inheritance
* Moved Browser class to proper location
# v0.9.0 beta
# v0.9.0
## 08/25/2014
1. [](#new)
@@ -224,7 +236,7 @@
* Various minor bug fixes
# v0.8.0 beta
# v0.8.0
## 08/13/2014
1. [](#new)

View File

@@ -2,7 +2,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '0.9.10');
define('GRAV_VERSION', '0.9.11');
define('DS', '/');
// Directories and Paths

View File

@@ -4,13 +4,18 @@ namespace Grav\Common;
/**
* Simple wrapper for the very simple parse_user_agent() function
*/
class Browser {
class Browser
{
protected $useragent;
protected $useragent = [];
public function __construct()
{
$this->useragent = parse_user_agent();
try {
$this->useragent = parse_user_agent();
} catch (\InvalidArgumentException $e) {
$this->useragent = parse_user_agent("Mozilla/5.0 (compatible; Unknown;)");
}
}
public function getBrowser()

View File

@@ -132,16 +132,12 @@ trait MarkdownGravLinkTrait
} elseif (strpos($markdown_url, '/') === 0) {
$new_url = rtrim($this->base_url, '/') . $markdown_url;
} else {
$relative_path = rtrim($this->base_url, '/') . $this->page->route();
$relative_path = rtrim($this->base_url, '/') . $this->page->route();
// If this is a 'real' filepath clean it up
if (file_exists($this->page->path().'/'.$markdown_url)) {
$relative_path = rtrim($this->base_url, '/') .
preg_replace('/\/([\d]+.)/', '/',
str_replace(PAGES_DIR, '/', $this->page->path()));
$markdown_url = preg_replace('/^([\d]+.)/', '',
preg_replace('/\/([\d]+.)/', '/',
trim(preg_replace('/[^\/]+(\.md$)/', '', $markdown_url), '/')));
if (file_exists($this->page->path().'/'.parse_url($markdown_url, PHP_URL_PATH))) {
$relative_path = rtrim($this->base_url, '/') . preg_replace('/\/([\d]+.)/', '/', str_replace(PAGES_DIR, '/', $this->page->path()));
$markdown_url = preg_replace('/^([\d]+.)/', '', preg_replace('/\/([\d]+.)/', '/', trim(preg_replace('/[^\/]+(\.md$)/', '', $markdown_url), '/')));
}
// else its a relative path already
@@ -158,7 +154,7 @@ trait MarkdownGravLinkTrait
}
// build the new url
$new_url = $relative_path . '/' . implode('/', $newpath);
$new_url = rtrim($relative_path, '/') . '/' . implode('/', $newpath);
}
return $new_url;

View File

@@ -236,11 +236,19 @@ class Pages
// Fetch page if there's a defined route to it.
$page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null;
// If the page cannot be reached, look into site wide routes + wildcards
// If the page cannot be reached, look into site wide redirects, routes + wildcards
if (!$all && (!$page || !$page->routable())) {
/** @var Config $config */
$config = $this->grav['config'];
// Try redirects
$redirect = $config->get("site.redirects.{$url}");
if ($redirect) {
$this->grav->redirect($redirect);
}
// See if route matches one in the site configuration
$route = $config->get("site.routes.{$url}");
if ($route) {

View File

@@ -177,17 +177,22 @@ class Twig
$local_twig = clone($this->twig);
// Get Twig template layout
if ($item->modularTwig()) {
$twig_vars['content'] = $content;
$template = $item->template() . TEMPLATE_EXT;
$output = $local_twig->render($template, $twig_vars);
} else {
$name = '@Page:' . $item->path();
$this->setTemplate($name, $content);
$output = $local_twig->render($name, $twig_vars);
try {
// Get Twig template layout
if ($item->modularTwig()) {
$twig_vars['content'] = $content;
$template = $item->template() . TEMPLATE_EXT;
$output = $local_twig->render($template, $twig_vars);
} else {
$name = '@Page:' . $item->path();
$this->setTemplate($name, $content);
$output = $local_twig->render($name, $twig_vars);
}
} catch (\Twig_Error_Loader $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
return $output;
}
@@ -204,7 +209,12 @@ class Twig
$name = '@Var:' . $string;
$this->setTemplate($name, $string);
$output = $this->twig->render($name, $vars);
try {
$output = $this->twig->render($name, $vars);
} catch (\Twig_Error_Loader $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
return $output;
}