-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #424 from letscolife/add-phoenix-live-view
Identify Phoenix LiveView metrics
- Loading branch information
Showing
24 changed files
with
277 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import "phoenix_html"; | ||
import { Socket } from "phoenix"; | ||
import { LiveSocket } from "phoenix_live_view"; | ||
|
||
let csrfToken = document | ||
.querySelector("meta[name='csrf-token']") | ||
.getAttribute("content"); | ||
let liveSocket = new LiveSocket("/live", Socket, { | ||
params: { _csrf_token: csrfToken }, | ||
}); | ||
|
||
liveSocket.connect(); | ||
window.liveSocket = liveSocket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
examples/apps/phx_example/lib/phx_example_web/components/layouts.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule PhxExampleWeb.Layouts do | ||
use PhxExampleWeb, :html | ||
|
||
embed_templates "layouts/*" | ||
end |
5 changes: 5 additions & 0 deletions
5
examples/apps/phx_example/lib/phx_example_web/components/layouts/app.html.heex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<main> | ||
<div> | ||
<%= @inner_content %> | ||
</div> | ||
</main> |
16 changes: 16 additions & 0 deletions
16
examples/apps/phx_example/lib/phx_example_web/components/layouts/root.html.heex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="csrf-token" content={get_csrf_token()} /> | ||
<.live_title suffix=" · Phoenix Framework"> | ||
<%= assigns[:page_title] || "PhxExample" %> | ||
</.live_title> | ||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}> | ||
</script> | ||
</head> | ||
<body> | ||
<%= @inner_content %> | ||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
examples/apps/phx_example/lib/phx_example_web/controllers/error_html.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule PhxExampleWeb.ErrorHTML do | ||
use PhxExampleWeb, :html | ||
|
||
embed_templates "error_html/*" | ||
|
||
def render(template, _assigns) do | ||
Phoenix.Controller.status_message_from_template(template) | ||
end | ||
end |
1 change: 1 addition & 0 deletions
1
examples/apps/phx_example/lib/phx_example_web/controllers/error_html/500.html.heex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"Oops, Internal Server Error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
examples/apps/phx_example/lib/phx_example_web/controllers/page_html.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule PhxExampleWeb.PageHTML do | ||
use PhxExampleWeb, :html | ||
|
||
embed_templates "page_html/*" | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
defmodule PhxExampleWeb.Endpoint do | ||
use Phoenix.Endpoint, otp_app: :phx_example | ||
|
||
@session_options [ | ||
store: :cookie, | ||
key: "_phx_example_key", | ||
signing_salt: "F6n7gjjvL6I61gUB", | ||
same_site: "Lax" | ||
] | ||
|
||
socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]] | ||
|
||
plug Plug.Static, | ||
at: "/", | ||
from: :phx_example, | ||
gzip: false, | ||
only: PhxExampleWeb.static_paths() | ||
|
||
plug Plug.RequestId | ||
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] | ||
|
||
plug Plug.Parsers, | ||
parsers: [:urlencoded, :multipart, :json], | ||
pass: ["*/*"], | ||
json_decoder: Phoenix.json_library() | ||
|
||
plug Plug.MethodOverride | ||
plug Plug.Head | ||
plug Plug.Session, @session_options | ||
plug PhxExampleWeb.Router | ||
end |
12 changes: 12 additions & 0 deletions
12
examples/apps/phx_example/lib/phx_example_web/live/error_live.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
defmodule PhxExampleWeb.ErrorLive do | ||
use PhxExampleWeb, :live_view | ||
|
||
@impl true | ||
def render(assigns) do | ||
~H""" | ||
<div> | ||
<h1><%= @some_variable %></h1> | ||
</div> | ||
""" | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
examples/apps/phx_example/lib/phx_example_web/live/home_live.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule PhxExampleWeb.HomeLive do | ||
use PhxExampleWeb, :live_view | ||
|
||
@impl true | ||
def render(assigns) do | ||
~H""" | ||
<div> | ||
<h1>Home</h1> | ||
<p>Some content</p> | ||
</div> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
examples/apps/phx_example/lib/phx_example_web/templates/layout/app.html.eex
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
examples/apps/phx_example/lib/phx_example_web/views/error_view.ex
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
examples/apps/phx_example/lib/phx_example_web/views/layout_view.ex
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
examples/apps/phx_example/lib/phx_example_web/views/page_view.ex
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.