~ubuntu-branches/ubuntu/hardy/bugzilla/hardy-security

« back to all changes in this revision

Viewing changes to docs/html/cust-templates.html

  • Committer: Bazaar Package Importer
  • Author(s): Rémi Perrot
  • Date: 2004-04-02 01:13:32 UTC
  • Revision ID: james.westby@ubuntu.com-20040402011332-hxrg0n2szimd7d25
Tags: upstream-2.16.5
Import upstream version 2.16.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<HTML
 
2
><HEAD
 
3
><TITLE
 
4
>Template Customisation</TITLE
 
5
><META
 
6
NAME="GENERATOR"
 
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
 
8
REL="HOME"
 
9
TITLE="The Bugzilla Guide - 2.16.4 Release"
 
10
HREF="index.html"><LINK
 
11
REL="UP"
 
12
TITLE="Administering Bugzilla"
 
13
HREF="administration.html"><LINK
 
14
REL="PREVIOUS"
 
15
TITLE="Bugzilla Security"
 
16
HREF="security.html"><LINK
 
17
REL="NEXT"
 
18
TITLE="Upgrading to New Releases"
 
19
HREF="upgrading.html"></HEAD
 
20
><BODY
 
21
CLASS="section"
 
22
BGCOLOR="#FFFFFF"
 
23
TEXT="#000000"
 
24
LINK="#0000FF"
 
25
VLINK="#840084"
 
26
ALINK="#0000FF"
 
27
><DIV
 
28
CLASS="NAVHEADER"
 
29
><TABLE
 
30
SUMMARY="Header navigation table"
 
31
WIDTH="100%"
 
32
BORDER="0"
 
33
CELLPADDING="0"
 
34
CELLSPACING="0"
 
35
><TR
 
36
><TH
 
37
COLSPAN="3"
 
38
ALIGN="center"
 
39
>The Bugzilla Guide - 2.16.4 Release</TH
 
40
></TR
 
41
><TR
 
42
><TD
 
43
WIDTH="10%"
 
44
ALIGN="left"
 
45
VALIGN="bottom"
 
46
><A
 
47
HREF="security.html"
 
48
ACCESSKEY="P"
 
49
>Prev</A
 
50
></TD
 
51
><TD
 
52
WIDTH="80%"
 
53
ALIGN="center"
 
54
VALIGN="bottom"
 
55
>Chapter 5. Administering Bugzilla</TD
 
56
><TD
 
57
WIDTH="10%"
 
58
ALIGN="right"
 
59
VALIGN="bottom"
 
60
><A
 
61
HREF="upgrading.html"
 
62
ACCESSKEY="N"
 
63
>Next</A
 
64
></TD
 
65
></TR
 
66
></TABLE
 
67
><HR
 
68
ALIGN="LEFT"
 
69
WIDTH="100%"></DIV
 
70
><DIV
 
71
CLASS="section"
 
72
><H1
 
73
CLASS="section"
 
74
><A
 
75
NAME="cust-templates"
 
76
></A
 
77
>5.7. Template Customisation</H1
 
78
><P
 
79
>&#13;      One of the large changes for 2.16 was the templatisation of the
 
80
      entire user-facing UI, using the 
 
81
      <A
 
82
HREF="http://www.template-toolkit.org"
 
83
TARGET="_top"
 
84
>Template Toolkit</A
 
85
>.
 
86
      Administrators can now configure the look and feel of Bugzilla without
 
87
      having to edit Perl files or face the nightmare of massive merge
 
88
      conflicts when they upgrade to a newer version in the future.
 
89
    </P
 
90
><P
 
91
>&#13;      Templatisation also makes localised versions of Bugzilla possible, 
 
92
      for the first time. In the future, a Bugzilla installation may
 
93
      have templates installed for multiple localisations, and select
 
94
      which ones to use based on the user's browser language setting.      
 
95
    </P
 
96
><DIV
 
97
CLASS="section"
 
98
><H2
 
99
CLASS="section"
 
100
><A
 
101
NAME="AEN1534"
 
102
></A
 
103
>5.7.1. What to Edit</H2
 
104
><P
 
105
>&#13;        There are two different ways of editing of Bugzilla's templates,
 
106
        and which you use depends mainly on how you upgrade Bugzilla. The
 
107
        template directory structure is that there's a top level directory,
 
108
        <TT
 
109
CLASS="filename"
 
110
>template</TT
 
111
>, which contains a directory for
 
112
        each installed localisation. The default English templates are
 
113
        therefore in <TT
 
114
CLASS="filename"
 
115
>en</TT
 
116
>. Underneath that, there
 
