{% load snipt_tags intercom %}

<!DOCTYPE html>
<html lang="en" class="{% block html-class %}{% endblock %}" ng-app="Snipt">
<head>

  <title>{% block page-title %}Snipt{% endblock %}</title>

  <meta charset="utf-8" />
  <meta name="google-site-verification" content="BantFMmY6nSP8wFvb_SDKwYZo08HglaCpNMXQqTyOuk" />

  {% block page-description %}
    <meta name="description" content="Long-term memory for coders. Share and store code snippets." />
  {% endblock %}

  {% if 'page' in request.GET %}
    <meta name="robots" content="noindex, follow" />
  {% endif %}

  {% if debug %}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/themes.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/chosen.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/ambiance.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/blackboard.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/cobalt.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/eclipse.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/elegant.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/erlang-dark.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/lesser-dark.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/monokai.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/neat.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/night.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/rubyblue.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/solarized.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/twilight.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/vibrant-ink.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/codemirror-themes/xq-dark.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/highlightjs-themes/tomorrow.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/blog-themes/default/style.css" />
  {% else %}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/snipt.css?111" />
  {% endif %}

  {% if has_snipts and not detail %}
    <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ request.path }}?rss{% if not public %}&amp;api_key={{ request.user.api_key.key }}{% endif %}" />
  {% endif %}

  <script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

  <link rel="author" href="/humans.txt" />

  {% block css %}{% endblock %}

  <!--[if IE]>
  <style type="text/css">
    .group {
      display: block;
      zoom: 1;
    }
  </style>
  <![endif]-->

  <!--[if lt IE 9]>
  <script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->

</head>
<body class="{% block body-class %}{% endblock %} {% if request.user.profile.is_pro %}is-pro{% endif %}" ng-controller="AppController">

