Skip to content

Commit

Permalink
Merge branch 'release/0.9.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Feb 6, 2015
2 parents 846a0ba + 50785c2 commit ab358dd
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 90 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# v0.9.17
## 02/05/2015

1. [](#new)
* Added **full HHVM support!** Get your speed on with Facebook's crazy fast PHP JIT compiler
2. [](#improved)
* More flexible page summary control
* Support **CamelCase** plugin and theme class names. Replaces dashes and underscores
* Moved summary delimiter into `site.yaml` so it can be configurable
* Various PSR fixes
3. [](#bugfix)
* Fix for `mergeConfig()` not falling back to defaults
* Fix for `addInlineCss()` and `addInlineJs()` Assets not working between Twig tags
* Fix for Markdown adding HTML tags into inline CSS and JS

# v0.9.16
## 01/30/2015

Expand Down
5 changes: 4 additions & 1 deletion system/config/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ taxonomies: [category,tag] # Arbitrary list of taxonomy types
blog:
route: '/blog' # Route to blog
metadata:
description: 'My Grav Site' # Site description
description: 'My Grav Site' # Site description
summary:
enabled: true # enable or disable summary of page
format: short # long = summary delimiter will be ignored; short = use the first occurence of delimter or size
size: 300 # Maximum length of summary (characters)
delimiter: === # The summary delimiter
routes:
/something/else: '/blog/sample-3' # Alias for /blog/sample-3
/another/one/here: '/blog/sample-3' # Another alias for /blog/sample-3
Expand Down
5 changes: 1 addition & 4 deletions 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.16');
define('GRAV_VERSION', '0.9.17');
define('DS', '/');

// Directories and Paths
Expand Down Expand Up @@ -40,6 +40,3 @@
define('TWIG_CONTENT', 2);
define('TWIG_CONTENT_LIST', 3);
define('TWIG_TEMPLATES', 4);

// Misc Defines
define('SUMMARY_DELIMITER', '===');
16 changes: 11 additions & 5 deletions system/src/Grav/Common/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public function config(array $config)
public function init()
{
/** @var Config $config */
$config = self::$grav['config'];
$base_url = self::$grav['base_url'];
$config = self::getGrav()['config'];
$base_url = self::getGrav()['base_url'];
$asset_config = (array)$config->get('system.assets');

$this->config($asset_config);
Expand Down Expand Up @@ -301,6 +301,9 @@ public function addJs($asset, $priority = 10, $pipeline = true)
*/
public function addInlineCss($asset, $priority = 10)
{
if (is_a($asset, 'Twig_Markup')) {
$asset = strip_tags((string)$asset);
}
$key = md5($asset);
if (is_string($asset) && !array_key_exists($key, $this->inline_css)) {
$this->inline_css[$key] = [
Expand All @@ -326,6 +329,9 @@ public function addInlineCss($asset, $priority = 10)
*/
public function addInlineJs($asset, $priority = 10)
{
if (is_a($asset, 'Twig_Markup')) {
$asset = strip_tags((string)$asset);
}
$key = md5($asset);
if (is_string($asset) && !array_key_exists($key, $this->inline_js)) {
$this->inline_js[$key] = [
Expand All @@ -352,7 +358,7 @@ public function css($attributes = [])
}

// Sort array by priorities (larger priority first)
if (self::$grav) {
if (self::getGrav()) {
usort($this->css, function ($a, $b) {
if ($a['priority'] == $b['priority']) {
return $b['order'] - $a['order'];
Expand Down Expand Up @@ -465,7 +471,7 @@ public function js($attributes = [])
protected function pipeline($css = true)
{
/** @var Cache $cache */
$cache = self::$grav['cache'];
$cache = self::getGrav()['cache'];
$key = '?' . $cache->getKey();

if ($css) {
Expand Down Expand Up @@ -681,7 +687,7 @@ protected function isRemoteLink($link)
protected function buildLocalLink($asset)
{
try {
$asset = self::$grav['locator']->findResource($asset, false);
$asset = self::getGrav()['locator']->findResource($asset, false);
} catch (\Exception $e) {
}

Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/GPM/Local/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Plugins extends Collection
*/
public function __construct()
{
$grav = self::$grav;
$grav = self::getGrav();

foreach ($grav['plugins']->all() as $name => $data) {
$this->items[$name] = new Package($data, $this->type);
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/GPM/Local/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Themes extends Collection
private $type = 'themes';
public function __construct()
{
$grav = self::$grav;
$grav = self::getGrav();

foreach ($grav['themes']->all() as $name => $data) {
$this->items[$name] = new Package($data, $this->type);
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/GPM/Remote/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct($repository = null) {
throw new \RuntimeException("A repository is required for storing the cache");
}

$cache_dir = self::$grav['locator']->findResource('cache://gpm', true, true);
$cache_dir = self::getGrav()['locator']->findResource('cache://gpm', true, true);
$this->cache = new FilesystemCache($cache_dir);

$this->repository = $repository;
Expand Down
3 changes: 3 additions & 0 deletions system/src/Grav/Common/GravTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ trait GravTrait
*/
public function getGrav()
{
if (!self::$grav) {
self::$grav = Grav::instance();
}
return self::$grav;
}

Expand Down
8 changes: 4 additions & 4 deletions system/src/Grav/Common/Markdown/ParsedownGravTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ trait ParsedownGravTrait
protected function init($page)
{
$this->page = $page;
$this->pages = self::$grav['pages'];
$this->pages = self::getGrav()['pages'];
$this->BlockTypes['{'] [] = "TwigTag";
$this->base_url = rtrim(self::$grav['base_url'] . self::$grav['pages']->base(), '/');
$this->pages_dir = self::$grav['locator']->findResource('page://');
$this->base_url = rtrim(self::getGrav()['base_url'] . self::getGrav()['pages']->base(), '/');
$this->pages_dir = self::getGrav()['locator']->findResource('page://');
$this->special_chars = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
}

Expand Down Expand Up @@ -159,7 +159,7 @@ protected function inlineImage($excerpt)

} else {
// Create the custom lightbox element

$attributes = $data['a_attributes'];
$attributes['href'] = $data['a_href'];

Expand Down
14 changes: 7 additions & 7 deletions system/src/Grav/Common/Page/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($path)
$medium = $this->get("{$basename}.{$ext}");

if (!$alternative) {

$medium = $medium ? $medium : $this->createMedium($info->getPathname());

if (!$medium) {
Expand All @@ -70,7 +70,7 @@ public function __construct($path)
} else {

$altMedium = $this->createMedium($info->getPathname());

if (!$altMedium) {
continue;
}
Expand All @@ -86,7 +86,7 @@ public function __construct($path)
}

$medium = $medium ? $medium : $this->scaleMedium($altMedium, $alternative, 1);

$medium->addAlternative($this->parseRatio($alternative), $altMedium);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ public function files()
* Create a Medium object from a file
*
* @param string $file
*
*
* @return Medium|null
*/
protected function createMedium($file)
Expand All @@ -202,7 +202,7 @@ protected function createMedium($file)
$basename = implode('.', $parts);

/** @var Config $config */
$config = self::$grav['config'];
$config = self::getGrav()['config'];

// Check if medium type has been configured.
$params = $config->get("media.".strtolower($ext));
Expand All @@ -224,7 +224,7 @@ protected function createMedium($file)
'modified' => filemtime($file),
);

$locator = self::$grav['locator'];
$locator = self::getGrav()['locator'];

$lookup = $locator->findResources('image://');
foreach ($lookup as $lookupPath) {
Expand Down Expand Up @@ -257,7 +257,7 @@ protected function scaleMedium($medium, $from, $to)
$medium->set('debug', false);

$file = $medium->resize($width, $height)->setPrettyName($basename)->url();
$file = preg_replace('|'. preg_quote(self::$grav['base_url_relative']) .'$|', '', GRAV_ROOT) . $file;
$file = preg_replace('|'. preg_quote(self::getGrav()['base_url_relative']) .'$|', '', GRAV_ROOT) . $file;

$medium->set('debug', $debug);

Expand Down
19 changes: 5 additions & 14 deletions system/src/Grav/Common/Page/Medium.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,7 @@ public function __construct($items = array(), Blueprint $blueprint = null)
$this->def('mime', 'application/octet-stream');
}

$debug = self::$grav['config']->get('system.images.debug');
// try to override with page setting if possible
$page = self::$grav['page'];
if (!is_null($page)) {
if (isset($page->header()->images['debug'])) {
$debug = $page->header()->images['debug'];
}
}

$this->set('debug', $debug);
$this->set('debug', self::getGrav()['config']->get('system.images.debug'));
}

/**
Expand Down Expand Up @@ -177,7 +168,7 @@ public function url($reset = true)
$output = preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('path')) . '/' . $this->get('filename');
}

return self::$grav['base_url'] . $output;
return self::getGrav()['base_url'] . $output;
}


Expand Down Expand Up @@ -341,7 +332,7 @@ public function link($width = null, $height = null)
}
} else {
// TODO: we need to find out URI in a bit better way.
$this->linkTarget = self::$grav['base_url'] . preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('path')) . '/' . $this->get('filename');
$this->linkTarget = self::getGrav()['base_url'] . preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('path')) . '/' . $this->get('filename');
}

return $this;
Expand Down Expand Up @@ -431,7 +422,7 @@ public function __call($method, $args)
*/
public function image($variable = 'thumb')
{
$locator = self::$grav['locator'];
$locator = self::getGrav()['locator'];

// TODO: add default file
$file = $this->get($variable);
Expand Down Expand Up @@ -462,7 +453,7 @@ protected function saveImage()
$ratio = 1;
}

$locator = self::$grav['locator'];
$locator = self::getGrav()['locator'];
$overlay = $locator->findResource("system://assets/responsive-overlays/{$ratio}x.png") ?: $locator->findResource('system://assets/responsive-overlays/unknown.png');
$this->image->merge(ImageFile::open($overlay));
}
Expand Down
Loading

0 comments on commit ab358dd

Please sign in to comment.