defmodule Usher.Web.Layouts do
@moduledoc false
use Usher.Web, :html
phoenix_js_paths =
for app <- ~w(phoenix phoenix_html phoenix_live_view)a do
path = Application.app_dir(app, ["priv", "static", "#{app}.js"])
Module.put_attribute(__MODULE__, :external_resource, path)
path
end
@static_path Application.app_dir(:usher_web, ["priv", "static"])
@external_resource css_path = Path.join(@static_path, "app.css")
@external_resource js_path = Path.join(@static_path, "app.js")
@css File.read!(css_path)
@js """
#{for path <- phoenix_js_paths, do: path |> File.read!() |> String.replace("//# sourceMappingURL=", "// ")}
#{File.read!(js_path)}
"""
def render("app.css"), do: @css
def render("app.js"), do: @js
embed_templates "layouts/*"
def logo(assigns) do
~H"""
"""
end
def footer(assigns) do
assigns =
assign(assigns,
usher_version: Application.spec(:usher, :vsn),
usher_web_version: Application.spec(:usher_web, :vsn)
)
~H"""
"""
end
defp version(assigns) do
~H"""
{@name} {if @version, do: "v#{@version}", else: "–"}
"""
end
end