Repository: phoenixframework/phoenix
Pull request #3384 (2019-04-25 08:23:01)

Fix caniuse-lite warning about deprecated version.


Patch:
diff --git a/assets/package-lock.json b/assets/package-lock.json
index cfd6385dc..61f932acc 100644
--- a/assets/package-lock.json
+++ b/assets/package-lock.json
@@ -1222,13 +1222,13 @@
           "integrity": "sha512-docXmVcYth9AiW5183dEe2IxnbmpXF4jiM6efGBVRAli/iDSS894Svvjenrv5NPqAJ4dEJULmT4MSvmLG9qoYg==",
           "dev": true,
           "requires": {
-            "caniuse-lite": "1.0.30000888",
+            "caniuse-lite": "1.0.30000963",
             "electron-to-chromium": "1.3.73",
             "node-releases": "1.0.0-alpha.12"
           }
         },
         "caniuse-lite": {
-          "version": "1.0.30000888",
+          "version": "1.0.30000963",
           "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000888.tgz",
           "integrity": "sha512-vftg+5p/lPsQGpnhSo/yBuYL36ai/cyjLvU3dOPJY1kkKrekLWIy8SLm+wzjX0hpCUdFTasC4/ZT7uqw4rKOnQ==",
           "dev": true
diff --git a/guides/views.md b/guides/views.md
index 787341c70..9e4086a3c 100644
--- a/guides/views.md
+++ b/guides/views.md
@@ -182,18 +182,23 @@ This is where the view module and its template from the controller are rendered
 
 ## The ErrorView
 
-Phoenix has a view called the `ErrorView` which lives in `lib/hello_web/views/error_view.ex`. The purpose of the `ErrorView` is to handle two of the most common errors - `404 not found` and `500 internal error` - in a general way, from one centralized location. Let's see what it looks like.
+Phoenix has a view called the `ErrorView` which lives in `lib/hello_web/views/error_view.ex`. The purpose of the `ErrorView` is to handle errors in a general way, from one centralized location. Let's see what it looks like.
 
 ```elixir
 defmodule HelloWeb.ErrorView do
   use HelloWeb, :view
 
-  def render("404.html", _assigns) do
-    "Page not found"
-  end
-
-  def render("500.html", _assigns) do
-    "Server internal error"
+  # If you want to customize a particular status code
+  # for a certain format, you may uncomment below.
+  # def render("500.html", _assigns) do
+  #   "Internal Server Error"
+  # end
+
+  # By default, Phoenix returns the status message from
+  # the template name. For example, "404.html" becomes
+  # "Not Found".
+  def template_not_found(template, _assigns) do
+    Phoenix.Controller.status_message_from_template(template)
   end
 end
 ```
@@ -212,19 +217,35 @@ config :hello, HelloWeb.Endpoint,
 
 After modifying our config file, we need to restart our server in order for this change to take effect. After restarting the server, let's go to [http://localhost:4000/such/a/wrong/path](http://localhost:4000/such/a/wrong/path) for a running local application and see what we get.
 
-Ok, that's not very exciting. We get the bare string "Page not found", displayed without any markup or styling.
+Ok, that's not very exciting. We get the bare string "Not Found", displayed without any markup or styling.
 
 Let's see if we can use what we already know about views to make this a more interesting error page.
 
 The first question is, where does that error string come from? The answer is right in the `ErrorView`.
 
+```elixir
+def template_not_found(template, _assigns) do
+  Phoenix.Controller.status_message_from_template(template)
+end
+```
+
+Great, so we have this `template_not_found/2` function that takes a template and an `assigns` map, which we ignore. Where is this function being called from? The answer is the `render/5` function defined in the `Phoenix.Endpoint.RenderErrors` module. The whole purpose of this module is to catch errors and render them with a view, in our case, the `HelloWeb.ErrorView`.
+
+Actually, `Phoenix.Endpoint.RenderErrors` tries to call a `render/2` with a matching clause in our ErrorView and since no such function exists, falls back to the `template_not_found/2` function which uses the `status_message_from_template/1` function to convert the error from the template to its name. In our case, the template `404.html`. becomes "Not Found" which is exactly the string you saw before.
+
+Now that we understand how we got here, let's make a better error page.
+
+The first option we have is to implement a matching `render/2` function in `HelloWeb.ErrorView`.
+
 ```elixir
 def render("404.html", _assigns) do
-  "Page not found"
+  "Page Not Found"
 end
 ```
 
-Great, so we have a `render/2` function that takes a template and an `assigns` map, which we ignore. Where is this `render/2` function being called from? The answer is the `render/5` function defined in the `Phoenix.Endpoint.RenderErrors` module. The whole purpose of this module is to catch errors and render them with a view, in our case, the `HelloWeb.ErrorView`. Now that we understand how we got here, let's make a better error page. Phoenix generates an `ErrorView` for us, but it doesn't give us a `lib/hello_web/templates/error` directory. Let's create one now. Inside our new directory, let's add a template, `404.html.eex` and give it some markup - a mixture of our application layout and a new `div` with our message to the user.
+But we can do even better.
+
+Phoenix generates an `ErrorView` for us, but it doesn't give us a `lib/hello_web/templates/error` directory. Let's create one now. Inside our new directory, let's add a template, `404.html.eex` and give it some markup - a mixture of our application layout and a new `div` with our message to the user.
 
 
 ```html
@@ -264,7 +285,7 @@ Great, so we have a `render/2` function that takes a template and an `assigns` m
 </html>
 ```
 
-Now we can use the `render/2` function we saw above when we were experimenting with rendering in the `iex` session. Since we know that Phoenix will precompile the `404.html.eex` template as a `render("404.html", assigns)` function clause, we can delete the clause from our ErrorView.
+Now we can use the `render/2` function we saw above when we were experimenting with rendering in the `iex` session. Since we know that Phoenix will precompile the `404.html.eex` template as a `render("404.html", assigns)` function clause, we can delete the clause from our ErrorView again.
 
 ```diff
 - def render("404.html", _assigns) do
diff --git a/installer/templates/phx_single/config/prod.exs b/installer/templates/phx_single/config/prod.exs
index 7b122462e..87b8f7e9a 100644
--- a/installer/templates/phx_single/config/prod.exs
+++ b/installer/templates/phx_single/config/prod.exs
@@ -57,7 +57,7 @@ config :logger, level: :info
 #
 #     config :<%= web_app_name %>, <%= endpoint_module %>, server: true
 #
-# Then you can assemble a release by caling `mix release`.
+# Then you can assemble a release by calling `mix release`.
 # See `mix help release` for more information.
 
 # Finally import the config/prod.secret.exs which loads secrets
diff --git a/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs b/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs
index d3d09701b..9258621d1 100644
--- a/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs
+++ b/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs
@@ -52,5 +52,5 @@ config :<%= web_app_name %>, <%= endpoint_module %>,
 #
 #     config :<%= web_app_name %>, <%= endpoint_module %>, server: true
 #
-# Then you can assemble a release by caling `mix release`.
+# Then you can assemble a release by calling `mix release`.
 # See `mix help release` for more information.
diff --git a/installer/templates/phx_umbrella/config/prod.exs b/installer/templates/phx_umbrella/config/prod.exs
index 6ca447298..ed1ecc7a9 100644
--- a/installer/templates/phx_umbrella/config/prod.exs
+++ b/installer/templates/phx_umbrella/config/prod.exs
@@ -2,3 +2,5 @@ use Mix.Config
 
 # Do not print debug messages in production
 config :logger, level: :info
+
+import_config "prod.secret.exs"
diff --git a/lib/phoenix/digester.ex b/lib/phoenix/digester.ex
index 3acdc9f9f..f397f778c 100644
--- a/lib/phoenix/digester.ex
+++ b/lib/phoenix/digester.ex
@@ -133,7 +133,7 @@ defmodule Phoenix.Digester do
 
   defp uncompressed_digested_file?(file_path) do
     Regex.match?(@digested_file_regex, Path.basename(file_path)) ||
-      !Path.extname(file_path) == ".gz"
+      Path.extname(file_path) != ".gz"
   end
 
   defp map_file(file_path, input_path) do


Test patch:
diff --git a/installer/test/phx_new_umbrella_test.exs b/installer/test/phx_new_umbrella_test.exs
index e802ef3a1..218df0955 100644
--- a/installer/test/phx_new_umbrella_test.exs
+++ b/installer/test/phx_new_umbrella_test.exs
@@ -476,6 +476,7 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
         assert_file "../config/prod.exs", fn file ->
           assert file =~ "port: 80"
           assert file =~ ":inet6"
+          assert file =~ "import_config \"prod.secret.exs\""
         end
 
         assert_file "another/lib/another/application.ex", ~r/defmodule Another.Application do/