<commit_before><!doctype html>
<html>
<head>
   <title>{% block page_title %}{% endblock %}</title>
   <meta name="renderer" content="webkit">
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
   <meta name="csrf-token" content="{{ csrf_token() }}"/>
   {% block meta %}{% endblock %}
   <link rel="Shortcut Icon" href="{{ static('image/favicon.png') }}">
   {{ link('bower_components/bootstrap/dist/css/bootstrap.min.css') }}
   {{ link('bower_components/font-awesome/css/font-awesome.min.css') }}
   {{ link('css/bootstrap.theme.css') }}
   {{ link('css/common.css') }}
   {{ link('css/component.css') }}
   {{ link('css/layout.css') }}
   {{ page_link(self) }}
   {{ script('bower_components/respond/dest/respond.min.js') }}
   {{ script('bower_components/jquery/dist/jquery.min.js') }}
   {{ script('bower_components/bootstrap/dist/js/bootstrap.min.js') }}
</head>

<body id="page" class="{{ page_name(self) }}">

{# Flash message #}
{% with message = get_flashed_messages()[0] %}
   {% if message %}
      <div class="alert alert-info flash-message">{{ message }}</div>
   {% endif %}
{% endwith %}

<nav class="navbar navbar-default navbar-static-top">
   <div class="container">
      <div class="navbar-header">
         <a class="navbar-brand" href="{{ url_for('site.index') }}">
            #{project|title}
         </a>
      </div>

      <div class="collapse navbar-collapse">
         <ul class="nav navbar-nav">
            <li id="nav-index">
               <a href="{{ url_for('site.index') }}">首页</a>
            </li>
            <li id="nav-about">
               <a href="{{ url_for('site.about') }}">关于</a>
            </li>
         </ul>

         <form class="navbar-form navbar-left" role="search" method="get" action="#">
            <div class="input-group">
               <input type="text" name="keyword" class="form-control input-sm"
                      placeholder="">
               <span class="input-group-btn">
                  <button class="btn btn-default btn-sm" type="submit">
                     <span class="fa fa-search"></span>
                  </button>
               </span>
            </div>
         </form>

         <ul class="nav navbar-nav navbar-right">
            {% if g.user %}
               <li id="nav-settings">
                  <a href="#">{{ g.user.name }}</a>
               </li>
               <li>
                  <a href="{{ url_for('account.signout') }}">登出</a>
               </li>
            {% else %}
               <li id="nav-signin">
                  <a href="{{ url_for('account.signin') }}">登录</a>
               </li>
               <li id="nav-signup">
                  <a href="{{ url_for('account.signup') }}">注册</a>
               </li>
            {% endif %}
         </ul>
      </div>
   </div>
</nav>

<div id="main-wap">
   {% block page_content %}{% endblock %}
</div>

<div id="footer">
   <div class='container'>
      <div id='copyright' class="pull-left">
         © 2015 #{project|title}
      </div>

      <ul id='links' class="pull-right list-unstyled list-inline">
         <li><a href="{{ url_for('site.about') }}">关于</a></li>
      </ul>
   </div>
</div>

{# JavaScript init codes #}
<script type="text/javascript">
   var g = {
      'csrfToken': "{{ csrf_token() }}",
      'rules':{{ rules|safe }}
   };

   // Add csrf token header for Ajax request
   $.ajaxSetup({
      beforeSend: function (xhr, settings) {
         if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
            xhr.setRequestHeader("X-CSRFToken", g.csrfToken);
         }
      }
   });

   // Find out params in routing rules
   var pattern = new RegExp("<[^:]*:?([^>]+)>", "g");
   var result = null;

   $.each(g.rules, function (endpoint, rules) {
      $.each(rules, function (index, rule) {
         rule.params = [];
         while ((result = pattern.exec(rule.rule)) !== null) {
            rule.params.push(result[1]);
         }
      });
   });

   /**
    * Generate url for the endpoint.
    * @param endpoint
    * @param values
    * @returns url for the endpoint.
    */
   function urlFor(endpoint, values) {
      var url = null, keys;

      if (g.rules[endpoint] === undefined) {
         throw "Uncorrect endpoint.";
      }

      keys = $.map(values, function (value, key) {
         return key;
      });

      // Find the first matched rule among rules in this endpoint.
      $.each(g.rules[endpoint], function (index, rule) {
         var match = true;
         $.each(rule.params, function (index, param) {
            if ($.inArray(param, keys) === -1) {
               match = false;
               return false;
            }
         });

         if (match) {
            url = rule.rule;

            $.each(keys, function (index, key) {
               if ($.inArray(key, rule.params) > -1) {
                  url = url.replace(new RegExp("<[^:]*:?" + key + ">"), values[key]);
               } else {
                  // Query string.
                  if (url.indexOf("?") === -1) {
                     url += "?";
                  }
                  if (!endsWith(url, '?')) {
                     url += "&";
                  }
                  url += key + "=" + values[key];
               }
            });

            return false;
         } else {
            // Continue searching if not match.
            return true;
         }
      });

      return url;
   }

   /**
    * Chech whether str ends with suffix.
    * @param str
    * @param suffix
    * @returns {boolean}
    */
   function endsWith(str, suffix) {
      return str.indexOf(suffix, str.length - suffix.length) !== -1;
   }
</script><commit_msg>Fix a bug.<commit_after><!doctype html>
<html>
<head>
   <title>{% block page_title %}{% endblock %}</title>
   <meta name="renderer" content="webkit">
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
   <meta name="csrf-token" content="{{ csrf_token() }}"/>
   {% block meta %}{% endblock %}
   <link rel="Shortcut Icon" href="{{ static('image/favicon.png') }}">
   {{ link('bower_components/bootstrap/dist/css/bootstrap.min.css') }}
   {{ link('bower_components/font-awesome/css/font-awesome.min.css') }}
   {{ link('css/bootstrap.theme.css') }}
   {{ link('css/common.css') }}
   {{ link('css/component.css') }}
   {{ link('css/layout.css') }}
   {{ page_link(self) }}
   {{ script('bower_components/respond/dest/respond.min.js') }}
   {{ script('bower_components/jquery/dist/jquery.min.js') }}
   {{ script('bower_components/bootstrap/dist/js/bootstrap.min.js') }}
</head>

<body id="page" class="{{ page_name(self) }}">

{# Flash message #}
{% with message = get_flashed_messages()[0] %}
   {% if message %}
      <div class="alert alert-info flash-message">{{ message }}</div>
   {% endif %}
{% endwith %}

<nav class="navbar navbar-default navbar-static-top">
   <div class="container">
      <div class="navbar-header">
         <a class="navbar-brand" href="{{ url_for('site.index') }}">
            #{project|title}
         </a>
      </div>

      <div class="collapse navbar-collapse">
         <ul class="nav navbar-nav">
            <li id="nav-index">
               <a href="{{ url_for('site.index') }}">首页</a>
            </li>
            <li id="nav-about">
               <a href="{{ url_for('site.about') }}">关于</a>
            </li>
         </ul>

         <form class="navbar-form navbar-left" role="search" method="get" action="#">
            <div class="input-group">
               <input type="text" name="keyword" class="form-control input-sm"
                      placeholder="">
               <span class="input-group-btn">
                  <button class="btn btn-default btn-sm" type="submit">
                     <span class="fa fa-search"></span>
                  </button>
               </span>
            </div>
         </form>

         <ul class="nav navbar-nav navbar-right">
            {% if g.user %}
               <li id="nav-settings">
                  <a href="#">{{ g.user.name }}</a>
               </li>
               <li>
                  <a href="{{ url_for('account.signout') }}">登出</a>
               </li>
            {% else %}
               <li id="nav-signin">
                  <a href="{{ url_for('account.signin') }}">登录</a>
               </li>
               <li id="nav-signup">
                  <a href="{{ url_for('account.signup') }}">注册</a>
               </li>
            {% endif %}
         </ul>
      </div>
   </div>
</nav>

<div id="main-wap">
   {% block page_content %}{% endblock %}
</div>

<div id="footer">
   <div class='container'>
      <div id='copyright' class="pull-left">
         © 2015 #{project|title}
      </div>

      <ul id='links' class="pull-right list-unstyled list-inline">
         <li><a href="{{ url_for('site.about') }}">关于</a></li>
      </ul>
   </div>
</div>

{# JavaScript init codes #}
<script type="text/javascript">
   var g = {
      'csrfToken': "{{ csrf_token() }}",
      'rules':{{ rules|safe }}
   };

   // Add csrf token header for Ajax request
   $.ajaxSetup({
      beforeSend: function (xhr, settings) {
         if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) {
            xhr.setRequestHeader("X-CSRFToken", g.csrfToken);
         }
      }
   });

   // Find out params in routing rules
   var pattern = new RegExp("<[^:]*:?([^>]+)>", "g");
   var result = null;

   $.each(g.rules, function (endpoint, rules) {
      $.each(rules, function (index, rule) {
         rule.params = [];
         while ((result = pattern.exec(rule.rule)) !== null) {
            rule.params.push(result[1]);
         }
      });
   });

   /**
    * Generate url for the endpoint.
    * @param endpoint
    * @param values
    * @returns url for the endpoint.
    */
   function urlFor(endpoint, values) {
      var url = null,
            params = [],
            maxMatchDegree = 0.0,
            keys;

      if (g.rules[endpoint] === undefined) {
         throw "Uncorrect endpoint.";
      }

      keys = $.map(values, function (value, key) {
         return key;
      });

      // Find the first matched rule among rules in this endpoint.
      $.each(g.rules[endpoint], function (index, rule) {
         var match = true,
               currentMatchDegree = 0.0;

         $.each(rule.params, function (index, param) {
            if ($.inArray(param, keys) === -1) {
               match = false;
               return false;
            }
         });

         if (match) {
            currentMatchDegree = parseFloat(rule.params.length) / keys.length;
            if (currentMatchDegree > maxMatchDegree || url === null) {
               maxMatchDegree = currentMatchDegree;
               url = rule.rule;
               params = rule.params;
            }
         }
      });

      if (url) {
         $.each(keys, function (index, key) {
            // Built-in params
            if ($.inArray(key, params) > -1) {
               url = url.replace(new RegExp("<[^:]*:?" + key + ">"), values[key]);
            } else {
               // Query string params
               if (url.indexOf("?") === -1) {
                  url += "?";
               }
               if (!endsWith(url, '?')) {
                  url += "&";
               }
               url += key + "=" + values[key];
            }
         });
      }

      return url;
   }

   /**
    * Chech whether str ends with suffix.
    * @param str
    * @param suffix
    * @returns {boolean}
    */
   function endsWith(str, suffix) {
      return str.indexOf(suffix, str.length - suffix.length) !== -1;
   }
</script>
{'fraction_non_alphanumeric': 0.18632696390658174, 'fraction_numerical': 0.00237791932059448, 'mean_word_length': 1.7872189349112426, 'pattern_counts': {'":': 0, '<': 165, '<?xml version=': 0, '>': 170, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '822307', 'n_tokens_mistral': 3734, 'n_tokens_neox': 3598, 'n_words': 759}