@**
 * Copyright (c) 2013-2019 Kaj Magnus Lindberg
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *@

@(tpi: debiki.SiteTpi, pageTitleUnsafe: Option[String], description: Option[String], faviconUrl: String)

@import com.debiki.core.Prelude._
@import org.owasp.encoder.Encode

@if(pageTitleUnsafe.nonEmpty) {
<title>@Html(Encode.forHtmlContent(pageTitleUnsafe.get))</title>
}
@if(description.nonEmpty) {
<meta name="description" content="@{description.get}">
}

@faviconType = @{
  val suffix = faviconUrl.takeRightWhile(_ != '.')
  // If too long, probably there is no real suffix. Then assume it's an icon? 'jpeg' = 4 chars.
  if (suffix == "ico" || suffix.length > 4 || suffix.isEmpty) "image/x-icon"
  else "image/" + suffix
}
@if(faviconUrl.nonEmpty) {
<link rel="icon" type="@faviconType" href="@faviconUrl">
}
@* Else, use Talkyard's own favicon. Sync with Nginx location directive [NGXMEDIA] *@
@if(faviconUrl.isEmpty) {
<link rel="apple-touch-icon" sizes="180x180" href="@tpi.mediaUrl("favicon/apple-touch-icon.png")">
<link rel="icon" type="image/png" sizes="32x32" href="@tpi.mediaUrl("favicon/favicon-32x32.png")">
<link rel="icon" type="image/png" sizes="16x16" href="@tpi.mediaUrl("favicon/favicon-16x16.png")">
<link rel="mask-icon" href="@tpi.mediaUrl("favicon/safari-pinned-tab.svg")" color="#0060ad">
<meta name="msapplication-TileColor" content="#b91d47">
<meta name="theme-color" content="#ffffff">
}

@* Some other viewport values, and the absence of a value,
trigger Android bugs that report the wrong screen.width,
window.innerWidth, document.documentElement.clientWidth and heights,
breaking dwScrollIntoView (and other stuff?) in debiki.js.
See: https://code.google.com/p/android/issues/detail?id=10775#c20
*@
<meta name="viewport" content="initial-scale=1.0, minimum-scale=0.01"/>
 @*
<link rel="manifest" href="/manifest.webmanifest">  [sw] *@
<meta charset="utf-8"/>

