       tabs: %{chapters: true},
       contributors: contributorlist(episode.gigs),
       chapters: chapterlist(episode.chapters),
-      audio: audiolist(episode.enclosures),
-      reference: %{base: PanWeb.Endpoint.url() <> "/web-player/"}
+      audio: audiolist(episode.enclosures)
     }
-    |> Jason.encode!()
-    |> raw
+    |> Jason.encode!
   end
 
   defp contributorlist(gigs) do

  import PanWeb.Router.Helpers

  prop(episode, :map, required: true)
  data(episodestruct, :map)

  def update(%{episode: episode} = assigns, socket) do
    socket =
      assign(socket, assigns)
      |> assign(episodestruct: episode |> podlove_episodestruct)

    {:ok, socket}
  end

  defp podlove_episodestruct(episode) do
    poster = Endpoint.url() <> "/images/missing-podcast.png"

    %{
      show: %{
        title: episode.podcast.title,
        subtitle: episode.podcast.summary,

    end)
  end

  defp playerconfig() do
    %{version: 5,
      activeTab: "chapters",
      base: PanWeb.Endpoint.url <> "/web-player/"}
    |> Jason.encode!
  end

  defp escape_javascript(nil), do: ""
  defp escape_javascript(string), do: javascript_escape(string)

  defp render_script(episode) do
    """
    <script>
      window.podlovePlayer("#app", #{episode_config(episode)}, #{playerconfig()});
    </script>
    """
    |> raw
  end

  def render(assigns) do
    ~F"""
    <div id="app" class="app"></div>
    <script src="/web-player/embed.js"></script>
    {render_script(@episode)}
    """
  end
end
