
THE TEMPLATING SYSTEM
~~~~~~~~~~~~~~~~~~~~~

Everyone wants their view onto their SVN repository to fit in with their look
and feel.  With WebSVN's templating system this is very possible.

To create your own templates, you first need to change your config.inc file to
tell WebSVN where the templates are stored.  For example:

$config->setTemplatePath("./templates/Standard/");

This directory should contain at least the following files:

header.tmpl - Header templated included before any other
footer.tmpl - Footer templated included after any other

index.tmpl - The main project page template

directory.tmpl - Listing of a directory
log.tmple - Log of a directory or file
file.tmpl - Contents of a text file
diff.tmpl - Differences between text files

Each template file should be written in HTML, but is allowed to contain certain
WebSVN controls.  There are two control types, commands and variables.


COMMANDS
~~~~~~~~

NOTE:  Commands MUST appear on their own line.

---

[websvn-test:varname]
...
[websvn-else]
...
[websvn-endtest]

If the variable is non-0 write out the first part else write out the second

---

[websvn-startlisting]
...
[websvn-endlisting]


Used in pages that contain listings of files, logs, etc.  Everything between
the controls is repeated for each item in the list

---

[websvn-defineicons] (used in directory.tmpl only)
...
[websvn-enddefineicons]
...
[websvn-icon]

These commands are used to display certain icons next to certain file types in
the directory view.

The [websvn-defineicons] block should contain a line for each file type,
defining the HTML to be used for that file type.  To define the HTML for a
particular extension use the syntax:

.<extension>=<HTML code>

There are also two special filetypes:

dir=<HTML code> is used for directory icons
*=<HTML code> is used for all filetypes which have no other definition

Example from the BlueGrey scheme:

[websvn-defineicons]
dir=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/folder.png" alt="[FOLDER]">
*=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/file.png" alt="[FILE]">
.c=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/filec.png" alt="[C-FILE]">
.h=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/fileh.png" alt="[H-FILE]">
[websvn-enddefineicons]

Inside the [websvn-startlisting] block, the command [websvn-icon] will output
the HTML code defined for the type of the current file.

---

[websvn-getlisting] (used in file.tmpl only)
 
Get the contents of the file being viewed and output it exactly (surrounded
with <PRE> .. </PRE>).

VARIABLES
~~~~~~~~~

Variables are written in the form [websvn:varname] where varname is the name of
a variable passed to the template.  The control is replaced with the variable
required.

The variables available are described below for each template.
You may also access the language file using [lang:varname] is order to keep your
templates international!

Take special notice of the use of the locwebsvnhttp variable.  It should be used
to locate other files and graphics that your templates need.  For example:

<link href="[websvn:locwebsvnhttp]/templates/tmptname/styles.css" ...

You may imagine that simply using . in place should work, however this isn't
the case when MultiViews are turned on.  Using this variable gives you a way to
access your template files in all cases.

Variables defined for in all scripts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

locwebsvnhttp - Root of websvn directory
charset - The charset requested by the user

projects_form - HTML <form> specification for the projects selection box
projects_select - HTML <select>...</select> specification for the project
                  options
projects_submut - HTML <input> specification for the projects selection GO
                  button
projects_endform - HTML </form> specification for the projects selection
                   box (includes hidden field declarations)



Variables defined for index.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Used in [websvn-startlisting] ... [websvn-endlisting] block:

projlink - Link to the project
rowparity - Parity of the row (0 or 1).  Used to generate striped tables

Variables defined for directory.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

repname - Name of the repository
rev - Revision being viewed
path - Path of item being logged
author - Author of current revision
date - Date that revision was committed
log - Log message of revision
goyoungestlink - Link to head revision of repository

showchanges - 1 if showing changes (for websvn-test)
hidechanges - 1 if hiding changes (for websvn-test)
showchangeslink - Link to page with changes hidden
hidechangeslink - Link to page with changes shown

newfilesbr - list of the new files separated by <BR>'s
changedfilesbr - list of the changed files separated by <BR>'s
deletedfilesbr - list of the deleted files separated by <BR>'s

newfiles - list of the new files separated by spaces
changedfiles - list of the changed files separated by spaces
deletedfiles - list of the deleted files separated by spaces

curdirlinks - List of the path of this directory with links to each one
curdirloglink - Link to the log view of current directory

Used in [websvn-startlisting] ... [websvn-endlisting] block:

filelink - Link to the file
rowparity - Parity of the row (0 or 1).  Used to generate striped tables
fileviewloglink - Link to the log page for the file
isDir - true if the current file is a directory (use with [websvn-test:isDir]
        to display icons) 


Variables defined for log.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

action - Action being performed ("Log")

repname - Name of the repository
rev - Revision being viewed
path - Path of item being logged
curdirlinks - List of the path of this directory with links to each one

pagelinks - List of list to all the pages of the log
showalllink - Link to show the entire log in one go

logsearch_form - HTML <form> specification for the log search box
logsearch_inputbox - HTML <input> specification for the log search box
logsearch_submit - HTML <input> specification for the log search GO button
logsearch_endform -  HTML </form> specification for the log search box box
                     (includes hidden field declarations)
logsearch_clearloglink - Link to unfiltered display (remove current search
                         criteria)
                         
logsearch_resultsfound - true when there are logs to display
logsearch_nomatches - true when there are no matches for the current request
logsearch_nomorematches - true when there are no further matches to the current
                          request (but there have been previous pages,
                          for example)

Used in [websvn-startlisting] ... [websvn-endlisting] block:

revpathlink - Link to revision
revauthor - Author of this revision
revage - Age of revision
revlog - Log message of revision


Variables defined for file.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

repname - Name of the repository
rev - Revision being viewed
path - Path of item being logged
curdirlinks - List of the path of this directory with links to each one

prevdifflink - Link to comparison with previous revision

Note: Use command [websvn-getlisting] to display the listing.


Variables defined for diff.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

action - Action being performed ("Diff")
locwebsvnhttp - Root of websvn directory
charset - The charset requested by the user

repname - Name of the repository
rev - Revision being viewed
path - Path of item being logged
curdirlinks - List of the path of this directory with links to each one

rev1 - Revision of the older file
rev2 - Revision of the newer file

showcompactlink - Link to compact view
showalllink - Link to full view

Used in [websvn-startlisting] ... [websvn-endlisting] block:

rev1lineno / rev2lineno - Line number of the next difference block.  Only
                          defined at the start of the block.
rev2diffclass / rev2diffclass - Class name of the diff block used for colouring
                                differences.  The result is one of:
                                    * diff (no changes)
                                    * diffadded
                                    * diffchanged
                                    *diffdeleted
rev1line / rev2line - The line under comparison

