Skip to content

Commit

Permalink
Merge pull request #29 from Netzweberei/master
Browse files Browse the repository at this point in the history
Recent changes and hotfixes
  • Loading branch information
tbreuss committed Mar 10, 2016
2 parents 8486585 + 9e16b65 commit 07c0e2e
Show file tree
Hide file tree
Showing 235 changed files with 2,484 additions and 387 deletions.
12 changes: 5 additions & 7 deletions .gitignore
@@ -1,6 +1,3 @@
# netbeans project files
nbproject

# apigen docs dir
/docs

Expand All @@ -13,9 +10,6 @@ composer.phar
# composer lock files
composer.lock

# mac DS_Store files
.DS_Store

# cache folders
cache/data/
cache/page/
Expand All @@ -25,4 +19,8 @@ cache/twig/
/apps

# Tests
/src/Tests
/src/Tests

# twig test and doc folders
plugins/twig/vendor/twig/twig/doc/
plugins/twig/vendor/twig/twig/test/
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -42,4 +42,4 @@ Weitere Informationen findest du unter [www.getherbie.org](http://www.getherbie.
[packagist]: https://packagist.org
[symfony]: http://symfony.com/doc/current/components/
[phpunit]: http://phpunit.de
[imagine]: https://github.com/avalanche123/Imagine
[imagine]: https://github.com/avalanche123/Imagine
2 changes: 1 addition & 1 deletion log/.gitignore
@@ -1,4 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
!.gitignore
2 changes: 1 addition & 1 deletion plugins/markdown/composer.json
Expand Up @@ -5,4 +5,4 @@
"keywords": ["herbie", "plugin", "markdown"],
"type": "herbie-plugin",
"license": "BSD-3-Clause"
}
}
7 changes: 2 additions & 5 deletions plugins/markdown/markdown.php
Expand Up @@ -12,7 +12,7 @@ public static function install()

