📄 cvs2html
字号:
#!/usr/bin/perl## Perl program to transform the 'cvs log' output to HTML## Perl program to transform the 'cvs log' output to HTML.# The HTML output will show the revision log history,# differences between versions and enable a flexible# configuration of the amount of information the user# like to see from the CVS repository.# cvs2html can be used for any type of cvs archive.## ** Note that the first line might be wrong depending **# ** on the location of your perl program. **# ** The program requires: **# ** perl version 5.003 or newer **## cvs2html should run on any Unix compatible machine# with the above programs.# Test machine: Linux RedHat 7.2 with Perl 5.6.0## Usage :## type cvs2html with no arguments to display basic help# or type cvs2html -h to get more help# Changelog# Ver Date Who did it What happened# -------------------------------------------------------------------------# 1.96 2002-11-09 Lloyd Parkes Patch for when -l and -R are used # at the same time. ## 1.95 2002-07-24 Holger L. Bille Patch against problem with empty# log-entries.## 1.94 2002-06-25 Magnus Ahlman Added a option argument -R CVS Reposity# specified in the cvsweb.conf# so you can integrate with cvsweb## 1.93 2002-05-25 John Hardin Patch against freezing problem# with cvs log would report "nothing# known about"## 1.92 2002-03-25 Anna Jonna Typos removed# Armannsdottir ## 1.91 2002-01-13 Jacob Sparre Andersen Major overhaul of the code# and Peter Toft in order to generate HTML 4.0# compliant code. Many bugs corrected.## 1.90 2001-09-07 Stefan Kost A few "cosmetical" corrections.## 1.89 2001-09-06 Stefan Kost * "back to main" links in chronofile# only if frames==1# * subs html_header/html_footer# * $cvs2html_diff is now called $diffdirname# (in preparation for more subdirs)# and defaults to just "diff"# * sub cvsrootinfo (with extended infos)# * the ususal cosmetical fixes here and there# * both halfs of diff output are now# delimited by a small gap# * entries in __rf-files are now sorted## 1.88 2001-09-04 Peter Toft Kim Schulz means that that # text in line 748 (previously 744) # was adequite. Updated.## 1.87 2001-08-30 Laurent Besson Bagged two bugs!!# Stefan Kost * fixed empty output# * copyright footer looks the same# for all pages# * chrono-file back-links go to# "top" frame## 1.86 2001-08-26 Stefan Kost Handling of verbosity level update## 1.85 2001-08-24 Stefan Kost * handles "cvs connection refused"# * find_alldirs, find_subdirs do not# follow symlinks# * new option -V <verbosity level># * cleaned up code indentation# * more comments## 1.84 2001-07-14 Peter Toft Added links in the cronological file# to the main page and removed a# debug-printout statement.## 1.83 2001-06-28 Grzegorz Pawelczak Patch to handle branches (fix)## 1.82 2001-06-22 Grzegorz Pawelczak Patch to handle branches## 1.81 2001-06-18 David Carson Minor update - added support# for underscore in author-field## 1.80 2001-05-31 Peter V. Pretsch Fixed the problem with missing# right frames## 1.79 2000-12-27 Peter Toft Peter made error in the Changelog :-)## 1.78 2000-12-27 Peter Toft Error in making diff-directories# corrected. Example included in help-# description.# Changed mkdir to perl-command.## 1.77 2000-12-15 Peter Toft Hack to avoid generating the# same diff-files over and over again.# Renaming of the diff-files.# Dumping the diff-files in a# separate subdir.## 1.76 2000-11-30 Jody Lewis Typo; The parent links in the# lower left frame were incorrect## 1.75 2000-11-04 Kirby Vandivort URL of cvs2html changed## 1.73 2000-11-02 Peter Toft Clean up - deleted an old status line## 1.72 2000-10-28 Peter Toft If basename() or dirname() adds# a \n code, then cvs2html malfunctions# This should solve the problem.## 1.71 2000-10-26 Peter Toft Minor clean-up## 1.70 2000-10-26 Jon Berndt Documentation problem -L option# Peter Toft -L/-E option was not working# Redefined -L and dumped the -E option## 1.69 2000-09-29 Robert Merkle Support for users with 0-9# in name## 1.68 2000-09-20 Wolfgang Bangerth Patch to avoid HTML syntax# problems and link error.## 1.67 2000-08-21 Kirby Vandivort Update to cvs2html to fix html# markup display in cvs comments## 1.66 2000-08-11 Kirby Vandivort Added support for an# parameter -P controlled location# of cvs## 1.65 2000-06-24 Peter Toft Added support for filenames# containing whitespaces -# requested by John Stone## 1.64 2000-06-11 Peter Toft Better documentation in the start# of the program## ---- ---------- -------------------- -------------------------------## This program is protected by the GPL, and all modifications of# general interest can be emailed to Peter Toft <pto@sslug.dk>## The GPL can be found at http://www.gnu.org/copyleft/gpl.html## Other people that have contributed directly or indirectly to cvs2html# Holger L. Bille <hlb@vitesse.com># Henner Zeller <zeller@think.de># Henning Niss <hniss@diku.dk># Henrik Carlquist <Henrik.Carlqvist@dynamics.saab.se># Tim Bradshaw <tfb@cley.com># David Miller# Parkes, Lloyd <lloyd.parkes@eds.com># David Carson <DCarson@extremenetworks.com># Finn Aarup Nielsen <fn@imm.dtu.dk># Michael Krause <mkrause@teuto.net># Jim Phillips <jim@ks.uiuc.edu># Jon S. Berndt <jsb@hal-pc.org># Edward S. Marshall <emarshal@logic.net># Curtis L. Olson <curt@me.umn.edu># Aubrey Jaffer <jaffer@colorage.com># Mark Cooke <mpc@star.sr.bham.ac.uk># Carlo Wood <carlo@runaway.xs4all.nl># Kirby Vandivort <kvandivo@ks.uiuc.edu># Dag Br點k <dag@Dynasim.se># Wolfgang Bangerth <wolfgang.bangerth@iwr.uni-heidelberg.de># Robert Merkle <r.merkle@siep.shell.com># Jody Lewis <jody.lewis@philips.com># Peter V. Pretsch <pvp@pe.dk># Grzegorz Pawelczak <gpawel@adlex.com># Stefan Kost <st_kost@gmx.de># Anna Jonna Armannsdottir <a@sleepy.dk># John Hardin <johnh@aproposretail.com># Magnus Ahlman <magnus.ahlman@eds.com>## Copyright under GPL 1997 - 2002 by# Peter Toft (pto@sslug.dk) + the persons above## Join the cvs2html mailing list <sslug-cvs2html@sslug.dk># by sending an email to <sslug-cvs2html-subscribe@sslug.dk>,# the contents of this mails is of no matter.# You will receive an email than you need to reply to.## If you want to unsubscribe from the list - write a mail to# <sslug-cvs2html-unsubscribe@sslug.dk>, and reply to the mail you get.# In case of problems contact <pto@sslug.dk>## The URL of cvs2html is:$URL = "http://cvs.sslug.dk/cvs2html";$cvs2html_version='$Id: cvs2html,v 1.1 2003-01-24 17:24:36 jwpeterson Exp $';require 'getopts.pl';require 'ctime.pl';use File::Basename;use File::Find;if($cvs2html_version =~ /^\$Id\: (\w+?),v (\d+?\.\d+?) /i) { $version=$2;}else { $version="?.?";}# get options from cfgfile# now get the options. The ones with a colon means the an extra argument follows.# all options given will override the ones specified in cfgfile&Getopts('R:r:abc:C:d:efhkl:n:N:s:vo:D:E:L:O:w:i:pP:V:');################################################################ graphic related default variables that you can change################################################################ Default width of the left frame in pixels. Also changed by -w option$leftframewidth = 150;# Default splitratio of the left frame in percent. Also changed by -s option$leftsplitratio = "70%";# Default cell color$cellcolor = "#c7c7c7";# Default filename cell color$filenamecellcolor = "#7777FF";# Default background color gray$backcolor = "#AAAAAA";# Default background for the difference cells$differencebackground = "#BBBBBB";# Colors and font to show the diff type of code changes when using -a$diffcolorHeading ='#999999'; # color of 'Line'-heading of each diffed file$diffcolorEmpty ='#999999'; # color of 'empty' lines$diffcolorNormal ='#BBBBBB'; # color of 'unchanged' ('equal') lines$diffcolorRemove ='#FF9999'; # Removed line(s) (left) (empty)$diffcolorChange ='#99FF99'; # Added line(s) (empty) (right)$diffcolorDarkChange ='#77AA77'; # lines, which are empty on the left/right$diffcolorAdd ='#AAAAFF'; # Changed line(s) ( both )# just uncomment if you don't want any font-changes#$difffontface ="Arial,Helvetica";$difffontface ="Courier,Courier New";$difffontsize ="-1";################################################################ other default variables that you can change################################################################ Set $kkon ="-kk" if you permanently want to hide keyword substitutions# when making diff-files.$kkon = "";# Set $whitespace = "-w" if you want to ignore white space changes# in diff$whitespace="-w";# The timedifference in seconds which we consider as the same# commit time$commit_smalltimedifference = 10;# default CVS location (default assumes in path)$cvsLocation="cvs";# warnings if omitting generating of diff-files$diffwarning = 0;# sub dir name for diff-files$diffdirname = "diff";################################################################ Subfunctions################################################################html helpersub html_footer { my ($stradd)=@_; if(!defined($stradd)){ $stradd=""; } (undef,$min,$hour,$mday,$mon,$year,undef,undef,undef) = localtime(time); $struser=getlogin; $strdate=sprintf "%4d-%02d-%02d %2d:%02d",$year+1900, $mon+1, $mday,$hour,$min; $ret="<hr>\n"; $ret.="<center><font size=\"-1\">\n"; $ret.="File made using version $version of "; $ret.="<a href=\"$URL\" target=\"_new\">cvs2html</a> by "; $ret.="$struser at $strdate $revisionlimitertext $stradd"; $ret.="</font></center>\n"; return($ret);}sub html_header { my ($title)=@_; $ret="<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n<head>\n<title>"; if(defined($title) && length($title)>0) { $ret.="$title"; } else { $ret.="cvs2html"; } $ret.="</title>\n</head>\n"; if ($opt_i) { $ret.="<body background=\"$opt_i\">\n"; } else { $ret.="<body bgcolor=\"$backcolor\">\n"; } if(defined($title) && length($title)>0) { $ret.="<h2 align=\"center\">$title</h2>\n<hr>\n"; } return($ret);}sub cvsrootinfo { # the two tables are needed for proper layout $ret="<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\" bgcolor=\"$cellcolor\" width=\"100%\">\n"; $ret.="<tr>\n"; $ret.="<td width=\"15%\" align=\"right\"><b>Protocol:</b></td><td width=\"35%\">$protocol</td>\n"; $ret.="<td width=\"15%\" align=\"right\"><b> User:</b></td><td width=\"35%\">$cvsuser</td>\n"; $ret.="</tr>\n<tr>\n"; $ret.="<td width=\"15%\" align=\"right\"><b> Machine:</b></td><td width=\"35%\">$machine</td>\n"; $ret.="<td width=\"15%\" align=\"right\"><b> CVSROOT:</b></td><td width=\"35%\">$cvsroot</td>\n"; $ret.="</tr>\n"; $ret.="</table><hr>\n"; return($ret);}#function to help sortsub sorter{ $chronotimesince0[$a] <=> $chronotimesince0[$b];}#Function to close the main filesub closemainfile { # Print date & copyright info in the last part of the HTML document $stradd=""; if ($cutdate>"00000000") { $stradd.=" leaving out any log message prior to $cutyearformat2"; } if (($opt_n>0) && ($opt_a)) { $stradd.=" and only showing the $opt_n latest version differences"; } print OUTFILE html_footer($stradd); # Lets wrap up OUTFILE print OUTFILE "</body>\n"; print OUTFILE "</html>\n"; close(OUTFILE);}# Function to show how the function is used. Called if no options are given.sub shorthelp { print "*** CVS2HTML ***\nA Perl program to transform the 'cvs log' output to HTML.\n"; print "Usage of cvs2html\n\n"; print "cvs2html [-a [-b][-k]] [-n NUMDIF] [-l/-L FTPHOME]\n"; print " [-e] [-f] [-d \"MMM DD [YYYY]\"] [-D DD] [-i IMAGE] [-h]\n"; print " [-v] [-w FRAMEWIDTH] [-s PERCENTAGE] [-N MAXCHRONO]\n"; print " [-rREV1:REV2] [-c/-C CFILENAME] -O/o HTMLNAME\n"; print " [-P CVSPATH] [-V VERBOSITY]\n [-R CVSWEB ROOT "; print "\n\nTry: cvs2html -help\n";}sub showhelp { print "\n"; print " cvs2html -O foo\n"; print " outputs html files foo.html and alike for each subdirectory\n"; print " Note that if foo is a directory the files are stored there\n"; print " using the name of the repository as the base filename.\n"; print "\n"; print " cvs2html -O foo -v\n"; print " which outputs a html file to the file foo.html including\n"; print " information about the CVSROOT setting.\n"; print "\n"; print " Using -o instead of -O, frames will be made for easy control.\n"; print "\n"; print " If -e is specified the log messages are printed\n"; print " in courier (non-proportional) font.\n"; print "\n"; print " If -c CFILENAME is specified a chronological sorted list of all log\n"; print " entries will be saved in CFILENAME (CFILENAME is a full html filename)\n"; print " Use -C CFILENAME instead of -c to do reverse sort of the log file.\n"; print " Add -p to include cvs log information into the CFILENAME.\n\n"; print " If -a is specified additional fields and files are generated\n"; print " containing differences betweeen versions\n"; print " in a xdiff-like side by side manner.\n"; print " The -n NUMDIF will only output the lastest NUMDIF diff files.\n"; print " The -N MAXCHRONO will only show the last MAXCHRONO file changes\n"; print " in the chronological list of changes.\n"; print "\n"; print " if -b is specified in addition to diff-mode\n"; print " spcaces are used as breakpoint to wrap the text\n"; print " so the two columns don't exceed the total width\n"; print " If -k is specified in addition to diff-mode\n"; print " changes in lines caused by CVS-keyword substition\n"; print " are ignored.\n"; print " If an option -l ftphome is given links to the files relative\n"; print " to the URL ftphome is made. Use -L ftphtmlhome to do the same as\n"; print " -l, but substitutes file extension with .html\n"; print "\n"; print " If an option -d \"month day year\" is given (year optional) any\n"; print " log message prior to that date is omitted. The three first \n"; print " letters of the name of the month is used, e.g., Jun 5.\n"; print " A -D DD option will drop any log DD days ago or earlier\n"; print "\n"; print " If an option -rREVISIONTAG1:REVISIONTAG2 is given, then\n"; print " the log messages are only shown between those revision\n"; print " REVISIONTAG1 and REVISIONTAG2. If a file was not tagged\n"; print " then the whole revision story of the file will be shown.\n"; print "\n"; print " If -o and -w FRAMEWIDTH is used the left frame will have\n"; print " FRAMEWIDTH pixels. Add -f when using the -o option to \n"; print " generate individual log files for each file.\n"; print " Use -s PERCENTAGE to set width of the fraction of the left\n"; print " bar in percentage.\n"; print "\n"; print " Use -i IMAGE to replace the background with file specified as IMAGE\n"; print "\n"; print " Use -P CVSPATH to specify an explicit location cvs. The\n"; print " default value is simply 'cvs', which means that cvs is in your\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -