Skip to content

Commit

Permalink
Merge branch 'release/0.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
w00fz committed Sep 2, 2014
2 parents fbc7ca4 + bbc8f6b commit 15db488
Show file tree
Hide file tree
Showing 41 changed files with 505 additions and 265 deletions.
2 changes: 0 additions & 2 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<IfModule mod_rewrite.c>

Options -Multiviews

RewriteEngine On

##
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ The underlying architecture of Grav has been designed to use well-established an
* [Twig Templating](http://twig.sensiolabs.org/): for powerful control of the user interface
* [Markdown](http://en.wikipedia.org/wiki/Markdown): for easy content creation
* [YAML](http://yaml.org): for simple configuration
* [Doctrine Cache](http://docs.doctrine-project.org/en/2.0.x/reference/caching.html): layer for incredible performance
* [Parsedown](http://parsedown.org/): for fast Markdown and Mardown Extra support
* [Doctrine Cache](http://docs.doctrine-project.org/en/2.0.x/reference/caching.html): layer for performance
* [Pimple Dependency Injection Container](http://pimple.sensiolabs.org/): for extensibility and maintainability
* [Symfony Event Dispacher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html): for plugin event handling
* [Symfony Console](http://symfony.com/doc/current/components/console/introduction.html): for CLI interface
* [Gregwar Image Library](https://github.com/Gregwar/Image): for dynamic image manipulation

# QuickStart

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.1
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
"tracy/tracy": "~2.2",
"gregwar/image": "~2.0",
"ircmaxell/password-compat": "1.0.*",
"mrclay/minify": "~2.2",
"mrclay/minify": "dev-master",
"donatj/phpuseragentparser": "dev-master",
"pimple/pimple": "~3.0"
},
"autoload": {
"psr-4": {
"psr-0": {
"Grav\\": "system/src/"
},
"files": ["system/defines.php"]
},
"archive": {
"exclude": ["VERSION"]
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/rhukster/minify"
}
]
}
35 changes: 23 additions & 12 deletions system/config/streams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ schemes:
- user/plugins
- system/plugins

# asset:
# type: ReadOnlyStream
# paths:
# - assets
asset:
type: ReadOnlyStream
paths:
- assets

# cache:
# type: ReadOnlyStream
# paths:
# - cache
cache:
type: ReadOnlyStream
paths:
- cache

# log:
# type: ReadOnlyStream
# paths:
# - logs
log:
type: ReadOnlyStream
paths:
- logs

user:
type: ReadOnlyStream
paths:
- user

page:
type: ReadOnlyStream
Expand All @@ -34,3 +39,9 @@ schemes:
type: ReadOnlyStream
paths:
- user/data

theme:
type: ReadOnlyStream
prefixes:
'/':
- user/themes
2 changes: 1 addition & 1 deletion system/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pages:
cache:
enabled: true # Set to true to enable caching
check:
pages: true # Check to see if page has been modifying to flush the cache
method: file # Method to check for updates in pages: file|folder|none
driver: auto # One of: auto|file|apc|xcache|memcache|memcached|wincache
prefix: 'g' # Cache prefix string (prevents cache conflicts)

Expand Down
7 changes: 4 additions & 3 deletions system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '0.9.0');
define('GRAV_VERSION', '0.9.1');
define('DS', '/');

// Directories and Paths
if (!defined('ROOT_DIR')) {
define('ROOT_DIR', getcwd() .'/');
if (!defined('GRAV_ROOT')) {
define('GRAV_ROOT', getcwd());
}
define('ROOT_DIR', GRAV_ROOT . '/');
define('USER_PATH', 'user/');
define('USER_DIR', ROOT_DIR . USER_PATH);
define('SYSTEM_DIR', ROOT_DIR .'system/');
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions system/src/Grav/Common/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public function init(Grav $grav)
$this->key = substr(md5(($prefix ? $prefix : 'g') . $uri->rootUrl(true) . $this->config->key . GRAV_VERSION), 2, 8);

$this->driver = $this->getCacheDriver();

// Set the cache namespace to our unique key
$this->driver->setNamespace($this->key);
}

/**
Expand Down Expand Up @@ -132,7 +135,6 @@ public function getCacheDriver()
public function fetch($id)
{
if ($this->enabled) {
$id = $this->key . $id;
return $this->driver->fetch($id);
} else {
return false;
Expand All @@ -149,7 +151,6 @@ public function fetch($id)
public function save($id, $data, $lifetime = null)
{
if ($this->enabled) {
$id = $this->key . $id;
$this->driver->save($id, $data, $lifetime);
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Filesystem/File/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function decode($var)
$var = preg_replace("/(\r\n|\r)/", "\n", $var);

// Parse header.
preg_match("/---\n(.+?)\n---(\n\n|$)/uism", $this->raw(), $m);
preg_match("/---\n(.+?)\n---(\n\n|$)/uism", $var, $m);
$content['header'] = isset($m[1]) ? YamlParser::parse(preg_replace("/\n\t/", "\n ", $m[1])) : array();

// Strip header to get content.
Expand Down
50 changes: 47 additions & 3 deletions system/src/Grav/Common/Filesystem/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ abstract class Folder
* @param string $path
* @return int
*/
public static function lastModified($path)
public static function lastModifiedFolder($path)
{
$last_modified = 0;

$directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);

$last_modified = 0;

/** @var \RecursiveDirectoryIterator $file */
foreach ($iterator as $file) {
$dir_modified = $file->getMTime();
Expand All @@ -32,6 +32,34 @@ public static function lastModified($path)
return $last_modified;
}

/**
* Recursively find the last modified time under given path by file.
*
* @param string $path
* @return int
*/
public static function lastModifiedFile($path)
{
$last_modified = 0;

$dirItr = new \RecursiveDirectoryIterator($path);
$filterItr = new GravRecursiveFilterIterator($dirItr);
$itr = new \RecursiveIteratorIterator($filterItr, \RecursiveIteratorIterator::SELF_FIRST);

/** @var \RecursiveDirectoryIterator $file */
foreach ($itr as $file) {
if (!$file->isDir()) {
$file_modified = $file->getMTime();
if ($file_modified > $last_modified) {
$last_modified = $file_modified;
}
}

}
return $last_modified;
}


/**
* Return recursive list of all files and directories under given path.
*
Expand Down Expand Up @@ -219,3 +247,19 @@ protected static function mkdir($folder)
}
}
}

class GravRecursiveFilterIterator extends \RecursiveFilterIterator {

public static $FILTERS = array(
'.', '..', '.DS_Store'
);

public function accept() {
return !in_array(
$this->current()->getFilename(),
self::$FILTERS,
true
);
}

}
66 changes: 65 additions & 1 deletion system/src/Grav/Common/Markdown/MarkdownGravLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@
namespace Grav\Common\Markdown;

use Grav\Common\Debugger;
use Grav\Common\GravTrait;

/**
* A trait to add some custom processing to the identifyLink() method in Parsedown and ParsedownExtra
*/
trait MarkdownGravLinkTrait
{
use GravTrait;

protected function identifyLink($Excerpt)
{
// Run the parent method to get the actual results
$Excerpt = parent::identifyLink($Excerpt);
$actions = array();
$command = '';
$this->base_url = trim(self::$grav['config']->get('system.base_url_relative'));

// if this is a link
if (isset($Excerpt['element']['attributes']['href'])) {

$url = parse_url(htmlspecialchars_decode($Excerpt['element']['attributes']['href']));

// if there is no host set but there is a path, the file is local
if (!isset($url['host']) && isset($url['path'])) {

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

// if this is an image
if (isset($Excerpt['element']['attributes']['src'])) {
Expand Down Expand Up @@ -75,9 +90,58 @@ protected function identifyLink($Excerpt)
// Set the lightbox element on the Excerpt
$Excerpt['element'] = $Element;
}
} else {
// not a current page media file, see if it needs converting to relative
$Excerpt['element']['attributes']['src'] = $this->convertUrl($url['path']);
}
}
}
return $Excerpt;
}

/**
* Converts links from absolute '/' or relative (../..) to a grav friendly format
* @param string $markdown_url the URL as it was written in the markdown
* @return string the more friendly formatted url
*/
protected function convertUrl($markdown_url)
{
// if absolue and starts with a base_url move on
if (strpos($markdown_url, $this->base_url) === 0) {
$new_url = $markdown_url;
// if its absolute with /
} elseif (strpos($markdown_url, '/') === 0) {
$new_url = rtrim($this->base_url, '/') . $markdown_url;
} else {
$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), '/')));
}

// else its a relative path already
$newpath = array();
$paths = explode('/', $markdown_url);

// remove the updirectory references (..)
foreach ($paths as $path) {
if ($path == '..') {
$relative_path = dirname($relative_path);
} else {
$newpath[] = $path;
}
}

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

return $new_url;
}
}
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function __construct($array = array())
public function init($file)
{
$this->filePath($file->getPathName());
$this->modified(filemtime($file->getPath()));
$this->modified($file->getMTime());
$this->id($this->modified().md5($this->filePath()));
$this->header();
$this->slug();
Expand Down
Loading

0 comments on commit 15db488

Please sign in to comment.