Skip to content

Commit

Permalink
Integration of feldspar storage in feldspar tool_form
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Sep 26, 2023
1 parent c0dda6e commit 9b01eb4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/systems/feldspar/_routes.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
defmodule Systems.Feldspar.Routes do
defmacro routes() do
quote do
scope "/apps", Systems.Feldspar do
scope "/feldspar", Systems.Feldspar do
pipe_through([:browser])
live("/:id", AppPage)
live("/apps/:id", AppPage)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions core/systems/feldspar/local_fs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Systems.Feldspar.LocalFS do
end

def get_public_url(id) do
"#{Endpoint.url()}/#{static_path()}/#{id}"
"#{Endpoint.url()}/#{public_path()}/#{id}"
end

def remove(id) do
Expand All @@ -33,5 +33,5 @@ defmodule Systems.Feldspar.LocalFS do
|> Access.fetch!(:local_fs_root_path)
end

def static_path, do: "/feldspar_apps"
def public_path, do: "/feldspar/apps"
end
2 changes: 1 addition & 1 deletion core/systems/feldspar/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Systems.Feldspar.Plug do

defmacro setup() do
quote do
plug(Systems.Feldspar.Plug, at: Systems.Feldspar.LocalFS.static_path())
plug(Systems.Feldspar.Plug, at: Systems.Feldspar.LocalFS.public_path())
end
end

Expand Down
6 changes: 5 additions & 1 deletion core/systems/feldspar/tool_form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ defmodule Systems.Feldspar.ToolForm do
%{assigns: %{entity: entity}} = socket,
{_local_relative_path, local_full_path, remote_file}
) do
archive_ref =
Feldspar.Public.store(local_full_path)
|> Feldspar.Public.get_public_url()

socket
|> save(entity, %{archive_ref: local_full_path, archive_name: remote_file})
|> save(entity, %{archive_ref: archive_ref, archive_name: remote_file})
end

@impl true
Expand Down
4 changes: 2 additions & 2 deletions core/test/systems/feldspar/app_page_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ defmodule Systems.Feldspar.AppPageTest do

describe "render an app page" do
test "renders page with iframe", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/apps/test")
{:ok, _view, html} = live(conn, ~p"/feldspar/apps/test")
assert html =~ "<iframe"
end
end

describe "handle app_event" do
test "can receive random app_event data", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/apps/test")
{:ok, view, _html} = live(conn, ~p"/feldspar/apps/test")

assert render_hook(view, :app_event, %{unexpected_key: "some data"}) =~
"Unsupported "
Expand Down

0 comments on commit 9b01eb4

Please sign in to comment.