From e08bcc8887513cde61e8192e435006a0313f5c3c Mon Sep 17 00:00:00 2001 From: Matthew Seremet Date: Wed, 6 Jul 2016 00:50:03 -0400 Subject: [PATCH 1/8] update page404() to respond with 404 response code This renders the 404 page via slim's halt() method. It also fixes the issue of unexpected 200 response codes with erroneous (mostly typo ridden) ajax requests. --- userfrosting/controllers/BaseController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/userfrosting/controllers/BaseController.php b/userfrosting/controllers/BaseController.php index e1b4a6810..fef4a1052 100644 --- a/userfrosting/controllers/BaseController.php +++ b/userfrosting/controllers/BaseController.php @@ -35,7 +35,9 @@ public function __construct($app){ * Request type: GET */ public function page404(){ - $this->_app->render('errors/404.twig'); + $twig = $this->_app->view()->getEnvironment(); + $this->_app->applyHook("UF.BaseController.page404"); + $this->_app->halt(404,$twig->render('errors/404.twig', $twig->getGlobals())); } /** From 6d8328d3fcab07ba7260b0794e4ec1581ed77c16 Mon Sep 17 00:00:00 2001 From: Matthew Seremet Date: Wed, 6 Jul 2016 16:32:44 -0400 Subject: [PATCH 2/8] Do same with pageDatabaseError() and remove hook Seems like the `pageDatabaseError()` is a good place to do this as well. --- userfrosting/controllers/BaseController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/userfrosting/controllers/BaseController.php b/userfrosting/controllers/BaseController.php index fef4a1052..0e2968ff1 100644 --- a/userfrosting/controllers/BaseController.php +++ b/userfrosting/controllers/BaseController.php @@ -35,9 +35,8 @@ public function __construct($app){ * Request type: GET */ public function page404(){ - $twig = $this->_app->view()->getEnvironment(); - $this->_app->applyHook("UF.BaseController.page404"); - $this->_app->halt(404,$twig->render('errors/404.twig', $twig->getGlobals())); + $twig = $this->_app->view()->getEnvironment(); + $this->_app->halt(404,$twig->render('errors/404.twig', $twig->getGlobals())); } /** @@ -48,7 +47,8 @@ public function page404(){ * Request type: GET */ public function pageDatabaseError(){ - $this->_app->render('errors/database.twig'); + $twig = $this->_app->view()->getEnvironment(); + $this->_app->halt(500,$twig->render('errors/database.twig', $twig->getGlobals())); } /** From 6277361c36e44a872460c69706f2b1e29a013973 Mon Sep 17 00:00:00 2001 From: Matthew Seremet Date: Thu, 7 Jul 2016 15:47:36 -0400 Subject: [PATCH 3/8] Use 503 (service unavailable) for pageDatabaseError() --- userfrosting/controllers/BaseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userfrosting/controllers/BaseController.php b/userfrosting/controllers/BaseController.php index 0e2968ff1..043ef1c74 100644 --- a/userfrosting/controllers/BaseController.php +++ b/userfrosting/controllers/BaseController.php @@ -48,7 +48,7 @@ public function page404(){ */ public function pageDatabaseError(){ $twig = $this->_app->view()->getEnvironment(); - $this->_app->halt(500,$twig->render('errors/database.twig', $twig->getGlobals())); + $this->_app->halt(503,$twig->render('errors/database.twig', $twig->getGlobals())); } /** From 655a362b22764da7fcc6fe8889b3193a7995f400 Mon Sep 17 00:00:00 2001 From: Matthew Seremet Date: Thu, 7 Jul 2016 16:08:35 -0400 Subject: [PATCH 4/8] use pageDatabaseError() if UserSession hits a PDOException --- userfrosting/middleware/usersession/UserSession.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/userfrosting/middleware/usersession/UserSession.php b/userfrosting/middleware/usersession/UserSession.php index b743ca954..efa92452c 100644 --- a/userfrosting/middleware/usersession/UserSession.php +++ b/userfrosting/middleware/usersession/UserSession.php @@ -91,6 +91,8 @@ public function setup(){ // If we can't connect to the DB, then we can't create an authenticated user. That's ok if we're in installation mode. error_log("Unable to authenticate user because the database is not yet initialized, invalid, or inaccessible. Falling back to guest user."); error_log($e->getTraceAsString()); + $controller = new AccountController($this->app); + return $controller->pageDatabaseError(); } } } From 196425cc7ecc45bf00d9308bb0b2d9d03a09fc51 Mon Sep 17 00:00:00 2001 From: Matthew Seremet Date: Thu, 7 Jul 2016 17:21:05 -0400 Subject: [PATCH 5/8] use BaseController both work, but this makes more sense. --- userfrosting/middleware/usersession/UserSession.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userfrosting/middleware/usersession/UserSession.php b/userfrosting/middleware/usersession/UserSession.php index efa92452c..f89d9105f 100644 --- a/userfrosting/middleware/usersession/UserSession.php +++ b/userfrosting/middleware/usersession/UserSession.php @@ -91,7 +91,7 @@ public function setup(){ // If we can't connect to the DB, then we can't create an authenticated user. That's ok if we're in installation mode. error_log("Unable to authenticate user because the database is not yet initialized, invalid, or inaccessible. Falling back to guest user."); error_log($e->getTraceAsString()); - $controller = new AccountController($this->app); + $controller = new BaseController($this->app); return $controller->pageDatabaseError(); } } From 0c621d3dae2f69f89acf1fead66a959d5e8b5580 Mon Sep 17 00:00:00 2001 From: Matthew Seremet Date: Tue, 12 Jul 2016 03:09:09 -0400 Subject: [PATCH 6/8] UI fixes A few cases where col-xs-12 could be used. Some changes to settings page where certain text would not fit in label. Better to have extra space than overlapping text. Some `div.well` elements converted to `
` to prevent text falling out of panels
---
 public/css/bootstrap-custom.css                      |  2 +-
 userfrosting/initialize.php                          |  1 +
 .../themes/default/config/site-settings.twig         | 12 +++++-------
 .../themes/default/install/install-errors.twig       |  6 ++----
 .../themes/default/install/install-master.twig       | 12 ++++++------
 .../themes/default/install/install-ready.twig        |  8 +++-----
 6 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/public/css/bootstrap-custom.css b/public/css/bootstrap-custom.css
index 5ad874476..021b02a13 100644
--- a/public/css/bootstrap-custom.css
+++ b/public/css/bootstrap-custom.css
@@ -6,7 +6,7 @@
 }
 
 .container-narrow {
-    width: 800px;
+    max-width: 800px;
 }
 
 .panel-heading-buttons h3 {
diff --git a/userfrosting/initialize.php b/userfrosting/initialize.php
index 32539a24b..48d4ae2f8 100644
--- a/userfrosting/initialize.php
+++ b/userfrosting/initialize.php
@@ -11,6 +11,7 @@
 
 // This if-block just checks that config-userfrosting.php exists
 if (!file_exists(__DIR__ . "/config-userfrosting.php")){
+	http_response_code(503);
     echo "

We can't seem to find config-userfrosting.php! You should rename the file config-userfrosting-example.php to config-userfrosting.php, and then fill in the configuration details for your database and server. For more information, please see the installation instructions.


"; exit; } diff --git a/userfrosting/templates/themes/default/config/site-settings.twig b/userfrosting/templates/themes/default/config/site-settings.twig index dc3eb4065..2fd605ced 100644 --- a/userfrosting/templates/themes/default/config/site-settings.twig +++ b/userfrosting/templates/themes/default/config/site-settings.twig @@ -25,10 +25,10 @@ {% for plugin_name, plugin in settings %} {% for name, setting in plugin %}
- -
+ +
{% if (setting.type == 'text') %} - + {% elseif (setting.type == 'select') %} -
+
-
+ {% endblock %} {% block page_scripts %} {% endblock %} diff --git a/userfrosting/templates/themes/default/install/install-ready.twig b/userfrosting/templates/themes/default/install/install-ready.twig index 53edb624d..8321ecc11 100644 --- a/userfrosting/templates/themes/default/install/install-ready.twig +++ b/userfrosting/templates/themes/default/install/install-ready.twig @@ -2,8 +2,8 @@ {# Set page properties (page.*) here. #} {% block page %} - {# By putting this in a special block, we ensure that it will be set AFTER the default values are set in the parent template, - but BEFORE the page itself is rendered. #} + {# By putting this in a special block, we ensure that it will be set AFTER the default values are set in the parent template, + but BEFORE the page itself is rendered. #} {% set page = page | merge({ "title" : "Installation", "description" : "Installation page for UserFrosting" @@ -14,10 +14,10 @@

Congratulations.
UserFrosting is ready to rock.


-
-
- -
+
+
+ +
{% for message in messages %}