<!DOCTYPE html>
{% import 'macros.html' as m %}
<html lang="{{ DEFAULT_LANG }}">
  <head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>{% block title %}Home{% endblock title %} | {{ SITENAME }}</title>

    <meta name="author" content="{{ AUTHOR|e }}"/>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"/>
    <script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"/>
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/jquery.mglass.css"/>
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/pygment-solarized-dark.css"/>
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/style.css"/>
    {% if FLAT_DESIGN is defined and not FLAT_DESIGN %}
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap-theme.min.css"/>
    {% endif %}

    <!-- Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'/>
    <link href='https://fonts.googleapis.com/css?family=Istok+Web' rel='stylesheet' type='text/css'/>
    <link href='https://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'/>
    {% if TYPOGRIFY %}
      <link href='https://fonts.googleapis.com/css?family=Expletus+Sans' rel='stylesheet' type='text/css'>
    {% endif %}

    {% block extra_css %}{% endblock %}

    <link rel="icon" href="{{ SITEURL }}/favicon.ico" type="image/x-icon">
    <link rel="shortcut icon" href="{{ SITEURL }}/favicon.ico" type="image/x-icon">

    <!-- Feeds -->
    {% set all_feeds = [] %}
    {% if FEED_ALL_ATOM %}
      {% if all_feeds.append({'kind': 'Atom', 'url': FEED_ALL_ATOM, 'name': 'All posts'}) %}{% endif %}
    {% endif %}
    {% if FEED_ALL_RSS %}
      {% if all_feeds.append({'kind': 'RSS', 'url': FEED_ALL_RSS, 'name': 'All posts'}) %}{% endif %}
    {% endif %}
    {% if FEED_ATOM %}
      {% if all_feeds.append({'kind': 'Atom', 'url': FEED_ATOM, 'name': 'Latest posts'}) %}{% endif %}
    {% endif %}
    {% if FEED_RSS %}
      {% if all_feeds.append({'kind': 'RSS', 'url': FEED_RSS, 'name': 'Latest posts'}) %}{% endif %}
    {% endif %}
    {% if CATEGORY_FEED_ATOM and category is defined %}
      {% if all_feeds.append({'kind': 'Atom', 'url': CATEGORY_FEED_ATOM.format(slug=category.slug), 'name': 'Category: ' + category.name}) %}{% endif %}
    {% endif %}
    {% if CATEGORY_FEED_RSS and category is defined %}
      {% if all_feeds.append({'kind': 'RSS', 'url': CATEGORY_FEED_RSS.format(slug=category.slug), 'name': 'Category: ' + category.name}) %}{% endif %}
    {% endif %}
    {% if TAG_FEED_ATOM and tag is defined %}
      {% if all_feeds.append({'kind': 'Atom', 'url': TAG_FEED_ATOM.format(slug=tag.slug), 'name': 'Tag: ' + tag.name}) %}{% endif %}
    {% endif %}
    {% if TAG_FEED_RSS and tag is defined %}
      {% if all_feeds.append({'kind': 'RSS', 'url': TAG_FEED_RSS.format(slug=tag.slug), 'name': 'Tag: ' + tag.name}) %}{% endif %}
    {% endif %}
    {% for feed in all_feeds %}
      <link href="{{ FEED_DOMAIN }}/{{ feed.url }}" type="application/{{ feed.kind|lower }}+xml" rel="alternate" title="{{ SITENAME|e }} - {{ feed.name|e }} - {{ feed.kind }} Feed"/>
    {% endfor %}

    {% block head %}
    {% endblock %}

  </head>

  <body>

    <div class="container">

      <div class="page-header">
        {% if SITE_THUMBNAIL %}
          <a href="{{ SITEURL }}" class="avatar-container pull-left">
            <div class="avatar {% if SITE_THUMBNAIL_TEXT %} animate {% endif %}">
              <div class="side"><img src="{{ SITE_THUMBNAIL }}" class="img-responsive"/></div>
              {% if SITE_THUMBNAIL_TEXT %}
                <div class="side back"><p class="text-center">{{ SITE_THUMBNAIL_TEXT }}</p></div>
              {% endif %}
            </div>
          </a>
        {% endif %}
        <h1><a href="{{ SITEURL }}">{{ SITENAME }}</a> <small>{{ SITESUBTITLE }}</small></h1>
      </div>

      <nav class="navbar navbar-default">

        <!-- Hamburger menu for mobile -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#plumage-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="{{ SITEURL }}" title="{{ SITESUBTITLE|e }}">{{ SITENAME }}</a>
        </div>

        <!-- Menus and search forms -->
        <div class="collapse navbar-collapse" id="plumage-navbar-collapse-1">

          <ul class="nav navbar-nav">
            {% for title, link in MENUITEMS %}
              {% set active_page = link == ("/%s"|format(output_file)).strip('index.html') -%}
              <li {% if active_page %} class="active" {% endif %}>
                <a href="{{ link }}">{{ title }}{% if active_page %} <span class="sr-only">(current)</span>{% endif %}</a>
              </li>
            {% endfor %}
            {% if DISPLAY_PAGES_ON_MENU %}
              {% for p in pages %}
                {% set active_page = (p == page) -%}
                <li {% if active_page %} class="active" {% endif %}>
                  <a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}{% if active_page %} <span class="sr-only">(current)</span>{% endif %}</a>
                </li>
              {% endfor %}
            {% endif %}
            {% if DISPLAY_CATEGORIES_ON_MENU %}
              {% for c, null in categories %}
                {% set active_category = (c == category) -%}
                <li {% if active_category %} class="active" {% endif %}>
                  <a href="{{ SITEURL }}/{{ c.url }}">{{ c.name }}{% if active_category %} <span class="sr-only">(current)</span>{% endif %}</a>
                </li>
              {% endfor %}
            {% endif %}
          </ul>

          {% if GOOGLE_SEARCH %}
            <form class="navbar-form navbar-right" role="search" action="https://www.google.com" target="_blank">
              <div class="form-group">
                <div class="input-group">
                  <input type="text" name="q" class="form-control search-query" placeholder="Search" required />
                  <span class="input-group-btn">
                    <button class="btn btn-default" type="button"><i class="fa fa-search fa-fw"></i></button>
                  </span>
                </div>
                <input type="hidden" name="cx" value="{{ GOOGLE_SEARCH }}" />
                <input type="hidden" name="ie" value="UTF-8" />
              </div>
            </form>
          {% endif %}

          {% if TIPUE_SEARCH %}
            <form class="navbar-form navbar-right" role="search" action="{{ SITEURL }}/search.html" onsubmit="return validateForm(this.elements['q'].value);">
              <div class="form-group">
                <div class="input-group">
                  <input type="text" name="q" id="tipue_search_input" class="form-control search-query" placeholder="Search" required />
                  <span class="input-group-btn">
                    <button class="btn btn-default" type="submit"><i class="fa
                        fa-search fa-fw"></i></button>
                  </span>
                </div>
              </div>
            </form>
          {% endif %}

        </div>

      </nav>

    </div>


    <div class="container main">

      {% set has_left_content = has_left or LEFT_SIDEBAR is defined %}
      {% set has_right_content = has_right or RIGHT_SIDEBAR is defined %}

      <div class="row">
        <div class="{% if (has_left_content and has_right_content) or LAYOUT == 'full-width' %} col-md-6 {% elif has_left_content or has_right_content%} col-md-9 {% else %} col-md-12 {% endif %} {% if has_left_content %} col-md-offset-3 {% endif %}">
          {% block top_center %}
          {% endblock %}
        </div>
      </div>

      <div class="row">

        {% if LAYOUT != 'full-width' and has_left_content %}
          <div class="col-md-3">
            {% block left_sidebar %}
            {% endblock %}
            {{ LEFT_SIDEBAR }}
          </div>
        {% endif %}

        <div class="{% if LAYOUT == 'full-width' %} col-md-offset-1 {% elif has_left_content and has_right_content %} col-md-6 {% elif has_left_content or has_right_content %} col-md-9 {% else %} col-md-12 {% endif %}" id="content" role="main">
          {% block content %}
          {% endblock %}
        </div>

        {% if LAYOUT != 'full-width' and has_right_content %}
          <div class="col-md-3">
            {% block right_sidebar %}
            {% endblock %}
            {{ RIGHT_SIDEBAR }}
          </div>
        {% endif %}

      </div>

    </div>

    <!-- TODO: make footer sticky -->
    <footer class="container-fluid">
      <div class="container">
        <div class="row">

          {% set SOCIAL_WIDGET_NAME = SOCIAL_WIDGET_NAME or 'Social' %}
          {% set LINKS_WIDGET_NAME = LINKS_WIDGET_NAME or 'Links' %}
          {% for group_title, group_links in ((SOCIAL_WIDGET_NAME, SOCIAL), (LINKS_WIDGET_NAME, LINKS)) %}
            <div class="col-md-2">
              {% if group_links %}
                <h5>{{ group_title }}</h5>
                <ul class="list-unstyled">
                  {% if MANUAL_LINKS%}
                    {% for item in group_links %}
                      <li>{{ item }}</li>
                    {% endfor %}
                  {% else %}
                    {% for title, link in group_links %}
                      <li>{{ m.render_link_icon(link, title, FAVICON_LINKS) }}</li>
                    {% endfor %}
                  {% endif%}
                </ul>
              {% endif %}
            </div>
          {% endfor %}

          <div class="col-md-2">
            <h5>Browse content by</h5>
            <ul class="list-unstyled">
              {% if CATEGORIES_SAVE_AS %}
                <li><a href="{{ SITEURL }}/{{ CATEGORIES_SAVE_AS }}"><i class="fas fa-th"></i> Categories</a></li>
              {% endif %}
              {% if ARCHIVES_SAVE_AS %}
                <li><a href="{{ SITEURL }}/{{ ARCHIVES_SAVE_AS }}"><i class="far fa-calendar-alt"></i> Dates</a></li>
              {% endif %}
              {% if TAGS_SAVE_AS %}
                <li><a href="{{ SITEURL }}/{{ TAGS_SAVE_AS }}"><i class="fas fa-tags"></i> Tags</a></li>
              {% endif %}
            </ul>
          </div>

          <div class="col-md-2 text-muted">
            <h5>Copyright notice</h5>
            {% set date_start = dates[-1].date.year if dates else None %}
            {% set date_end   = dates[0].date.year if dates else None %}
            <p>© Copyright {{ date_start if date_start }}{{ '-%s' % date_end if date_end and date_end != date_start }} {{ AUTHOR }}.</p>
            {% if COPYRIGHT %}
              <p>{{ COPYRIGHT }}</p>
            {% endif %}
          </div>

          <div class="col-md-2 text-muted">
            <h5>Disclaimer</h5>
            {% if DISCLAIMER %}
              <p>{{ DISCLAIMER }}</p>
            {% else %}
              <p>All opinions expressed in this site are my own personal opinions and are not endorsed by, nor do they represent the opinions of my previous, current and future employers or any of its affiliates, partners or customers.</p>
            {% endif %}
          </div>

          <div class="col-md-2">
            {% if all_feeds %}
              <h5>Feeds</h5>
              <ul class="list-unstyled">
                {% for feed in all_feeds %}
                  <li><small><a href="{{ FEED_DOMAIN }}/{{ feed.url }}"><i class="fa fa-rss"></i> {{ feed.name }} ({{ feed.kind }})</a></small></li>
                {% endfor %}
              </ul>
            {% endif %}
          </div>

        </div>
      </div>

      <h5 class="text-right"><a href="#"><i class="fa fa-arrow-up"></i> Back to top</a></h5>

      <div class="container">
        <div class="row col-md-12 text-muted text-center">
          Site generated by <a href="https://getpelican.com"> Pelican</a>.<br/>
          <a href="https://github.com/kdeldycke/plumage"> Plumage</a> theme by <a href="https://kevin.deldycke.com">Kevin Deldycke</a>.
        </div>
      </div>

    </footer>

    {% include "analytics.html" %}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/fitvids/1.1.0/jquery.fitvids.min.js"></script>
    <script src="{{ SITEURL }}/theme/js/jquery.mglass.js"></script>
    <script src="{{ SITEURL }}/theme/js/application.js"></script>
    {% block extra_js %}{% endblock %}

  </body>
</html>
