!!!
%html.main
  %head
    %title #{page_title.reverse.join(' - ')}
    = csrf_meta_tags
    = stylesheet_link_tag 'application/application', 'data-turbolinks-track' => 'reload'
    = javascript_include_tag 'application/application', 'data-turbolinks-track' => 'reload'
    %link{:href => asset_path('favicon.png'), :rel => 'shortcut icon'}
    <meta name="turbolinks-cache-control" content="no-cache">
    = yield :head
  %body
    = display_flash
    %header.siteHeader{'data-turbolinks-permanent' => true}
      - if flash[:remember_login] && !auth_session.persistent?
        .siteHeader__remember.js-remember
          .siteHeader__rememberText
            %p.siteHeader__rememberTextTitle Would you like to stay logged in?
            %p This will keep you logged in in this browser for 2 months.
          .siteHeader__rememberButtons.buttonSet
            = link_to "Remember me", '#', :class => 'button button--positive button--small', :data => {:remember => 'yes'}
            = link_to "Close", '#', :class => 'button button--dark button--small', :data => {:remember => 'no'}

      .siteHeader__inside
        .siteHeader__logo= link_to "Postal", root_path
        %p.siteHeader__version The open source e-mail platform
        %ul.siteHeader__nav
          - if defined?(organization) && organization
            %li.siteHeader__navItem
            %li.siteHeader__navItem.siteHeader__navItem--organization
              = link_to organization.name, organization_root_path(organization), :class => 'siteHeader__navLinkWithMenu'
              %ul.siteHeader__subMenu
                %li.siteHeader__subMenuItem.siteHeader__subMenuItem--header= link_to organization.name, organization_settings_path(organization)
                - if organization.admin?(current_user)
                  %li.siteHeader__subMenuItem= link_to "Organization Settings", organization_settings_path(organization), :class => 'siteHeader__subMenuLink'
                  %li.siteHeader__subMenuItem= link_to "Manage Users", organization_users_path(organization), :class => 'siteHeader__subMenuLink'
                - if current_user.admin?
                  %li.siteHeader__subMenuItem= link_to "Create new organization", :new_organization, :class => 'siteHeader__subMenuLink'
                - if current_user.organizations.present.count > 1
                  %li.siteHeader__subMenuItem= link_to "Switch organization", root_path, :class => 'siteHeader__subMenuLink'
          %li.siteHeader__navItem.siteHeader__navItem--user= current_user.name
          %li.siteHeader__navItem= link_to "My Settings", settings_path, :class => 'sideHeader__navItemLink'
          - if current_user.admin? && Postal.ip_pools?
            %li.siteHeader__navItem= link_to "IP Pools", ip_pools_path, :class => 'sideHeader__navItemLink'
          %li.siteHeader__navItem= link_to "Logout", logout_path, :method => :delete, :class => 'sideHeader__navItemLink'

    .siteContent
      - if content_for?(:sidebar)
        %nav.sidebar
          = content_for :sidebar

      %section.siteContent__main
        = yield

    - if logged_in?
      <!--- Postal Version #{Postal.version} -->