{% block header %}
  <header class="main">
    <div class="inner">
      <div class="shadey"></div>
      <h1 class="main-logo"><a href="{% if request.user.is_authenticated %}/{{ request.user.username }}/{% else %}/{% endif %}">snip<span>t</span></a></h1> 
      <form class="search" action="/search/" method="get" ng-controller="HeaderSearchController">
        <fieldset>
          <div class="fields">
            <input ng-model="search.query" type="text" class="search-query" name="q"
            ng-init="search.query='{{ query|escapejs }}'"
            placeholder="Search snipts" id="id_q"
            value="{{ query }}" />
          </div>
        </fieldset>
      </form>
      <nav class="public">
        <ul>
          {% if not request.user.is_authenticated %}
            <li>
              <a href="/public/" {% if '/public/' in request.path or public %} class="active"{% endif %}>Public snipts</a>
            </li>
            <li>
              <a href="/login/?next={{ request.path }}" {% if '/login/' in request.path %} class="active"{% endif %}>Log in</a>
            </li>
            <li>
              <a href="/signup/" {% if '/signup/' in request.path %} class="active"{% endif %}>Sign up</a>
            </li>
          {% else %}
            <li>
              <a href="/{{ request.user.username }}/" {% if request.user.username in request.path %} class="active"{% endif %}>My snipts</a>
            </li>
            <li>
              <a href="/public/" {% if '/public/' in request.path or public %} class="active"{% endif %}>Public snipts</a>
            </li>
            {% block add-snipt %}{% endblock %}
          {% endif %}
        </ul>
      </nav>
      {% if request.user.is_authenticated %}
        <aside class="nav">
          <a href="#" class="mini-profile">
            <span class="avatar" style="background-image: url('https://secure.gravatar.com/avatar/{{ request.user.email|md5 }}?s=35');"></span>
            <span class="info">
              <span class="username">{{ request.user.username }}</span>
              <i class="icon-cog icon-white"></i>
              <span class="type">
                {% if request.user.profile.is_pro %}
                  <span class="is-pro">Pro</span>
                {% else %}
                  Basic member
                {% endif %}
              </span>
            </span>
          </a>
          <ul>
            <li>
              <a href="/{{ request.user.username }}/">
                <i class="icon-user icon-white"></i>
                Profile
              </a>
            </li>
            <li>
              <a href="/account/stats/">
                <i class="icon-star icon-white"></i>
                Stats
              </a>
            </li>
            <li>
              <a href="/account/">
                <i class="icon-cog icon-white"></i>
                Account
              </a>
            </li>
            {% if not request.user.profile.is_pro %}
              <li>
                <a href="/pro/">
                  <i class="icon-star-empty icon-white"></i>
                  Go Pro
                </a>
              </li>
            {% endif %}
            {% if request.user.is_superuser %}
              <li>
                <a href="/admin/">
                  <i class="icon-cog icon-white"></i>
                  Admin
                </a>
              </li>
            {% endif %}
            <li>
              <a href="/logout/?next={{ request.path }}">
                <i class="icon-off icon-white"></i>
                Log out
              </a>
            </li>
          </ul>
        </aside>
      {% endif %}
    </div>
  </header>
{% endblock %}
{% block sub-header %}
  <header class="sub">
    <div class="inner group">
      <ul class="bcrumb group">
        <li class="prompt">/</li>
        {% block breadcrumb %}{% endblock %}
      </ul>
      <div class="shortcuts">
        Ctrl+h for KB shortcuts
      </div>
    </div>
  </header>
{% endblock %}
{% block main %}
  <section class="main group" id="main">
    {% block aside %}
      <aside class="main">
        {% block ad %}
          {% if not request.user.profile.is_pro %}
            {% include 'ad-sidebar.html' %}
          {% endif %}
        {% endblock %}
        {% block aside-top %}{% endblock %}
        {% block aside-inner %}{% endblock %}
        <nav class="footer">
          <ul>
            <li class="api">
              <a href="/api/" {% if '/api/' in request.path %}class="active"{% endif %}><span>API</span></a>
            </li>
            <li class="twitter">
              <a href="https://twitter.com/#!/snipt"><span>@snipt</span></a>
            </li>
            {% if not request.user.profile.is_pro %}
              <li class="pro">
                <a href="/pro/"><span>Go Pro</span></a>
              </li>
            {% endif %}
            <li class="blog">
              <a href="https://blog.snipt.net/"><span>Snipt Blog</span></a>
            </li>
            <li class="blog">
              <a href="/apps/" {% if '/apps/' in request.path %}class="active"{% endif %}><span>Snipt Apps</span></a>
            </li>
            <li class="blog">
              <a href="/blogging/" {% if '/blogging/' in request.path %}class="active"{% endif %}><span>Blogging on Snipt</span></a>
            </li>
            <li class="roadmap">
              <a href="https://github.com/nicksergeant/snipt/"><span>Open source on GitHub</span></a>
            </li>
            <li class="roadmap">
              <a href="https://github.com/nicksergeant/snipt/issues?state=open"><span>Bugs & feature requests</span></a>
            </li>
            <li class="roadmap">
              <a href="http://getsentry.com/"><span>Shipped with confidence</span></a>
            </li>
          </ul>
        </nav>
        <div class="linode">
          <a href="http://www.linode.com/" title="Linode - Xen VPS Hosting. Deploy and Manage Linux Virtual Servers in the Linode Cloud." target="blank">
            <span>Proudly hosted on</span>
          </a>
        </div>
      </aside>
    {% endblock %}
    <div class="inner">
      {% block content %}{% endblock %}
      {% block rochester-made %}
        <div class="rochester-made">
          <a href="http://rochestermade.com/" title="Proudly made in Rochester, NY, USA">
            <img src="{{ STATIC_URL }}img/rochester-made.png" alt="" />
          </a>
        </div>
      {% endblock %}
    </div>
    <div class="left-y ruler"></div>
    <div class="right-y ruler"></div>
  </section>
{% endblock %}
{% block main-edit %}
  <section class="main group hidden" id="main-edit"></section>
{% endblock %}
{% if request.user.is_authenticated and request.user.profile.get_account_age > 7 %}
<div class="get-support">
  <a class="btn btn-info" href="/pro/">Get support &raquo;</a>
