Rev Author Line No. Line
185 miho 1  
2 THE TEMPLATING SYSTEM
3 ~~~~~~~~~~~~~~~~~~~~~
4  
5 Everyone wants their view onto their SVN repository to fit in with their look
6 and feel. With WebSVN's templating system this is very possible.
7  
8 To create your own templates, you first need to change your config.inc file to
9 tell WebSVN where the templates are stored. For example:
10  
11 $config->setTemplatePath("./templates/Standard/");
12  
13 This directory should contain at least the following files:
14  
15 header.tmpl - Header templated included before any other
16 footer.tmpl - Footer templated included after any other
17  
18 index.tmpl - The main project page template
19  
20 directory.tmpl - Listing of a directory
21 log.tmple - Log of a directory or file
22 file.tmpl - Contents of a text file
23 diff.tmpl - Differences between text files
24 blame.tmpl - Blame information for a file
25  
26 Each template file should be written in HTML, but is allowed to contain certain
27 WebSVN controls. There are two control types, commands and variables.
28  
29  
30 COMMANDS
31 ~~~~~~~~
32  
33 NOTE: Commands MUST appear on their own line.
34  
35 ---
36  
37 [websvn-test:varname]
38 ...
39 [websvn-else]
40 ...
41 [websvn-endtest]
42  
43 If the variable is non-0 write out the first part else write out the second
44  
45 ---
46  
47 [websvn-startlisting]
48 ...
49 [websvn-endlisting]
50  
51  
52 Used in pages that contain listings of files, logs, etc. Everything between
53 the controls is repeated for each item in the list
54  
55 ---
56  
57 [websvn-defineicons] (used in directory.tmpl only)
58 ...
59 [websvn-enddefineicons]
60 ...
61  
62 [websvn-treenode]
63 [websvn-icon]
64  
65 These commands are used to display certain icons next to certain file types in
66 the directory view.
67  
68 The [websvn-defineicons] block should contain a line for each file type,
69 defining the HTML to be used for that file type. To define the HTML for a
70 particular extension use the syntax:
71  
72 .<extension>=<HTML code>
73  
74 There are also some special filetypes:
75  
76 dir=<HTML code> is used for directory icons
77 diropen=<HTML code> is used for open directory icons
78 *=<HTML code> is used for all filetypes which have no other definition
79  
80 i-node - | shaped node of the tree view
81 t-node - T shaped node of the tree view
82 l-node - L shaped node of the tree view
83 e-node - Empty node of the tree view
84  
85 Example from the BlueGrey scheme:
86  
87 [websvn-defineicons]
88 dir=<img align="middle" valign="center" src="[websvn:locwebsvnhttp]/templates/BlueGrey/folder.png" alt="[FOLDER]">
89 diropen=<img align="middle" valign="center" src="[websvn:locwebsvnhttp]/templates/BlueGrey/folder-open.png" alt="[FOLDER]">
90 *=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/file.png" alt="[FILE]">
91 .c=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/filec.png" alt="[C-FILE]">
92 .h=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/fileh.png" alt="[H-FILE]">
93 .s=<img align="middle" src="[websvn:locwebsvnhttp]/templates/BlueGrey/files.png" alt="[S-FILE]">
94  
95 i-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/i-node.png" alt="[NODE]">
96 t-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/t-node.png" alt="[NODE]">
97 l-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/l-node.png" alt="[NODE]">
98 e-node=<img align="middle" border="0" width="24" height="26" src="[websvn:locwebsvnhttp]/templates/BlueGrey/e-node.png" alt="[NODE]">
99 [websvn-enddefineicons]
100  
101 Inside the [websvn-startlisting] block, the command [websvn-treeview] will
102 output the HTML code defined for the appropriate tree view icon.
103 [websvn-icon] will output the HTML code defined for the type of the current
104 file.
105  
106 ---
107  
108 [websvn-getlisting] (used in file.tmpl only)
109  
110 Get the contents of the file being viewed and output it exactly (surrounded
111 with <PRE> .. </PRE>).
112  
113 VARIABLES
114 ~~~~~~~~~
115  
116 Variables are written in the form [websvn:varname] where varname is the name of
117 a variable passed to the template. The control is replaced with the variable
118 required.
119  
120 The variables available are described below for each template.
121 You may also access the language file using [lang:varname] is order to keep your
122 templates international!
123  
124 Take special notice of the use of the locwebsvnhttp variable. It should be used
125 to locate other files and graphics that your templates need. For example:
126  
127 <link href="[websvn:locwebsvnhttp]/templates/tmptname/styles.css" ...
128  
129 You may imagine that simply using . in place should work, however this isn't
130 the case when MultiViews are turned on. Using this variable gives you a way to
131 access your template files in all cases.
132  
133 Variables defined for in all scripts
134 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135  
136 locwebsvnhttp - Root of websvn directory
137 charset - The charset requested by the user
138  
139 projects_form - HTML <form> specification for the projects selection box
140 projects_select - HTML <select>...</select> specification for the project
141 options
142 projects_submit - HTML <input> specification for the projects selection GO
143 button
144 projects_endform - HTML </form> specification for the projects selection
145 box (includes hidden field declarations)
146  
147 lang_form - HTML <form> specification for the language selection box
148 lang_select - HTML <select>...</select> specification for the language options
149 lang_submit - HTML <input> specification for the language selection GO button
150 lang_endform - HTML </form> specification for the language selection box
151  
152 noaccess - True if the user should be blocked from accessing this page due
153 to insufficient access rights.
154  
155 Variables defined for index.tmpl
156 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157  
158 treeview - true if the index should be displayed as a tree of grouped projects
159 flatview - true if the index should be displayed as a simple list of projects
160 opentree - true if the tree viewed should be open by default
161  
162 Used in [websvn-startlisting] ... [websvn-endlisting] block of a flat view:
163  
164 projlink - Link to the project
165 rowparity - Parity of the row (0 or 1). Used to generate striped tables
166  
167 Used in [websvn-startlisting] ... [websvn-endlisting] block of a tree view:
168  
169 isprojlink - This item is a project link
170 isgrouphead - This item is a group name
171 rowparity - Parity of the row (0 or 1). Used to generate striped tables
172 listitem - The item to display
173  
174 Variables defined for directory.tmpl
175 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176  
177 restricted - True if the users has restricted access to this directory (to
178 allow access to a readable directory lower down only)
179 repname - Name of the repository
180 rev - Revision being viewed
181 path - Path of item being logged
182 author - Author of current revision
183 date - Date that revision was committed
184 log - Log message of revision
185 lastchangedrev - Revision of the last modification to current directory
186 goyoungestlink - Link to head revision of repository
187  
188 showchanges - 1 if showing changes (for websvn-test)
189 hidechanges - 1 if hiding changes (for websvn-test)
190 showchangeslink - Link to page with changes hidden
191 hidechangeslink - Link to page with changes shown
192  
193 newfilesbr - list of the new files separated by <BR>'s
194 changedfilesbr - list of the changed files separated by <BR>'s
195 deletedfilesbr - list of the deleted files separated by <BR>'s
196  
197 newfiles - list of the new files separated by spaces
198 changedfiles - list of the changed files separated by spaces
199 deletedfiles - list of the deleted files separated by spaces
200  
201 curdirlinks - List of the path of this directory with links to each one
202 curdirloglink - Link to the log view of current directory
203 curdirrsslink - Link to the RSS feed for the current directory
204 curdirrssanchor - The <a href=...> tag to the RSS feed for the current directory
205 curdirrsshref - URL of the feed for the current directory (without anchor tag)
206 curdirdllink - Link to the tarball of current directory
207 curdircomplink - Link to comparison with previously changed revision
208  
209 allowdownload - True if downloading has been configured
210  
211 compare_form - HTML <form> specification for the comparison form
212 compare_submit - HTML <input> specification for the comparison button
213 compare_endform - HTML </form> specification for the comparison form
214  
215 Used in [websvn-startlisting] ... [websvn-endlisting] block:
216  
217 compare_box - HTML checkbox specification for the comparison option
218 filelink - Link to the file
219 rowparity - Parity of the row (0 or 1). Used to generate striped tables
220 fileviewloglink - Link to the log page for the file
221 fileviewdllink - Link to the tarball of current directory
222 isDir - true if the current file is a directory (use with [websvn-test:isDir]
223 to display icons)
224 rsslink - Link to the RSS feed for this file/directory
225 rssanchor - The <a href=...> tag to the RSS feed for this file/directory
226  
227 Variables defined for log.tmpl
228 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229  
230 action - Action being performed ("Log")
231  
232 repname - Name of the repository
233 rev - Revision being viewed
234 path - Path of item being logged
235 curdirlinks - List of the path of this directory with links to each one
236 error - Error message when results not available
237  
238 pagelinks - List of list to all the pages of the log
239 showalllink - Link to show the entire log in one go
240  
241 logsearch_form - HTML <form> specification for the log search box
242 logsearch_inputbox - HTML <input> specification for the log search box
243 logsearch_submit - HTML <input> specification for the log search GO button
244 logsearch_endform - HTML </form> specification for the log search box box
245 (includes hidden field declarations)
246 logsearch_clearloglink - Link to unfiltered display (remove current search
247 criteria)
248  
249 logsearch_resultsfound - true when there are logs to display
250 logsearch_nomatches - true when there are no matches for the current request
251 logsearch_nomorematches - true when there are no further matches to the current
252 request (but there have been previous pages,
253 for example)
254  
255 compare_form - HTML <form> specification for the comparison form
256 compare_submit - HTML <input> specification for the comparison button
257 compare_endform - HTML </form> specification for the comparison form
258  
259 Used in [websvn-startlisting] ... [websvn-endlisting] block:
260  
261 compare_box - HTML checkbox specification for the comparison option
262 revpathlink - Link to revision
263 revauthor - Author of this revision
264 revage - Age of revision
265 revlog - Log message of revision
266  
267  
268 Variables defined for file.tmpl
269 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270  
271 repname - Name of the repository
272 rev - Revision being viewed
273 path - Path of item being logged
274 curdirlinks - List of the path of this directory with links to each one
275  
276 prevdifflink - Link to comparison with previous revision
277 blamelink - Link to the blame information for this file
278 fileviewloglink - Link to the log page for the file
279  
280 Note: Use command [websvn-getlisting] to display the listing.
281  
282  
283 Variables defined for diff.tmpl
284 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285  
286 action - Action being performed ("Diff")
287 locwebsvnhttp - Root of websvn directory
288 charset - The charset requested by the user
289  
290 repname - Name of the repository
291 rev - Revision being viewed
292 path - Path of item being logged
293 curdirlinks - List of the path of this directory with links to each one
294  
295 rev1 - Revision of the older file
296 rev2 - Revision of the newer file
297  
298 showcompactlink - Link to compact view
299 showalllink - Link to full view
300  
301 Used in [websvn-startlisting] ... [websvn-endlisting] block:
302  
303 rev1lineno / rev2lineno - Line number of the next difference block. Only
304 defined at the start of the block.
305 rev2diffclass / rev2diffclass - Class name of the diff block used for colouring
306 differences. The result is one of:
307 * diff (no changes)
308 * diffadded
309 * diffchanged
310 * diffdeleted
311 rev1line / rev2line - The line under comparison
312  
313 Variables defined for blame.tmpl
314 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315  
316 locwebsvnhttp - Root of websvn directory
317 charset - The charset requested by the user
318  
319 repname - Name of the repository
320 rev - Revision being viewed
321 path - Path of item being logged
322 curdirlinks - List of the path of this directory with links to each one
323  
324 Used in [websvn-startlisting] ... [websvn-endlisting] block:
325  
326 lineno - Line number of the line
327 revision - Revision in which the line changed
328 author - Last author to modify the line
329 line - The line itself
330  
331 Variables defined for compare.tmpl
332 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333  
334 action - Action being performed ("Path Comparison")
335 repname - Name of the repository
336 path1 - First path being compared
337 rev1 - Revision of first path
338 path2 - Second path being compared
339 rev2 - Revision of second path
340  
341 success = true if the comparison succeeded
342  
343 revlink - Link to reverse comparison
344  
345 compare_form - HTML <form> specification for the comparison form
346 compare_path1input/compare_path2input - HTML specifications for the path input areas
347 compare_rev1input/compare_rev2input - HTML specifications for the revision input areas
348 compare_submit - HTML <input> specification for the comparison button
349 compare_endform - HTML </form> specification for the comparison form
350  
351 Used in [websvn-startlisting] ... [websvn-endlisting] block:
352  
353 newpath - Name of new file under comparison (only defined at start of block)
354 difflines - Lines changed information for this file. Start of diff lines.
355 (only defined after newpath)
356 diffclass - Class name of the diff block used for colouring
357 differences. The result is one of:
358 * diff (no changes)
359 * diffadded
360 * diffdeleted
361 line - The line under comparison
362 enddifflines - End of diff lines
363 properties - Property changes
364 endpath - End of current path