Skip to content

Commit

Permalink
Merge branch 'release/0.9.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Dec 22, 2014
2 parents f284147 + c8287d1 commit b568ad8
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 36 deletions.
36 changes: 24 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -224,7 +236,7 @@
* Various minor bug fixes


# v0.8.0 beta
# v0.8.0
## 08/13/2014

1. [](#new)
Expand Down
2 changes: 1 addition & 1 deletion system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions system/src/Grav/Common/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
/**
* 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()
Expand Down
14 changes: 5 additions & 9 deletions system/src/Grav/Common/Markdown/MarkdownGravLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,12 @@ protected function convertUrl($markdown_url)
} 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
Expand All @@ -158,7 +154,7 @@ protected function convertUrl($markdown_url)
}

// build the new url
$new_url = $relative_path . '/' . implode('/', $newpath);
$new_url = rtrim($relative_path, '/') . '/' . implode('/', $newpath);
}

return $new_url;
Expand Down
10 changes: 9 additions & 1 deletion system/src/Grav/Common/Page/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,19 @@ public function dispatch($url, $all = false)
// 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) {
Expand Down
30 changes: 20 additions & 10 deletions system/src/Grav/Common/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,22 @@ public function processPage(Page $item, $content = null)

$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;
}

Expand All @@ -204,7 +209,12 @@ public function processString($string, array $vars = array())

$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;
}
Expand Down

0 comments on commit b568ad8

Please sign in to comment.