2024-09-04 10:12:36 +02:00
|
|
|
defmodule Mse25Web.Layouts do
|
|
|
|
|
use Mse25Web, :html
|
|
|
|
|
|
2024-10-16 15:40:53 +02:00
|
|
|
@url "https://madr.se"
|
|
|
|
|
@list_views ["webblogg", "delningar", "evenemang"]
|
|
|
|
|
|
2024-09-04 10:12:36 +02:00
|
|
|
embed_templates "layouts/*"
|
2024-10-16 15:40:53 +02:00
|
|
|
|
|
|
|
|
def canonical(%{year: _, conn: %{path_info: path}}) do
|
|
|
|
|
~s"""
|
|
|
|
|
<link rel="canonical" href="#{@url}/#{Enum.join(path, "/")}" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def canonical(_) do
|
|
|
|
|
""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def opengraph(%{heading: title, lead: lead, conn: %{path_info: path}}) do
|
|
|
|
|
~s"""
|
|
|
|
|
<meta property="og:title" content="#{title}" />
|
|
|
|
|
<meta property="og:description" content="#{lead}" />
|
|
|
|
|
<meta property="og:type" content="event" />
|
|
|
|
|
<meta property="og:url" content="#{@url}/#{Enum.join(path, "/")}" />
|
|
|
|
|
<meta property="og:site_name" content="madr.se" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def opengraph(%{heading: title, conn: %{path_info: path}}) do
|
|
|
|
|
~s"""
|
|
|
|
|
<meta property="og:title" content="#{title}" />
|
|
|
|
|
<meta property="og:type" content="article" />
|
|
|
|
|
<meta property="og:url" content="#{@url}/#{Enum.join(path, "/")}" />
|
|
|
|
|
<meta property="og:site_name" content="madr.se" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def opengraph(%{page_title: title, conn: %{path_info: path}}) do
|
|
|
|
|
~s"""
|
|
|
|
|
<meta property="og:title" content="#{title}" />
|
|
|
|
|
<meta property="og:type" content="page" />
|
|
|
|
|
<meta property="og:url" content="#{@url}/#{Enum.join(path, "/")}" />
|
|
|
|
|
<meta property="og:site_name" content="madr.se" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def robots(%{conn: %{path_info: [first | []]}}) do
|
|
|
|
|
case Integer.parse(first) do
|
|
|
|
|
:error ->
|
|
|
|
|
case Enum.member?(@list_views, first) do
|
|
|
|
|
true ->
|
|
|
|
|
~s"""
|
|
|
|
|
<meta name="robots" content="noindex,follow" />
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
false ->
|
|
|
|
|
~s"""
|
|
|
|
|
<meta name="robots" content="index,follow" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
{_i, _d} ->
|
|
|
|
|
~s"""
|
|
|
|
|
<meta name="robots" content="noindex,follow" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def robots(%{conn: %{path_info: [_p, _c]}}) do
|
|
|
|
|
~s"""
|
|
|
|
|
<meta name="robots" content="index,follow" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def robots(_) do
|
|
|
|
|
~s"""
|
|
|
|
|
<meta name="robots" content="noindex,follow" />
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show_interactive_event_map?(assigns) do
|
|
|
|
|
Map.has_key?(assigns, :events)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show_footer?(%{heading: "Kolofon"}), do: false
|
|
|
|
|
|
|
|
|
|
def show_footer?(%{}), do: true
|
2025-02-16 14:43:32 +01:00
|
|
|
|
|
|
|
|
def current?(_key, []) do
|
|
|
|
|
false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def current?(k, path) do
|
|
|
|
|
Enum.member?(path, k)
|
|
|
|
|
end
|
2024-09-04 10:12:36 +02:00
|
|
|
end
|