File:  [mozdev] / cdn / www / sources.html
Revision 1.168: download - view: text, annotated - select for diffs - revision graph
Wed Mar 12 19:51:33 2003 UTC (16 years, 5 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
lose '/./' take ][

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

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