This repository has been archived on 2024-06-16. You can view files and clone it, but cannot push or open issues or pull requests.
mebe/web/views/layout_view.ex

42 lines
957 B
Elixir
Raw Normal View History

2015-05-14 20:58:25 +00:00
defmodule MebeWeb.LayoutView do
use MebeWeb.Web, :view
alias MebeWeb.Utils
2015-09-13 16:47:49 +00:00
@doc """
Resolve title from the current assigns. Will use the current page's or post's title, if available.
Otherwise will render default title.
"""
def title(conn) do
2015-08-05 20:52:06 +00:00
cond do
conn.assigns[:post] ->
conn.assigns[:post].title
conn.assigns[:page] ->
conn.assigns[:page].title
true -> Utils.get_conf :blog_name
end
end
@doc """
Return the extra HTML defined in the config.
"""
def extra_html(), do: Utils.get_conf :extra_html
2015-09-13 16:47:49 +00:00
@doc """
Return the custom footer HTML defined in the config.
"""
def custom_footer_html(), do: Utils.get_conf :custom_footer_html
2015-05-24 19:46:42 +00:00
@doc """
Calculate time taken for request so far.
"""
def request_time(conn) do
MebeWeb.RequestStartTimePlug.calculate_time conn
end
def safe_round(val) when is_integer(val), do: val
def safe_round(val), do: Float.round val
2015-05-14 20:58:25 +00:00
end