From 0eede10c1d02c1670368af6656274cb17159c43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Votruba?= Date: Wed, 18 Mar 2015 19:12:48 +0100 Subject: [PATCH 1/5] Readme: simplify install; highlighting added --- README.md | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 88d1601..7030761 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,11 @@ Nette component for creating menus and breadcrumbs. ``` $ composer require sakren/nette-menu -$ composer update ``` Now you need to register this as Nette extension in your config.neon file. -``` +```yaml extensions: menu: DK\Menu\DI\Extension @@ -24,7 +23,7 @@ includes: Than you can create new `menu` section for example in menu.neon. -``` +```yaml menu: default: @@ -49,13 +48,13 @@ Of course you can create more nested menu. Also you can see that there are more ways how to write link. If you have got single link without children, you can use this. -``` +```yaml Title of link: Presenter:action ``` or links with children -``` +```yaml Title of link: target: Presenter:action items: [] @@ -65,7 +64,7 @@ there is actually also third way, but it is useful just for specific cases and i ## Render menu and breadcrumb -``` +```php class BasePresenter extends Nette\Application\UI\Presenter { @@ -87,7 +86,7 @@ class BasePresenter extends Nette\Application\UI\Presenter @layout.latte: -``` +```smarty {control menu:breadcrumb} {control menu} @@ -96,12 +95,12 @@ class BasePresenter extends Nette\Application\UI\Presenter ## Render sitemap.xml Router -``` +```php $router[] = new Route('sitemap.xml', 'Homepage:sitemap'); ``` Homepage/sitemap.latte -``` +```smarty {extends none} {control menu:sitemapXml} ``` @@ -111,7 +110,7 @@ Homepage/sitemap.latte You can hide some links for example for users without specific role, guest users, actions in other module or when needed presenter parameter is missing. -``` +```yaml menu: default: @@ -145,7 +144,7 @@ menu: or whole menu can be allowed for example just logged users: -``` +```yaml menu: default: @@ -161,7 +160,7 @@ menu: Imagine that you have for example link to books settings and page for adding book which you do not wish to add to your menu but at the same time you want base books settings link to be highlighted. -``` +```yaml menu: default: @@ -179,7 +178,7 @@ menu: if you want to highlight "Books settings" link for all actions in BookPresenter, you can include all targets with regexp. -``` +```yaml menu: default: @@ -191,7 +190,7 @@ menu: or with array of included targets. -``` +```yaml menu: default: @@ -207,7 +206,7 @@ menu: ## Custom templates -``` +```yaml menu: default: @@ -221,7 +220,7 @@ menu: ## Translated titles -``` +```yaml menu: default: @@ -233,7 +232,7 @@ menu: Lets say that we want base menu and menu just for users in `admin` role. -``` +```yaml menu: default: @@ -250,7 +249,7 @@ menu services. Solution is to create custom control and factory classes. -``` +```php namespace App\Components\AdminMenu; use DK; @@ -271,7 +270,7 @@ interface IMenuControlFactory now we have to update our menu configuration -``` +```yaml menu: admin: @@ -288,7 +287,7 @@ below: Books / Harry Potter / Edit -``` +```yaml menu: default: @@ -304,7 +303,7 @@ link for adding another links into it. First, we will add just one small helper method to our BasePresenter. -``` +```php class BasePresenter extends Nette\Application\UI\Presenter { @@ -337,7 +336,7 @@ class BasePresenter extends Nette\Application\UI\Presenter BookPresenter: -``` +```php class BookPresenter extends BasePresenter { From 6edabc584e7ce4c6086eb48c83a93198572170e6 Mon Sep 17 00:00:00 2001 From: David Kudera Date: Wed, 18 Mar 2015 20:18:27 +0100 Subject: [PATCH 2/5] update tests so they can run under nette 2.3.0 --- composer.json | 2 +- tests/DKTests/Menu/Extension.phpt | 22 +++++++++++++++---- .../HomepagePresenter.php | 2 +- .../AboutPresenter.php | 0 .../BasePresenter.php | 16 ++++++++++++-- .../BookPresenter.php | 0 .../HomepagePresenter.php | 0 .../SettingsPresenter.php | 0 .../UserPresenter.php | 0 tests/DKTests/app/config/config.neon | 5 +---- tests/DKTests/app/config/more.neon | 6 +++-- tests/DKTests/bootstrap.php | 4 +++- 12 files changed, 42 insertions(+), 15 deletions(-) rename tests/DKTests/app/BooksModule/{presenters => Presenters}/HomepagePresenter.php (73%) rename tests/DKTests/app/{presenters => Presenters}/AboutPresenter.php (100%) rename tests/DKTests/app/{presenters => Presenters}/BasePresenter.php (57%) rename tests/DKTests/app/{presenters => Presenters}/BookPresenter.php (100%) rename tests/DKTests/app/{presenters => Presenters}/HomepagePresenter.php (100%) rename tests/DKTests/app/{presenters => Presenters}/SettingsPresenter.php (100%) rename tests/DKTests/app/{presenters => Presenters}/UserPresenter.php (100%) diff --git a/composer.json b/composer.json index 2a80d8e..de9a2d6 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "issues": "https://github.com/sakren/nette-menu/issues" }, "require": { - "nette/nette": ">= 2.1.0" + "nette/nette": ">= 2.2.0" }, "require-dev": { "nette/tester": "@dev" diff --git a/tests/DKTests/Menu/Extension.phpt b/tests/DKTests/Menu/Extension.phpt index 2c36127..08ce9ad 100644 --- a/tests/DKTests/Menu/Extension.phpt +++ b/tests/DKTests/Menu/Extension.phpt @@ -107,9 +107,9 @@ class ExtensionTest extends TestCase { $di = $this->createContainer('more'); - $controlFactory = $di->getByType('DKTests\Menu\ICustomControlFactory'); /** @var $controlFactory \DKTests\Menu\ICustomControlFactory */ - Assert::true($controlFactory instanceof ICustomControlFactory); - Assert::true($controlFactory->create() instanceof CustomControl); + $controlFactory = $di->getByType('DKTests\Menu\IOtherCustomControlFactory'); /** @var $controlFactory \DKTests\Menu\ICustomControlFactory */ + Assert::true($controlFactory instanceof IOtherCustomControlFactory); + Assert::true($controlFactory->create() instanceof OtherCustomControl); } } @@ -117,7 +117,7 @@ class ExtensionTest extends TestCase class CustomControl extends Control {} -interface ICustomControlFactory +interface ICustomControlFactory extends IControlFactory { @@ -129,4 +129,18 @@ interface ICustomControlFactory } +class OtherCustomControl extends Control {} + +interface IOtherCustomControlFactory extends IControlFactory +{ + + + /** + * @return \DKTests\Menu\OtherCustomControl + */ + public function create(); + +} + + \run(new ExtensionTest); diff --git a/tests/DKTests/app/BooksModule/presenters/HomepagePresenter.php b/tests/DKTests/app/BooksModule/Presenters/HomepagePresenter.php similarity index 73% rename from tests/DKTests/app/BooksModule/presenters/HomepagePresenter.php rename to tests/DKTests/app/BooksModule/Presenters/HomepagePresenter.php index 54b8fa9..1d79e60 100644 --- a/tests/DKTests/app/BooksModule/presenters/HomepagePresenter.php +++ b/tests/DKTests/app/BooksModule/Presenters/HomepagePresenter.php @@ -2,7 +2,7 @@ namespace DKTests\BooksModule\Presenters; -require_once __DIR__ . '/../../presenters/BasePresenter.php'; +require_once __DIR__ . '/../../Presenters/BasePresenter.php'; use DKTests\Presenters\BasePresenter; diff --git a/tests/DKTests/app/presenters/AboutPresenter.php b/tests/DKTests/app/Presenters/AboutPresenter.php similarity index 100% rename from tests/DKTests/app/presenters/AboutPresenter.php rename to tests/DKTests/app/Presenters/AboutPresenter.php diff --git a/tests/DKTests/app/presenters/BasePresenter.php b/tests/DKTests/app/Presenters/BasePresenter.php similarity index 57% rename from tests/DKTests/app/presenters/BasePresenter.php rename to tests/DKTests/app/Presenters/BasePresenter.php index dc85066..5e92ef4 100644 --- a/tests/DKTests/app/presenters/BasePresenter.php +++ b/tests/DKTests/app/Presenters/BasePresenter.php @@ -3,6 +3,7 @@ namespace DKTests\Presenters; use Nette\Application\UI\Presenter; +use Nette\DI\Container; /** * @@ -12,8 +13,19 @@ class BasePresenter extends Presenter { - /** @var \DK\Menu\UI\IControlFactory @inject */ - public $menuFactory; + /** @var \DK\Menu\UI\IControlFactory */ + private $menuFactory; + + + /** + * @param \Nette\DI\Container $context + */ + public function __construct(Container $context) + { + parent::__construct(); + + $this->menuFactory = $context->getByType('DK\Menu\UI\IControlFactory'); // just for disabling warning about more than one services of same type + } /** diff --git a/tests/DKTests/app/presenters/BookPresenter.php b/tests/DKTests/app/Presenters/BookPresenter.php similarity index 100% rename from tests/DKTests/app/presenters/BookPresenter.php rename to tests/DKTests/app/Presenters/BookPresenter.php diff --git a/tests/DKTests/app/presenters/HomepagePresenter.php b/tests/DKTests/app/Presenters/HomepagePresenter.php similarity index 100% rename from tests/DKTests/app/presenters/HomepagePresenter.php rename to tests/DKTests/app/Presenters/HomepagePresenter.php diff --git a/tests/DKTests/app/presenters/SettingsPresenter.php b/tests/DKTests/app/Presenters/SettingsPresenter.php similarity index 100% rename from tests/DKTests/app/presenters/SettingsPresenter.php rename to tests/DKTests/app/Presenters/SettingsPresenter.php diff --git a/tests/DKTests/app/presenters/UserPresenter.php b/tests/DKTests/app/Presenters/UserPresenter.php similarity index 100% rename from tests/DKTests/app/presenters/UserPresenter.php rename to tests/DKTests/app/Presenters/UserPresenter.php diff --git a/tests/DKTests/app/config/config.neon b/tests/DKTests/app/config/config.neon index d461e4c..ce43e93 100644 --- a/tests/DKTests/app/config/config.neon +++ b/tests/DKTests/app/config/config.neon @@ -7,9 +7,6 @@ nette: mapping: *: DKTests\*Module\Presenters\*Presenter - security: - frames: null - session: autoStart: false @@ -21,7 +18,7 @@ services: cacheStorage: class: Nette\Caching\Storages\MemoryStorage - # to lazy to create new factory service + # too lazy to create new factory service router: class: Nette\Application\Routers\RouteList setup: diff --git a/tests/DKTests/app/config/more.neon b/tests/DKTests/app/config/more.neon index 110b69c..4c04554 100644 --- a/tests/DKTests/app/config/more.neon +++ b/tests/DKTests/app/config/more.neon @@ -1,7 +1,9 @@ menu: default: - - other: controlClass: DKTests\Menu\CustomControl controlInterface: DKTests\Menu\ICustomControlFactory + + other: + controlClass: DKTests\Menu\OtherCustomControl + controlInterface: DKTests\Menu\IOtherCustomControlFactory diff --git a/tests/DKTests/bootstrap.php b/tests/DKTests/bootstrap.php index 4bd33f4..467d02d 100644 --- a/tests/DKTests/bootstrap.php +++ b/tests/DKTests/bootstrap.php @@ -1,10 +1,12 @@ addPsr4('DKTests\\', __DIR__. '/app'); + // configure environment Tester\Environment::setup(); class_alias('Tester\Assert', 'Assert'); From f51eb25eb92e25fbf9a537f6dd1c01d26069cd24 Mon Sep 17 00:00:00 2001 From: David Kudera Date: Wed, 18 Mar 2015 20:20:59 +0100 Subject: [PATCH 3/5] using standard tester run script --- .travis.yml | 2 +- tests/run-tests.sh | 43 ------------------------------------------- 2 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 tests/run-tests.sh diff --git a/.travis.yml b/.travis.yml index 1fb3ccd..bd81317 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ before_script: - composer self-update - composer install --no-interaction --prefer-source --dev -script: VERBOSE=true sh ./tests/run-tests.sh -s tests/DKTests/ +script: ./vendor/bin/tester -s -p php -c ./tests/php.ini-unix ./tests/DKTests/ diff --git a/tests/run-tests.sh b/tests/run-tests.sh deleted file mode 100644 index 7afb6d0..0000000 --- a/tests/run-tests.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -# Path to this script's directory -dir=$(cd `dirname $0` && pwd) - -# Path to test runner script -runnerScript="$dir/../vendor/nette/tester/Tester/tester.php" -if [ ! -f "$runnerScript" ]; then - runnerScript="$dir/../../../nette/tester/Tester/tester.php" - if [ ! -f "$runnerScript" ]; then - echo "Nette Tester is missing. You can install it using Composer:" >&2 - echo "php composer.phar update --dev." >&2 - exit 2 - fi -fi - -# Path to php.ini if passed as argument option -phpIni= -while getopts ":c:" opt; do - case $opt in - c) phpIni="$OPTARG" - ;; - - :) echo "Missing argument for -$OPTARG option" >&2 - exit 2 - ;; - esac -done - -# Runs tests with script's arguments, add default php.ini if not specified -# Doubled -c option intentionally -if [ -n "$phpIni" ]; then - php -c "$phpIni" "$runnerScript" -j 20 "$@" -else - php -c "$dir/php.ini-unix" "$runnerScript" -j 20 -c "$dir/php.ini-unix" "$@" -fi -error=$? - -# Print *.actual content if tests failed -if [ "${VERBOSE-false}" != "false" -a $error -ne 0 ]; then - for i in $(find . -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done - exit $error -fi From 9710bee1b15eb889e12a4b98f090424c772a9948 Mon Sep 17 00:00:00 2001 From: David Kudera Date: Wed, 18 Mar 2015 20:41:16 +0100 Subject: [PATCH 4/5] extension tests: testing interfaces does not extends base control factories --- tests/DKTests/Menu/Extension.phpt | 4 ++-- tests/DKTests/app/Presenters/BasePresenter.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/DKTests/Menu/Extension.phpt b/tests/DKTests/Menu/Extension.phpt index 08ce9ad..9fa8604 100644 --- a/tests/DKTests/Menu/Extension.phpt +++ b/tests/DKTests/Menu/Extension.phpt @@ -117,7 +117,7 @@ class ExtensionTest extends TestCase class CustomControl extends Control {} -interface ICustomControlFactory extends IControlFactory +interface ICustomControlFactory { @@ -131,7 +131,7 @@ interface ICustomControlFactory extends IControlFactory class OtherCustomControl extends Control {} -interface IOtherCustomControlFactory extends IControlFactory +interface IOtherCustomControlFactory { diff --git a/tests/DKTests/app/Presenters/BasePresenter.php b/tests/DKTests/app/Presenters/BasePresenter.php index 5e92ef4..2c359a1 100644 --- a/tests/DKTests/app/Presenters/BasePresenter.php +++ b/tests/DKTests/app/Presenters/BasePresenter.php @@ -24,7 +24,7 @@ public function __construct(Container $context) { parent::__construct(); - $this->menuFactory = $context->getByType('DK\Menu\UI\IControlFactory'); // just for disabling warning about more than one services of same type + $this->menuFactory = $context->getByType('DK\Menu\UI\IControlFactory'); // just for disabling warning about non existing services } From 41dd31ab44c1e23a76af0d88216539b5de78c55e Mon Sep 17 00:00:00 2001 From: David Kudera Date: Sat, 18 Jul 2015 15:25:50 +0200 Subject: [PATCH 5/5] move repository --- README.md | 7 +++++-- composer.json | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7030761..7a1cbb5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Build Status](https://travis-ci.org/sakren/nette-menu.png?branch=master)](https://travis-ci.org/sakren/nette-menu) -[![Donate](http://b.repl.ca/v1/donate-PayPal-brightgreen.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPH6AC9D5LGHY) +[![Build Status](https://img.shields.io/travis/Carrooi/Nette-Menu.svg?style=flat-square)](https://travis-ci.org/Carrooi/Nette-Menu) +[![Donate](https://img.shields.io/badge/donate-PayPal-brightgreen.svg?style=flat-square)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPH6AC9D5LGHY) # Nette menu @@ -354,6 +354,9 @@ class BookPresenter extends BasePresenter ## Changelog +* 1.1.1 + + Move under Carrooi organization + * 1.1.0 + Support for ACL permissions (thanks [whipsterCZ](https://github.com/whipsterCZ)) + Support for generating sitemap (thanks [whipsterCZ](https://github.com/whipsterCZ)) diff --git a/composer.json b/composer.json index de9a2d6..b1db895 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "sakren/nette-menu", + "name": "carrooi/nette-menu", "type": "library", "description": "Menu controls for Nette framework", "keywords": ["nette", "menu", "control", "breadcrumbs"], - "homepage": "http://github.com/sakren/nette-menu", + "homepage": "https://github.com/Carrooi/Nette-Menu", "license": "MIT", "authors": [ { @@ -13,7 +13,7 @@ } ], "support": { - "issues": "https://github.com/sakren/nette-menu/issues" + "issues": "https://github.com/Carrooi/Nette-Menu/issues" }, "require": { "nette/nette": ">= 2.2.0"