Skip to content

Instantly share code, notes, and snippets.

@vegg89
Last active August 20, 2019 15:09
Show Gist options
  • Save vegg89/b4363641df20351754c483f1cba88e5d to your computer and use it in GitHub Desktop.
Save vegg89/b4363641df20351754c483f1cba88e5d to your computer and use it in GitHub Desktop.
LiveView installation
@import "../../deps/phoenix_live_view/assets/css/live_view.css";
# Configures the endpoint
config :phoenix_observer, PhoenixObserverWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "HZeXYAfTEvY59ZdUBBI7yRTqBXZITAAjv6pYMeRg0art4EQmVYWhPeOuijMF9r4y",
render_errors: [view: PhoenixObserverWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: PhoenixObserver.PubSub, adapter: Phoenix.PubSub.PG2],
live_view: [
signing_salt: "JT9vHYpcubGCuh+83mpKBQrH9NT9nZyb"
]
config :phoenix_observer, PhoenixObserverWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/phoenix_observer_web/{live,views}/.*(ex)$",
~r"lib/phoenix_observer_web/templates/.*(eex)$",
~r{lib/phoenix_observer/live/.*(ex)$}
]
]
socket "/live", Phoenix.LiveView.Socket
{:plug_cowboy, "~> 2.0"},
{:phoenix_live_view, github: "phoenixframework/phoenix_live_view"},
{:recon, "~> 2.5}
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view"
}
defmodule PhoenixObserverWeb do
def controller do
quote do
import Phoenix.LiveView.Controller, only: [live_render: 3]
alias PhoenixObserverWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
import Phoenix.LiveView, only: [live_render: 2, live_render: 3, live_link: 1, live_link: 2]
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
end
end
def router do
quote do
import Phoenix.LiveView.Router
end
end
end
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug Phoenix.LiveView.Flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment