File:  [mozdev] / cdn / www / sources.html
Revision 1.142: download - view: text, annotated - select for diffs - revision graph
Thu Feb 27 18:21:39 2003 UTC (16 years, 6 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
cdn

    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: // $project = 'www';
   20:  ?>
   21: 
   22: <?php
   23: 
   24: // $Id: sources.html,v 1.142 2003/02/27 18:21:39 cdn Exp $
   25: 
   26:   require("include/CVS_PATHS");
   27: 
   28:   define(MAX_READ_SIZE, 500000);
   29:   define(MAX_READ, 100000);
   30: 
   31:   $today              = date("y/m/d"); if (ereg('local', HOST) ): $today = '03/02/21'; endif;
   32:   $day = (int)date('d');
   33:   --$day;
   34:   $yesterday          = date("y/m/") . sprintf('%2u', $day);
   35:   $this_month         = date("y/m/");
   36:   
   37:  // $today = $this_month; // limit of 500k makes this not quite work
   38:  // $today = $yesterday;
   39:   
   40:   $commit_log         = "cvs@$project.mozdev.org";
   41: 
   42:   if(!$local_conf_commits)
   43:     print '<span id="CVS-local-conf-commits">' . $local_conf_commits_msg . "</span>\n";
   44: 
   45:   //BEGIN BLOCK
   46:  
   47:    if(file_exists(COMMIT_PATH.$commit_log) && 
   48:       $local_conf_commits) {
   49: 
   50:      $size = filesize(COMMIT_PATH.$commit_log);
   51: 
   52:     $contents = array();
   53:     if ($size > MAX_READ_SIZE) {
   54:       // print "<!-- Log File is greater than 500K -->\n";
   55: 
   56:       $fp = fopen (COMMIT_PATH.$commit_log, "r");
   57:       fseek($fp, $size - MAX_READ);
   58:       if ($contents) {
   59:         print "$contents\n";
   60:         exit;
   61:       }
   62:       $tok = strtok(fread($fp, MAX_READ),"\n");
   63:       while ($tok) {
   64:         array_push($contents, $tok);
   65:         $tok = strtok("\n");
   66:       }
   67:       fclose($fp);
   68:     }
   69:     
   70:     if (!$contents)
   71:       $contents = file(COMMIT_PATH.$commit_log);
   72: 
   73:     // preprocess Tag: stuff would be here if it didn't mess
   74:     // things up completely
   75: 
   76:     $len=count($contents);
   77:     $r            = -1;
   78:     
   79:     $_project = $project;
   80:     
   81:     if ( !isset($doNotCapitalise) )
   82:       $_project = PROJECT;
   83:    
   84:     print '<script type="text/javascript" src="http://www.' . HOST . '/js/styleswitcher.js"></script>' . "\n";
   85: 
   86:     print '<h4 id="CVS-h4">' . "Today's CVS Commits for " . $_project . " Project</h4>\n";
   87:     print '<div id="CVS-table">' . "\n";
   88: 
   89:     if($len) {
   90:       
   91:       print '<p id="CVS-style-switch"><a href="#" onclick="setActiveStyleSheet(\'Default Checkins\'); return false;">change style to default</a> |' . "\n";
   92:       print '<a href="#" onclick="setActiveStyleSheet(\'Bonsai-esque Checkins\'); return false;">change style to bonsai</a></p>' . "\n";
   93:       
   94:       print '<div class="CVS-block CVS-dft-hidden">' . "\n";
   95:       print '<div class="CVS-td-900 CVS-headers">Who</div>' . "\n";
   96:       print '<div class="CVS-td-f90 CVS-headers">When</div>' . "\n";
   97:       print '<div class="CVS-td-checkins">' . "\n" .
   98:             '<div class="CVS-checkins CVS-headers" style="margin-top: 1px;">';
   99:       print 'What</div>' . "\n";
  100:       print '<div class="CVS-log CVS-headers" style="margin-top: 1px;">Why</div>' . "\n";
  101:       print '</div></div>';
  102:       print '<div style="clear: left; float: none;"></div>' . "\n";
  103: 
  104:       for($i=0;$i<$len;$i++) {
  105:         if(ereg("Modified:    www", $contents[$l]) &&
  106:            !$local_conf_commits)
  107:           break;
  108: 
  109: //start of parse of commitlog for $today / $yesterday
  110: 
  111:         if(ereg("  Date: $today", $contents[$i])) {
  112:           $r++;
  113: 
  114:           $yy = substr(YEAR, 0, 2);
  115: 
  116:           $_timestamp = str_replace('Date: ', '', ltrim($contents[$i]));
  117:           $_timestamp = str_replace("\n", '', $_timestamp);
  118: 
  119:           $_ts_link = $yy . ereg_replace('[\ \/]', '_', $_timestamp);
  120: 
  121:           $_timestamp = '<a name="' . $_ts_link . '">'; 
  122: 
  123:           $result[$r] = '<div class="CVS-block';
  124: 
  125:           if ($r == 0) 
  126:             $result[$r] .= ' CVS-last-block';
  127: 
  128:           $result[$r] .= '"><div class="CVS-td-900">' . "\n";
  129: 
  130: //who
  131:           $result[$r] .= "<strong>" . $_timestamp . htmlspecialchars($contents[$i-1]) . "</a></strong>\n" .
  132:           "</div>\n" .
  133:           '<div class="CVS-td-f90">' . "\n";
  134: 
  135:           $_time = htmlspecialchars($contents[$i]);
  136: 
  137: // when
  138:           $result[$r] .= '<a class="CVS-td-f90" href="' . '#' . $_ts_link . '">' . $_time . '</a>';
  139: 
  140:           $result[$r] = eregi_replace("(User|Date):{1}", '<span class="CVS-bonsai-hidden"' . ">\\1</span> ", $result[$r]);
  141: 
  142:           $result[$r] .= "\n</div>\n" .
  143:           '<div class="CVS-td-checkins">' . "\n" .
  144:           '<div class="CVS-checkins">' . "\n";
  145: 
  146:           $webcvs = 'http://www.' . HOST . '/source/browse/' . $project;
  147: 
  148:           for($l=$i+1;$l<$len;$l++) {
  149:             if(ereg("  Revision  Changes    Path", $contents[$l]))
  150:               break;
  151: 
  152:             if(ereg("  User:", $contents[$l]))
  153:               break;
  154: 
  155:             $checkins = eregi_replace("((https|http|mailto|ftp):\/\/[^[:space:]<>]{1,})",
  156:             "<a href=\"\\1\">\\1</a>", htmlspecialchars($contents[$l]));
  157: 
  158:             // '  Added:       www/img  background.png' 
  159:             // '  Modified:    www      cdn.css' 
  160:             // '  Removed:     www/protected sources.html'
  161:             // '               www/compact index.html'
  162:             // '  mozpos/downloads - New directory'
  163: 
  164:             if ( ereg("^[[:space:]]{1,3}Log\:", $checkins) ) {
  165:               $idRemoved = false; $_log_section = true;
  166: 
  167:               $checkins = '</div>' . "\n" . '</div>' . "\n" .
  168:                           '<div class="CVS-log"><div class="CVS-bonsai-hidden">' . $checkins;
  169:             }
  170: 
  171:             if ( ereg("^[[:space:]]{1,3}((Added|Modified|Removed):)", $checkins) || ereg("^[[:space:]]{9}", $checkins) ||
  172:                  strstr($checkins, "New directory")
  173:                ) {
  174: 
  175:               if ( !strstr($checkins, "New directory") ) {
  176:                 $identifier = trim(substr($checkins, 0, 15)); // may change to &nbsp; group
  177: 
  178:                 $checkins = substr($checkins, 15);
  179: 
  180:                 $_New_directory = false;
  181:               }
  182:               else {
  183:                 $checkins = str_replace('- New directory', '-_New_directory', $checkins);
  184: 
  185:                 $webcvs = 'http://www.' . HOST . '/source/browse';
  186: 
  187:                 unset($identifier);
  188: 
  189:                 $_New_directory = true;
  190:               }
  191: 
  192:               $_16 = strpos($checkins, ' ');
  193: 
  194:               $_path = substr( $checkins, 0, $_16);
  195: 
  196:               $checkins = ereg_replace('[[:space:]]{1,}', ' ',
  197:                           trim( substr ( $checkins, $_16 ) ) );
  198: 
  199:               $checkinsA = explode(' ', $checkins);
  200: 
  201:               unset($checkins);
  202: 
  203:               for($z=0; $z < count($checkinsA); ++$z)
  204:                 $checkinsA[$z] = trim($checkinsA[$z]);
  205: 
  206:               if ( !empty($identifier) )
  207:                 $checkins = '<span class="CVS-bonsai-hidden">' . $identifier . '</span>';
  208: 
  209:               if ( !empty($_path)) {
  210:                 // reset, important !
  211:                 $webcvs = 'http://www.' . HOST . '/source/browse/' . $project; 
  212:                 $webcvs .= '/' . $_path;
  213:                 $checkins .= ' <span class="CVS-bonsai-hidden"><a href="' . $webcvs;
  214:                 $checkins .= '">' . $_path . '</a></span>';
  215:               }
  216: 
  217:               $Y = count($checkinsA);
  218: 
  219:               for($y=0; $y < $Y; ++$y) {
  220: 
  221:                 if ( ereg('Tag:', $checkinsA[$y]) || ereg('Tag:', $checkinsA[$y-1]) || $_tag ||
  222:                      strstr($checkinsA[$y], '-_New_directory')
  223:                    )
  224:                   $TAG = true;
  225:                 else
  226:                   $TAG = false;
  227: 
  228:                 $checkins .= ' <span';
  229: 
  230:                 if ( !$_New_directory )
  231:                   $checkins .= ' class="CVS-dft-inline"';
  232: 
  233:                 if ( strstr($checkinsA[$y+1], '-_New_directory') )
  234:                   $checkins .= ' class="CVS-dft-inline"';
  235: 
  236:                 $checkins .= '>';
  237: 
  238:                 if(!$TAG) {
  239:                   $checkins .= '<a href="' . $webcvs . '/';
  240: 
  241:                   if( $identifier == 'Removed:' || $idRemoved )
  242:                     $checkins .= 'Attic/';
  243: 
  244:                   $checkins .= $checkinsA[$y] . '">';
  245:                 }
  246: 
  247:                 if ( !$_New_directory && !$TAG ) {
  248:                   $checkins .= '<span class="CVS-dft-hidden">'; // $project / $_path
  249:                   $_webcvs = str_replace('http://www.' . HOST . '/source/browse/', '', $webcvs);
  250: 
  251:                   if ( strlen($_webcvs) > 15 )
  252:                     $checkins .= substr($_webcvs, 0, 12) . '...' . substr($_webcvs, strrpos($_webcvs, '/'));
  253:                   else
  254:                     $checkins .= $_webcvs;
  255: 
  256:                   if( $identifier == 'Removed:' || $idRemoved )
  257:                     $checkins .= '/Attic';
  258: 
  259:                   $checkins .= '/</span>';
  260:                 }
  261: 
  262:                 $checkinsA[$y] = str_replace('-_New_directory', '- New directory', $checkinsA[$y]);
  263: 
  264:                 $checkins .= $checkinsA[$y];
  265: 
  266:                 if (ereg("Tag\:$", trim($checkinsA[$y])) &&
  267:                     empty($checkinsA[$y+1]))
  268:                   $_tag = true; 
  269:                 else
  270:                   $_tag = false;
  271: 
  272:                 if (!$TAG)
  273:                   $checkins .= '</a>';
  274: 
  275:                   $checkins .= '</span>';
  276: 
  277:               }
  278: 
  279:               if ( $identifier == 'Removed:' || $idRemoved )
  280:                 $idRemoved = true;
  281:               else
  282:                 $idRemoved = false;
  283: 
  284:             }
  285: 
  286:             $checkins = trim( str_replace('</span> <span>', ' ', $checkins) );
  287: 
  288:             if ( !ereg('^<d', $checkins) )
  289:               $checkins = '<div class="CVS-div-checkins">' . $checkins;
  290: // what
  291:             if ( !empty( $checkins ) )
  292:               $result[$r] .= $checkins . "</div>\n"; // what
  293:   
  294: 
  295:           }
  296: 
  297:             if ( $_log_section || $_New_directory ) {
  298:               $_log_section = false;
  299:               $result[$r] .= '</div>';
  300:             }
  301: 
  302:           $result[$r] .= "</div>\n";
  303:           $result[$r] .= "</div>\n";
  304:           $result[$r] .= '<div style="clear: left; float: none;"></div>' . "\n";
  305:         }
  306: 
  307: // end  of parse of commitlog for $today / $yesterday
  308: 
  309:       }
  310:     }
  311: 
  312:     if (!$result) {  
  313:       print '<div id="CVS-no-commits">There are no new commits today</div>'."\n";
  314:     } else {
  315:       $reversed=array_reverse($result);
  316:       for ($i=0;$i<count($result);$i++)
  317:         print $reversed[$i];
  318:     }
  319: 
  320:     print "</div>\n\n";
  321: 
  322:   } // END BLOCK
  323: ?>

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