- Update twig

Support for excerpt in meta
This commit is contained in:
kpavlov 2013-09-03 00:05:02 +03:00
parent 86b4135ff7
commit 512307b835
14 changed files with 112 additions and 93 deletions

View file

@ -251,7 +251,7 @@ class Pico
'url' => $url,
'date_formatted' => isset($page_meta['date']) ? date($config['date_format'], strtotime($page_meta['date'])) : null,
'content' => $page_content,
'excerpt' => $this->limit_words(strip_tags($page_content), $excerpt_length),
'excerpt' => isset($page_meta['excerpt']) ? $page_meta['excerpt'] : $this->limit_words(strip_tags($page_content), $excerpt_length),
'last_modified' => new DateTime('@' . filemtime($page))
);
$data = array_merge($data, $extras);

4
vendor/autoload.php vendored
View file

@ -1,7 +1,7 @@
<?php
// autoload.php generated by Composer
// autoload.php @generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9::getLoader();
return ComposerAutoloaderInit85cada45d374b066060648da37bbf294::getLoader();

View file

@ -49,7 +49,7 @@ class ClassLoader
public function getPrefixes()
{
return $this->prefixes;
return call_user_func_array('array_merge', $this->prefixes);
}
public function getFallbackDirs()
@ -98,19 +98,21 @@ class ClassLoader
return;
}
if (!isset($this->prefixes[$prefix])) {
$this->prefixes[$prefix] = (array) $paths;
$first = $prefix[0];
if (!isset($this->prefixes[$first][$prefix])) {
$this->prefixes[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixes[$prefix] = array_merge(
$this->prefixes[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixes[$prefix]
$this->prefixes[$first][$prefix]
);
} else {
$this->prefixes[$prefix] = array_merge(
$this->prefixes[$prefix],
$this->prefixes[$first][$prefix] = array_merge(
$this->prefixes[$first][$prefix],
(array) $paths
);
}
@ -119,8 +121,8 @@ class ClassLoader
/**
* Registers a set of classes, replacing any others previously set.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
*/
public function set($prefix, $paths)
{
@ -129,7 +131,7 @@ class ClassLoader
return;
}
$this->prefixes[$prefix] = (array) $paths;
$this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths;
}
/**
@ -195,6 +197,7 @@ class ClassLoader
*/
public function findFile($class)
{
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
if ('\\' == $class[0]) {
$class = substr($class, 1);
}
@ -205,7 +208,7 @@ class ClassLoader
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
$classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
} else {
// PEAR-like class name
@ -213,13 +216,16 @@ class ClassLoader
$className = $class;
}
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
$classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';
foreach ($this->prefixes as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
$first = $class[0];
if (isset($this->prefixes[$first])) {
foreach ($this->prefixes[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
}
}
}
}

View file

@ -1,6 +1,6 @@
<?php
// autoload_classmap.php generated by Composer
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

View file

@ -1,11 +1,11 @@
<?php
// autoload_namespaces.php generated by Composer
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Twig_' => $vendorDir . '/twig/twig/lib',
'Michelf' => $vendorDir . '/michelf/php-markdown',
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
);

View file

@ -1,8 +1,8 @@
<?php
// autoload_real.php generated by Composer
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9
class ComposerAutoloaderInit85cada45d374b066060648da37bbf294
{
private static $loader;
@ -19,16 +19,16 @@ class ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit85cada45d374b066060648da37bbf294', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit85cada45d374b066060648da37bbf294', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
$loader->set($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';

View file

@ -1,55 +1,4 @@
[
{
"name": "twig/twig",
"version": "v1.13.1",
"version_normalized": "1.13.1.0",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Twig.git",
"reference": "v1.13.1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.13.1",
"reference": "v1.13.1",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"time": "2013-06-06 06:06:01",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Twig_": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"keywords": [
"templating"
]
},
{
"name": "michelf/php-markdown",
"version": "1.3",
@ -102,5 +51,56 @@
"keywords": [
"markdown"
]
},
{
"name": "twig/twig",
"version": "v1.13.2",
"version_normalized": "1.13.2.0",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Twig.git",
"reference": "6d6a1009427d1f398c9d40904147bf9f723d5755"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Twig/zipball/6d6a1009427d1f398c9d40904147bf9f723d5755",
"reference": "6d6a1009427d1f398c9d40904147bf9f723d5755",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"time": "2013-08-03 15:35:31",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Twig_": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"keywords": [
"templating"
]
}
]

View file

@ -4,6 +4,7 @@ php:
- 5.2
- 5.3
- 5.4
- 5.5
env:
- TWIG_EXT=no

View file

@ -1,3 +1,8 @@
* 1.13.2 (2013-08-03)
* fixed the error line number for an error occurs in and embedded template
* fixed crashes of the C extension on some edge cases
* 1.13.1 (2013-06-06)
* added the possibility to ignore the filesystem constructor argument in Twig_Loader_Filesystem

View file

@ -4,7 +4,7 @@
"description": "Twig, the flexible, fast, and secure template language for PHP",
"keywords": ["templating"],
"homepage": "http://twig.sensiolabs.org",
"license": "BSD-3",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Fabien Potencier",

View file

@ -16,7 +16,7 @@
*/
class Twig_Environment
{
const VERSION = '1.13.1';
const VERSION = '1.13.2';
protected $charset;
protected $loader;
@ -728,7 +728,7 @@ class Twig_Environment
public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
{
if ($this->extensionInitialized) {
throw new LogicException('Unable to add a node visitor as extensions have already been initialized.', $extension->getName());
throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
}
$this->staging->addNodeVisitor($visitor);

View file

@ -186,6 +186,7 @@ class Twig_Error extends Exception
protected function guessTemplateInfo()
{
$template = null;
$templateClass = null;
if (version_compare(phpversion(), '5.3.6', '>=')) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
@ -195,8 +196,11 @@ class Twig_Error extends Exception
foreach ($backtrace as $trace) {
if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) {
if (null === $this->filename || $this->filename == $trace['object']->getTemplateName()) {
$currentClass = get_class($trace['object']);
$isEmbedContainer = 0 === strpos($templateClass, $currentClass);
if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) {
$template = $trace['object'];
$templateClass = get_class($trace['object']);
}
}
}

View file

@ -16,6 +16,9 @@
*/
class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
{
/** Identifier of the main namespace. */
const MAIN_NAMESPACE = '__main__';
protected $paths;
protected $cache;
@ -38,7 +41,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
*
* @return array The array of paths where to look for templates
*/
public function getPaths($namespace = '__main__')
public function getPaths($namespace = self::MAIN_NAMESPACE)
{
return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
}
@ -46,7 +49,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
/**
* Returns the path namespaces.
*
* The "__main__" namespace is always defined.
* The main namespace is always defined.
*
* @return array The array of defined namespaces
*/
@ -61,7 +64,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
* @param string|array $paths A path or an array of paths where to look for templates
* @param string $namespace A path namespace
*/
public function setPaths($paths, $namespace = '__main__')
public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
{
if (!is_array($paths)) {
$paths = array($paths);
@ -81,7 +84,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
*
* @throws Twig_Error_Loader
*/
public function addPath($path, $namespace = '__main__')
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = array();
@ -101,7 +104,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
*
* @throws Twig_Error_Loader
*/
public function prependPath($path, $namespace = '__main__')
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = array();
@ -175,7 +178,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
$this->validateName($name);
$namespace = '__main__';
$namespace = self::MAIN_NAMESPACE;
if (isset($name[0]) && '@' == $name[0]) {
if (false === $pos = strpos($name, '/')) {
throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));

View file

@ -146,7 +146,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
if (array_key_exists($name, $parameters)) {
if (array_key_exists($pos, $parameters)) {
throw new Twig_Error_Syntax(sprintf('Arguments "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
}
$arguments[] = $parameters[$name];
@ -164,8 +164,8 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
}
}
foreach (array_keys($parameters) as $name) {
throw new Twig_Error_Syntax(sprintf('Unknown argument "%s" for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
if (!empty($parameters)) {
throw new Twig_Error_Syntax(sprintf('Unknown argument%s "%s" for %s "%s".', count($parameters) > 1 ? 's' : '' , implode('", "', array_keys($parameters)), $this->getAttribute('type'), $this->getAttribute('name')));
}
return $arguments;