Skip to content

Commit

Permalink
Merge branch 'release/0.9.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Nov 10, 2014
2 parents e2aff43 + 60bbb32 commit 4b46ea2
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 70 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# v0.9.5 beta
## 11/09/2014

1. [](#new)
* Added quality setting to medium for compression configuration of images
* Added new onPageContentProcessed() event that is post-content processing but pre-caching
2. [](#improved)
* Added support for AND and OR taxonomy filtering. AND by default (was OR)
* Added specific clearing options for CLI clear-cache command
* Moved environment method to URI so it can be accessible in plugins and themes
* Set Grav's output variable to public so it can be manipulated in onOutputGenerated event
* Updated vendor libraries to latest versions
* Better handing of 'home' in active menu state detection
* Various PSR code tidying
* Improved some error messages and notices
3. [](#bugfix)
* Force route rebuild when configuration changes
* Fix for 'installed undefined' error in CLI versions command
* Do not remove the JSON/Text error handlers
* Fix for supporting inline JS and CSS when Asset pipeline enabled
* Fix for Data URLs in CSS being badly formed
* Fix Markdown links with fragment and query elements

# v0.9.4 beta
## 10/29/2014

Expand Down
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
{
"type": "vcs",
"url": "https://github.com/rockettheme/toolbox"
},
{
"type": "vcs",
"url": "https://github.com/rhukster/minify"
}
],
"autoload": {
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.4');
define('GRAV_VERSION', '0.9.5');
define('DS', '/');

// Directories and Paths
Expand Down
24 changes: 12 additions & 12 deletions system/src/Grav/Common/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,10 @@ public function css($attributes = [])
foreach ($this->css_no_pipeline as $file) {
$output .= '<link href="'.$file['asset'].'"'.$attributes.' />'."\n";
}
return $output;
}


foreach($this->css as $file) {
$output .= '<link href="' . $file['asset'] . '"' . $attributes . ' />' . "\n";
} else {
foreach($this->css as $file) {
$output .= '<link href="' . $file['asset'] . '"' . $attributes . ' />' . "\n";
}
}

// Render Inline CSS
Expand Down Expand Up @@ -387,12 +385,10 @@ public function js($attributes = [])
foreach ($this->js_no_pipeline as $file) {
$output .= '<script src="'.$file['asset'].'"'.$attributes.' ></script>'."\n";
}
return $output;
}


foreach($this->js as $file) {
$output .= '<script src="' . $file['asset'] . '"' . $attributes . ' ></script>' . "\n";
} else {
foreach($this->js as $file) {
$output .= '<script src="' . $file['asset'] . '"' . $attributes . ' ></script>' . "\n";
}
}

// Render Inline JS
Expand Down Expand Up @@ -632,6 +628,10 @@ protected function cssRewrite($file, $relative_path)
function($matches) use ($relative_path) {

$old_url = $matches[1];

// ensure this is not a data url
if (strpos($old_url, 'data:') === 0) return $matches[0];

$newpath = array();
$paths = explode('/', $old_url);

Expand Down
2 changes: 0 additions & 2 deletions system/src/Grav/Common/Errors/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function resetHandlers()
$config = $grav['config']->get('system.errors');
if (isset($config['display']) && !$config['display']) {
unset($this->handlerStack['pretty']);
unset($this->handlerStack['text']);
unset($this->handlerStack['json']);
$this->handlerStack = array('simple' => new SimplePageHandler()) + $this->handlerStack;
}
if (isset($config['log']) && !$config['log']) {
Expand Down
6 changes: 3 additions & 3 deletions system/src/Grav/Common/Grav.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Grav extends Container
/**
* @var string
*/
protected $output;
public $output;

/**
* @var static
Expand Down Expand Up @@ -112,7 +112,7 @@ protected static function load(array $values)
$medium = $media[$media_file];

// loop through actions for the image and call them
foreach ($c['uri']->query(null,true) as $action => $params) {
foreach ($c['uri']->query(null, true) as $action => $params) {
if (in_array($action, Medium::$valid_actions)) {
call_user_func_array(array(&$medium, $action), explode(',', $params));
}
Expand Down Expand Up @@ -294,7 +294,7 @@ public function fireEvent($eventName, Event $event = null)
*/
public function shutdown()
{
if($this['config']->get('system.debugger.shutdown.close_connection')) {
if ($this['config']->get('system.debugger.shutdown.close_connection')) {
set_time_limit(0);
ignore_user_abort(true);

Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Markdown/MarkdownGravLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function identifyLink($Excerpt)
if (!isset($url['host']) && isset($url['path'])) {

// convert the URl is required
$Excerpt['element']['attributes']['href'] = $this->convertUrl($url['path']);
$Excerpt['element']['attributes']['href'] = $this->convertUrl(Uri::build_url($url));
}
}

Expand Down
11 changes: 11 additions & 0 deletions system/src/Grav/Common/Page/Medium.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public function path()
return $output;
}

/**
* Sets the quality of the image
* @param Int $quality 0-100 quality
* @return Medium
*/
public function quality($quality) {
$this->quality = $quality;
return $this;
}

/**
* Return URL to file.
*
Expand Down Expand Up @@ -149,6 +159,7 @@ public function format($type = null, $quality = 80)

$this->type = $type;
$this->quality = $quality;
return $this;
}

/**
Expand Down
40 changes: 36 additions & 4 deletions system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,34 @@ public function content($var = null)

$this->content = $content;

// Process any post-processing but pre-caching functionality
self::$grav->fireEvent('onPageContentProcessed', new Event(['page' => $this]));

}

return $this->content;
}

/**
* Needed by the onPageContentProcessed event to get the raw page content
*
* @return string the current page content
*/
public function getRawContent()
{
return $this->content;
}

/**
* Needed by the onPageContentProcessed event to set the raw page content
*
* @param $content
*/
public function setRawContent($content)
{
$this->content = $content;
}

/**
* Get value from a page variable (used mostly for creating edit forms).
*
Expand Down Expand Up @@ -1326,10 +1349,21 @@ public function activeChild()
{
/** @var Uri $uri */
$uri = self::$grav['uri'];
$config = self::$grav['config'];

if (!$this->home() && (strpos($uri->url(), $this->url()) === 0)) {
return true;
// Special check when item is home
if ($this->home()) {
$paths = $uri->paths();
$home = ltrim($config->get('system.home.alias'), '/');
if ($paths[0] == $home) {
return true;
}
} else {
if (strpos($uri->url(), $this->url()) === 0) {
return true;
}
}

return false;
}

Expand Down Expand Up @@ -1418,8 +1452,6 @@ public function collection($params = 'content')
}
}
}

$config->set('system.cache.enabled', false); // TODO: Do we still need this?
}
}
// TODO: END OF MOVE
Expand Down
27 changes: 17 additions & 10 deletions system/src/Grav/Common/Page/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ public function sortCollection(Collection $collection, $orderBy, $orderDir = 'as
*/
public function get($path)
{
if (!is_null($path) && !is_string($path)) throw new \Exception();
if (!is_null($path) && !is_string($path)) {
throw new \Exception();
}
return isset($this->instances[(string) $path]) ? $this->instances[(string) $path] : null;
}

Expand Down Expand Up @@ -319,7 +321,7 @@ public function getList(Page $current = null, $level = 0)
*
* @return Types
*/
static public function getTypes()
public static function getTypes()
{
if (!self::$types) {
self::$types = new Types();
Expand All @@ -339,7 +341,7 @@ static public function getTypes()
*
* @return array
*/
static public function types()
public static function types()
{
$types = self::getTypes();

Expand All @@ -351,7 +353,7 @@ static public function types()
*
* @return array
*/
static public function modularTypes()
public static function modularTypes()
{
$types = self::getTypes();

Expand All @@ -363,7 +365,7 @@ static public function modularTypes()
*
* @return array
*/
static public function parents()
public static function parents()
{
$grav = Grav::instance();

Expand Down Expand Up @@ -404,10 +406,11 @@ protected function buildPages()
$last_modified = Folder::lastModifiedFile(PAGES_DIR);
}

$page_cache_id = md5(USER_DIR.$last_modified);
$page_cache_id = md5(USER_DIR.$last_modified.$config->checksum());

list($this->instances, $this->routes, $this->children, $taxonomy_map, $this->sort) = $cache->fetch($page_cache_id);
if (!$this->instances) {
$this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..');
$this->recurse();
$this->buildRoutes();

Expand All @@ -418,6 +421,7 @@ protected function buildPages()
);
} else {
// If pages was found in cache, set the taxonomy
$this->grav['debugger']->addMessage('Page cache hit.');
$taxonomy->taxonomy($taxonomy_map);
}
} else {
Expand Down Expand Up @@ -445,7 +449,9 @@ protected function recurse($directory = PAGES_DIR, Page &$parent = null)
$config = $this->grav['config'];

$page->path($directory);
if ($parent) $page->parent($parent);
if ($parent) {
$page->parent($parent);
}

$page->orderDir($config->get('system.pages.order.dir'));
$page->orderBy($config->get('system.pages.order.by'));
Expand Down Expand Up @@ -608,7 +614,7 @@ protected function buildSort($path, array $pages, $order_by = 'default', $manual

// handle special case when order_by is random
if ($order_by == 'random') {
$list = $this->array_shuffle($list);
$list = $this->arrayShuffle($list);
} else {
// else just sort the list according to specified key
asort($list);
Expand Down Expand Up @@ -643,12 +649,13 @@ protected function buildSort($path, array $pages, $order_by = 'default', $manual
}

// Shuffles and associative array
protected function array_shuffle($list) {
protected function arrayShuffle($list)
{
$keys = array_keys($list);
shuffle($keys);

$new = array();
foreach($keys as $key) {
foreach ($keys as $key) {
$new[$key] = $list[$key];
}

Expand Down
19 changes: 6 additions & 13 deletions system/src/Grav/Common/Service/ConfigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Uri;
use Grav\Common\Filesystem\Folder;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
Expand Down Expand Up @@ -33,7 +34,7 @@ public function register(Container $container)

public function loadMasterConfig(Container $container)
{
$environment = $this->getEnvironment();
$environment = $this->getEnvironment($container);
$file = CACHE_DIR . 'compiled/config/master-'.$environment.'.php';
$data = is_file($file) ? (array) include $file : [];
if ($data) {
Expand All @@ -54,25 +55,17 @@ public function loadMasterConfig(Container $container)

public function loadMasterBlueprints(Container $container)
{
$environment = $this->getEnvironment();
$environment = $this->getEnvironment($container);
$file = CACHE_DIR . 'compiled/blueprints/master-'.$environment.'.php';
$data = is_file($file) ? (array) include $file : [];

return new Blueprints($data, $container);
}

public function getEnvironment()
public function getEnvironment(Container $container)
{
if (!$this->environment) {
$address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1';

// check for localhost variations
if ($address == '::1' || $address == '127.0.0.1') {
$hostname = 'localhost';
} else {
$hostname = gethostname();
}
$this->environment = $hostname;
if (!isset($this->environment)) {
$this->environment = $container['uri']->environment();
}

return $this->environment;
Expand Down
Loading

0 comments on commit 4b46ea2

Please sign in to comment.