ViewVC to the rescue.
Prerequisites: Python2.x, Apache2.0+, CVS, CVS/SVN Python Bindings.
Detailed installation process:
1. ViewVC:
I have CVSNT on my workstation. So I downloaded ViewVC-1.0.7 from http://www.viewvc.org/download.html (spcecifically, version 1.0.7 from http://viewvc.tigris.org/servlets/ProjectDocumentList?folderID=6004).
To install ViewVC, first unpack it to some folder, run 'python viewvc-install' from the command line, with the current directory as the unpacked directory. I chose all the defaults values when prompted.
Next, I configured viewvc to pick up my repositories by editing the
2. SVN Python bindings for ViewVC:
ViewVC is written in python and tigris.org provides python bindings to talk to the CVS/SVN repository. This can be got from subversion.tigris.org Documents Area. Be sure to download the version appropirate for your version of python. Simply run the installer. You will be asked to point the installer to the Apache installation directory.
3. mod_python:
You will need to download the mod_python for Apache if you dont have it already. You can check the
4. Configuring Apache.
Edit the httpd.conf file to add the following:
a)
LoadModule python_module modules/mod_python.so
b)
ScriptAlias /viewcvs "C:/Program Files/viewvc-1.0.7/bin/mod_python/viewvc.py"
<location>
AddHandler python-program .py
PythonPath "[r'c:\\Program Files\\viewvc-1.0.7\\bin\\mod_python']+sys.path"
PythonHandler apache
PythonDebug On
AddDefaultCharset UTF-8
</location>
NOTE: The above will work if you have chosen the defaults while installing ViewVC.
Done! Goto: http://your-machine/viewcvs.
However, I got an error when I did this: "ImportError: No module named apache"
So, I tried the alternate approach:
A) Copy <viewvc-install-dir>/bin/cgi/*.cgi to <apache-install-dir>/cgi-bin/
B) Add the following line to the <apache-install-dir>/conf/httpd.conf file:
ScriptAlias /viewvc /cgi-bin/viewvc.cgi
C) Restart Apache.
Done! Go to: http://localhost/cgi-bin/viewvc.cgi
It works for me!! I wish I could fix the other method too.
Good. Now that it works, I should be happy. But I was not :( When I 'view' a source file, it does not do the syntax highlighting (I use CVS with C++/C projects and I was not getting the syntax highlighting for these languages). So what do I do? Wanted to integrate some open source syntax highlighters. I dug thru' the code of viewvc.py and from there went on to find the place where the markup is done. (search the code base for view_markup function. I use RedHat sourcenavigator to browse and read code). They seemed to be using some PHP code to get the job done. However, I remembered I was very happy with Google's Prettify (any code you browse on code.google.com has probably used Google prettify to syntax highlight the code). So I decided to use it.
Also, using the Google Pettify is quite simple:
A) Add the following lines to the "head" section:
<link href="[docroot]/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="[docroot]/prettify/prettify.js" > < /script >
B) Add "onload=prettyPrint()" attribute to the "body" tag.
C) Put your code in <pre class="prettyprint"> or <code class="prettyprint" >tags.
D) Done!
It took quite some reading of the ViewVC python code to figure out simple ways to do it. Here is my story:
I read thru the ViewVC python code and found that there was a header and footer being used for each page. Then there was a template for markup and each of the different views that ViweVC supports. Then I stumbled upon the EZT class (EaZyTemplates). Just what I needed to integrate with Google Prettify!! So I found the templates being loaded by ViewVC. They are loacated under <viewvc-install-dir>/templates/. Here are my modifications:
1. Download Google Prettify from: http://code.google.com/p/google-code-prettify/
2. Unzip it. Copy the src folder to <viewvc-install-dir>/templates/docroot/
3. I renamed the src folder to prettify (just to help me later)
4. Add the following lines to <viewvc-install-dir>/templates/include/header.ezt, in the "head" section:
<link href="[docroot]/prettify/prettify.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="%5Bdocroot%5D/prettify/prettify.js"></script>
also, modify the body tag to: <body onload="prettyPrint()">
5. Modify <viewvc-install-dir>/templates/markup.ezt:
Change this: <div id="vc_markup"><pre&t;[markup]</pre></div>
to: <div id="vc_markup"><pre class="prettyprint">[markup]</pre></div>
Done!.
Have fun! And post your questions as comments.