<commit_before><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Crazy Ivan: CI straight up.</title>
    
    <link rel="stylesheet" href="css/ci.css" type="text/css" charset="utf-8">
    <script type="text/javascript" src="javascript/prototype.js"></script>
    <script type="text/javascript" src="javascript/scriptaculous.js"></script>
    <script type="text/javascript" src="javascript/date.js"></script>
    <script type="text/javascript" src="javascript/json-template.js"></script>
    <script type="text/javascript">
      var template = jsontemplate.Template("                                                                                             \
        <div class='projects'>                                                                                                           \
          {.section projects}                                                                                                            \
            {.repeated section @}                                                                                                        \
              <div class='project'>                                                                                                      \
                <h2>{name}</h2>                                                                                                          \
                <div class='tests'>                                                                                                      \
                  {.section reports}  \
                    {.repeated section @}      \
                      <a id='{.section version}{output}{.end}' class='test {.section test} {.section exit_status} error {.end} {.end} {.section update} {.section exit_status} error {.end} {.end}' href='#'>{timestamp.finish}</a>   \
                    {.end}                                                                                                               \
                  {.end}                                                                                                                 \
                  {.section build_in_progress}                                                                                             \
                    <div>Build {.section version}{output} {.end} in progress &ndash; started {minutes_started_ago} minutes(s) ago</div>   \
                  {.end}                                                                                                                   \
                </div>                                                                                                                   \
                <div class='results'>                                                                                                    \
                  {.section reports}                                                                                                     \
                    {.repeated section @}                                                                                                \
                      <div class='result' style='display:none' id='result-{.section version}{output}{.end}'>                             \
                        <div>                                                                                                            \
                          <span class='timestamp'>{timestamp.finish}</span>                                                              \
                          <span class='version'>{version.output}</span>                                                                  \
                        </div>                                                                                                           \
                                                                                                                                         \
                        <div class='output'>                                                                                             \
                          {.section version}                                                                                             \
                            {.section exit_status}                                                                                       \
                              <div class='version'>                                                                                      \
                                <pre class='error'>{error}</pre>                                                                         \
                              </div>                                                                                                     \
                            {.end}                                                                                                       \
                          {.end}                                                                                                         \
                                                                                                                                         \
                          <div class='update'>                                                                                           \
                            <pre>{update.output}</pre>                                                                                   \
                            {.section update}                                                                                            \
                              {.section exit_status}                                                                                     \
                                <pre class='error'>{update.error}</pre>                                                                  \
                              {.end}                                                                                                     \
                            {.end}                                                                                                       \
                          </div>                                                                                                         \
                                                                                                                                         \
                          <div class='test'>                                                                                             \
                            <pre>{test.output}</pre>                                                                                     \
                            {.section test}                                                                                              \
                              {.section exit_status}                                                                                     \
                                <pre class='error'>{test.error}</pre>                                                                    \
                              {.end}                                                                                                     \
                            {.end}                                                                                                       \
                          </div>                                                                                                         \
                        </div>                                                                                                           \
                      </div>                                                                                                             \
                    {.end}                                                                                                               \
                  {.end}                                                                                                                 \
                </div>                                                                                                                   \
              </div>                                                                                                                     \
            {.end}                                                                                                                       \
          {.or}                                                                                                                          \
            <p>No projects found.</p>                                                                                                    \
          {.end}                                                                                                                         \
        </div>                                                                                                                           \
      ");
        
      var json = {projects: []};

      var init = function() {
        new Ajax.Request('projects.json', {
          method: 'get',
          onSuccess: function(transport) {
            try {
              transport.responseText.evalJSON().projects.each(addProjectToJson);
            } catch (e) {  console.error(e)  }
          }
        });
        
        //new PeriodicalExecuter(render_projects, 4);
      }
      
      function addProjectToJson(project_name) {
        var project = {name: project_name, reports: []};

        new Ajax.Request(project_name + '/recent.json', {
          method: 'get',
          onSuccess: function(transport) {
            try {
              var results = transport.responseText.evalJSON();
              
              results.recent_versions.each(function(version) {
                
                 var url = project_name + '/' + version + '.json';
                 
                 var onBuildUpdate = function(transport) {
                   var r = JSON.parse(transport.responseText);
                   r.test.output = r.test.output.escapeHTML();
                   project.reports.push(r)
                   
                   trigger_render();
                 }                 

                 new Ajax.Request(url, {method: 'get', onSuccess: onBuildUpdate});                
              })
                                          
              trigger_render();              
            } catch(e) { console.error(e); }
          }
        });
             
        json.projects.push(project);
      }
      
      var timeout = null;
      
      function trigger_render() {       
        if (timeout)  { clearTimeout(timeout) }
        timeout = setTimeout(render, 50);
      }
      
      var render = function() {
        console.log(json);
        
        var html = template.expand(json);
        $("replace").update(html);
        
        $$('.project .tests').each(function(t) {
          latest_date = t.down('.test');
          if(latest_date) {
            latest_date.addClassName('latest')
          }
        });
        
        // Reformat the test timestamps to be less enormous and open up on clicking
        $$('.project .tests .test').each(function(t) {
          t.update(Date.parse(t.innerHTML).toString("HH:mm"));
          t.observe('click', function(e) {
            $$('div.result').each(Element.hide);
            $('result-'+e.target.id).toggle();
            Event.stop(e);
            return false;
          });
        });
      }
      
      $(document).observe('dom:loaded', function() {
        init();      
      });
    </script>
  </head>
  <body>
    <h1>Projects</h1>
    <div id="replace"></div>
    
    <div class="footer">
      <a href="http://github.com/edward/crazy_ivan">Crazy Ivan on Github</a>
    </div>
  </body>
