Packages
phoenix_live_reload
0.3.3
1.6.2
1.6.1
1.6.0
1.5.3
1.5.2
1.5.1
1.5.0
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.4
1.2.3
retired
1.2.2
1.2.1
1.2.0
1.2.0-rc.0
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.0
0.1.0
Provides live-reload functionality for Phoenix
Current section
Files
Jump to
Current section
Files
lib/phoenix_live_reload/frame.ex
defmodule Phoenix.LiveReload.Frame do
import Plug.Conn
@behaviour Plug
@external_resource phoenix_path = "priv/static/phoenix.js"
@external_resource reload_path = "priv/static/phoenix_live_reload.js"
@phoenix_js File.read!(Application.app_dir(:phoenix, phoenix_path))
@phoenix_live_reload_js File.read!(Application.app_dir(:phoenix_live_reload, reload_path))
def init(opts) do
opts
end
def call(conn, _) do
config = conn.private.phoenix_endpoint.config(:live_reload)
url = Path.join(config[:url] || "/", "phoenix/live_reload/listen")
conn
|> put_resp_content_type("text/html")
|> send_resp(200, """
<html><body>
<script>
#{@phoenix_js}
var phx = require("phoenix")
var socket = new phx.Socket("#{url}")
#{@phoenix_live_reload_js}
</script>
</body></html>
""")
end
end