From 50a6e1f07a71ffaa6dc9943dbc5f5e7bdb9f39be Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 22 Jul 2015 09:30:10 +0200 Subject: [PATCH 1/6] Added a new "Welcome Page" for fresh Symfony installs --- app/Resources/views/default/index.html.twig | 91 ++++++++++++++++++- .../Controller/DefaultController.php | 9 +- .../Controller/DefaultControllerTest.php | 3 +- 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index ed261498cb..36895eed52 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -1,5 +1,94 @@ {% extends 'base.html.twig' %} {% block body %} - Homepage. +
+
+
+

Welcome to Symfony {{ constant('\\Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}

+
+ + {% if requirements.failedRequirements|length > 0 %} + +
+

+ + + Your system is not ready to run Symfony applications. + Check technical requirements +

+
+ + {% else %} + +
+

+ + + Your application is ready to start working on it at: + {{ base_dir }}/ +

+
+ + {% set symfony_version = constant('\\Symfony\\Component\\HttpKernel\\Kernel::MAJOR_VERSION') ~ '.' ~ constant('\\Symfony\\Component\\HttpKernel\\Kernel::MINOR_VERSION') %} + + + + {% endif %} +
+
+{% endblock %} + +{% block stylesheets %} + {% endblock %} diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php index 8569811ee0..d751b8ef4c 100644 --- a/src/AppBundle/Controller/DefaultController.php +++ b/src/AppBundle/Controller/DefaultController.php @@ -9,10 +9,15 @@ class DefaultController extends Controller { /** - * @Route("/app/example", name="homepage") + * @Route("/", name="homepage") */ public function indexAction() { - return $this->render('default/index.html.twig'); + require_once __DIR__.'/../../../app/SymfonyRequirements.php'; + + return $this->render('default/index.html.twig', array( + 'base_dir' => realpath($this->container->getParameter('kernel.root_dir').'/..'), + 'requirements' => new \SymfonyRequirements(), + )); } } diff --git a/src/AppBundle/Tests/Controller/DefaultControllerTest.php b/src/AppBundle/Tests/Controller/DefaultControllerTest.php index 66ca01878a..06f3ec1671 100644 --- a/src/AppBundle/Tests/Controller/DefaultControllerTest.php +++ b/src/AppBundle/Tests/Controller/DefaultControllerTest.php @@ -12,6 +12,7 @@ public function testIndex() $crawler = $client->request('GET', '/'); - $this->assertTrue($crawler->filter('html:contains("Homepage")')->count() > 0); + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertContains('Welcome to Symfony', $client->getResponse()->getContent()); } } From 2a2510490035fb804f982f51da3cd144260930dc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 22 Jul 2015 15:08:38 +0200 Subject: [PATCH 2/6] Minor fixes --- app/Resources/views/default/index.html.twig | 2 +- src/AppBundle/Controller/DefaultController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index 36895eed52..9907f3054c 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -61,7 +61,7 @@ {% endblock %} {% block stylesheets %} - {% endblock %} From 3196523c2dba5268bdcd88d93d897c78e53864ab Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 23 Jul 2015 15:22:40 +0200 Subject: [PATCH 5/6] Simplified the new Welcome Page --- app/Resources/views/default/index.html.twig | 77 ++++++++----------- .../Controller/DefaultController.php | 3 - 2 files changed, 33 insertions(+), 47 deletions(-) diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index 3c974b9ff9..f266d49561 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -9,53 +9,42 @@

Welcome to Symfony {{ symfony_version }}

- {% if requirements.failedRequirements|length > 0 %} +
+

+ + -

-

- - - Your system is not ready to run Symfony applications. - Check technical requirements -

-
- - {% else %} - -
-

- - - Your application is ready to start working on it at: - {{ base_dir }}/ -

-
+ Your application is ready to start working on it at: + {{ base_dir }}/ +

+
- - {% endif %} {% endblock %} @@ -85,7 +74,7 @@ @-webkit-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } - body { -webkit-animation: fade-in 1.5s .1s; animation: fade-in 1.5s .1s;} + body { -webkit-animation: fade-in 1.2s .1s; animation: fade-in 1.2s .1s;} .sf-toolbar { opacity: 0; -webkit-animation: fade-in .7s .5s forwards; animation: fade-in .7s .5s forwards;} } diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php index a956f8f38f..5a2c67c949 100644 --- a/src/AppBundle/Controller/DefaultController.php +++ b/src/AppBundle/Controller/DefaultController.php @@ -13,11 +13,8 @@ class DefaultController extends Controller public function indexAction() { // replace this example code with whatever you need - require_once __DIR__.'/../../../app/SymfonyRequirements.php'; - return $this->render('default/index.html.twig', array( 'base_dir' => realpath($this->container->getParameter('kernel.root_dir').'/..'), - 'requirements' => new \SymfonyRequirements(), )); } } From fd5c07326af2440c98b60acd320e3403d27423c2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 23 Jul 2015 17:37:00 +0200 Subject: [PATCH 6/6] Implemented the latest suggestions --- app/Resources/views/default/index.html.twig | 13 ++++--------- src/AppBundle/Controller/DefaultController.php | 3 ++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index f266d49561..75842ebe18 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -1,18 +1,15 @@ {% extends 'base.html.twig' %} {% block body %} - {% set symfony_version = constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') %} -
-

Welcome to Symfony {{ symfony_version }}

+

Welcome to Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION') }}

- - + Your application is ready to start working on it at: {{ base_dir }}/ @@ -39,7 +36,7 @@ Read Symfony documentation to learn - + How to create your first page in Symfony

@@ -73,9 +70,7 @@ @-webkit-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } - - body { -webkit-animation: fade-in 1.2s .1s; animation: fade-in 1.2s .1s;} - .sf-toolbar { opacity: 0; -webkit-animation: fade-in .7s .5s forwards; animation: fade-in .7s .5s forwards;} + .sf-toolbar { opacity: 0; -webkit-animation: fade-in 1s .2s forwards; animation: fade-in 1s .2s forwards;} } {% endblock %} diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php index 5a2c67c949..3bd767561a 100644 --- a/src/AppBundle/Controller/DefaultController.php +++ b/src/AppBundle/Controller/DefaultController.php @@ -4,13 +4,14 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; class DefaultController extends Controller { /** * @Route("/", name="homepage") */ - public function indexAction() + public function indexAction(Request $request) { // replace this example code with whatever you need return $this->render('default/index.html.twig', array(