From bafe0629f2e46cbe7c2bb03d3edf94f50058d107 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Thu, 14 Apr 2016 15:44:58 +0100 Subject: [PATCH] First commit --- .editorconfig | 15 +++ .gitattributes | 8 ++ .gitignore | 7 ++ .scrutinizer.yml | 35 ++++++ .travis.yml | 26 +++++ CONTRIBUTING.md | 31 +++++ LICENSE.md | 21 ++++ README.md | 48 ++++++++ composer.json | 44 +++++++ config/pages.php | 7 ++ config/sidebar/main.php | 5 + phpunit.xml | 28 +++++ src/Http/Routes/Back/StatsRoutes.php | 34 ++++++ src/PagesServiceProvider.php | 109 ++++++++++++++++++ .../AuthorizationServiceProvider.php | 41 +++++++ src/Providers/CommandServiceProvider.php | 38 ++++++ src/Providers/ComposerServiceProvider.php | 32 +++++ src/Providers/PackagesServiceProvider.php | 24 ++++ src/Providers/RouteServiceProvider.php | 88 ++++++++++++++ tests/PagesServiceProviderTest.php | 66 +++++++++++ tests/TestCase.php | 52 +++++++++ 21 files changed, 759 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .scrutinizer.yml create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 config/pages.php create mode 100644 config/sidebar/main.php create mode 100644 phpunit.xml create mode 100644 src/Http/Routes/Back/StatsRoutes.php create mode 100644 src/PagesServiceProvider.php create mode 100644 src/Providers/AuthorizationServiceProvider.php create mode 100644 src/Providers/CommandServiceProvider.php create mode 100644 src/Providers/ComposerServiceProvider.php create mode 100644 src/Providers/PackagesServiceProvider.php create mode 100644 src/Providers/RouteServiceProvider.php create mode 100644 tests/PagesServiceProviderTest.php create mode 100644 tests/TestCase.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..042d009 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..301e170 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +/_docs export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/CONTRIBUTING.md export-ignore +/phpunit.xml export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80296ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/.idea/ +/_arcanedev/ +/build/ +/vendor/ +_ide_helper.php +composer.lock +composer.phar diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..69d4755 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,35 @@ +filter: + excluded_paths: [tests/*, vendor/*] + +checks: + php: + code_rating: true + duplication: true + remove_extra_empty_lines: true + remove_php_closing_tag: true + remove_trailing_whitespace: true + fix_use_statements: + remove_unused: true + preserve_multiple: false + preserve_blanklines: true + order_alphabetically: true + fix_php_opening_tag: true + fix_linefeed: true + fix_line_ending: true + fix_identation_4spaces: true + fix_doc_comments: true + +tools: + external_code_coverage: + timeout: 600 + runs: 4 + php_code_sniffer: + enabled: true + config: + standard: PSR2 + filter: + paths: ['src'] + php_loc: + enabled: true + php_cpd: + enabled: true diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4f263d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +language: php + +sudo: false + +php: + - 5.5.9 + - 5.5 + - 5.6 + - 7.0 + - hhvm + +env: + - TESTBENCH_VERSION=3.1.* + +before_script: + - travis_retry composer self-update + - travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench:${TESTBENCH_VERSION}" + +script: + - composer validate + - mkdir -p build/logs + - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + +after_script: + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..eebedc7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# CONTRIBUTING + +Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests. + +## Guidelines + + * Please follow the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) Coding Standard, PHP-FIG Naming Conventions and the [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) autoloading standard + * Ensure that the current tests pass, and if you've added something new, add the tests where relevant. + * Remember that we follow SemVer. If you are changing the behaviour, or the public api, you may need to update the docs. + * Send a coherent commit history, making sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. + * You may also need to rebase to avoid merge conflicts. + +## Running Tests + +You will need an install of [Composer](https://getcomposer.org) before continuing. + +First, install the dependencies: + +```bash +$ composer install +``` + +Then run phpunit: + +```bash +$ vendor/bin/phpunit --coverage-text +``` + +If the test suite passes on your local machine you should be good to go. + +When you make a pull request, the tests will automatically be run again by [Travis CI](https://travis-ci.org/). diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7be0425 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 ARCANEDEV - Pages For ARCANESOFT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..47a963c --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Pages [![Packagist License][badge_license]](LICENSE.md) [![For ARCANESOFT][badge_laravel]](https://github.com/ARCANESOFT/Pages#pages) + +[![Travis Status][badge_build]](https://travis-ci.org/ARCANESOFT/Pages) +[![HHVM Status][badge_hhvm]](http://hhvm.h4cc.de/package/arcanesoft/pages) +[![Coverage Status][badge_coverage]](https://scrutinizer-ci.com/g/ARCANESOFT/Pages/?branch=master) +[![Scrutinizer Code Quality][badge_quality]](https://scrutinizer-ci.com/g/ARCANESOFT/Pages/?branch=master) +[![SensioLabs Insight][badge_insight]](https://insight.sensiolabs.com/projects/[id]) +[![Github Issues][badge_issues]](https://github.com/ARCANESOFT/Pages/issues) + +[![Packagist][badge_package]](https://packagist.org/packages/arcanesoft/pages) +[![Packagist Release][badge_release]](https://packagist.org/packages/arcanesoft/pages) +[![Packagist Downloads][badge_downloads]](https://packagist.org/packages/arcanesoft/pages) + +[badge_laravel]: https://img.shields.io/badge/For-ARCANESOFT%20CMS-orange.svg?style=flat-square +[badge_license]: https://img.shields.io/packagist/l/arcanesoft/pages.svg?style=flat-square + +[badge_build]: https://img.shields.io/travis/ARCANESOFT/Pages.svg?style=flat-square +[badge_hhvm]: https://img.shields.io/hhvm/arcanesoft/pages.svg?style=flat-square +[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANESOFT/Pages.svg?style=flat-square +[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANESOFT/Pages.svg?style=flat-square +[badge_insight]: https://img.shields.io/sensiolabs/i/[id].svg?style=flat-square +[badge_issues]: https://img.shields.io/github/issues/ARCANESOFT/Pages.svg?style=flat-square + +[badge_package]: https://img.shields.io/badge/package-arcanesoft/pages-blue.svg?style=flat-square +[badge_release]: https://img.shields.io/packagist/v/arcanesoft/pages.svg?style=flat-square +[badge_downloads]: https://img.shields.io/packagist/dt/arcanesoft/pages.svg?style=flat-square + +*By [ARCANEDEV©](http://www.arcanedev.net/)* + +Pages package for ARCANESOFT CMS. + +Feel free to check out the [releases](https://github.com/ARCANESOFT/Pages/releases), [license](LICENSE.md), and [contribution guidelines](CONTRIBUTING.md). + +## Features + + - Coming soon… + +### TODOS + + - [ ] Documentation. + +## Security + +If you discover any security related issues, please email arcanedev-maroc@gmail.com instead of using the issue tracker. + +## Contribution + +Any ideas are welcome. Feel free to submit any issues or pull requests, please check the [contribution guidelines](CONTRIBUTING.md). diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..148efaf --- /dev/null +++ b/composer.json @@ -0,0 +1,44 @@ +{ + "name": "arcanesoft/pages", + "description": "Pages package for ARCANESOFT/Foundation.", + "homepage": "https://github.com/ARCANESOFT/Pages", + "keywords": [ + "arcanesoft", "arcanedev", "pages", "cms" + ], + "authors": [ + { + "name": "ARCANEDEV", + "email": "arcanedev.maroc@gmail.com", + "homepage": "https://github.com/arcanedev-maroc", + "role": "Developer" + } + ], + "type": "library", + "license": "MIT", + "require": { + "php": ">=5.5.9", + "arcanesoft/core": "~0.4" + }, + "require-dev": { + "phpunit/phpcov": "~2.0|~3.0", + "phpunit/phpunit": "~4.0|~5.0" + }, + "autoload": { + "psr-4": { + "Arcanesoft\\Pages\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Arcanesoft\\Pages\\Tests\\": "tests/" + } + }, + "scripts": { + "testbench": "composer require --dev \"orchestra/testbench=~3.1.0\"" + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/config/pages.php b/config/pages.php new file mode 100644 index 0000000..fcebc23 --- /dev/null +++ b/config/pages.php @@ -0,0 +1,7 @@ + [ + 'prefix' => 'pages', + ], +]; diff --git a/config/sidebar/main.php b/config/sidebar/main.php new file mode 100644 index 0000000..ca5d8ed --- /dev/null +++ b/config/sidebar/main.php @@ -0,0 +1,5 @@ + + + + + ./tests/ + + + + + ./src/ + + + + + + + + diff --git a/src/Http/Routes/Back/StatsRoutes.php b/src/Http/Routes/Back/StatsRoutes.php new file mode 100644 index 0000000..91aeb2c --- /dev/null +++ b/src/Http/Routes/Back/StatsRoutes.php @@ -0,0 +1,34 @@ + + */ +class StatsRoutes extends RouteRegister +{ + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Map routes. + * + * @param \Illuminate\Contracts\Routing\Registrar $router + */ + public function map(Registrar $router) + { + $this->group([ + 'prefix' => 'stats', + ], function () { + $this->get('/', [ + 'as' => 'dashboard', // pages::foundation.dashboard + 'uses' => 'DashboardController@index', + ]); + }); + } +} diff --git a/src/PagesServiceProvider.php b/src/PagesServiceProvider.php new file mode 100644 index 0000000..7d3fb80 --- /dev/null +++ b/src/PagesServiceProvider.php @@ -0,0 +1,109 @@ + + */ +class PagesServiceProvider extends PackageServiceProvider +{ + /* ------------------------------------------------------------------------------------------------ + | Properties + | ------------------------------------------------------------------------------------------------ + */ + protected $package = 'pages'; + + /* ------------------------------------------------------------------------------------------------ + | Getters & Setters + | ------------------------------------------------------------------------------------------------ + */ + /** + * Get the base path of the package. + * + * @return string + */ + public function getBasePath() + { + return dirname(__DIR__); + } + + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Register the service provider. + */ + public function register() + { + $this->registerConfig(); + $this->registerSidebarItems(); + + $this->app->register(CoreServiceProvider::class); + $this->app->register(Providers\PackagesServiceProvider::class); + $this->app->register(Providers\AuthorizationServiceProvider::class); + $this->app->register(Providers\ComposerServiceProvider::class); + + if ($this->app->runningInConsole()) { + $this->app->register(Providers\CommandServiceProvider::class); + } + } + + /** + * Boot the service provider. + */ + public function boot() + { + $this->registerPublishes(); + + $this->app->register(Providers\RouteServiceProvider::class); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return [ + // + ]; + } + + /* ------------------------------------------------------------------------------------------------ + | Other Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Register publishes. + */ + private function registerPublishes() + { + // Config + $this->publishes([ + $this->getConfigFile() => config_path("{$this->vendor}/{$this->package}.php"), + ], 'config'); + + // Views + $viewsPath = $this->getBasePath() . '/resources/views'; + $this->loadViewsFrom($viewsPath, $this->package); + $this->publishes([ + $viewsPath => base_path("resources/views/vendor/{$this->package}"), + ], 'views'); + + // Translations + $translationsPath = $this->getBasePath() . '/resources/lang'; + $this->loadTranslationsFrom($translationsPath, $this->package); + $this->publishes([ + $translationsPath => base_path("resources/lang/vendor/{$this->package}"), + ], 'lang'); + + // Sidebar items + $this->publishSidebarItems(); + } +} diff --git a/src/Providers/AuthorizationServiceProvider.php b/src/Providers/AuthorizationServiceProvider.php new file mode 100644 index 0000000..46cb9a7 --- /dev/null +++ b/src/Providers/AuthorizationServiceProvider.php @@ -0,0 +1,41 @@ + + */ +class AuthorizationServiceProvider extends ServiceProvider +{ + /* ------------------------------------------------------------------------------------------------ + | Properties + | ------------------------------------------------------------------------------------------------ + */ + /** + * The policy mappings for the application. + * + * @var array + */ + protected $policies = [ + // + ]; + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Register any application authentication / authorization services. + * + * @param \Illuminate\Contracts\Auth\Access\Gate $gate + */ + public function boot(GateContract $gate) + { + parent::registerPolicies($gate); + + // + } +} diff --git a/src/Providers/CommandServiceProvider.php b/src/Providers/CommandServiceProvider.php new file mode 100644 index 0000000..946940e --- /dev/null +++ b/src/Providers/CommandServiceProvider.php @@ -0,0 +1,38 @@ + + */ +class CommandServiceProvider extends ServiceProvider +{ + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // TODO: Implement register() method. + } + + /** + * Get the provided commands. + * + * @return array + */ + public function provides() + { + return [ + // + ]; + } +} diff --git a/src/Providers/ComposerServiceProvider.php b/src/Providers/ComposerServiceProvider.php new file mode 100644 index 0000000..170b533 --- /dev/null +++ b/src/Providers/ComposerServiceProvider.php @@ -0,0 +1,32 @@ + + */ +class ComposerServiceProvider extends ServiceProvider +{ + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * {@inheritdoc} + */ + public function boot() + { + // + } + + /** + * {@inheritdoc} + */ + public function register() + { + // + } +} diff --git a/src/Providers/PackagesServiceProvider.php b/src/Providers/PackagesServiceProvider.php new file mode 100644 index 0000000..49ae551 --- /dev/null +++ b/src/Providers/PackagesServiceProvider.php @@ -0,0 +1,24 @@ + + */ +class PackagesServiceProvider extends ServiceProvider +{ + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Register the service provider. + */ + public function register() + { + // + } +} diff --git a/src/Providers/RouteServiceProvider.php b/src/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..bc5f1e0 --- /dev/null +++ b/src/Providers/RouteServiceProvider.php @@ -0,0 +1,88 @@ + + */ +class RouteServiceProvider extends ServiceProvider +{ + /* ------------------------------------------------------------------------------------------------ + | Getters & Setters + | ------------------------------------------------------------------------------------------------ + */ + /** + * Get the routes namespace + * + * @return string + */ + protected function getRouteNamespace() + { + return 'Arcanesoft\\Pages\\Http\\Routes'; + } + + /** + * Get the auth foundation route prefix. + * + * @return string + */ + public function getFoundationPagesPrefix() + { + $prefix = array_get($this->getFoundationRouteGroup(), 'prefix', 'dashboard'); + + return "$prefix/" . config('arcanesoft.pages.route.prefix', 'pages'); + } + + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Define the routes for the application. + * + * @param \Illuminate\Contracts\Routing\Registrar $router + */ + public function map(Router $router) + { + $this->mapPublicRoutes($router); + $this->mapFoundationRoutes($router); + } + + /** + * Define the public routes for the application. + * + * @param \Illuminate\Contracts\Routing\Registrar $router + */ + private function mapPublicRoutes(Router $router) + { + $attributes = [ + 'prefix' => 'pages', + 'as' => 'pages::', + 'namespace' => 'Arcanesoft\\Pages\\Http\\Controllers\\Front', + ]; + } + /** + * Define the foundation routes for the application. + * + * @param \Illuminate\Contracts\Routing\Registrar $router + */ + private function mapFoundationRoutes(Router $router) + { + $attributes = array_merge($this->getFoundationRouteGroup(), [ + 'as' => 'pages::foundation.', + 'namespace' => 'Arcanesoft\\Auth\\Http\\Controllers\\Back', + ]); + + $router->group(array_merge( + $attributes, + ['prefix' => $this->getFoundationPagesPrefix()] + ), function (Router $router) { + Routes\Back\StatsRoutes::register($router); + }); + } +} diff --git a/tests/PagesServiceProviderTest.php b/tests/PagesServiceProviderTest.php new file mode 100644 index 0000000..c604432 --- /dev/null +++ b/tests/PagesServiceProviderTest.php @@ -0,0 +1,66 @@ + + */ +class PagesServiceProviderTest extends TestCase +{ + /* ------------------------------------------------------------------------------------------------ + | Properties + | ------------------------------------------------------------------------------------------------ + */ + /** @var \Arcanesoft\Pages\PagesServiceProvider */ + private $provider; + + /* ------------------------------------------------------------------------------------------------ + | Main Functions + | ------------------------------------------------------------------------------------------------ + */ + public function setUp() + { + parent::setUp(); + + $this->provider = $this->app->getProvider(PagesServiceProvider::class); + } + + public function tearDown() + { + unset($this->provider); + + parent::tearDown(); + } + + /* ------------------------------------------------------------------------------------------------ + | Test Functions + | ------------------------------------------------------------------------------------------------ + */ + /** @test */ + public function it_can_be_instantiated() + { + $expectations = [ + \Illuminate\Support\ServiceProvider::class, + \Arcanedev\Support\ServiceProvider::class, + \Arcanedev\Support\PackageServiceProvider::class, + \Arcanesoft\Pages\PagesServiceProvider::class, + ]; + + foreach ($expectations as $expected) { + $this->assertInstanceOf($expected, $this->provider); + } + } + + /** @test */ + public function it_can_provider() + { + $expected = [ + // + ]; + + $this->assertEquals($expected, $this->provider->provides()); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..a69627a --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,52 @@ + + */ +abstract class TestCase extends BaseTestCase +{ + /* ------------------------------------------------------------------------------------------------ + | Package Functions + | ------------------------------------------------------------------------------------------------ + */ + /** + * Get package providers. + * + * @param \Illuminate\Foundation\Application $app + * + * @return array + */ + protected function getPackageProviders($app) + { + return [ + \Arcanesoft\Pages\PagesServiceProvider::class, + ]; + } + /** + * Get package aliases. + * + * @param \Illuminate\Foundation\Application $app + * + * @return array + */ + protected function getPackageAliases($app) + { + return [ + // + ]; + } + /** + * Define environment setup. + * + * @param \Illuminate\Foundation\Application $app + */ + protected function getEnvironmentSetUp($app) + { + // + } +}