24 řádky
475 B
Elixir
24 řádky
475 B
Elixir
defmodule OpenpodWeb.FeedView do
|
|
use OpenpodWeb, :view
|
|
|
|
def format_length(length) do
|
|
min = length / 60 |> trunc()
|
|
sec = length - (min * 60) |> Integer.to_string |> String.pad_leading(2, "0")
|
|
"#{min}:#{sec}"
|
|
end
|
|
|
|
def base_url(conn) do
|
|
scheme = conn
|
|
|> Map.fetch!(:scheme)
|
|
|> Atom.to_string
|
|
|
|
host = conn
|
|
|> Map.fetch!(:host)
|
|
|
|
port = conn
|
|
|> Map.fetch!(:port)
|
|
|> Integer.to_string
|
|
|
|
"#{scheme}://#{host}:#{port}"
|
|
end
|
|
end
|