mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
add viewport meta hook
This commit is contained in:
parent
5fe3fc2e00
commit
40debb9634
2 changed files with 18 additions and 1 deletions
|
@ -3,7 +3,8 @@ html lang="en"
|
|||
head
|
||||
meta charset="utf-8"
|
||||
meta http-equiv="X-UA-Compatible" content="IE=edge"
|
||||
meta name="viewport" content="width=device-width, initial-scale=1"
|
||||
= viewport_meta_tag(@conn)
|
||||
|
||||
title
|
||||
= if assigns[:title] do
|
||||
=> assigns[:title]
|
||||
|
|
|
@ -117,4 +117,20 @@ defmodule PhilomenaWeb.LayoutView do
|
|||
|
||||
def manages_bans?(conn),
|
||||
do: can?(conn, :create, Philomena.Bans.User)
|
||||
|
||||
def viewport_meta_tag(conn) do
|
||||
ua = get_user_agent(conn)
|
||||
|
||||
case String.contains?(ua, ["Mobile", "webOS"]) do
|
||||
true -> tag(:meta, name: "viewport", content: "width=device-width, initial-scale=1")
|
||||
_false -> tag(:meta, name: "viewport", content: "width=1024, initial-scale=1")
|
||||
end
|
||||
end
|
||||
|
||||
defp get_user_agent(conn) do
|
||||
case Plug.Conn.get_req_header(conn, "user-agent") do
|
||||
[ua] -> ua
|
||||
_ -> ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue