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
blame.tmpl - Blame information for a file
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-treenode]
[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 some special filetypes:
dir=<HTML code> is used for directory icons
diropen=<HTML code> is used for open directory icons
*=<HTML code> is used for all filetypes which have no other definition
i-node - | shaped node of the tree view
t-node - T shaped node of the tree view
l-node - L shaped node of the tree view
e-node - Empty node of the tree view
Example from the BlueGrey scheme:
[websvn-defineicons]
dir=<img align="middle" valign="center" src="[websvn:locwebsvnhttp]/templates/BlueGrey/folder.png" alt="[FOLDER]">
diropen=<img align="middle" valign="center" src="[websvn:locwebsvnhttp]/templates/BlueGrey/folder-open.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]">
.s=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/files.png" alt="[S-FILE]">
i-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/i-node.png" alt="[NODE]">
t-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/t-node.png" alt="[NODE]">
l-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/l-node.png" alt="[NODE]">
e-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/e-node.png" alt="[NODE]">
[websvn-enddefineicons]
Inside the [websvn-startlisting] block, the command [websvn-treeview] will
output the HTML code defined for the appropriate tree view icon.
[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_submit - HTML <input> specification for the projects selection GO
button
projects_endform - HTML </form> specification for the projects selection
box (includes hidden field declarations)
lang_form - HTML <form> specification for the language selection box
lang_select - HTML <select>...</select> specification for the language options
lang_submit - HTML <input> specification for the language selection GO button
lang_endform - HTML </form> specification for the language selection box
noaccess - True if the user should be blocked from accessing this page due
to insufficient access rights.
Variables defined for index.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
treeview - true if the index should be displayed as a tree of grouped projects
flatview - true if the index should be displayed as a simple list of projects
opentree - true if the tree viewed should be open by default
Used in [websvn-startlisting] ... [websvn-endlisting] block of a flat view:
projlink - Link to the project
rowparity - Parity of the row (0 or 1). Used to generate striped tables
Used in [websvn-startlisting] ... [websvn-endlisting] block of a tree view:
isprojlink - This item is a project link
isgrouphead - This item is a group name
rowparity - Parity of the row (0 or 1). Used to generate striped tables
listitem - The item to display
Variables defined for directory.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
restricted - True if the users has restricted access to this directory (to
allow access to a readable directory lower down only)
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
lastchangedrev - Revision of the last modification to current directory
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
curdirrsslink - Link to the RSS feed for the current directory
curdirrssanchor - The <a href=...> tag to the RSS feed for the current directory
curdirrsshref - URL of the feed for the current directory (without anchor tag)
curdirdllink - Link to the tarball of current directory
curdircomplink - Link to comparison with previously changed revision
allowdownload - True if downloading has been configured
compare_form - HTML <form> specification for the comparison form
compare_submit - HTML <input> specification for the comparison button
compare_endform - HTML </form> specification for the comparison form
Used in [websvn-startlisting] ... [websvn-endlisting] block:
compare_box - HTML checkbox specification for the comparison option
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
fileviewdllink - Link to the tarball of current directory
isDir - true if the current file is a directory (use with [websvn-test:isDir]
to display icons)
rsslink - Link to the RSS feed for this file/directory
rssanchor - The <a href=...> tag to the RSS feed for this file/directory
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
error - Error message when results not available
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)
compare_form - HTML <form> specification for the comparison form
compare_submit - HTML <input> specification for the comparison button
compare_endform - HTML </form> specification for the comparison form
Used in [websvn-startlisting] ... [websvn-endlisting] block:
compare_box - HTML checkbox specification for the comparison option
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
blamelink - Link to the blame information for this file
fileviewloglink - Link to the log page for the file
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
Variables defined for blame.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
Used in [websvn-startlisting] ... [websvn-endlisting] block:
lineno - Line number of the line
revision - Revision in which the line changed
author - Last author to modify the line
line - The line itself
Variables defined for compare.tmpl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
action - Action being performed ("Path Comparison")
repname - Name of the repository
path1 - First path being compared
rev1 - Revision of first path
path2 - Second path being compared
rev2 - Revision of second path
success = true if the comparison succeeded
revlink - Link to reverse comparison
compare_form - HTML <form> specification for the comparison form
compare_path1input/compare_path2input - HTML specifications for the path input areas
compare_rev1input/compare_rev2input - HTML specifications for the revision input areas
compare_submit - HTML <input> specification for the comparison button
compare_endform - HTML </form> specification for the comparison form
Used in [websvn-startlisting] ... [websvn-endlisting] block:
newpath - Name of new file under comparison (only defined at start of block)
difflines - Lines changed information for this file. Start of diff lines.
(only defined after newpath)
diffclass - Class name of the diff block used for colouring
differences. The result is one of:
* diff (no changes)
* diffadded
* diffdeleted
line - The line under comparison
enddifflines - End of diff lines
properties - Property changes
endpath - End of current path