117
        is the <TT
 
118
CLASS="filename"
 
119
>default</TT
 
120
> directory and optionally the 
 
121
        <TT
 
122
CLASS="filename"
 
123
>custom</TT
 
124
> directory. The <TT
 
125
CLASS="filename"
 
126
>default</TT
 
127
>
 
128
        directory contains all the templates shipped with Bugzilla, whereas
 
129
        the <TT
 
130
CLASS="filename"
 
131
>custom</TT
 
132
> directory does not exist at first and
 
133
        must be created if you want to use it.
 
134
      </P
 
135
><P
 
136
>&#13;        The first method of making customisations is to directly edit the
 
137
        templates in <TT
 
138
CLASS="filename"
 
139
>template/en/default</TT
 
140
>. This is
 
141
        probably the best method for small changes if you are going to use
 
142
        the CVS method of upgrading, because if you then execute a
 
143
        <B
 
144
CLASS="command"
 
145
>cvs update</B
 
146
>, any template fixes will get
 
147
        automagically merged into your modified versions.
 
148
      </P
 
149
><P
 
150
>&#13;        If you use this method, your installation will break if CVS conflicts
 
151
        occur.
 
152
      </P
 
153
><P
 
154
>&#13;        The other method is to copy the templates into a mirrored directory
 
155
        structure under <TT
 
156
CLASS="filename"
 
157
>template/en/custom</TT
 
158
>.  The templates
 
159
        in this directory automatically override those in default.  
 
160
        This is the technique you
 
161
        need to use if you use the overwriting method of upgrade, because
 
162
        otherwise your changes will be lost.  This method is also better if
 
163
        you are using the CVS method of upgrading and are going to make major
 
164
        changes, because it is guaranteed that the contents of this directory
 
165
        will not be touched during an upgrade, and you can then decide whether
 
166
        to continue using your own templates, or make the effort to merge your
 
167
        changes into the new versions by hand.
 
168
      </P
 
169
><P
 
170
>&#13;        If you use this method, your installation may break if incompatible
 
171
        changes are made to the template interface.  If such changes are made
 
172
        they will be documented in the release notes, provided you are using a
 
173
        stable release of Bugzilla.  If you use using unstable code, you will
 
174
        need to deal with this one yourself, although if possible the changes
 
175
        will be mentioned before they occur in the deprecations section of the
 
176
        previous stable release's release notes.
 
177
      </P
 
178
><DIV
 
179
CLASS="note"
 
180
><P
 
181
></P
 
182
><TABLE
 
183
CLASS="note"
 
184
WIDTH="100%"
 
185
BORDER="0"
 
186
><TR
 
187
><TD
 
188
WIDTH="25"
 
189
ALIGN="CENTER"
 
190
VALIGN="TOP"
 
191
><IMG
 
192
SRC="../images/note.gif"
 
193
HSPACE="5"
 
194
ALT="Note"></TD
 
195
><TD
 
196
ALIGN="LEFT"
 
197
VALIGN="TOP"
 
198
><P
 
199
>&#13;          Don't directly edit the compiled templates in 
 
200
          <TT
 
201
CLASS="filename"
 