// add twig function / filter
if ((bool)$config->get('plugins.config.markdown.twig', false)) {
Hook::attach('twigInitialized', function($twig) {
Hook::attach('twigInitialized', function(\Twig_Environment $twig) {
$options = ['is_safe' => ['html']];
$twig->addFunction(
new \Twig_SimpleFunction('markdown', ['MarkdownPlugin', 'parseMarkdown'], $options)
Expand All @@ -25,9 +25,6 @@ public static function install()

// add shortcode
if ((bool)$config->get('plugins.config.markdown.shortcode', true)) {
#Hook::attach('shortcodeInitialized', function($shortcode) {
# $shortcode->add('markdown', ['MarkdownPlugin', 'markdownShortcode']);
#});
Hook::attach('shortcodeInitialized', ['MarkdownPlugin', 'addShortcode']);

}
Expand All @@ -40,7 +37,7 @@ public static function install()
});
}

public static function addShortcode($shortcode)
public static function addShortcode(\herbie\sysplugin\shortcode\classes\Shortcode $shortcode)
{
$shortcode->add('markdown', ['MarkdownPlugin', 'markdownShortcode']);
}
Expand Down
13 changes: 4 additions & 9 deletions plugins/shortcode/shortcode.php
Expand Up @@ -164,12 +164,12 @@ protected function addListingTag()
$collection = $collection->sort($field, $direction);
}

if (true == (int)$options['shuffle']) {
if (1 == (int)$options['shuffle']) {
$collection = $collection->shuffle();
}

// filter pages with empty title
$collection = $collection->filter(function ($page) {
$collection = $collection->filter(function (\Herbie\Page $page) {
return !empty($page->title);
});

Expand Down Expand Up @@ -360,11 +360,6 @@ protected function addFileTag()
$attributes = $this->extractValuesFromArray(['title', 'text', 'alt', 'class'], $options);
$attributes['alt'] = isset($attributes['alt']) ? $attributes['alt'] : '';

// Interne Ressource
if (strpos($options['path'], 'http') !== 0) {
#$options['path'] = $this->config->get('web.url') . '/' . $options['src'];
}

$info = '';
if (!empty($options['info'])) {
$info = $this->getFileInfo($options['path']);
Expand All @@ -387,13 +382,13 @@ protected function getFileInfo($path)
return '';
}
$replace = [
'{size}' => $this->human_filesize(filesize($path)),
'{size}' => $this->humanFilesize(filesize($path)),
'{extension}' => strtoupper(pathinfo($path, PATHINFO_EXTENSION))
];
return strtr(' ({extension}, {size})', $replace);
}

protected function human_filesize($bytes, $decimals = 0)
protected function humanFilesize($bytes, $decimals = 0)
{
$sz = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
$factor = floor((strlen($bytes) - 1) / 3);
Expand Down
2 changes: 1 addition & 1 deletion plugins/textile/composer.json
Expand Up @@ -5,4 +5,4 @@
"keywords": ["herbie", "plugin", "textile"],
"type": "herbie-plugin",
"license": "BSD-3-Clause"
}
}
8 changes: 4 additions & 4 deletions plugins/textile/textile.php
Expand Up @@ -20,7 +20,7 @@ public function install()
Hook::attach('renderContent', [$this, 'renderContent']);
}

public function addTwigFunctionAndFilter($twig)
public function addTwigFunctionAndFilter(\Twig_Environment $twig)
{
$options = ['is_safe' => ['html']];
$twig->addFunction(
Expand All @@ -31,17 +31,17 @@ public function addTwigFunctionAndFilter($twig)
);
}

public function addSortcode($shortcode)
public function addSortcode(herbie\sysplugin\shortcode\classes\Shortcode $shortcode)
{
$shortcode->add('textile', [$this, 'textileShortcode']);
}

public function renderContent($segment, array $attributes)
public function renderContent( $segment, array $attributes)
{
if(!in_array($attributes['format'], ['textile'])) {
return $segment;
}
return $this->parseTextile($segment->string);
return $this->parseTextile($segment);
}

public function parseTextile($value)
Expand Down
9 changes: 2 additions & 7 deletions plugins/twig/classes/HerbieExtension.php
Expand Up @@ -446,7 +446,7 @@ public function functionMenu(array $options = [])
$htmlTree = new Menu\Page\Renderer\HtmlTree($filterIterator);
$htmlTree->setMaxDepth($maxDepth);
$htmlTree->setClass($class);
$htmlTree->itemCallback = function ($node) {
$htmlTree->itemCallback = function (\Herbie\Node $node) {
$menuItem = $node->getMenuItem();
$href = $this->urlGenerator->generate($menuItem->route);
return sprintf('<a href="%s">%s</a>', $href, $menuItem->getMenuTitle());
Expand Down Expand Up @@ -482,7 +482,6 @@ public function functionPagetitle(array $options = [])
$titles[] = $item->title;
}

#$page = Application::getPage();
if ($this->testIsPost($this->page)) {
$titles[] = $this->page->title;
}
Expand Down Expand Up @@ -549,10 +548,6 @@ public function functionPager($limit = '', $template = '{prev}{next}', $linkClas
}
$replacements['{prev}'] = $this->createLink($prev->route, $label, $attribs);
}
/*if(isset($cur)) {
$label = empty($curPageLabel) ? $cur->getMenuTitle() : $curPageLabel;
$replacements['{cur}'] = $this->createLink($cur->route, $label, $attribs);
}*/
if (isset($next)) {
$label = empty($nextPageLabel) ? $next->getMenuTitle() : $nextPageLabel;
$label = sprintf('<span>%s</span>', $label);
Expand Down Expand Up @@ -597,7 +592,7 @@ public function functionSitemap(array $options = [])
$htmlTree = new Menu\Page\Renderer\HtmlTree($filterIterator);
$htmlTree->setMaxDepth($maxDepth);
$htmlTree->setClass($class);
$htmlTree->itemCallback = function ($node) {
$htmlTree->itemCallback = function (\Herbie\Node $node) {
$menuItem = $node->getMenuItem();
$href = $this->urlGenerator->generate($menuItem->route);
return sprintf('<a href="%s">%s</a>', $href, $menuItem->getMenuTitle());
Expand Down
19 changes: 12 additions & 7 deletions plugins/twig/classes/Twig.php
Expand Up @@ -64,18 +64,24 @@ public function init()
$this->addTwigPlugins();

foreach(Hook::trigger(Hook::CONFIG, 'addTwigFunction') as $function) {
@list($name, $callable, $options) = $function;
$this->environment->addFunction(new \Twig_SimpleFunction($name, $callable, (array)$options));
try {
list($name, $callable, $options) = $function;
$this->environment->addFunction(new \Twig_SimpleFunction($name, $callable, (array)$options));
} catch (\Exception $e) {;/*do nothing else yet*/}
}

foreach(Hook::trigger(Hook::CONFIG, 'addTwigFilter') as $filter) {
@list($name, $callable, $options) = $filter;
$this->environment->addFilter(new \Twig_SimpleFilter($name, $callable, (array)$options));
try {
list($name, $callable, $options) = $filter;
$this->environment->addFilter(new \Twig_SimpleFilter($name, $callable, (array)$options));
} catch (\Exception $e) {;/*do nothing else yet*/}
}

foreach(Hook::trigger(Hook::CONFIG, 'addTwigTest') as $test) {
@list($name, $callable, $options) = $test;
$this->environment->addTest(new \Twig_SimpleTest($name, $callable, (array)$options));
try {
list($name, $callable, $options) = $test;
$this->environment->addTest(new \Twig_SimpleTest($name, $callable, (array)$options));
} catch (\Exception $e) {;/*do nothing else yet*/}
}

$this->initialized = true;
Expand Down Expand Up @@ -179,7 +185,6 @@ public function renderString($string)
*/
private function getContext()
{
// @todo Inject request object or refactor code
return [
'route' => Application::getService('Request')->getRoute(),
'baseUrl' => Application::getService('Request')->getBasePath(),
Expand Down
1 change: 0 additions & 1 deletion plugins/twig/classes/widgets/blog/archives.html
@@ -1,6 +1,5 @@
{% set title = title ? title : 'Archives' %}
{% set showCount = showCount ? showCount : false %}
{# @todo: option dropdown (Display as dropdown) #}

{% if site.posts.months|length > 0 %}
<div class="widget-blog widget-blog-archives">
Expand Down
2 changes: 0 additions & 2 deletions plugins/twig/classes/widgets/blog/categories.html
@@ -1,7 +1,5 @@
{% set title = title ? title : 'Categories' %}
{% set showCount = showCount ? showCount : false %}
{# @todo: option dropdown (Display as dropdown) #}
{# @todo: option hierarchical (Show hierarchy) #}

{% if site.posts.categories|length > 0 %}
<div class="widget-blog widget-blog-categories">
Expand Down
2 changes: 0 additions & 2 deletions plugins/twig/classes/widgets/blog/tags.html
@@ -1,7 +1,5 @@
{% set title = title ? title : 'Tags' %}
{% set showCount = showCount ? showCount : false %}
{# @todo: option dropdown (Display as dropdown) #}
{# @todo: option hierarchical (Show hierarchy) #}

{% if site.posts.tags|length > 0 %}
<div class="widget-blog widget-blog-tags">
Expand Down
2 changes: 1 addition & 1 deletion plugins/twig/classes/widgets/listing.twig
Expand Up @@ -22,4 +22,4 @@
<a class="pure-button" href="{{ url(route) }}?page={{ pagination.getNextPage() }}">Nächste Seite <i class="fa fa-chevron-right"></i></a>
{% endif %}
</nav>
</div>
</div>
7 changes: 5 additions & 2 deletions plugins/twig/composer.json
Expand Up @@ -4,5 +4,8 @@
"description": "Herbie Twig Plugin.",
"keywords": ["herbie", "plugin", "twig"],
"type": "herbie-plugin",
"license": "BSD-3-Clause"
}
"license": "BSD-3-Clause",
"require": {
"twig/twig": "v1.24.0"
}
}
4 changes: 2 additions & 2 deletions plugins/twig/twig.php
Expand Up @@ -23,7 +23,7 @@ public function initTwig()
// Add custom namespace path to Imagine lib
$vendorDir = $config->get('site.path') . '/../vendor';
$autoload = require($vendorDir . '/autoload.php');
$autoload->add('Twig_', __DIR__ . '/vendor/twig/lib');
$autoload->add('Twig_', __DIR__ . '/vendor/twig/twig/lib');

$this->twig = new Twig($config);
$this->twig->init();
Expand All @@ -39,7 +39,7 @@ public function twigifyContent($content, array $attributes)
return $this->twig->renderString($content);
}

public function twigifyLayout($page)
public function twigifyLayout(\Herbie\Page $page)
{
$this->twig->getEnvironment()->getExtension('herbie')->setPage($page);
return $this->twig->render($page->layout);
Expand Down
7 changes: 7 additions & 0 deletions plugins/twig/vendor/autoload.php
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInitf84460c64075609698bc244298114a62::getLoader();
18 changes: 18 additions & 0 deletions plugins/twig/vendor/twig/twig/.editorconfig
@@ -0,0 +1,18 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF

[*.php]
indent_style = space
indent_size = 4

[*.test]
indent_style = space
indent_size = 4

[*.rst]
indent_style = space
indent_size = 4
5 changes: 5 additions & 0 deletions plugins/twig/vendor/twig/twig/.gitignore
@@ -0,0 +1,5 @@
/build
/composer.lock
/ext/twig/autom4te.cache/
/phpunit.xml
/vendor
39 changes: 39 additions & 0 deletions plugins/twig/vendor/twig/twig/.travis.yml
@@ -0,0 +1,39 @@
language: php

sudo: false

cache:
directories:
- vendor
- $HOME/.composer/cache

php:
- 5.2
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

env:
- TWIG_EXT=no
- TWIG_EXT=yes

install:
# Composer is not available on PHP 5.2
- if [ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]; then travis_retry composer install; fi

before_script:
- if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi
- if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
- if [ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]; then sed -i.bak "s|vendor/autoload.php|test/bootstrap.php|" phpunit.xml.dist; fi

matrix:
fast_finish: true
exclude:
- php: hhvm
env: TWIG_EXT=yes
allow_failures:
- php: 7.0
env: TWIG_EXT=yes

0 comments on commit 07c0e2e

Please sign in to comment.