Skip to content

Commit

Permalink
Fix URL helpers. Add additional URL section for old frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
remotecom committed Jul 8, 2023
1 parent eff3cd9 commit e88585a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
4 changes: 4 additions & 0 deletions lib/magpie_web/templates/experiment/edit.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ serverUrl: '<%= get_home_url() %>',
socketUrl: '<%= get_socket_url() %>',</pre>
</ul>

<p>
(If you're basing your experiment on a frontend version that was before the <code>magpie-base</code> package, please note the full submission URL: <code><%= get_home_url() <> Magpie.Router.Helpers.experiment_path(Magpie.Endpoint, :submit, @experiment.id) %></code>)
</p>

<%= form_for @changeset, experiment_path(@conn, :update, @experiment), fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger" >
Expand Down
19 changes: 3 additions & 16 deletions lib/magpie_web/views/experiment_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,33 +107,20 @@ defmodule Magpie.ExperimentView do
end

def get_endpoint_url(type, id) do
base_url =
Application.get_env(
:magpie,
:canonical_url,
Magpie.Router.Helpers.page_url(Magpie.Endpoint, :index)
)
base_url = Magpie.Router.Helpers.page_url(Magpie.Endpoint, :index)

path = Magpie.Router.Helpers.experiment_path(Magpie.Endpoint, type, id)
base_url <> path
end

def get_home_url() do
base_url =
Application.get_env(
:magpie,
:canonical_url,
Magpie.Router.Helpers.page_url(Magpie.Endpoint, :index)
)

home_path = Magpie.Router.Helpers.page_path(Magpie.Endpoint, :index)
base_url <> home_path
Magpie.Endpoint.url()
end

def get_socket_url() do
get_home_url()
|> String.replace_leading("http", "ws")
|> Kernel.<>("socket")
|> Kernel.<>("/socket")
end

def format_timestamp(timestamp, timezone) do
Expand Down

0 comments on commit e88585a

Please sign in to comment.