[RFC] New web server for bazaar
Goffredo Baroncelli
kreijack at alice.it
Tue Sep 13 18:38:26 BST 2005
Hi all,
I have ported the mercurial[*] web interfaces to bazaar-ng; an example can be
viewed on 'http://goffredo-baroncelli.homelinux.net/bzr'; the source can
be pulled at the same address:
$ bzr branch http://goffredo-baroncelli.homelinux.net/bzr
the diff can be viewed at
http://goffredo-baroncelli.homelinux.net/bzr/?cmd=changeset;rev=1194
The web interface can be started in two way:
1) standalone server, via the 'bzr serve' command
$ bzr serve --help
usage: serve [NAME] [ROOTREPOSITORY]
Start the webserver
options:
--templates
--address
--port
--ipv6
--acceslog
--errorlog
where
NAME -> name of the repository ( default the current dir )
ROOTREPOSITORY -> repository directory ( default the current dir )
--templates -> set the template directory ( default the
ROOTREPOSITORY )
--address -> interface to listen
--port -> port to listen ( default 8088 )
--ipv6 -> ipv6 enable/disable ( untested )
--accesslog -> accesslog file ( default stderr )
--errorlog -> errorlog file ( default stderr )
After the start of the server with the default parameters ( bzr serve ),
you can browse the repository at the address: 'http://127.0.0.1:8088/'
2) cgi script via apache, configuring apache to use the 'hgweb.cgi' python
script as the default index script. Below is an example of the httpd.conf file
<Directory BlaBlaBla/BlaBlaBla/bzr>
DirectoryIndex index.html hgweb.cgi
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Indexes
Order allow,deny
Allow from all
AddHandler cgi-script .cgi
</Directory>
Mi first TODO is to implement the web interface as external plug in order to
simplify the integration.
The code of the web interface is based on expansion of a template files. Under the
directory templates/ there are files which are the skeleton of the html pages. These files
have field like '#<field name>#' which the code expand with a value or with another
template expansion....
In code:
$ cat templatefile
<html>
<body>
<table>
#rows#
</table>
</body>
</html>
$ cat templaterows
<tr>
<td>#tag#
$
[...]
t = templater("mapfile")
def func( ):
for i in range(1,10):
yield t("templaterows", tag = str(i) )
write(t("templatefile", rows = func( ) ))
[...]
the code above, take the contents of the file "templatefile" and
replace every string '#tag#' with the value(s) returned by
the function func( ).
The function func( ) return 9 times the content of the file
"templatefile2", replacing the field '#anothertag#' with a value
between 1 and 9.
Because the function 'func( )' return 9 different values,
the unique field '#tag#' is expanded 9 times.
The 'mapfile' file contains the mapping between the name of the
template name and the template filename...
The goal is separate the html code to the python code. In fact the
template contains the major part of the html code, only the
dynamic part are generated by the python code, tipically on the basis of another
template; an example is the changelog web page: the main page is
a template, where the table rows are an another template expansion...
I know that somebody will not agree with the fact that the web interface is
integrated in the core code, but I think that a good web interface is useful to
view the revision without any tool, and can improve the acceptance of a tool like
bzr. So i think that should be integrated with the core project.
Note the code is not production-ready; comments are welcome.
[*] If you don't know what is mercurial see http://selenic.com/mercurial
--
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack @ inwind . it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87 87C0 BB86 505C 6B2A CFF9
More information about the bazaar
mailing list