From a0e501f9fdf13c2881c858c0a58481078a21f596 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 08:29:41 +0200 Subject: [PATCH] First attempt at implementing Twig. --- .env.backup | 18 ++ .env.local | 18 ++ app/Http/Controllers/Auth/AuthController.php | 11 ++ app/Providers/FireflyServiceProvider.php | 9 + bootstrap/app.php | 6 + composer.json | 4 +- composer.lock | 176 ++++++++++++++++++- config/app.php | 9 +- config/view.php | 2 +- resources/twig/auth/login.twig | 57 ++++++ resources/twig/layout/guest.twig | 62 +++++++ 11 files changed, 366 insertions(+), 6 deletions(-) create mode 100755 .env.backup create mode 100755 .env.local create mode 100644 resources/twig/auth/login.twig create mode 100644 resources/twig/layout/guest.twig diff --git a/.env.backup b/.env.backup new file mode 100755 index 0000000000..6e6fd0fa1a --- /dev/null +++ b/.env.backup @@ -0,0 +1,18 @@ +APP_ENV=local +APP_DEBUG=true +APP_KEY=SomeRandomString + +DB_CONNECTION=mysql +DB_HOST=localhost +DB_DATABASE=homestead +DB_USERNAME=homestead +DB_PASSWORD=secret + +CACHE_DRIVER=file +SESSION_DRIVER=file + +EMAIL_SMTP= +EMAIL_DRIVER=smtp +EMAIL_USERNAME= +EMAIL_PASSWORD= +ANALYTICS_ID= \ No newline at end of file diff --git a/.env.local b/.env.local new file mode 100755 index 0000000000..6e6fd0fa1a --- /dev/null +++ b/.env.local @@ -0,0 +1,18 @@ +APP_ENV=local +APP_DEBUG=true +APP_KEY=SomeRandomString + +DB_CONNECTION=mysql +DB_HOST=localhost +DB_DATABASE=homestead +DB_USERNAME=homestead +DB_PASSWORD=secret + +CACHE_DRIVER=file +SESSION_DRIVER=file + +EMAIL_SMTP= +EMAIL_DRIVER=smtp +EMAIL_USERNAME= +EMAIL_PASSWORD= +ANALYTICS_ID= \ No newline at end of file diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 97bb5bc4b1..079ec4dcf3 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -8,6 +8,7 @@ use Illuminate\Http\Request; use Illuminate\Mail\Message; use Mail; use Session; +use Twig; /** * Class AuthController @@ -47,6 +48,16 @@ class AuthController extends Controller $this->middleware('guest', ['except' => 'getLogout']); } + /** + * Show the application login form. + * + * @return \Illuminate\Http\Response + */ + public function getLogin() + { + return Twig::render('auth.login'); + } + /** * Handle a registration request for the application. * diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 542475d282..1b57c3508e 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -2,6 +2,7 @@ namespace FireflyIII\Providers; +use App; use FireflyIII\Support\Amount; use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; @@ -9,6 +10,8 @@ use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; +use Twig; +use TwigBridge\Extension\Loader\Functions; use Validator; /** @@ -25,10 +28,15 @@ class FireflyServiceProvider extends ServiceProvider return new FireflyValidator($translator, $data, $rules, $messages); } ); + } public function register() { + + $config = App::make('config'); + Twig::addExtension(new Functions($config)); + $this->app->bind( 'preferences', function () { return new Preferences; @@ -72,6 +80,7 @@ class FireflyServiceProvider extends ServiceProvider $this->app->bind('FireflyIII\Helpers\Report\ReportHelperInterface', 'FireflyIII\Helpers\Report\ReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\ReportQueryInterface', 'FireflyIII\Helpers\Report\ReportQuery'); + } } diff --git a/bootstrap/app.php b/bootstrap/app.php index e3ec5b5519..5b299a9c83 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,6 +11,7 @@ | */ + $app = new Illuminate\Foundation\Application( realpath(__DIR__ . '/../') ); @@ -26,6 +27,8 @@ $app = new Illuminate\Foundation\Application( | */ + + $app->singleton( 'Illuminate\Contracts\Http\Kernel', 'FireflyIII\Http\Kernel' @@ -41,6 +44,9 @@ $app->singleton( 'FireflyIII\Exceptions\Handler' ); + + + /* |-------------------------------------------------------------------------- | Return The Application diff --git a/composer.json b/composer.json index c9459d4f3f..5bbf617f3b 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,9 @@ "watson/validating": "~1.0", "doctrine/dbal": "~2.5", "illuminate/html": "~5.0", - "league/commonmark": "0.7.*" + "league/commonmark": "0.7.*", + "rcrowe/twigbridge": "0.7.x@dev", + "twig/extensions": "~1.2" }, "require-dev": { "barryvdh/laravel-debugbar": "@stable", diff --git a/composer.lock b/composer.lock index 394312ec5e..bce1a9507c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "0d43c4c85607c5cdc901cde2d18b75d5", + "hash": "e3e90dd365b74f4878cf3b5b4a1c4007", "packages": [ { "name": "classpreloader/classpreloader", @@ -1527,6 +1527,70 @@ ], "time": "2015-03-26 18:43:54" }, + { + "name": "rcrowe/twigbridge", + "version": "0.7.x-dev", + "source": { + "type": "git", + "url": "https://github.com/rcrowe/TwigBridge.git", + "reference": "ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rcrowe/TwigBridge/zipball/ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026", + "reference": "ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026", + "shasum": "" + }, + "require": { + "illuminate/support": "5.0.*", + "illuminate/view": "5.0.*", + "php": ">=5.4.0", + "twig/twig": "~1.15" + }, + "require-dev": { + "laravel/framework": "5.0.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "~0.6", + "squizlabs/php_codesniffer": "~1.5" + }, + "suggest": { + "laravelcollective/html": "For bringing back html/form in Laravel 5.x", + "twig/extensions": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.7-dev" + } + }, + "autoload": { + "psr-4": { + "TwigBridge\\": "src", + "TwigBridge\\Tests\\": "tests" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + }, + { + "name": "Rob Crowe", + "email": "hello@vivalacrowe.com" + } + ], + "description": "Adds the power of Twig to Laravel", + "keywords": [ + "laravel", + "twig" + ], + "time": "2015-04-22 09:19:03" + }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.0", @@ -2291,6 +2355,115 @@ ], "time": "2015-03-31 08:12:29" }, + { + "name": "twig/extensions", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig-extensions.git", + "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", + "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", + "shasum": "" + }, + "require": { + "twig/twig": "~1.12" + }, + "require-dev": { + "symfony/translation": "~2.3" + }, + "suggest": { + "symfony/translation": "Allow the time_diff output to be translated" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_Extensions_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Common additional features for Twig that do not directly belong in core", + "homepage": "http://twig.sensiolabs.org/doc/extensions/index.html", + "keywords": [ + "i18n", + "text" + ], + "time": "2014-10-30 14:30:03" + }, + { + "name": "twig/twig", + "version": "v1.18.1", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "shasum": "" + }, + "require": { + "php": ">=5.2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "http://twig.sensiolabs.org/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2015-04-19 08:30:27" + }, { "name": "vlucas/phpdotenv", "version": "v1.1.0", @@ -4179,6 +4352,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "rcrowe/twigbridge": 20, "barryvdh/laravel-debugbar": 0 }, "prefer-stable": false, diff --git a/config/app.php b/config/app.php index 17bf91779e..f0b8a7a614 100644 --- a/config/app.php +++ b/config/app.php @@ -136,11 +136,12 @@ return [ 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Html\HtmlServiceProvider', + 'TwigBridge\ServiceProvider', + 'DaveJamesMiller\Breadcrumbs\ServiceProvider', 'Barryvdh\Debugbar\ServiceProvider', 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', - /* * Application Service Providers... */ @@ -152,6 +153,7 @@ return [ 'FireflyIII\Providers\FireflyServiceProvider', 'FireflyIII\Providers\TestingServiceProvider', + ], /* @@ -201,13 +203,14 @@ return [ 'View' => 'Illuminate\Support\Facades\View', 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade', - 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade', - + 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade', 'Preferences' => 'FireflyIII\Support\Facades\Preferences', 'Navigation' => 'FireflyIII\Support\Facades\Navigation', 'Amount' => 'FireflyIII\Support\Facades\Amount', 'Steam' => 'FireflyIII\Support\Facades\Steam', 'ExpandedForm' => 'FireflyIII\Support\Facades\ExpandedForm', + 'Twig' => 'TwigBridge\Facade\Twig', + ], diff --git a/config/view.php b/config/view.php index 88fc534aeb..6e1a698a10 100644 --- a/config/view.php +++ b/config/view.php @@ -14,7 +14,7 @@ return [ */ 'paths' => [ - realpath(base_path('resources/views')) + realpath(base_path('resources/twig')) ], /* diff --git a/resources/twig/auth/login.twig b/resources/twig/auth/login.twig new file mode 100644 index 0000000000..6853a7f764 --- /dev/null +++ b/resources/twig/auth/login.twig @@ -0,0 +1,57 @@ +{% extends "./layout/guest.twig" %} + +{% block content %} + +{% if errors.has('email') %} +
+
+ +
+
+{% endif %} + + +
+
+ +
+
+{% endblock %} + diff --git a/resources/twig/layout/guest.twig b/resources/twig/layout/guest.twig new file mode 100644 index 0000000000..1d81e22141 --- /dev/null +++ b/resources/twig/layout/guest.twig @@ -0,0 +1,62 @@ + + + + + + + + Firefly III + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + {% block content %}{% endblock %} +
+ + + + + + + +