Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 278 lines (213 sloc) 9.979 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
{% extends "v2-base.html" %}
{% load i18n %}
{% load toc from templatefilters %}

{% get_current_language as LANGUAGE_CODE %}

{% block headauthor %}{{ tut.author.given_name }} {{ tut.author.family_name }} - {{ tut.author.email }}{% endblock %}
{% block headtitle %}{{ tut.title|safe }}{% if tut.subtitle %}: {{tut.subtitle|safe}}{% endif %}{% endblock %}

{% block body %}

  <section class="title">

    {% if redirect_from_locale %}
    <section class="redirect_notification error-block" lang="{{ redirect_from_locale.lang }}">
      <p>{{ redirect_from_locale.msg }}</p>
    </section>
    {% endif %}

    <section class="title-text container">
      {% if tut %}
      <h1>{{ tut.title|safe }}</h1>
      {% if tut.subtitle %}<h2>{{tut.subtitle|safe}}</h2>{% endif %}
      {% elif page_title %}
      <h1>{{ page_title }}</h1>
      {% endif %}

      <a href="/{{LANGUAGE_CODE}}/" class="watermark">HTML5 Rocks</a>
    </section>
  </section>

  <article class="content-wrapper{% if hide_toc != None %} wide{% endif %}">

    <section class="container">

      {% if hide_toc == None %}

      <div class="article-meta" id="article-meta">
        <nav class="toc">
          <h1>{% trans "Table of Contents" %}</h1>

          {% toc %}
        </nav>

        <aside class="localizations">
          <h1>{% trans "Localizations" %}</h1>
          <ul>
            {% if localizations %}
              {% for l in localizations %}
              <li><a href="{{ l.path }}">{{ l.lang }}</a></li>
              {% endfor %}
              <li><a href="https://github.com/html5rocks/www.html5rocks.com/blob/master/CONTRIBUTING.md">Contribute another</a></li>
            {% else %}
              <li><a href="https://github.com/html5rocks/www.html5rocks.com/blob/master/CONTRIBUTING.md">Contribute one</a></li>
            {% endif %}
          </ul>
        </aside>
      </div>
      {% endif %}

      <div class="content" id="article-content">

        <section class="byline">

          <div class="byline-content">
            {% if tut %}
            <section class="author-images">
              <a href="/profiles/#{{ tut.author.key.name }}">
                <img src="/static/images/profiles/{{ tut.author.key.name }}.png" itemprop="photo" alt="{{ tut.author.given_name }} {{ tut.author.family_name }}" title="{{ tut.author.given_name }} {{ tut.author.family_name }}">
              </a>

              {% if tut.second_author %}
                <a href="/profiles/#{{ tut.second_author.key.name }}">
                  <img src="/static/images/profiles/{{ tut.second_author.key.name }}.png" itemprop="photo" alt="{{ tut.second_author.given_name }} {{ tut.second_author.family_name }}" title="{{ tut.second_author.given_name }} {{ tut.second_author.family_name }}">
                </a>
              {% endif %}
            </section>

            <section class="meta">
              <div class="authors">
                <strong>{% trans "By" %}</strong> <a href="/profiles/#{{ tut.author.key.name }}">{{ tut.author.given_name }} {{ tut.author.family_name }}</a>
                {% if tut.second_author %}
                  and <a href="/profiles/#{{ tut.second_author.key.name }}">{{ tut.second_author.given_name }} {{ tut.second_author.family_name }}</a>
                {% endif %}
              </div>

              {% block translator %}{% endblock %}

              <div class="date">
                <time pubdate><strong>{% blocktrans %}Published{% endblocktrans %}:</strong> {{ tut.publication_date|date:"F jS, Y"}}</time>
                {% if tut.update_date %}
                <time class="updated"><strong>{% blocktrans %}Updated{% endblocktrans %}:</strong> {{ tut.update_date|date:"F jS, Y"}}</time>{% endif %}
                <span><strong>Comments:</strong> <a href="#disqus_thread" class="load-comments" data-disqus-identifier="{{ disqus_url }}">0</a></span>
              </div>

              <div id="notcompatible" class="hidden">
                Your browser may not support the functionality in this article.
              </div>
            </section>
            <div class="clear"></div>

            {% endif %}
          </div>
        </section>

        {% block content %}{% endblock %}
      </div>
    </section>
  </article>

  {% if tut %}
  <section class="disqus pattern-bg-lighter">

    <div id="disqus" class="container">

      <h2>{% trans "Comments" %}</h2>

      <div id="disqus_thread">

        <a href="#disqus_thread" class="load-comments" data-disqus-identifier="{{ disqus_url }}">0</a>

      </div>
    </div>

    <noscript>
      <p class="center">
        <strong>
          <a href="http://disqus.com/?ref_noscript">{% trans "Please enable JavaScript to view the comments powered by Disqus." %}</a>
        </strong>
      </p>
    </noscript>

    <script>

      var disqus_shortname = 'html5rocks';
      var disqus_identifier = '{{disqus_url}}';
      var disqus_url = '{{disqus_url}}';
      var disqus_developer = {% if not prod %}1{% else %}0{% endif %};

      var disqus_config = function () {
        var funky_language_code_mapping = {
          'de': 'de_inf',
          'es': 'es_ES',
          'pt': 'pt_EU',
          'sr': 'sr_CYRL',
          'sv': 'sv_SE',
          'zh': 'zh_HANT'
        };
        this.language = funky_language_code_mapping['{{LANGUAGE_CODE}}'] ||
                        '{{LANGUAGE_CODE}}';

        this.callbacks.onReady = [ function () {
                                      try {
                                        _gaq.push(['_trackEvent', 'View comments']);
                                      } catch(err){}
                                   } ];
        this.callbacks.onNewComment = [ function (comment) {
                                          try {
                                            _gaq.push(['_trackEvent', 'Commented']);
                                          } catch(err){}
                                        } ];
      };

      window.addEventListener('load', function(e) {

        var c = document.createElement('script');
        c.type = 'text/javascript';
        c.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
        c.async = true;

        var s = document.getElementsByTagName('script')[0], sp = s.parentNode;
        sp.insertBefore(c, s);

        if (window.location.hash === '#disqus_thread')
          loadComments();

      }, false);

      var disqus_loaded = false;
      function loadComments() {

        if (disqus_loaded)
          return;

        disqus_loaded = true;

        _gaq.push(['_trackEvent', 'Interactions', 'Comments', 'Comments Loaded']);

        var s = document.getElementsByTagName('script')[0], sp = s.parentNode;
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;

        var disqusContainer = document.getElementById('disqus');
        disqusContainer.classList.add('active');

        dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
        sp.insertBefore(dsq, s);
      }

      function outgoing(url) {
        try {
          _gaq.push(['_trackEvent', 'Outbound Links' , url]);
        } catch(err){}
      }
      // Open external links (also that don't have a target defined) in a new tab.
      var externLinks = document.querySelectorAll('article.tutorial a[href^="http"]:not([target])');
      for(var i = 0, a; a = externLinks[i]; ++i) {
        a.target = '_blank';
        a.addEventListener('click', new Function('outgoing(' + '"' + a.href.replace(/.*?:\/\//g, "") + '"' + ');'));
      }

      var loadCommentsButtons = document.querySelectorAll('.load-comments');
      for(var l = 0; l < loadCommentsButtons.length; l++)
        loadCommentsButtons[l].addEventListener('click', loadComments);

    </script>
  </section>
  {% else %}
  <div class="padder"></div>
  {% endif %}

  <footer>
    <div class="container">

      {% if tut %}
        <h1>{% trans "Next steps" %}</h2>

        {% block relatedreading %}{% endblock %}

        <aside class="panel share">
          <h2>{% trans "Share" %}</h2>

            <a href="https://twitter.com/share?url={{ disqus_url }}&text={{ tut.title }}&lang={{ LANGUAGE_CODE }}&via=ChromiumDev&related=ChromiumDev" class="twitter" target="_blank">Twitter</a>

            <a href="https://www.facebook.com/sharer/sharer.php?u={{ disqus_url}}" class="facebook" target="_blank">Facebook</a>

            <a href="https://plus.google.com/share?url={{ disqus_url }}" class="gplus" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">Google+</a>

        </aside>

        <aside class="panel rss">
          <h2>{% trans "Subscribe" %}</h2>
          <p>{% blocktrans %}Enjoyed this article? Grab the <a href="http://feeds.feedburner.com/html5rocks">RSS feed</a> and stay up-to-date.{% endblocktrans %}</p>
        </aside>

      {% endif %}

      <p class="licensing">
      {% blocktrans %}
        Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>, the content of this page is licensed under the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 License</a>, and code samples are licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a>.
      {% endblocktrans %}
      </p>

    </div>
  </footer>

  <script>
    window.isCompatible = function() {
      {% block iscompatible %}
      return null;
      {% endblock %}
    };

    if (isCompatible() === false) {
      document.getElementById('notcompatible').className = '';
    }

    function _prettyPrint() {
      if (typeof customPrettyPrintLanguage != 'undefined') {
        customPrettyPrintLanguage();
      }
      prettyPrint();
    }
  </script>
  <script async src="/static/js/prettify.min.js" onload="_prettyPrint()"></script>

{% endblock %}
Something went wrong with that request. Please try again.