<!DOCTYPE html>
<html lang="{{ DEFAULT_LANG }}">
  <head>
    {% block head %}
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />

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

    <meta charset="utf-8" />
    {% if FEED_ALL_ATOM %}
    <link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Full Atom Feed" />
    {% endif %}
    {% if FEED_ALL_RSS %}
    <link href="{{ FEED_DOMAIN }}/{{ FEED_ALL_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Full RSS Feed" />
    {% endif %}
    {% if FEED_ATOM %}
    <link href="{{ FEED_DOMAIN }}/{{ FEED_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Atom Feed" />
    {% endif %}
    {% if FEED_RSS %}
    <link href="{{ FEED_DOMAIN }}/{{ FEED_RSS }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} RSS Feed" />
    {% endif %}
    {% if CATEGORY_FEED_RSS and category %}
    <link href="{{ FEED_DOMAIN }}/{{ CATEGORY_FEED_RSS|format(category.slug) }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Categories RSS Feed" />
    {% endif %}
    {% if TAG_FEED_ATOM and tag %}
    <link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_ATOM|format(tag.slug) }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} Tags Atom Feed" />
    {% endif %}
    {% if TAG_FEED_RSS and tag %}
    <link href="{{ FEED_DOMAIN }}/{{ TAG_FEED_RSS|format(tag.slug) }}" type="application/rss+xml" rel="alternate" title="{{ SITENAME }} Tags RSS Feed" />
    {% endif %}
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/poole.css"/>
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/syntax.css"/>
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/lanyon.css"/>
    <link rel="stylesheet" href="//fonts.googleapis.com/css?family=PT+Serif:400,400italic,700%7CPT+Sans:400">
    <link rel="stylesheet" href="{{ SITEURL }}/theme/css/styles.css"/>
    {% endblock head %}
    {% block extrahead %}{% endblock %}
  </head>

  <body>
    {% include 'sidebar.html' %}
    <div class="wrap">
      <div class="masthead">
        <div class="{% block containertitleclass %}container{% endblock %}">
          <h3 class="masthead-title">
            <a href="{{ SITEURL }}/" title="Home">{{ SITENAME }}</a>
            {% if SITEDESCRIPTION %}
            <small>{{ SITEDESCRIPTION }}</small>
            {% endif %}
          </h3>
        </div>
      </div>

      <div class="{% block containerclass %}container{% endblock %} content">
        {% block content %}{% endblock %}
      </div>

      <label for="sidebar-checkbox" class="sidebar-toggle"></label>

      <script>
        (function(document) {
          var i = 0;
          // snip empty header rows since markdown can't
          var rows = document.querySelectorAll('tr');
          for(i=0; i<rows.length; i++) {
            var ths = rows[i].querySelectorAll('th');
            var rowlen = rows[i].children.length;
            if (ths.length > 0 && ths.length === rowlen) {
              rows[i].remove();
            }
          }
        })(document);
      </script>

      <script>
        /* Lanyon & Poole are Copyright (c) 2014 Mark Otto. Adapted to Pelican 20141223 and extended a bit by @thomaswilley */
        (function(document) {
          var toggle = document.querySelector('.sidebar-toggle');
          var sidebar = document.querySelector('#sidebar');
          var checkbox = document.querySelector('#sidebar-checkbox');
          document.addEventListener('click', function(e) {
            var target = e.target;
            if(!checkbox.checked ||
            sidebar.contains(target) ||
            (target === checkbox || target === toggle)) return;
            checkbox.checked = false;
            }, false);
            })(document);
      </script>
      {% if GA_ACCOUNT %}
      <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '{{ GA_ACCOUNT }}']);
        _gaq.push(['_trackPageview']);
        (function() {
         var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
         ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
         })();
       </script>
       {% endif %}
      {% if PIWIK_SERVER_URL %}
      <!-- Piwik -->
      <script type="text/javascript">
        var _paq = _paq || [];
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function() {
          var u="{{ PIWIK_SERVER_URL }}";
          _paq.push(['setTrackerUrl', u+'piwik.php']);
          _paq.push(['setSiteId', {{ PIWIK_SITE_ID }}]);
          var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
          g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
        })();
      </script>
      <noscript><p><img src="{{ PIWIK_SERVER_URL }}piwik.php?idsite={{ PIWIK_SITE_ID }}" style="border:0;" alt="" /></p></noscript>
      <!-- End Piwik Code -->
      {% endif %}
     </div>
  </body>
</html>
