File:  [mozdev] / cdn / www / sources.html
Revision 1.102: download - view: text, annotated - select for diffs - revision graph
Sat Feb 22 22:18:36 2003 UTC (16 years, 9 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
funky approach

    1: <!-- MAIN CONTENT -->
    2: <h5 class="page-header">Source Code</h5>
    3: 
    4: <p>
    5:   The cdn source code can be accessed in either of the following ways:
    6: </p>
    7: 
    8: <ul>
    9: <li>View the source using the CVS <a href="http://www.mozdev.org/source/browse/cdn/">web interface</a></li>
   10: <li>Check out the source using anonymous CVS with the following commands (password is guest):
   11: 
   12: <pre>
   13: cvs -d :pserver:guest@mozdev.org:/cvs login
   14: cvs -d :pserver:guest@mozdev.org:/cvs co cdn
   15: </pre>
   16: 
   17: </li>
   18: </ul><?php $doNotCapitalise = 1; // $project='orbits'; // testing ?>
   19: 
   20: <?php 
   21: 
   22: // $Id: sources.html,v 1.102 2003/02/22 22:18:36 cdn Exp $
   23: // $cvsId: sources.html,v 1.37 2003/02/21 00:43:24 cdn Exp svc$
   24:   
   25:   require("include/CVS_PATHS");
   26: 
   27:   define(MAX_READ_SIZE, 500000);
   28:   define(MAX_READ, 100000);
   29: 
   30:   $today              = date("y/m/d");
   31:   $day = (int)date('d');
   32:   --$day; // --$day;
   33:   $yesterday          = date("y/m/" . sprintf('%2u', $day));
   34:   $commit_log         = "cvs@$project.mozdev.org";
   35: 
   36: function cvs_parse ($contents, $day, $len) {
   37: 
   38:     $r            = -1;
   39: 
   40:        // if(ereg("  Date: [0-9]{2}/[0-9]{2}/[0-9]{2}", $contents[$i])) {
   41:        // if(ereg("  Date: $yesterday", $contents[$i])) {
   42:        // if(ereg("  Date: $today", $contents[$i])) {
   43: 
   44:         if(ereg("  Date: $day", $contents)) {
   45:           $r++;
   46: 
   47:           $yy = substr(YEAR, 0, 2);
   48: 
   49:           $_timestamp = str_replace('Date: ', '', ltrim($contents[$i]));
   50:           $_timestamp = str_replace("\n", '', $_timestamp);
   51: 
   52:           $_ts_link = $yy . ereg_replace('[\ \/]', '_', $_timestamp);
   53: 
   54:           $_timestamp = '<a name="' . $_ts_link . '">'; 
   55: 
   56:           $result[$r] = '<tr class="CVS-tr-header" valign="top"><td class="CVS-td-900">' . "\n";
   57: 
   58: // who
   59:           $result[$r] .= "<strong>" . $_timestamp . htmlspecialchars($contents[$i-1]) . "</a></strong>\n" . // who
   60:           "</td></tr>\n" .
   61:           '<tr class="CVS-tr-date">' .
   62:           '<td class="CVS-td-f90">' . "\n";
   63: 
   64:           $_time = htmlspecialchars($contents[$i]);
   65: 
   66: // when
   67:           $result[$r] .= '<a class="CVS-td-f90" href="' . '#' . $_ts_link . '">' . $_time . '</a>'; // when
   68: 
   69:           $result[$r] .= "\n</td></tr>\n" .
   70:           '<tr class="CVS-tr-checkins"><td class="CVS-td-checkins">' . "\n";
   71: 
   72:           $webcvs = 'http://www.mozdev.org/source/browse/' . $project;
   73: 
   74:           for($l=$i+1;$l<$len;$l++) {
   75:             if(ereg("  Revision  Changes    Path", $contents[$l])) {
   76:               break;
   77:             }
   78: 
   79:             if(ereg("  User:", $contents[$l])) {
   80:               break;
   81:             }
   82: 
   83:             $checkins = eregi_replace("((https|http|mailto|ftp):\/\/[^[:space:]<>]{1,})", 
   84:             "<a href=\"\\1\">\\1</a>", htmlspecialchars($contents[$l]));
   85: 
   86:             // '  Added:       www/img  background.png' 
   87:             // '  Modified:    www      cdn.css' 
   88:             // '  Removed:     www/protected sources.html'
   89:             // '               www/compact index.html'
   90:             // '  mozpos/downloads - New directory'
   91: 
   92:             if ( ereg("((Added|Modified|Removed):)", $checkins) || ereg("^[[:space:]]{9}", $checkins) ||
   93:                  strstr($checkins, "New directory")
   94:                ) {
   95: 
   96:               if ( !strstr($checkins, "New directory") ) {
   97:                 $identifier = trim(substr($checkins, 0, 15)); // may change to &nbsp; group
   98: 
   99:                 $checkins = substr($checkins, 15);
  100:               }
  101:               else {
  102:                 $checkins = str_replace('- New directory', '-_New_directory', $checkins);
  103: 
  104:                 $webcvs = 'http://www.mozdev.org/source/browse';
  105: 
  106:                 unset($identifier);
  107:               }
  108: 
  109:               $_16 = strpos($checkins, ' ');
  110: 
  111:               $_path = substr( $checkins, 0, $_16);
  112: 
  113:               $checkins = ereg_replace('[[:space:]]{1,}', ' ', trim( substr ( $checkins, $_16 ) ) );
  114: 
  115:               $checkinsA = explode(' ', $checkins);
  116: 
  117:               unset($checkins);
  118: 
  119:               for($z=0; $z < count($checkinsA); ++$z) {
  120:                 $checkinsA[$z] = trim($checkinsA[$z]);
  121:               }
  122: 
  123:               if ( !empty($identifier) ) {
  124:                 $checkins = $identifier;
  125:               }
  126: 
  127:               if ( !empty($_path)) {
  128:                 $webcvs = 'http://www.mozdev.org/source/browse/' . $project; // reset important !
  129:                 $webcvs .= '/' . $_path;
  130:                 $_path_ = $_path;
  131:                 $checkins .= ' <a href="' . $webcvs;
  132:                 $checkins .= '">' . $_path . '</a>';
  133:               }
  134: 
  135:               for($y=0; $y < count($checkinsA); ++$y) {
  136: 
  137:                 if (ereg('Tag:', $checkinsA[$y]) || ereg('Tag:', $checkinsA[$y-1]) || $_tag ||
  138:                      strstr($checkinsA[$y], '-_New_directory')
  139:                    ) {
  140:                   $TAG = true;
  141:                 }
  142:                 else {
  143:                   $TAG = false;
  144:                 }
  145: 
  146:                 if(!$TAG) {
  147:                   $checkins .= ' <a href="' . $webcvs . '/';
  148: 
  149:                   if( $identifier == 'Removed:' || $idRemoved ) {
  150:                     $checkins .= 'Attic/';
  151:                   }
  152: 
  153:                   $checkins .= $checkinsA[$y] . '">';
  154:                 }
  155:                 else {
  156:                   $checkins .= ' ';
  157:                 }
  158: 
  159:                 $checkinsA[$y] = str_replace('-_New_directory', '- New directory', $checkinsA[$y]);
  160: 
  161:                 $checkins .= $checkinsA[$y];
  162: 
  163:                 if ( ereg("Tag\:$", trim($checkinsA[$y])) && empty($checkinsA[$y+1])) {
  164:                   $_tag = true;
  165:                 }
  166:                 else {
  167:                   $_tag = false;
  168:                 }
  169: 
  170:                 if(!$TAG) {
  171:                  $checkins .= '</a>';
  172:                 }
  173: 
  174:               }
  175: 
  176:               if ( $identifier == 'Removed:' ) {
  177:                 $idRemoved = true;
  178:               }
  179:               else {
  180:                 $idRemoved = false;
  181:               }
  182: 
  183:             }
  184: 
  185: // what
  186:             $result[$r] .= '<div class="CVS-div-checkins">' . $checkins . "</div>\n"; // what
  187:           }
  188: 
  189:           $result[$r]     .= "</td></tr>\n";
  190:         }
  191: 
  192:   return $result;
  193: }
  194:   
  195:  //   $today = '03/02/14';
  196: 
  197:   if(!$local_conf_commits) {
  198:     print '<span id="CVS-local-conf-commits">' . $local_conf_commits_msg . "</span>\n";
  199:   }
  200: 
  201:   //BEGIN BLOCK
  202:  //
  203:    if(file_exists(COMMIT_PATH.$commit_log) && $local_conf_commits) { 
  204:  //  if(file_exists('/tmp/commit_test') && $local_conf_commits) { 
  205: 
  206:     $size = filesize(COMMIT_PATH.$commit_log);
  207:    // $size = filesize('/tmp/commit_test');
  208:     $contents = array();
  209:     if ($size > MAX_READ_SIZE) {
  210:       // print "<!-- Log File is greater than 500K -->\n";
  211: 
  212:       $fp = fopen (COMMIT_PATH.$commit_log, "r");
  213:       fseek($fp, $size - MAX_READ);
  214:       if ($contents) {
  215:         print "$contents\n";
  216:         exit;
  217:       }
  218:       $tok = strtok(fread($fp, MAX_READ),"\n");
  219:       while ($tok) {
  220:         array_push($contents, $tok);
  221:         $tok = strtok("\n");
  222:       }
  223:       fclose($fp);
  224:     }
  225:     
  226:     if (!$contents) {
  227:      //
  228:       $contents = file(COMMIT_PATH.$commit_log);
  229:      //      $contents = file('/tmp/commit_test'); // echo 'boing '; echo $contents;
  230:     }
  231: 
  232:     // preprocess Tag: stuff
  233:     
  234:     // /preprocess Tag: stuff
  235:     
  236:     $len=count($contents);
  237:     
  238:     $_project = $project;
  239:     
  240:     if ( !isset($doNotCapitalise) ) {
  241:       $_project = PROJECT;
  242:     }
  243:    
  244:     print '<h4 id="CVS-h4">' . "Today's CVS Commits for " . $_project . " Project</h4>\n";
  245:    // print '<h4 id="CVS-h4">' . "Yesterday's CVS Commits for " . $_project . " Project</h4>\n";
  246:    // print '<h4 id="CVS-h4">' . "Some day's CVS Commits for " . $_project . " Project</h4>\n";
  247:     print '<table border="0" cellpadding="0" cellspacing="2" id="CVS-table">' . "\n";
  248: 
  249:     if($len) {
  250:       for($i=0;$i<$len;$i++) {
  251:         if(ereg("Modified:    www", $contents[$l]) && !$local_conf_commits)
  252:           break;
  253: 
  254: //start of parse of commitlog for $today / $yesterday
  255: 
  256:         $result = cvs_parse($contents, $today, $len);
  257: 
  258: // end  of parse of commitlog for $today / $yesterday
  259: 
  260:       }
  261:     }
  262: 
  263:   if(!$result) {  
  264:     print '<tr><td id="CVS-no-commits">There are no new commits today</td></tr>' . "\n";
  265:   } else {
  266:     $reversed=array_reverse($result);
  267:     for($i=0;$i<count($result);$i++)
  268:       PRINT $reversed[$i];
  269:   }
  270: 
  271:     print "</table>\n\n";
  272: 
  273:   } //END BLOCK
  274: ?>

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