<!doctype html>
<html xmlns:fb="http://ogp.me/ns/fb#">
<head>
  <title><%= yield :page_title %></title>
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  <link rel="top" title="<%= Danbooru.config.app_name %>" href="/">
  <%= csrf_meta_tag %>
  <meta name="current-user-name" content="<%= CurrentUser.name %>">
  <meta name="current-user-id" content="<%= CurrentUser.id %>">
  <meta name="user-comment-threshold" content="<%= CurrentUser.comment_threshold %>">
  <% if CurrentUser.user.blacklisted_tags.present? %>
    <meta name="blacklisted-tags" content="<%= CurrentUser.user.blacklisted_tags.gsub(/(?:\r|\n)+/, ",") %>">
  <% end %>
  <% if flash[:notice] =~ /error/ %>
    <meta name="errors" content="true">
  <% end %>
  <meta name="enable-js-navigation" content="<%= CurrentUser.user.enable_post_navigation %>">
  <meta name="default-image-size" content="<%= CurrentUser.user.default_image_size %>">
  <meta name="enable-auto-complete" content="<%= CurrentUser.user.enable_auto_complete %>">
  <%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
  <%= stylesheet_link_tag "application", :media => "screen" %>
  <% if CurrentUser.user.custom_style.present? %>
    <style><%= CurrentUser.user.custom_style %></style>
  <% end %>
  <%= javascript_include_tag "application" %>
  <%= raw Danbooru.config.custom_html_header_content %>
  <%= yield :html_header %>
</head>
<body lang="en">
  <header id="top">
    <%= render "news_updates/listing" %>

    <h1><%= link_to Danbooru.config.app_name, "/" %></h1>
    <nav>
      <%= render "layouts/main_links" %>
      <%= yield :secondary_links %>
    </nav>

    <%= render "layouts/more_links" %>
  </header>

  <div id="page">
    <% if CurrentUser.is_anonymous? && session[:started_at] && session[:started_at] < 1.minute.ago && cookies[:hide_sign_up_notice].blank? %>
      <%= render "users/sign_up_notice" %>
    <% end %>

    <% if !CurrentUser.is_anonymous? && !CurrentUser.is_gold? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %>
      <%= render "users/upgrade_notice" %>
    <% end %>

    <% if CurrentUser.user.is_banned? %>
      <%= render "users/ban_notice" %>
    <% end %>

    <% if CurrentUser.dmail_count.present? && CurrentUser.dmails.unread.present? && cookies[:hide_dmail_notice].to_i != CurrentUser.dmails.unread.first.id %>
      <%= render "users/dmail_notice" %>
    <% end %>

    <% if cookies["accepted_tos"].blank? && !CurrentUser.is_gold? %>
      <%= render "users/tos" %>
    <% end %>

    <div class="ui-corner-all ui-state-highlight" id="notice" style="<%= "display: none;" unless flash[:notice] %>">
      <span><%= flash[:notice] %></span>
      <a href="#" id="close-notice-link">close</a>
    </div>

    <%= yield :layout %>
  </div>

  <%= render "static/footer" %>
</body>
</html>