</html><commit_msg>Fix for test link toggling when testing multiple versions of the same project<commit_after><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Crazy Ivan: CI straight up.</title>
    
    <link rel="stylesheet" href="css/ci.css" type="text/css" charset="utf-8">
    <script type="text/javascript" src="javascript/prototype.js"></script>
    <script type="text/javascript" src="javascript/scriptaculous.js"></script>
    <script type="text/javascript" src="javascript/date.js"></script>
    <script type="text/javascript" src="javascript/json-template.js"></script>
    <script type="text/javascript">
      var template = jsontemplate.Template("                                                                                             \
        <div class='projects'>                                                                                                           \
          {.section projects}                                                                                                            \
            {.repeated section @}                                                                                                        \
              <div class='project'>                                                                                                      \
                <h2>{name}</h2>                                                                                                          \
                <div class='tests'>                                                                                                      \
                  {.section reports}  \
                    {.repeated section @}      \
                      <a id='{name}-{.section version}{output}{.end}' class='test {.section test} {.section exit_status} error {.end} {.end} {.section update} {.section exit_status} error {.end} {.end}' href='#'>{timestamp.finish}</a>   \
                    {.end}                                                                                                               \
                  {.end}                                                                                                                 \
                  {.section build_in_progress}                                                                                             \
                    <div>Build {.section version}{output} {.end} in progress &ndash; started {minutes_started_ago} minutes(s) ago</div>   \
                  {.end}                                                                                                                   \
                </div>                                                                                                                   \
                <div class='results'>                                                                                                    \
                  {.section reports}                                                                                                     \
                    {.repeated section @}                                                                                                \
                      <div class='result' style='display: none' id='result-{name}-{.section version}{output}{.end}'>                             \
                        <div>                                                                                                            \
                          <span class='timestamp'>{timestamp.finish}</span>                                                              \
                          <span class='version'>{version.output}</span>                                                                  \
                        </div>                                                                                                           \
                                                                                                                                         \
                        <div class='output'>                                                                                             \
                          {.section version}                                                                                             \
                            {.section exit_status}                                                                                       \
                              <div class='version'>                                                                                      \
                                <pre class='error'>{error}</pre>                                                                         \
                              </div>                                                                                                     \
                            {.end}                                                                                                       \
                          {.end}                                                                                                         \
                                                                                                                                         \
                          <div class='update'>                                                                                           \
                            <pre>{update.output}</pre>                                                                                   \
                            {.section update}                                                                                            \
                              {.section exit_status}                                                                                     \
                                <pre class='error'>{update.error}</pre>                                                                  \
                              {.end}                                                                                                     \
                            {.end}                                                                                                       \
                          </div>                                                                                                         \
                                                                                                                                         \
                          <div class='test'>                                                                                             \
                            <pre>{test.output}</pre>                                                                                     \
                            {.section test}                                                                                              \
                              {.section exit_status}                                                                                     \
                                <pre class='error'>{test.error}</pre>                                                                    \
                              {.end}                                                                                                     \
                            {.end}                                                                                                       \
                          </div>                                                                                                         \
                        </div>                                                                                                           \
                      </div>                                                                                                             \
                    {.end}                                                                                                               \
                  {.end}                                                                                                                 \
                </div>                                                                                                                   \
              </div>                                                                                                                     \
            {.end}                                                                                                                       \
          {.or}                                                                                                                          \
            <p>No projects found.</p>                                                                                                    \
          {.end}                                                                                                                         \
        </div>                                                                                                                           \
      ");

      var json = {projects: []};

      var init = function() {
        new Ajax.Request('projects.json', {
          method: 'get',
          onSuccess: function(transport) {
            try {
              transport.responseText.evalJSON().projects.each(addProjectToJson);
            } catch (e) {  console.error(e)  }
          }
        });

        //new PeriodicalExecuter(render_projects, 4);
      }

      function addProjectToJson(project_name) {
        var project = {name: project_name, reports: []};

        new Ajax.Request(project_name + '/recent.json', {
          method: 'get',
          onSuccess: function(transport) {
            try {
              var results = transport.responseText.evalJSON();

              results.recent_versions.each(function(version) {

                 var url = project_name + '/' + version + '.json';

                 var onBuildUpdate = function(transport) {
                   var r = JSON.parse(transport.responseText);
                   r.test.output = r.test.output.escapeHTML();
                   project.reports.push(r)
                   trigger_render();
                 }                 

                 new Ajax.Request(url, {method: 'get', onSuccess: onBuildUpdate});                
              })

              trigger_render();              
            } catch(e) { console.error(e); }
          }
        });

        json.projects.push(project);
      }

      var timeout = null;

      function trigger_render() {       
        if (timeout)  { clearTimeout(timeout) }
        timeout = setTimeout(render, 50);
      }

      var render = function() {
        console.log(json);

        var html = template.expand(json);
        $("replace").update(html);

        $$('.project .tests').each(function(t) {
          latest_date = t.down('.test');
          if(latest_date) {
            latest_date.addClassName('latest')
          }
        });

        // Reformat the test timestamps to be less enormous and open up on clicking
        $$('.project .tests .test').each(function(t) {
          t.update(Date.parse(t.innerHTML).toString("HH:mm"));
          t.observe('click', function(e) {
            $$('div.result').each(Element.hide);
            $('result-'+e.target.id).toggle();
            Event.stop(e);
            return false;
          });
        });
      }

      $(document).observe('dom:loaded', function() {
        init();      
      });
    </script>
  </head>
  <body>
    <h1>Projects</h1>
    <div id="replace"></div>

    <div class="footer">
      <a href="http://github.com/edward/crazy_ivan">Crazy Ivan on Github</a>
    </div>
  </body>
</html>
{'fraction_non_alphanumeric': 0.07642093883830194, 'fraction_numerical': 0.0012473493825620556, 'mean_word_length': 0.39351100811123985, 'pattern_counts': {'":': 0, '<': 145, '<?xml version=': 0, '>': 145, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 477, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '652215', 'n_tokens_mistral': 3417, 'n_tokens_neox': 3230, 'n_words': 594}