202
>data/template/*</TT
 
203
> - your
 
204
          changes will be lost when Template Toolkit recompiles them.
 
205
        </P
 
206
></TD
 
207
></TR
 
208
></TABLE
 
209
></DIV
 
210
><DIV
 
211
CLASS="note"
 
212
><P
 
213
></P
 
214
><TABLE
 
215
CLASS="note"
 
216
WIDTH="100%"
 
217
BORDER="0"
 
218
><TR
 
219
><TD
 
220
WIDTH="25"
 
221
ALIGN="CENTER"
 
222
VALIGN="TOP"
 
223
><IMG
 
224
SRC="../images/note.gif"
 
225
HSPACE="5"
 
226
ALT="Note"></TD
 
227
><TD
 
228
ALIGN="LEFT"
 
229
VALIGN="TOP"
 
230
><P
 
231
>It is recommended that you run <B
 
232
CLASS="command"
 
233
>./checksetup.pl</B
 
234
>
 
235
        after any template edits, especially if you've created a new file in
 
236
        the <TT
 
237
CLASS="filename"
 
238
>custom</TT
 
239
> directory.
 
240
        </P
 
241
></TD
 
242
></TR
 
243
></TABLE
 
244
></DIV
 
245
></DIV
 
246
><DIV
 
247
CLASS="section"
 
248
><H2
 
249
CLASS="section"
 
250
><A
 
251
NAME="AEN1557"
 
252
></A
 
253
>5.7.2. How To Edit Templates</H2
 
254
><P
 
255
>&#13;        The syntax of the Template Toolkit language is beyond the scope of
 
256
        this guide. It's reasonably easy to pick up by looking at the current 
 
257
        templates; or, you can read the manual, available on the
 
258
        <A
 
259
HREF="http://www.template-toolkit.org"
 
260
TARGET="_top"
 
261
>Template Toolkit home
 
262
        page</A
 
263
>. However, you should particularly remember (for security
 
264
        reasons) to always HTML filter things which come from the database or
 
265
        user input, to prevent cross-site scripting attacks.
 
266
      </P
 
267
><P
 
268
>&#13;        However, one thing you should take particular care about is the need
 
269
        to properly HTML filter data that has been passed into the template.
 
270
        This means that if the data can possibly contain special HTML characters
 
271
        such as &#60;, and the data was not intended to be HTML, they need to be
 
272
        converted to entity form, ie &#38;lt;.  You use the 'html' filter in the
 
273
        Template Toolkit to do this.  If you fail to do this, you may open up
 
274
        your installation to cross-site scripting attacks.
 
275
      </P
 
276
><P
 
277
>&#13;        Also note that Bugzilla adds a few filters of its own, that are not
 
278
        in standard Template Toolkit.  In particular, the 'url_quote' filter
 
279
        can convert characters that are illegal or have special meaning in URLs,
 
280
        such as &#38;, to the encoded form, ie %26.  This actually encodes most
 
281
        characters (but not the common ones such as letters and numbers and so
 
282
        on), including the HTML-special characters, so there's never a need to
 
283
        HTML filter afterwards.
 
284
      </P
 
285
><P
 
286
>&#13;        Editing templates is a good way of doing a "poor man's custom fields".
 
287
        For example, if you don't use the Status Whiteboard, but want to have
 
288
        a free-form text entry box for "Build Identifier", then you can just
 
289
        edit the templates to change the field labels. It's still be called
 
290
        status_whiteboard internally, but your users don't need to know that.
 
291
      </P
 
292
><DIV
 
293
CLASS="note"
 
294
><P
 
295
></P
 
296
><TABLE
 
297
CLASS="note"
 
298
WIDTH="100%"
 
299
BORDER="0"
 
300
><TR
 
301
><TD
 
302
WIDTH="25"
 
303
ALIGN="CENTER"
 
304
VALIGN="TOP"
 
305
><IMG
 
306
SRC="../images/note.gif"
 
307
HSPACE="5"
 
308
ALT="Note"></TD
 
309
><TD
 
310
ALIGN="LEFT"
 
311
VALIGN="TOP"
 
312
><P
 
313
>&#13;          If you are making template changes that you intend on submitting back
 
314
          for inclusion in standard Bugzilla, you should read the relevant
 
315
          sections of the 
 
316
          <A
 
317
HREF="http://www.bugzilla.org/developerguide.html"
 
318
TARGET="_top"
 
319
>Developers'
 
320
          Guide</A
 
321
>.
 
322
        </P
 
323
></TD
 
324
></TR
 
325
></TABLE
 
326
></DIV
 
327
></DIV
 
328
><DIV
 
329
CLASS="section"
 
330
><H2
 
331
CLASS="section"
 
332
><A
 
333
NAME="AEN1567"
 
334
></A
 
335
>5.7.3. Template Formats</H2
 
336
><P
 
337
>&#13;        Some CGIs have the ability to use more than one template. For
 
338
        example, buglist.cgi can output bug lists as RDF or two
 
339
        different forms of HTML (complex and simple). (Try this out
 
340
        by appending <TT
 
341
CLASS="filename"
 
342
>&#38;format=simple</TT
 
343
> to a buglist.cgi
 
344
        URL on your Bugzilla installation.) This
 
345
        mechanism, called template 'formats', is extensible.
 
346
      </P
 
347
><P
 
348
>&#13;        To see if a CGI supports multiple output formats, grep the
 
349
        CGI for "ValidateOutputFormat". If it's not present, adding
 
350
        multiple format support isn't too hard - see how it's done in
 
351
        other CGIs.
 
352
      </P
 
353
><P
 
354
>&#13;        To make a new format template for a CGI which supports this, 
 
355
        open a current template for
 
356
        that CGI and take note of the INTERFACE comment (if present.) This 
 
357
        comment defines what variables are passed into this template. If 
 
358
        there isn't one, I'm afraid you'll have to read the template and
 
359
        the code to find out what information you get. 
 
360
      </P
 
361
><P
 
362
>&#13;        Write your template in whatever markup or text style is appropriate.
 
363
      </P
 
364
><P
 
365
>&#13;        You now need to decide what content type you want your template
 
366
        served as. Open up the <TT
 
367
CLASS="filename"
 
368
>localconfig</TT
 
369
> file and find the 
 
370
        <TT
 
371
CLASS="filename"
 
372
>$contenttypes</TT
 
373
>
 
374
        variable. If your content type is not there, add it. Remember
 
375
        the three- or four-letter tag assigned to you content type. 
 
376
        This tag will be part of the template filename.
 
377
      </P
 
378
><P
 
379
>&#13;        Save the template as <TT
 
380
CLASS="filename"
 
381
>&#60;stubname&#62;-&#60;formatname&#62;.&#60;contenttypetag&#62;.tmpl</TT
 
382
>. 
 
383
        Try out the template by calling the CGI as 
 
384
        <TT
 
385
CLASS="filename"
 
386
>&#60;cginame&#62;.cgi?format=&#60;formatname&#62;</TT
 
387
> .
 
388
      </P
 
389
></DIV
 
390
><DIV
 
391
CLASS="section"
 
392
><H2
 
393
CLASS="section"
 
394
><A
 
395
NAME="AEN1580"
 
396
></A
 
397
>5.7.4. Particular Templates</H2
 
398
><P
 
399
>&#13;        There are a few templates you may be particularly interested in
 
400
        customising for your installation.
 
401
      </P
 
402
><P
 
403
>&#13;        <B
 
404
CLASS="command"
 
405
>index.html.tmpl</B
 
406
>:
 
407
        This is the Bugzilla front page.
 
408
      </P
 
409
><P
 
410
>&#13;        <B
 
411
CLASS="command"
 
412
>global/header.html.tmpl</B
 
413
>:
 
414
        This defines the header that goes on all Bugzilla pages.
 
415
        The header includes the banner, which is what appears to users
 
416
        and is probably what you want to edit instead.  However the
 
417
        header also includes the HTML HEAD section, so you could for
 
418
        example add a stylesheet or META tag by editing the header.
 
419
      </P
 
420
><P
 
421
>&#13;        <B
 
422
CLASS="command"
 
423
>global/banner.html.tmpl</B
 
424
>:
 
425
        This contains the "banner", the part of the header that appears
 
426
        at the top of all Bugzilla pages.  The default banner is reasonably
 
427
        barren, so you'll probably want to customise this to give your
 
428
        installation a distinctive look and feel.  It is recommended you
 
429
        preserve the Bugzilla version number in some form so the version 
 
430
        you are running can be determined, and users know what docs to read.
 
431
      </P
 
432
><P
 
433
>&#13;        <B
 
434
CLASS="command"
 
435
>global/footer.html.tmpl</B
 
436
>:
 
437
        This defines the footer that goes on all Bugzilla pages.  Editing
 
438
        this is another way to quickly get a distinctive look and feel for
 
439
        your Bugzilla installation.
 
440
      </P
 
441
><P
 
442
>&#13;        <B
 
443
CLASS="command"
 
444
>bug/create/user-message.html.tmpl</B
 
445
>:
 
446
        This is a message that appears near the top of the bug reporting page.
 
447
        By modifying this, you can tell your users how they should report
 
448
        bugs.
 
449
      </P
 
450
><P
 
451
>&#13;        <B
 
452
CLASS="command"
 
453
>bug/create/create.html.tmpl</B
 
454
> and
 
455
        <B
 
456
CLASS="command"
 
457
>bug/create/comment.txt.tmpl</B
 
458
>:
 
459
        You may wish to get bug submitters to give certain bits of structured
 
460
        information, each in a separate input widget, for which there is not a
 
461
        field in the database. The bug entry system has been designed in an
 
462
        extensible fashion to enable you to define arbitrary fields and widgets,
 
463
        and have their values appear formatted in the initial
 
464
        Description, rather than in database fields. An example of this
 
465
        is the mozilla.org 
 
466
        <A
 
467
HREF="http://bugzilla.mozilla.org/enter_bug.cgi?format=guided"
 
468
TARGET="_top"
 
469
>guided 
 
470
        bug submission form</A
 
471
>.
 
472
      </P
 
473
><P
 
474
>&#13;        To make this work, create a custom template for 
 
475
        <TT
 
476
CLASS="filename"
 
477
>enter_bug.cgi</TT
 
478
> (the default template, on which you
 
479
        could base it, is <TT
 
480
CLASS="filename"
 
481
>create.html.tmpl</TT
 
482
>),
 
483
        and either call it <TT
 
484
CLASS="filename"
 
485
>create.html.tmpl</TT
 
486
> or use a format and
 
487
        call it <TT
 
488
CLASS="filename"
 
489
>create-&#60;formatname&#62;.html.tmpl</TT
 
490
>.
 
491
        Put it in the <TT
 
492
CLASS="filename"
 
493
>custom/bug/create</TT
 
494
>
 
495
        directory. In it, add widgets for each piece of information you'd like
 
496
        collected - such as a build number, or set of steps to reproduce.
 
497
      </P
 
498
><P
 
499
>&#13;        Then, create a template like 
 
500
        <TT
 
501
CLASS="filename"
 
502
>custom/bug/create/comment.txt.tmpl</TT
 
503
>, also named
 
504
        after your format if you are using one, which
 
505
        references the form fields you have created. When a bug report is
 
506
        submitted, the initial comment attached to the bug report will be
 
507
        formatted according to the layout of this template.
 
508
      </P
 
509
><P
 
510
>&#13;        For example, if your enter_bug template had a field
 
511
        <TABLE
 
512
BORDER="0"
 
513
BGCOLOR="#E0E0E0"
 
514
WIDTH="100%"
 
515
><TR
 
516
><TD
 
517
><FONT
 
518
COLOR="#000000"
 
519
><PRE
 
520
CLASS="programlisting"
 
521
>&#60;input type="text" name="buildid" size="30"&#62;</PRE
 
522
></FONT
 
523
></TD
 
524
></TR
 
525
></TABLE
 
526
>
 
527
        and then your comment.txt.tmpl had
 
528
        <TABLE
 
529
BORDER="0"
 
530
BGCOLOR="#E0E0E0"
 
531
WIDTH="100%"
 
532
><TR
 
533
><TD
 
534
><FONT
 
535
COLOR="#000000"
 
536
><PRE
 
537
CLASS="programlisting"
 
538
>BuildID: [% form.buildid %]</PRE
 
539
></FONT
 
540
></TD
 
541
></TR
 
542
></TABLE
 
543
>
 
544
        then
 
545
        <TABLE
 
546
BORDER="0"
 
547
BGCOLOR="#E0E0E0"
 
548
WIDTH="100%"
 
549
><TR
 
550
><TD
 
551
><FONT
 
552
COLOR="#000000"
 
553
><PRE
 
554
CLASS="programlisting"
 
555
>BuildID: 20020303</PRE
 
556
></FONT
 
557
></TD
 
558
></TR
 
559
></TABLE
 
560
>
 
561
        would appear in the initial checkin comment.
 
562
      </P
 
563
></DIV
 
564
></DIV
 
565
><DIV
 
566
CLASS="NAVFOOTER"
 
567
><HR
 
568
ALIGN="LEFT"
 
569
WIDTH="100%"><TABLE
 
570
SUMMARY="Footer navigation table"
 
571
WIDTH="100%"
 
572
BORDER="0"
 
573
CELLPADDING="0"
 
574
CELLSPACING="0"
 
575
><TR
 
576
><TD
 
577
WIDTH="33%"
 
578
ALIGN="left"
 
579
VALIGN="top"
 
580
><A
 
581
HREF="security.html"
 
582
ACCESSKEY="P"
 
583
>Prev</A
 
584
></TD
 
585
><TD
 
586
WIDTH="34%"
 
587
ALIGN="center"
 
588
VALIGN="top"
 
589
><A
 
590
HREF="index.html"
 
591
ACCESSKEY="H"
 
592
>Home</A
 
593
></TD
 
594
><TD
 
595
WIDTH="33%"
 
596
ALIGN="right"
 
597
VALIGN="top"
 
598
><A
 
599
HREF="upgrading.html"
 
600
ACCESSKEY="N"
 
601
>Next</A
 
602
></TD
 
603
></TR
 
604
><TR
 
605
><TD
 
606
WIDTH="33%"
 
607
ALIGN="left"
 
608
VALIGN="top"
 
609
>Bugzilla Security</TD
 
610
><TD
 
611
WIDTH="34%"
 
612
ALIGN="center"
 
613
VALIGN="top"
 
614
><A
 
615
HREF="administration.html"
 
616
ACCESSKEY="U"
 
617
>Up</A
 
618
></TD
 
619
><TD
 
620
WIDTH="33%"
 
621
ALIGN="right"
 
622
VALIGN="top"
 
623
>Upgrading to New Releases</TD
 
624
></TR
 
625
></TABLE
 
626
></DIV
 
627
></BODY
 
628
></HTML
 
629
>
 
 
b'\\ No newline at end of file'