</div>
{% endif %}
{% block keyboard-shortcuts %}
  <div class="modal hide" id="keyboard-shortcuts">
    <div class="modal-header">
      <a href="#" class="close">×</a>
      <h3><span>Keyboard shortcuts</span></h3>
    </div>
    <div class="modal-body">
      <table class="table table-striped table-bordered table-condensed">
        <thead>
          <tr>
            <th>Key</th>
            <th>Function</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>&lt;ctrl-h&gt;</td>
            <td>Show / hide keyboard shortcuts</td>
          </tr>
          <tr>
            <td>/</td>
            <td>Focus search field</td>
          </tr>
          <tr>
            <td>esc</td>
            <td>Unfocus search field / deselect snipt</td>
          </tr>
          <tr>
            <td>j</td>
            <td>Next snipt</td>
          </tr>
          <tr>
            <td>k</td>
            <td>Previous snipt</td>
          </tr>
          <tr>
            <td>o / return</td>
            <td>Go to snipt</td>
          </tr>
          <tr>
            <td>u</td>
            <td>Go to snipt's author</td>
          </tr>
          <tr>
            <td>e</td>
            <td>Expand / collapse snipt</td>
          </tr>
          <tr>
            <td>v</td>
            <td>Embed snipt</td>
          </tr>
          <tr>
            <td>c</td>
            <td>Copy snipt</td>
          </tr>
          <tr>
            <td>&lt;ctrl-e&gt;</td>
            <td>Edit snipt</td>
          </tr>
          <tr>
            <td>&lt;ctrl-delete&gt; or &lt;ctrl-backspace&gt;</td>
            <td>Delete snipt</td>
          </tr>
          <tr>
            <td>&lt;ctrl-n&gt; or &lt;alt+n&gt;</td>
            <td>Add new snipt</td>
          </tr>
          <tr>
            <td>&lt;ctrl-s&gt;</td>
            <td>Save snipt</td>
          </tr>
          <tr>
            <td>&lt;ctrl-c&gt;</td>
            <td>Save snipt and close</td>
          </tr>
          <tr>
            <td>n</td>
            <td>Next page</td>
          </tr>
          <tr>
            <td>p</td>
            <td>Previous page</td>
          </tr>
          <tr>
            <td>g</td>
            <td>Scroll to top of page</td>
          </tr>
          <tr>
            <td>G</td>
            <td>Scroll to bottom of page</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
{% endblock %}

{% block extra-scripts %}{% endblock %}

{% block inline-js %}
  <script type="text/javascript">
    {% block js %}
      window.user = '{{ request.user.username }}';
      window.user_id = {% firstof request.user.id 'null' %};
      window.user_ip = '{{ request.META.REMOTE_ADDR }}';
      window.user_profile_id = {% firstof request.user.profile.id 'null' %};
      window.user_email = '{{ request.user.email }}';
      window.user_account_age = {% firstof request.user.profile.get_account_age 'null' %};

      {% if public %}
        window.pub = {{ public|lower }};
      {% else %}
        window.pub = null;
      {% endif %}

      window.api_key = '{{ request.user.api_key.key }}';
    {% endblock %}
    {% if request.user.profile.is_pro %}
      window.user_is_pro = true;
    {% else %}
      window.user_is_pro = false;
    {% endif %}
    window.default_editor = '{{ request.user.profile.get_default_editor_display|lower }}';
    window.editor_theme = '{{ request.user.profile.editor_theme }}';
  </script>
{% endblock %}

{% if debug %}
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/jquery.min.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/jquery-ui.min.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/angular.min.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/angular-route.min.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/underscore.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/json2.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/backbone.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/bootstrap.min.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/plugins/jquery.hotkeys.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/plugins/jquery.infieldlabel.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/plugins/jquery.chosen.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/codemirror.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/libs/highlight.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/src/application.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/src/modules/site.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/src/modules/snipt.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/src/account.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/src/snipts.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/src/search.js"></script>
{% else %}
  <script type="text/javascript" src="{{ STATIC_URL }}js/snipt-all.min.js?72"></script>
{% endif %}

