mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-29 00:05:01 +08:00
Update Phoenix LV (#656)
* Wrap live routes in live_session * Update Phoenix LV * Migrate to live_component component call * render_block -> render_slot * phx-disconnected -> phx-loading * phx-capture-click -> phx-click-away * Add hook dealing with current user * Bump LV * Bump LV
This commit is contained in:
parent
9c00f1622d
commit
fbd03d6725
20 changed files with 169 additions and 186 deletions
|
@ -15,10 +15,10 @@ iframe[hidden] {
|
|||
transition: opacity 1s ease-out;
|
||||
}
|
||||
|
||||
.phx-disconnected {
|
||||
.phx-loading {
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.phx-disconnected * {
|
||||
.phx-loading * {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ defmodule LivebookWeb.Helpers do
|
|||
|
||||
~H"""
|
||||
<button class={"choice-button #{if(@active, do: "active")} #{@class}"} disabled={@disabled} {@attrs}>
|
||||
<%= render_block(@inner_block) %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</button>
|
||||
"""
|
||||
end
|
||||
|
@ -263,7 +263,7 @@ defmodule LivebookWeb.Helpers do
|
|||
~H"""
|
||||
<div id={"password-toggle-#{@id}"} class="relative inline w-min" phx-hook="PasswordToggle">
|
||||
<!-- render password input -->
|
||||
<%= render_block(@inner_block) %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
<button
|
||||
class="bg-gray-50 p-1 icon-button absolute inset-y-0 right-1"
|
||||
type="button"
|
||||
|
|
|
@ -1,25 +1,17 @@
|
|||
defmodule LivebookWeb.ExploreLive do
|
||||
use LivebookWeb, :live_view
|
||||
|
||||
import LivebookWeb.UserHelpers
|
||||
import LivebookWeb.SessionHelpers
|
||||
|
||||
alias LivebookWeb.{SidebarHelpers, ExploreHelpers, PageHelpers}
|
||||
alias Livebook.Notebook.Explore
|
||||
|
||||
@impl true
|
||||
def mount(_params, %{"current_user_id" => current_user_id} = session, socket) do
|
||||
if connected?(socket) do
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "users:#{current_user_id}")
|
||||
end
|
||||
|
||||
current_user = build_current_user(session, socket)
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
[lead_notebook_info | notebook_infos] = Explore.notebook_infos()
|
||||
|
||||
{:ok,
|
||||
assign(socket,
|
||||
current_user: current_user,
|
||||
lead_notebook_info: lead_notebook_info,
|
||||
notebook_infos: notebook_infos
|
||||
)}
|
||||
|
@ -98,12 +90,4 @@ defmodule LivebookWeb.ExploreLive do
|
|||
end
|
||||
|
||||
def handle_params(_params, _url, socket), do: {:noreply, socket}
|
||||
|
||||
@impl true
|
||||
def handle_info(
|
||||
{:user_change, %{id: id} = user},
|
||||
%{assigns: %{current_user: %{id: id}}} = socket
|
||||
) do
|
||||
{:noreply, assign(socket, :current_user, user)}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -98,7 +98,7 @@ defmodule LivebookWeb.FileSelectComponent do
|
|||
</div>
|
||||
<%= if @inner_block do %>
|
||||
<div>
|
||||
<%= render_block(@inner_block) %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,26 +1,22 @@
|
|||
defmodule LivebookWeb.HomeLive do
|
||||
use LivebookWeb, :live_view
|
||||
|
||||
import LivebookWeb.UserHelpers
|
||||
import LivebookWeb.SessionHelpers
|
||||
|
||||
alias LivebookWeb.{SidebarHelpers, ExploreHelpers}
|
||||
alias Livebook.{Sessions, Session, LiveMarkdown, Notebook, FileSystem}
|
||||
|
||||
@impl true
|
||||
def mount(_params, %{"current_user_id" => current_user_id} = session, socket) do
|
||||
def mount(_params, _session, socket) do
|
||||
if connected?(socket) do
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "tracker_sessions")
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "users:#{current_user_id}")
|
||||
end
|
||||
|
||||
current_user = build_current_user(session, socket)
|
||||
sessions = sort_sessions(Sessions.list_sessions())
|
||||
notebook_infos = Notebook.Explore.notebook_infos() |> Enum.take(3)
|
||||
|
||||
{:ok,
|
||||
assign(socket,
|
||||
current_user: current_user,
|
||||
file: Livebook.Config.default_dir(),
|
||||
file_info: %{exists: true, access: :read_write},
|
||||
sessions: sessions,
|
||||
|
@ -59,11 +55,11 @@ defmodule LivebookWeb.HomeLive do
|
|||
</div>
|
||||
|
||||
<div class="h-80">
|
||||
<%= live_component LivebookWeb.FileSelectComponent,
|
||||
id: "home-file-select",
|
||||
file: @file,
|
||||
extnames: [LiveMarkdown.extension()],
|
||||
running_files: files(@sessions) do %>
|
||||
<.live_component module={LivebookWeb.FileSelectComponent}
|
||||
id="home-file-select"
|
||||
file={@file}
|
||||
extnames={[LiveMarkdown.extension()]}
|
||||
running_files={files(@sessions)}>
|
||||
<div class="flex justify-end space-x-2">
|
||||
<button class="button button-outlined-gray whitespace-nowrap"
|
||||
phx-click="fork"
|
||||
|
@ -85,7 +81,7 @@ defmodule LivebookWeb.HomeLive do
|
|||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</.live_component>
|
||||
</div>
|
||||
|
||||
<div class="py-12">
|
||||
|
@ -351,13 +347,6 @@ defmodule LivebookWeb.HomeLive do
|
|||
{:noreply, socket}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{:user_change, %{id: id} = user},
|
||||
%{assigns: %{current_user: %{id: id}}} = socket
|
||||
) do
|
||||
{:noreply, assign(socket, :current_user, user)}
|
||||
end
|
||||
|
||||
def handle_info(_message, socket), do: {:noreply, socket}
|
||||
|
||||
defp sort_sessions(sessions) do
|
||||
|
|
|
@ -34,7 +34,9 @@ defmodule LivebookWeb.HomeLive.ImportComponent do
|
|||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<%= live_component component_for_tab(@tab), [{:id, "import-#{@tab}"} | @import_opts] %>
|
||||
<.live_component module={component_for_tab(@tab)}
|
||||
id={"import-#{@tab}"}
|
||||
{@import_opts} />
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
|
|
|
@ -11,7 +11,6 @@ defmodule LivebookWeb.ModalComponent do
|
|||
<!-- Overlay -->
|
||||
<div class="absolute inset-0 bg-gray-500 opacity-75 z-0"
|
||||
aria-hidden="true"
|
||||
phx-capture-click="close"
|
||||
phx-window-keydown="close"
|
||||
phx-key="escape"
|
||||
phx-target={@myself}
|
||||
|
@ -19,6 +18,8 @@ defmodule LivebookWeb.ModalComponent do
|
|||
|
||||
<!-- Modal box -->
|
||||
<div class={"relative max-h-full overflow-y-auto bg-white rounded-lg shadow-xl #{@modal_class}"}
|
||||
phx-click-away="close"
|
||||
phx-target={@myself}
|
||||
role="dialog"
|
||||
aria-modal="true">
|
||||
|
||||
|
|
|
@ -11,18 +11,15 @@ defmodule LivebookWeb.SessionLive do
|
|||
alias Livebook.JSInterop
|
||||
|
||||
@impl true
|
||||
def mount(%{"id" => session_id}, %{"current_user_id" => current_user_id} = web_session, socket) do
|
||||
def mount(%{"id" => session_id}, _session, socket) do
|
||||
# We use the tracked sessions to locate the session pid, but then
|
||||
# we talk to the session process exclusively for getting all the information
|
||||
case Sessions.fetch_session(session_id) do
|
||||
{:ok, %{pid: session_pid}} ->
|
||||
current_user = build_current_user(web_session, socket)
|
||||
|
||||
data =
|
||||
if connected?(socket) do
|
||||
data = Session.register_client(session_pid, self(), current_user)
|
||||
data = Session.register_client(session_pid, self(), socket.assigns.current_user)
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "sessions:#{session_id}")
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "users:#{current_user_id}")
|
||||
|
||||
data
|
||||
else
|
||||
|
@ -38,7 +35,6 @@ defmodule LivebookWeb.SessionLive do
|
|||
|> assign(
|
||||
session: session,
|
||||
platform: platform,
|
||||
current_user: current_user,
|
||||
self: self(),
|
||||
data_view: data_to_view(data),
|
||||
autofocus_cell_id: autofocus_cell_id(data.notebook)
|
||||
|
@ -247,25 +243,26 @@ defmodule LivebookWeb.SessionLive do
|
|||
</div>
|
||||
<% end %>
|
||||
<%= for {section_view, index} <- Enum.with_index(@data_view.section_views) do %>
|
||||
<%= live_component LivebookWeb.SessionLive.SectionComponent,
|
||||
id: section_view.id,
|
||||
index: index,
|
||||
session_id: @session.id,
|
||||
runtime: @data_view.runtime,
|
||||
section_view: section_view %>
|
||||
<.live_component module={LivebookWeb.SessionLive.SectionComponent}
|
||||
id={section_view.id}
|
||||
index={index}
|
||||
session_id={@session.id}
|
||||
runtime={@data_view.runtime}
|
||||
section_view={section_view} />
|
||||
<% end %>
|
||||
<div style="height: 80vh"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fixed bottom-[0.4rem] right-[1.5rem]">
|
||||
<%= live_component LivebookWeb.SessionLive.IndicatorsComponent,
|
||||
session_id: @session.id,
|
||||
file: @data_view.file,
|
||||
dirty: @data_view.dirty,
|
||||
autosave_interval_s: @data_view.autosave_interval_s,
|
||||
runtime: @data_view.runtime,
|
||||
global_status: @data_view.global_status %>
|
||||
<LivebookWeb.SessionLive.IndicatorsComponent.render
|
||||
socket={@socket}
|
||||
session_id={@session.id}
|
||||
file={@data_view.file}
|
||||
dirty={@data_view.dirty}
|
||||
autosave_interval_s={@data_view.autosave_interval_s}
|
||||
runtime={@data_view.runtime}
|
||||
global_status={@data_view.global_status} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -838,13 +835,6 @@ defmodule LivebookWeb.SessionLive do
|
|||
{:noreply, push_event(socket, "intellisense_response", payload)}
|
||||
end
|
||||
|
||||
def handle_info(
|
||||
{:user_change, %{id: id} = user},
|
||||
%{assigns: %{current_user: %{id: id}}} = socket
|
||||
) do
|
||||
{:noreply, assign(socket, :current_user, user)}
|
||||
end
|
||||
|
||||
def handle_info({:location_report, client_pid, report}, socket) do
|
||||
report = Map.put(report, :client_pid, inspect(client_pid))
|
||||
{:noreply, push_event(socket, "location_report", report)}
|
||||
|
|
|
@ -246,7 +246,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do
|
|||
<div class="w-1 h-full rounded-lg absolute top-0 -left-3" data-element="cell-focus-indicator">
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<%= render_block(@inner_block) %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
|
@ -416,7 +416,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do
|
|||
<div class={"#{if(@tooltip, do: "tooltip")} bottom distant-medium"} data-tooltip={@tooltip}>
|
||||
<div class="flex items-center space-x-1">
|
||||
<div class="flex text-xs text-gray-400">
|
||||
<%= render_block(@inner_block) %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
<%= if @change_indicator do %>
|
||||
<span data-element="change-indicator">*</span>
|
||||
<% end %>
|
||||
|
|
|
@ -46,10 +46,10 @@ defmodule LivebookWeb.SessionLive.ExportComponent do
|
|||
<% end %>
|
||||
</div>
|
||||
<div>
|
||||
<%= live_component component_for_tab(@tab),
|
||||
id: "export-notebook-#{@tab}",
|
||||
session: @session,
|
||||
notebook: @notebook %>
|
||||
<.live_component module={component_for_tab(@tab)}
|
||||
id={"export-notebook-#{@tab}"}
|
||||
session={@session}
|
||||
notebook={@notebook} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -41,13 +41,13 @@ defmodule LivebookWeb.SessionLive.MixStandaloneLive do
|
|||
</p>
|
||||
<%= if @status == :initial do %>
|
||||
<div class="h-full h-52">
|
||||
<%= live_component LivebookWeb.FileSelectComponent,
|
||||
id: "mix-project-dir",
|
||||
file: @file,
|
||||
extnames: [],
|
||||
running_files: [],
|
||||
submit_event: if(disabled?(@file.path), do: nil, else: :init),
|
||||
file_system_select_disabled: true %>
|
||||
<.live_component module={LivebookWeb.FileSelectComponent}
|
||||
id="mix-project-dir"
|
||||
file={@file}
|
||||
extnames={[]}
|
||||
running_files={[]}
|
||||
submit_event={if(disabled?(@file.path), do: nil, else: :init)}
|
||||
file_system_select_disabled={true} />
|
||||
</div>
|
||||
<button class="button button-blue" phx-click="init" disabled={disabled?(@file.path)}>
|
||||
<%= if(matching_runtime?(@current_runtime, @file.path), do: "Reconnect", else: "Connect") %>
|
||||
|
|
|
@ -102,12 +102,12 @@ defmodule LivebookWeb.SessionLive.PersistenceLive do
|
|||
<%= if @draft_file do %>
|
||||
<div class="flex flex-col">
|
||||
<div class="h-full h-52">
|
||||
<%= live_component LivebookWeb.FileSelectComponent,
|
||||
id: "persistence_file_select",
|
||||
file: @draft_file,
|
||||
extnames: [LiveMarkdown.extension()],
|
||||
running_files: @running_files,
|
||||
submit_event: :confirm_file do %>
|
||||
<.live_component module={LivebookWeb.FileSelectComponent}
|
||||
id="persistence_file_select"
|
||||
file={@draft_file}
|
||||
extnames={[LiveMarkdown.extension()]}
|
||||
running_files={@running_files}
|
||||
submit_event={:confirm_file}>
|
||||
<div class="flex justify-end space-x-2">
|
||||
<button class="button button-gray"
|
||||
phx-click="close_file_select"
|
||||
|
@ -120,7 +120,7 @@ defmodule LivebookWeb.SessionLive.PersistenceLive do
|
|||
Choose
|
||||
</button>
|
||||
</div>
|
||||
<% end %>
|
||||
</.live_component>
|
||||
</div>
|
||||
<div class="mt-6 text-gray-500 text-sm">
|
||||
File: <%= normalize_file(@draft_file).path %>
|
||||
|
|
|
@ -93,24 +93,24 @@ defmodule LivebookWeb.SessionLive.SectionComponent do
|
|||
<div class="container">
|
||||
<div class="flex flex-col space-y-1">
|
||||
<%= for {cell_view, index} <- Enum.with_index(@section_view.cell_views) do %>
|
||||
<%= live_component LivebookWeb.SessionLive.InsertButtonsComponent,
|
||||
id: "#{@section_view.id}:#{index}",
|
||||
persistent: false,
|
||||
section_id: @section_view.id,
|
||||
insert_cell_index: index %>
|
||||
<.live_component module={LivebookWeb.SessionLive.InsertButtonsComponent}
|
||||
id={"#{@section_view.id}:#{index}"}
|
||||
persistent={false}
|
||||
section_id={@section_view.id}
|
||||
insert_cell_index={index} />
|
||||
|
||||
<%= live_component LivebookWeb.SessionLive.CellComponent,
|
||||
id: cell_view.id,
|
||||
session_id: @session_id,
|
||||
runtime: @runtime,
|
||||
cell_view: cell_view %>
|
||||
<.live_component module={LivebookWeb.SessionLive.CellComponent}
|
||||
id={cell_view.id}
|
||||
session_id={@session_id}
|
||||
runtime={@runtime}
|
||||
cell_view={cell_view} />
|
||||
<% end %>
|
||||
|
||||
<%= live_component LivebookWeb.SessionLive.InsertButtonsComponent,
|
||||
id: "#{@section_view.id}:last",
|
||||
persistent: @section_view.cell_views == [],
|
||||
section_id: @section_view.id,
|
||||
insert_cell_index: length(@section_view.cell_views) %>
|
||||
<.live_component module={LivebookWeb.SessionLive.InsertButtonsComponent}
|
||||
id={"#{@section_view.id}:last"}
|
||||
persistent={@section_view.cell_views == []}
|
||||
section_id={@section_view.id}
|
||||
insert_cell_index={length(@section_view.cell_views)} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,24 +1,15 @@
|
|||
defmodule LivebookWeb.SettingsLive do
|
||||
use LivebookWeb, :live_view
|
||||
|
||||
import LivebookWeb.UserHelpers
|
||||
|
||||
alias LivebookWeb.{SidebarHelpers, PageHelpers}
|
||||
|
||||
@impl true
|
||||
def mount(_params, %{"current_user_id" => current_user_id} = session, socket) do
|
||||
if connected?(socket) do
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "users:#{current_user_id}")
|
||||
end
|
||||
|
||||
current_user = build_current_user(session, socket)
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
file_systems = Livebook.Config.file_systems()
|
||||
file_systems_env = Livebook.Config.file_systems_as_env(file_systems)
|
||||
|
||||
{:ok,
|
||||
assign(socket,
|
||||
current_user: current_user,
|
||||
file_systems: file_systems,
|
||||
file_systems_env: file_systems_env
|
||||
)}
|
||||
|
@ -66,8 +57,9 @@ defmodule LivebookWeb.SettingsLive do
|
|||
<span class="hidden" id="file-systems-env-source"><%= @file_systems_env %></span>
|
||||
</span>
|
||||
</div>
|
||||
<%= live_component LivebookWeb.SettingsLive.FileSystemsComponent,
|
||||
file_systems: @file_systems %>
|
||||
<LivebookWeb.SettingsLive.FileSystemsComponent.render
|
||||
file_systems={@file_systems}
|
||||
socket={@socket} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -108,15 +100,10 @@ defmodule LivebookWeb.SettingsLive do
|
|||
def handle_params(_params, _url, socket), do: {:noreply, socket}
|
||||
|
||||
@impl true
|
||||
def handle_info(
|
||||
{:user_change, %{id: id} = user},
|
||||
%{assigns: %{current_user: %{id: id}}} = socket
|
||||
) do
|
||||
{:noreply, assign(socket, :current_user, user)}
|
||||
end
|
||||
|
||||
def handle_info({:file_systems_updated, file_systems}, socket) do
|
||||
file_systems_env = Livebook.Config.file_systems_as_env(file_systems)
|
||||
{:noreply, assign(socket, file_systems: file_systems, file_systems_env: file_systems_env)}
|
||||
end
|
||||
|
||||
def handle_info(_message, socket), do: {:noreply, socket}
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule LivebookWeb.SidebarHelpers do
|
|||
def sidebar(assigns) do
|
||||
~H"""
|
||||
<div class="w-16 flex flex-col items-center space-y-5 px-3 py-7 bg-gray-900">
|
||||
<%= render_block(@inner_block) %>
|
||||
<%= render_slot(@inner_block) %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
defmodule LivebookWeb.UserHelpers do
|
||||
use Phoenix.Component
|
||||
|
||||
alias Livebook.Users.User
|
||||
|
||||
@doc """
|
||||
Renders user avatar.
|
||||
|
||||
|
@ -39,24 +37,4 @@ defmodule LivebookWeb.UserHelpers do
|
|||
initials -> List.first(initials) <> List.last(initials)
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Builds `Livebook.Users.User` using information from
|
||||
session and socket.
|
||||
|
||||
Uses `user_data` from socket `connect_params` as initial
|
||||
attributes if the socket is connected. Otherwise uses
|
||||
`user_data` from session.
|
||||
"""
|
||||
def build_current_user(session, socket) do
|
||||
%{"current_user_id" => current_user_id} = session
|
||||
|
||||
connect_params = get_connect_params(socket) || %{}
|
||||
user_data = connect_params["user_data"] || session["user_data"] || %{}
|
||||
|
||||
case User.change(%{User.new() | id: current_user_id}, user_data) do
|
||||
{:ok, user} -> user
|
||||
{:error, _errors, user} -> user
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
45
lib/livebook_web/live/user_hook.ex
Normal file
45
lib/livebook_web/live/user_hook.ex
Normal file
|
@ -0,0 +1,45 @@
|
|||
defmodule LivebookWeb.CurrentUserHook do
|
||||
import Phoenix.LiveView
|
||||
|
||||
alias Livebook.Users.User
|
||||
|
||||
def on_mount(:default, _params, %{"current_user_id" => current_user_id} = session, socket) do
|
||||
if connected?(socket) do
|
||||
Phoenix.PubSub.subscribe(Livebook.PubSub, "users:#{current_user_id}")
|
||||
end
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> assign_new(:current_user, fn -> build_current_user(session, socket) end)
|
||||
|> attach_hook(:current_user_subscription, :handle_info, &info/2)
|
||||
|
||||
{:cont, socket}
|
||||
end
|
||||
|
||||
defp info(
|
||||
{:user_change, %{id: id} = user},
|
||||
%{assigns: %{current_user: %{id: id}}} = socket
|
||||
) do
|
||||
{:cont, assign(socket, :current_user, user)}
|
||||
end
|
||||
|
||||
defp info(_message, socket), do: {:cont, socket}
|
||||
|
||||
# Builds `Livebook.Users.User` using information from
|
||||
# session and socket.
|
||||
#
|
||||
# Uses `user_data` from socket `connect_params` as initial
|
||||
# attributes if the socket is connected. Otherwise uses
|
||||
# `user_data` from session.
|
||||
defp build_current_user(session, socket) do
|
||||
%{"current_user_id" => current_user_id} = session
|
||||
|
||||
connect_params = get_connect_params(socket) || %{}
|
||||
user_data = connect_params["user_data"] || session["user_data"] || %{}
|
||||
|
||||
case User.change(%{User.new() | id: current_user_id}, user_data) do
|
||||
{:ok, user} -> user
|
||||
{:error, _errors, user} -> user
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,6 +16,7 @@ defmodule LivebookWeb.Router do
|
|||
plug LivebookWeb.UserPlug
|
||||
end
|
||||
|
||||
live_session :default, on_mount: LivebookWeb.CurrentUserHook do
|
||||
scope "/", LivebookWeb do
|
||||
pipe_through [:browser, :auth]
|
||||
|
||||
|
@ -46,19 +47,25 @@ defmodule LivebookWeb.Router do
|
|||
live "/sessions/:id/delete-section/:section_id", SessionLive, :delete_section
|
||||
get "/sessions/:id/images/:image", SessionController, :show_image
|
||||
live "/sessions/:id/*path_parts", SessionLive, :catch_all
|
||||
end
|
||||
|
||||
# Public authenticated URLs that people may be directed to
|
||||
scope "/", LivebookWeb do
|
||||
pipe_through [:browser, :auth]
|
||||
|
||||
live "/import", HomeLive, :public_import
|
||||
end
|
||||
end
|
||||
|
||||
scope "/" do
|
||||
pipe_through [:browser, :auth]
|
||||
|
||||
live_dashboard "/dashboard",
|
||||
metrics: LivebookWeb.Telemetry,
|
||||
home_app: {"Livebook", :livebook}
|
||||
end
|
||||
|
||||
# Public URLs that people may be directed to
|
||||
scope "/", LivebookWeb do
|
||||
pipe_through [:browser, :auth]
|
||||
|
||||
live "/import", HomeLive, :public_import
|
||||
end
|
||||
|
||||
# Public URLs without authentication
|
||||
scope "/", LivebookWeb do
|
||||
pipe_through :browser
|
||||
|
||||
|
|
4
mix.exs
4
mix.exs
|
@ -51,8 +51,8 @@ defmodule Livebook.MixProject do
|
|||
[
|
||||
{:phoenix, "~> 1.5"},
|
||||
{:phoenix_html, "~> 3.0"},
|
||||
{:phoenix_live_view, "~> 0.16.0"},
|
||||
{:phoenix_live_dashboard, "~> 0.5.0"},
|
||||
{:phoenix_live_view, "~> 0.17.3"},
|
||||
{:phoenix_live_dashboard, "~> 0.6.0"},
|
||||
{:telemetry_metrics, "~> 0.4"},
|
||||
{:telemetry_poller, "~> 0.4"},
|
||||
{:jason, "~> 1.0"},
|
||||
|
|
6
mix.lock
6
mix.lock
|
@ -12,10 +12,10 @@
|
|||
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
|
||||
"mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"},
|
||||
"phoenix": {:hex, :phoenix, "1.6.2", "6cbd5c8ed7a797f25a919a37fafbc2fb1634c9cdb12a4448d7a5d0b26926f005", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7bbee475acae0c3abc229b7f189e210ea788e63bd168e585f60c299a4b2f9133"},
|
||||
"phoenix_html": {:hex, :phoenix_html, "3.0.4", "232d41884fe6a9c42d09f48397c175cd6f0d443aaa34c7424da47604201df2e1", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "ce17fd3cf815b2ed874114073e743507704b1f5288bb03c304a77458485efc8b"},
|
||||
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.5.3", "ff153c46aee237dd7244f07e9b98d557fe0d1de7a5916438e634c3be2d13c607", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.16.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "e36e62b1f61c19b645853af78290a5e7900f7cae1e676714ff69f9836e2f2e76"},
|
||||
"phoenix_html": {:hex, :phoenix_html, "3.1.0", "0b499df05aad27160d697a9362f0e89fa0e24d3c7a9065c2bd9d38b4d1416c09", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "0c0a98a2cefa63433657983a2a594c7dee5927e4391e0f1bfd3a151d1def33fc"},
|
||||
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.6.1", "fb94a33c077141f9ac7930b322a7a3b99f9b144bf3a08dd667b9f9aaf0319889", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.3", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17.1", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "6faf1373e5846c8ab68c2cf55cfa5c196c1fbbe0c72d12a4cdfaaac6ef189948"},
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
|
||||
"phoenix_live_view": {:hex, :phoenix_live_view, "0.16.4", "5692edd0bac247a9a816eee7394e32e7a764959c7d0cf9190662fc8b0cd24c97", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.9 or ~> 1.6.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "754ba49aa2e8601afd4f151492c93eb72df69b0b9856bab17711b8397e43bba0"},
|
||||
"phoenix_live_view": {:hex, :phoenix_live_view, "0.17.4", "c994c248c1195ccdb25a4e990eadabddb34c59d8f620d5c0aec418e2b7913651", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.9 or ~> 1.6.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "86d27af55e78bd42476a4084d54c3add660e565c07233d8afacb20ab6d7f53b6"},
|
||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
|
||||
"phoenix_view": {:hex, :phoenix_view, "1.0.0", "fea71ecaaed71178b26dd65c401607de5ec22e2e9ef141389c721b3f3d4d8011", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "82be3e2516f5633220246e2e58181282c71640dab7afc04f70ad94253025db0c"},
|
||||
"plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
|
||||
|
|
Loading…
Add table
Reference in a new issue