Bazaar-NG web interface


The latest revision of this documents can be download at http://goffredo-baroncelli.homelinux.net/bazaar/bazaar-webserve/?cmd=content;rev=;path=docs/README.html;pathrevid=;style=raw

Introduction

This is the porting of the mercurial web interfaces to bazaar-ng; todate the porting is implemented as plugin.

Index

Features

Usage

The web interface can be started via the 'bzr webserve' command

  $ bzr webserve --help
  usage: webserve [NAME] [ROOTREPOSITORY]

  Start the webserver

  options:
    --templates
    --address
    --port
    --ipv6
    --acceslog
    --errorlog
    --lock
    --profile 
    --tararchive

where
        NAME            -> name of the repository ( default the current dir )
        ROOTREPOSITORY  -> repository directory ( default the current dir ) 
                           or an URL ( currently only http:// transport is supported )
        --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 )
	--lock		-> enable the locking of the repository when a request
			   is performed
    	--profile       -> show the profile info at the bottom of page
    	--tararchive    -> permit the download of the archive as a tar.gz file
	--fileserver    -> permit to provide the archive for pulling/branching

After the start of the server with the default parameters ( bzr webserve ), you can browse the repository at the address: 'http://127.0.0.1:8088/'

In the next section, you can see how configure webserve as cgi.

Apache configuration

The webserve can be configured to work as cgi under apache. That can be useful if you want to provied access via internet to several repositories in a more robust way. The cgi script are two (webserve.cgi and webserve-dir.cgi), and are place under the script directory. Under the docs directory you can see an example of configuration file.

The configuration of has to cover three aspects:

  1. Configure apache in order to start the correct cgi
  2. Configure apache in order to provide the access to the repositories
  3. Configure the script in order to permit the repositories browsing

  1. Configure apache in order to start the correct cgi

    This configuration is better covered in the apache manual. However below you can see a simple example of apache configuration.
    Supposing that your cgi script is

    /home/test/bazaar/webserve-dir.cgi
    you have to add the following directives to the apache configuration file
    Alias /bazaar /home/test/bazaar/webserve-dir.cgi
    <Directory /home/test/bazaar/>
    	AllowOverride None
    	Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Indexes
    	Order allow,deny
    	Allow from all
    	AddHandler cgi-script .cgi
    </Directory>
    
    When the URL /bazaar ( and the /bazaar/<somethingelse> ) is ivoked, the cgi /home/test/bazaar/webserve.cgi is started. The first line links the url (/bazaar) to the cgi (/home/test/bazaar/webserve.cgi); the <Directory...> directive permits the cgi execution under the directory /home/test/bazaar/.

  2. Configure apache in order to provide the access to the repositories

    Apache has to grant the acces to the .bzr directory inside a branch; and if you want to serve multiple branches inside a repository, apache has to be configured to serve also the .bzr directory of the repository.

  3. Configure the scripts

    The webserve interface can be started as cgi in two modes:

Internal

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, takes 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 "templaterows", replacing the field '#tag#' with a value between 1 and 9.

Because the function 'func( )' return 9 different values, the unique field '#rows#' is expanded 9 times. The 'mapfile' file contains the mapping between the name of the template name and the template filename...

The goal is to 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...

Bug

Todo

Download

In order to download the plugin you can

Install

After the download of the plugins, you have to move the file under a directory named webserve on one of the following places

See http://bazaar.canonical.com/BzrPlugins for more information


Goffredo Baroncelli <kreijack AT inwind DOT it>