{% if has_snipts and detail %}
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
{% endif %}
{% block snipt-templates %}
  <div class="hidden" id="templates">
    {% include 'snipts/snipt-js-template.html' %}
    {% include 'snipts/snipt-edit-js-template.html' %}
  </div>
{% endblock %}
{% if request.user.is_authenticated and not debug %}
  <script id="IntercomSettingsScriptTag">
    var intercomSettings = {
      app_id: 'sajf131y',
      user_id: {{ request.user.id }},
      user_hash: '{{ request.user.id|intercom_sha_256 }}',
      email: '{{ request.user.email }}',
      created_at: {{ request.user.date_joined|date:"U" }},
      custom_data: {
        'snipts count': {% snipts_count_for_user %},
        'profile link': 'https://snipt.net/{{ request.user.username }}/',
        'is pro': window.user_is_pro,
        'blog domain': '{{ request.user.profile.blog_domain }}',
        'pro date': {% firstof request.user.profile.pro_date|date:"U" 'null' %},
      }
    };
  </script>
  <script>
    (function() {
      function async_load() {
        var s = document.createElement('script');
        s.type = 'text/javascript'; s.async = true;
        s.src = 'https://static.intercomcdn.com/intercom.v1.js';
        var x = document.getElementsByTagName('script')[0];
        x.parentNode.insertBefore(s, x);
      }
      if (window.attachEvent) {
        window.attachEvent('onload', async_load);
      } else {
        window.addEventListener('load', async_load, false);
      }
    })();
  </script>
  {% if request.user.profile.get_account_age <= 7 or request.user.profile.is_pro %}
    {% block olark %}
      <!-- begin olark code -->
      <script data-cfasync="false" type='text/javascript'>/*<![CDATA[*/window.olark||(function(c){var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";var nt=function(){
      f[z]=function(){
      (a.s=a.s||[]).push(arguments)};var a=f[z]._={
      },q=c.methods.length;while(q--){(function(n){f[z][n]=function(){
      f[z]("call",n,arguments)}})(c.methods[q])}a.l=c.loader;a.i=nt;a.p={
      0:+new Date};a.P=function(u){
      a.p[u]=new Date-a.p[0]};function s(){
      a.P(r);f[z](r)}f.addEventListener?f.addEventListener(r,s,false):f.attachEvent("on"+r,s);var ld=function(){function p(hd){
      hd="head";return["<",hd,"></",hd,"><",i,' onl' + 'oad="var d=',g,";d.getElementsByTagName('head')[0].",j,"(d.",h,"('script')).",k,"='",l,"//",a.l,"'",'"',"></",i,">"].join("")}var i="body",m=d[i];if(!m){
      return setTimeout(ld,100)}a.P(1);var j="appendChild",h="createElement",k="src",n=d[h]("div"),v=n[j](d[h](z)),b=d[h]("iframe"),g="document",e="domain",o;n.style.display="none";m.insertBefore(n,m.firstChild).id=z;b.frameBorder="0";b.id=z+"-loader";if(/MSIE[ ]+6/.test(navigator.userAgent)){
      b.src="javascript:false"}b.allowTransparency="true";v[j](b);try{
      b.contentWindow[g].open()}catch(w){
      c[e]=d[e];o="javascript:var d="+g+".open();d.domain='"+d.domain+"';";b[k]=o+"void(0);"}try{
      var t=b.contentWindow[g];t.write(p());t.close()}catch(x){
      b[k]=o+'d.write("'+p().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}a.P(2)};ld()};nt()})({
      loader: "static.olark.com/jsclient/loader0.js",name:"olark",methods:["configure","extend","declare","identify"]});
      /* custom configuration goes here (www.olark.com/documentation) */
      olark.identify('9104-133-10-2665');/*]]>*/</script><noscript><a href="https://www.olark.com/site/9104-133-10-2665/contact" title="Contact us" target="_blank">Questions? Feedback?</a> powered by <a href="http://www.olark.com?welcome" title="Olark live chat software">Olark live chat software</a></noscript>
      <!-- end olark code -->
      {% if request.user.is_authenticated %}
        <script type="text/javascript">
          olark('api.visitor.updateEmailAddress', { emailAddress: '{{ request.user.email }}' });
          olark('api.visitor.updateFullName', { fullName: '{{ request.user.username }}' });
          olark('api.visitor.updateCustomFields', {
            userId: {{ request.user.id }},
            createdAt: '{{ request.user.date_joined }}',
            sniptsCount: {% snipts_count_for_user %},
            isPro: window.user_is_pro,
            blogDomain: '{{ request.user.profile.blog_domain }}',
            proDate: '{% firstof request.user.profile.pro_date 'null' %}'
          });
        </script>
      {% endif %}
    {% endblock %}
  {% endif %}
{% endif %}

{% include 'analytics.html' %}

{% block preload %}
  <div class="hidden">
    <img src="{{ STATIC_URL }}img/header-fixed-save.gif" alt="" />
    <img src="{{ STATIC_URL }}img/chosen-sprite.png" alt="" />
    <img src="{{ STATIC_URL }}img/aside-nav-open-bottom-bg.gif" alt="" />
    <img src="{{ STATIC_URL }}img/aside-nav-open-top-bg.gif" alt="" />
  </div>
{% endblock %}

</body>
</html>
