File:  [mozdev] / cdn / www / sources.html
Revision 1.135: download - view: text, annotated - select for diffs - revision graph
Thu Feb 27 10:40:49 2003 UTC (14 years, 8 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
tweaks to tweaks

<!-- MAIN CONTENT -->
<h5 class="page-header">Source Code</h5>

<p>
  The cdn source code can be accessed in either of the following ways:
</p>

<ul>
<li>View the source using the CVS <a href="http://www.mozdev.org/source/browse/cdn/">web interface</a></li>
<li>Check out the source using anonymous CVS with the following commands (password is guest):

<pre>
cvs -d :pserver:guest@mozdev.org:/cvs login
cvs -d :pserver:guest@mozdev.org:/cvs co cdn
</pre>

</li>
</ul><?php $doNotCapitalise = 1; // $project='orbits'; // testing ?>

<?php

// $Id: sources.html,v 1.135 2003/02/27 10:40:49 cdn Exp $

  require("include/CVS_PATHS");

  define(MAX_READ_SIZE, 500000);
  define(MAX_READ, 100000);

  $today              = date("y/m/d"); if (ereg('local', HOST) ): $today = '03/02/21'; endif;
  $day = (int)date('d');
  --$day;
  $yesterday          = date("y/m/" . sprintf('%2u', $day));
  $commit_log         = "cvs@$project.mozdev.org";

  if(!$local_conf_commits)
    print '<span id="CVS-local-conf-commits">' . $local_conf_commits_msg . "</span>\n";

  //BEGIN BLOCK
 
   if(file_exists(COMMIT_PATH.$commit_log) && 
      $local_conf_commits) {

     $size = filesize(COMMIT_PATH.$commit_log);

    $contents = array();
    if ($size > MAX_READ_SIZE) {
      // print "<!-- Log File is greater than 500K -->\n";

      $fp = fopen (COMMIT_PATH.$commit_log, "r");
      fseek($fp, $size - MAX_READ);
      if ($contents) {
        print "$contents\n";
        exit;
      }
      $tok = strtok(fread($fp, MAX_READ),"\n");
      while ($tok) {
        array_push($contents, $tok);
        $tok = strtok("\n");
      }
      fclose($fp);
    }
    
    if (!$contents)
      $contents = file(COMMIT_PATH.$commit_log);

    // preprocess Tag: stuff would be here if it didn't mess
    // things up completely

    $len=count($contents);
    $r            = -1;
    
    $_project = $project;
    
    if ( !isset($doNotCapitalise) )
      $_project = PROJECT;
   
    print '<script type="text/javascript" src="/js/styleswitcher.js"></script>' . "\n";

    print '<h4 id="CVS-h4">' . "Today's CVS Commits for " . $_project . " Project</h4>\n";
    print '<div id="CVS-table">' . "\n";

    if($len) {
      
      print '<p id="CVS-style-switch"><a href="#" onclick="setActiveStyleSheet(\'Default Checkins\'); return false;">change style to default</a> |' . "\n";
      print '<a href="#" onclick="setActiveStyleSheet(\'Bonsai-esque Checkins\'); return false;">change style to bonsai</a></p>' . "\n";
      
      print '<div class="CVS-block CVS-dft-hidden">' . "\n";
      print '<div class="CVS-td-900 CVS-headers">Who</div>' . "\n";
      print '<div class="CVS-td-f90 CVS-headers">When</div>' . "\n";
      print '<div class="CVS-td-checkins">' . "\n" .
            '<div class="CVS-checkins CVS-headers" style="margin-top: 2px;">';
      print 'What</div>' . "\n";
      print '<div class="CVS-log CVS-headers">Why</div>' . "\n";
      print '</div></div>';
      print '<div style="clear: left; float: none;"></div>' . "\n";

      for($i=0;$i<$len;$i++) {
        if(ereg("Modified:    www", $contents[$l]) &&
           !$local_conf_commits)
          break;

//start of parse of commitlog for $today / $yesterday

        if(ereg("  Date: $today", $contents[$i])) {
          $r++;

          $yy = substr(YEAR, 0, 2);

          $_timestamp = str_replace('Date: ', '', ltrim($contents[$i]));
          $_timestamp = str_replace("\n", '', $_timestamp);

          $_ts_link = $yy . ereg_replace('[\ \/]', '_', $_timestamp);

          $_timestamp = '<a name="' . $_ts_link . '">'; 

          $result[$r] = '<div class="CVS-block';

          if ($r == 0) 
            $result[$r] .= ' CVS-last-block';

          $result[$r] .= '"><div class="CVS-td-900">' . "\n";

//who
          $result[$r] .= "<strong>" . $_timestamp . htmlspecialchars($contents[$i-1]) . "</a></strong>\n" .
          "</div>\n" .
          '<div class="CVS-td-f90">' . "\n";

          $_time = htmlspecialchars($contents[$i]);

// when
          $result[$r] .= '<a class="CVS-td-f90" href="' . '#' . $_ts_link . '">' . $_time . '</a>';

          $result[$r] = eregi_replace("(User|Date):{1}", '<span class="CVS-bonsai-hidden"' . ">\\1</span> ", $result[$r]);

          $result[$r] .= "\n</div>\n" .
          '<div class="CVS-td-checkins">' . "\n" .
          '<div class="CVS-checkins">' . "\n";

          $webcvs = 'http://www.' . HOST . '/source/browse/' . $project;

          for($l=$i+1;$l<$len;$l++) {
            if(ereg("  Revision  Changes    Path", $contents[$l]))
              break;

            if(ereg("  User:", $contents[$l]))
              break;

            $checkins = eregi_replace("((https|http|mailto|ftp):\/\/[^[:space:]<>]{1,})",
                        "<a href=\"\\1\">\\1</a>", htmlspecialchars($contents[$l]));

            // '  Added:       www/img  background.png' 
            // '  Modified:    www      cdn.css' 
            // '  Removed:     www/protected sources.html'
            // '               www/compact index.html'
            // '  mozpos/downloads - New directory'

            if ( ereg("^[[:space:]]{1,3}Log\:", $checkins) ) {
              $idRemoved = false; $_log_section = true;
             // $checkins = eregi_replace("(Log):{1}", '<span class="CVS-bonsai-hidden"' . ">\\1</span>", $checkins);
              $checkins = '</div>' . "\n" . '</div>' . "\n" .
                          '<div class="CVS-log"><div class="CVS-bonsai-hidden">' . $checkins;
            }

            if ( ereg("^[[:space:]]{1,3}((Added|Modified|Removed):)", $checkins) || ereg("^[[:space:]]{9}", $checkins) ||
                 strstr($checkins, "New directory")
               ) {

              if ( !strstr($checkins, "New directory") ) {
                $identifier = trim(substr($checkins, 0, 15)); // may change to &nbsp; group

                $checkins = substr($checkins, 15);

                $_New_directory = false;
              }
              else {
                $checkins = str_replace('- New directory', '-_New_directory', $checkins);

                $webcvs = 'http://www.' . HOST . '/source/browse';

                unset($identifier);

                $_New_directory = true;
              }

              $_16 = strpos($checkins, ' ');

              $_path = substr( $checkins, 0, $_16);

              $checkins = ereg_replace('[[:space:]]{1,}', ' ',
                          trim( substr ( $checkins, $_16 ) ) );

              $checkinsA = explode(' ', $checkins);

              unset($checkins);

              for($z=0; $z < count($checkinsA); ++$z)
                $checkinsA[$z] = trim($checkinsA[$z]);

              if ( !empty($identifier) )
                $checkins = '<span class="CVS-bonsai-hidden">' . $identifier . '</span>';

              if ( !empty($_path)) {
                // reset, important !
                $webcvs = 'http://www.' . HOST . '/source/browse/' . $project; 
                $webcvs .= '/' . $_path;
                $checkins .= ' <span class="CVS-bonsai-hidden"><a href="' . $webcvs;
                $checkins .= '">' . $_path . '</a></span>';
              }

              $Y = count($checkinsA);

              for($y=0; $y < $Y; ++$y) {

                if ( ereg('Tag:', $checkinsA[$y]) || ereg('Tag:', $checkinsA[$y-1]) || $_tag ||
                     strstr($checkinsA[$y], '-_New_directory')
                   )
                  $TAG = true;
                else
                  $TAG = false;

                $checkins .= ' <span';

                if ( !$_New_directory )
                  $checkins .= ' class="CVS-dft-inline"';

                if ( strstr($checkinsA[$y+1], '-_New_directory') )
                  $checkins .= ' class="CVS-dft-inline"';

                $checkins .= '>';

                if(!$TAG) {
                  $checkins .= '<a href="' . $webcvs . '/';

                  if( $identifier == 'Removed:' || $idRemoved )
                    $checkins .= 'Attic/';

                  $checkins .= $checkinsA[$y] . '">';
                }

                if ( !$_New_directory ) {
                  $checkins .= '<span class="CVS-dft-hidden">'; // $project / $_path
                  $_webcvs = str_replace('http://www.' . HOST . '/source/browse/', '', $webcvs);

                  if ( strlen($_webcvs) > 15 )
                    $checkins .= substr($_webcvs, 0, 12) . '...' . substr($_webcvs, strrpos($_webcvs, '/'));
                  else
                    $checkins .= $_webcvs;

                  if( $identifier == 'Removed:' || $idRemoved )
                    $checkins .= '/Attic';

                  $checkins .= '/</span>';
                }

                $checkinsA[$y] = str_replace('-_New_directory', '- New directory', $checkinsA[$y]);

                $checkins .= $checkinsA[$y];

                if (ereg("Tag\:$", trim($checkinsA[$y])) &&
                    empty($checkinsA[$y+1]))
                  $_tag = true; 
                else
                  $_tag = false;

                if (!$TAG)
                  $checkins .= '</a>';

                  $checkins .= '</span>';

              }

              if ( $identifier == 'Removed:' || $idRemoved )
                $idRemoved = true;
              else
                $idRemoved = false;

            }

            $checkins = trim( str_replace('</span> <span>', ' ', $checkins) );

            if ( !ereg('^<d', $checkins) )
              $checkins = '<div class="CVS-div-checkins">' . $checkins;
// what
            if ( !empty( $checkins ) )
              $result[$r] .= $checkins . "</div>\n"; // what
  

          }

            if ( $_log_section ) {
              $_log_section = false;
              $result[$r] .= '</div>';
            }

          $result[$r] .= "</div>\n";
          $result[$r] .= "</div>\n";
          $result[$r] .= '<div style="clear: left; float: none;"></div>' . "\n";
        }

// end  of parse of commitlog for $today / $yesterday

      }
    }

    if (!$result) {  
      print '<div id="CVS-no-commits">There are no new commits today</div>'."\n";
    } else {
      $reversed=array_reverse($result);
      for ($i=0;$i<count($result);$i++)
        print $reversed[$i];
//        print $reversed[0];
    }

    print "</div>\n\n";

  } // END BLOCK
?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>