Mercurial > p > roundup > code
comparison doc/customizing.txt @ 1125:3c1533be3822
more doc
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 12 Sep 2002 03:57:09 +0000 |
| parents | 1fc1f92c5f31 |
| children | 36ec30d286ea |
comparison
equal
deleted
inserted
replaced
| 1124:1fc1f92c5f31 | 1125:3c1533be3822 |
|---|---|
| 1 =================== | 1 =================== |
| 2 Customising Roundup | 2 Customising Roundup |
| 3 =================== | 3 =================== |
| 4 | 4 |
| 5 :Version: $Revision: 1.30 $ | 5 :Version: $Revision: 1.31 $ |
| 6 | 6 |
| 7 .. This document borrows from the ZopeBook section on ZPT. The original is at: | 7 .. This document borrows from the ZopeBook section on ZPT. The original is at: |
| 8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx | 8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx |
| 9 | 9 |
| 10 .. contents:: | 10 .. contents:: |
| 11 | 11 :depth: 1 |
| 12 | 12 |
| 13 What You Can Do | 13 What You Can Do |
| 14 =============== | 14 =============== |
| 15 | 15 |
| 16 Customisation of Roundup can take one of five forms: | 16 Customisation of Roundup can take one of five forms: |
| 434 XXX example | 434 XXX example |
| 435 | 435 |
| 436 | 436 |
| 437 Web Interface | 437 Web Interface |
| 438 ============= | 438 ============= |
| 439 | |
| 440 .. contents:: | |
| 441 :local: | |
| 442 :depth: 1 | |
| 439 | 443 |
| 440 The web is provided by the roundup.cgi.client module and is used by | 444 The web is provided by the roundup.cgi.client module and is used by |
| 441 roundup.cgi, roundup-server and ZRoundup. | 445 roundup.cgi, roundup-server and ZRoundup. |
| 442 In all cases, we determine which tracker is being accessed | 446 In all cases, we determine which tracker is being accessed |
| 443 (the first part of the URL path inside the scope of the CGI handler) and pass | 447 (the first part of the URL path inside the scope of the CGI handler) and pass |
| 534 When a user requests a web page, they may optionally also request for an | 538 When a user requests a web page, they may optionally also request for an |
| 535 action to take place. As described in `how requests are processed`_, the | 539 action to take place. As described in `how requests are processed`_, the |
| 536 action is performed before the requested page is generated. Actions are | 540 action is performed before the requested page is generated. Actions are |
| 537 triggered by using a ``:action`` CGI variable, where the value is one of: | 541 triggered by using a ``:action`` CGI variable, where the value is one of: |
| 538 | 542 |
| 539 login | 543 **login** |
| 540 Attempt to log a user in. | 544 Attempt to log a user in. |
| 541 logout | 545 **logout** |
| 542 Log the user out - make them "anonymous". | 546 Log the user out - make them "anonymous". |
| 543 register | 547 **register** |
| 544 Attempt to create a new user based on the contents of the form and then log | 548 Attempt to create a new user based on the contents of the form and then log |
| 545 them in. | 549 them in. |
| 546 edit | 550 **edit** |
| 547 Perform an edit of an item in the database. There are some special form | 551 Perform an edit of an item in the database. There are some special form |
| 548 elements you may use: | 552 elements you may use: |
| 549 | 553 |
| 550 :link=designator:property and :multilink=designator:property | 554 :link=designator:property and :multilink=designator:property |
| 551 The value specifies an item designator and the property on that | 555 The value specifies an item designator and the property on that |
| 558 "files" property. Attach the file to the message created from | 562 "files" property. Attach the file to the message created from |
| 559 the :note if it's supplied. | 563 the :note if it's supplied. |
| 560 :required=property,property,... | 564 :required=property,property,... |
| 561 The named properties are required to be filled in the form. | 565 The named properties are required to be filled in the form. |
| 562 | 566 |
| 563 new | 567 **new** |
| 564 Add a new item to the database. You may use the same special form elements | 568 Add a new item to the database. You may use the same special form elements |
| 565 as in the "edit" action. | 569 as in the "edit" action. |
| 566 | 570 |
| 567 editCSV | 571 **editCSV** |
| 568 Performs an edit of all of a class' items in one go. See also the | 572 Performs an edit of all of a class' items in one go. See also the |
| 569 *class*.csv templating method which generates the CSV data to be edited, and | 573 *class*.csv templating method which generates the CSV data to be edited, and |
| 570 the "_generic.index" template which uses both of these features. | 574 the "_generic.index" template which uses both of these features. |
| 571 | 575 |
| 572 search | 576 **search** |
| 573 Mangle some of the form variables. | 577 Mangle some of the form variables. |
| 574 | 578 |
| 575 Set the form ":filter" variable based on the values of the | 579 Set the form ":filter" variable based on the values of the |
| 576 filter variables - if they're set to anything other than | 580 filter variables - if they're set to anything other than |
| 577 "dontcare" then add them to :filter. | 581 "dontcare" then add them to :filter. |
| 588 Each action also has a corresponding *actionPermission* (where | 592 Each action also has a corresponding *actionPermission* (where |
| 589 "action" is the name of the action) method which determines | 593 "action" is the name of the action) method which determines |
| 590 whether the action is permissible given the current user. The base permission | 594 whether the action is permissible given the current user. The base permission |
| 591 checks are: | 595 checks are: |
| 592 | 596 |
| 593 login | 597 **login** |
| 594 Determine whether the user has permission to log in. | 598 Determine whether the user has permission to log in. |
| 595 Base behaviour is to check the user has "Web Access". | 599 Base behaviour is to check the user has "Web Access". |
| 596 logout | 600 **logout** |
| 597 No permission checks are made. | 601 No permission checks are made. |
| 598 register | 602 **register** |
| 599 Determine whether the user has permission to register | 603 Determine whether the user has permission to register |
| 600 Base behaviour is to check the user has "Web Registration". | 604 Base behaviour is to check the user has "Web Registration". |
| 601 edit | 605 **edit** |
| 602 Determine whether the user has permission to edit this item. | 606 Determine whether the user has permission to edit this item. |
| 603 Base behaviour is to check the user can edit this class. If we're | 607 Base behaviour is to check the user can edit this class. If we're |
| 604 editing the "user" class, users are allowed to edit their own | 608 editing the "user" class, users are allowed to edit their own |
| 605 details. Unless it's the "roles" property, which requires the | 609 details. Unless it's the "roles" property, which requires the |
| 606 special Permission "Web Roles". | 610 special Permission "Web Roles". |
| 607 new | 611 **new** |
| 608 Determine whether the user has permission to create (edit) this item. | 612 Determine whether the user has permission to create (edit) this item. |
| 609 Base behaviour is to check the user can edit this class. No | 613 Base behaviour is to check the user can edit this class. No |
| 610 additional property checks are made. Additionally, new user items | 614 additional property checks are made. Additionally, new user items |
| 611 may be created if the user has the "Web Registration" Permission. | 615 may be created if the user has the "Web Registration" Permission. |
| 612 editCSV | 616 **editCSV** |
| 613 Determine whether the user has permission to edit this class. | 617 Determine whether the user has permission to edit this class. |
| 614 Base behaviour is to check the user can edit this class. | 618 Base behaviour is to check the user can edit this class. |
| 615 search | 619 **search** |
| 616 Determine whether the user has permission to search this class. | 620 Determine whether the user has permission to search this class. |
| 617 Base behaviour is to check the user can view this class. | 621 Base behaviour is to check the user can view this class. |
| 618 | 622 |
| 619 | 623 |
| 620 Default templates | 624 Default templates |
| 621 ----------------- | 625 ----------------- |
| 622 | 626 |
| 623 Most customisation of the web view can be done by modifying the templates in | 627 Most customisation of the web view can be done by modifying the templates in |
| 624 the tracker **html** directory. There are several types of files in there: | 628 the tracker **html** directory. There are several types of files in there: |
| 625 | 629 |
| 626 page | 630 **page** |
| 627 This template defines the overall look of your tracker. When you | 631 This template defines the overall look of your tracker. When you |
| 628 view an issue, it appears inside this template. When you view an index, it | 632 view an issue, it appears inside this template. When you view an index, it |
| 629 also appears inside this template. It will have a ``tal:content`` or | 633 also appears inside this template. It will have a ``tal:content`` or |
| 630 ``tal:replace`` command with the expression ``structure content`` which | 634 ``tal:replace`` command with the expression ``structure content`` which |
| 631 will show the issue, list of issues or whatever. | 635 will show the issue, list of issues or whatever. |
| 632 home | 636 **home** |
| 633 the default page displayed when no other page is indicated by the user | 637 the default page displayed when no other page is indicated by the user |
| 634 home.classlist | 638 **home.classlist** |
| 635 a special version of the default page that lists the classes in the tracker | 639 a special version of the default page that lists the classes in the tracker |
| 636 *classname*.item | 640 **classname.item** |
| 637 displays an item of the *classname* class | 641 displays an item of the *classname* class |
| 638 *classname*.index | 642 **classname.index** |
| 639 displays a list of *classname* items | 643 displays a list of *classname* items |
| 640 *classname*.search | 644 **classname.search** |
| 641 displays a search page for *classname* items | 645 displays a search page for *classname* items |
| 642 _generic.index | 646 **_generic.index** |
| 643 used to display a list of items where there is no *classname*.index available | 647 used to display a list of items where there is no *classname*.index available |
| 644 _generic.help | 648 **_generic.help** |
| 645 used to display a "class help" page where there is no *classname*.help | 649 used to display a "class help" page where there is no *classname*.help |
| 646 user.register | 650 **user.register** |
| 647 a special page just for the user class that renders the registration page | 651 a special page just for the user class that renders the registration page |
| 648 style.css | 652 **style.css** |
| 649 a static file that is served up as-is | 653 a static file that is served up as-is |
| 650 | 654 |
| 651 How the templates work | 655 How the templates work |
| 652 ---------------------- | 656 ---------------------- |
| 653 | 657 |
| 654 Roundup's templates consist of special attributes on your template tags. These | 658 Roundup's templates consist of special attributes on your template tags. These |
| 655 attributes form the Template Attribute Language, or TAL. The commands are: | 659 attributes form the Template Attribute Language, or TAL. The commands are: |
| 656 | 660 |
| 657 | 661 |
| 658 tal:define="variable expression; variable expression; ..." | 662 **tal:define="variable expression; variable expression; ..."** |
| 659 Define a new variable that is local to this tag and its contents. For | 663 Define a new variable that is local to this tag and its contents. For |
| 660 example:: | 664 example:: |
| 661 | 665 |
| 662 <html tal:define="title request/description"> | 666 <html tal:define="title request/description"> |
| 663 <head><title tal:content="title"></title></head> | 667 <head><title tal:content="title"></title></head> |
| 665 | 669 |
| 666 In the example, the variable "title" is defined as being the result of the | 670 In the example, the variable "title" is defined as being the result of the |
| 667 expression "request/description". The tal:content command inside the <html> | 671 expression "request/description". The tal:content command inside the <html> |
| 668 tag may then use the "title" variable. | 672 tag may then use the "title" variable. |
| 669 | 673 |
| 670 tal:condition="expression" | 674 **tal:condition="expression"** |
| 671 Only keep this tag and its contents if the expression is true. For example:: | 675 Only keep this tag and its contents if the expression is true. For example:: |
| 672 | 676 |
| 673 <p tal:condition="python:request.user.hasPermission('View', 'issue')"> | 677 <p tal:condition="python:request.user.hasPermission('View', 'issue')"> |
| 674 Display some issue information. | 678 Display some issue information. |
| 675 </p> | 679 </p> |
| 678 user has the View permission for issues. We consider the number zero, a | 682 user has the View permission for issues. We consider the number zero, a |
| 679 blank string, an empty list, and the built-in variable nothing to be false | 683 blank string, an empty list, and the built-in variable nothing to be false |
| 680 values. Nearly every other value is true, including non-zero numbers, and | 684 values. Nearly every other value is true, including non-zero numbers, and |
| 681 strings with anything in them (even spaces!). | 685 strings with anything in them (even spaces!). |
| 682 | 686 |
| 683 tal:repeat="variable expression" | 687 **tal:repeat="variable expression"** |
| 684 Repeat this tag and its contents for each element of the sequence that the | 688 Repeat this tag and its contents for each element of the sequence that the |
| 685 expression returns, defining a new local variable and a special "repeat" | 689 expression returns, defining a new local variable and a special "repeat" |
| 686 variable for each element. For example:: | 690 variable for each element. For example:: |
| 687 | 691 |
| 688 <tr tal:repeat="u user/list"> | 692 <tr tal:repeat="u user/list"> |
| 692 </tr> | 696 </tr> |
| 693 | 697 |
| 694 The example would iterate over the sequence of users returned by | 698 The example would iterate over the sequence of users returned by |
| 695 "user/list" and define the local variable "u" for each entry. | 699 "user/list" and define the local variable "u" for each entry. |
| 696 | 700 |
| 697 tal:replace="expression" | 701 **tal:replace="expression"** |
| 698 Replace this tag with the result of the expression. For example:: | 702 Replace this tag with the result of the expression. For example:: |
| 699 | 703 |
| 700 <span tal:replace="request/user/realname"></span> | 704 <span tal:replace="request/user/realname"></span> |
| 701 | 705 |
| 702 The example would replace the <span> tag and its contents with the user's | 706 The example would replace the <span> tag and its contents with the user's |
| 703 realname. If the user's realname was "Bruce" then the resultant output | 707 realname. If the user's realname was "Bruce" then the resultant output |
| 704 would be "Bruce". | 708 would be "Bruce". |
| 705 | 709 |
| 706 tal:content="expression" | 710 **tal:content="expression"** |
| 707 Replace the contents of this tag with the result of the expression. For | 711 Replace the contents of this tag with the result of the expression. For |
| 708 example:: | 712 example:: |
| 709 | 713 |
| 710 <span tal:content="request/user/realname">user's name appears here</span> | 714 <span tal:content="request/user/realname">user's name appears here</span> |
| 711 | 715 |
| 712 The example would replace the contents of the <span> tag with the user's | 716 The example would replace the contents of the <span> tag with the user's |
| 713 realname. If the user's realname was "Bruce" then the resultant output | 717 realname. If the user's realname was "Bruce" then the resultant output |
| 714 would be "<span>Bruce</span>". | 718 would be "<span>Bruce</span>". |
| 715 | 719 |
| 716 tal:attributes="attribute expression; attribute expression; ..." | 720 **tal:attributes="attribute expression; attribute expression; ..."** |
| 717 Set attributes on this tag to the results of expressions. For example:: | 721 Set attributes on this tag to the results of expressions. For example:: |
| 718 | 722 |
| 719 <a tal:attributes="href string:user${request/user/id}">My Details</a> | 723 <a tal:attributes="href string:user${request/user/id}">My Details</a> |
| 720 | 724 |
| 721 In the example, the "href" attribute of the <a> tag is set to the value of | 725 In the example, the "href" attribute of the <a> tag is set to the value of |
| 722 the "string:user${request/user/id}" expression, which will be something | 726 the "string:user${request/user/id}" expression, which will be something |
| 723 like "user123". | 727 like "user123". |
| 724 | 728 |
| 725 tal:omit-tag="expression" | 729 **tal:omit-tag="expression"** |
| 726 Remove this tag (but not its contents) if the expression is true. For | 730 Remove this tag (but not its contents) if the expression is true. For |
| 727 example:: | 731 example:: |
| 728 | 732 |
| 729 <span tal:omit-tag="python:1">Hello, world!</span> | 733 <span tal:omit-tag="python:1">Hello, world!</span> |
| 730 | 734 |
| 742 which would othewise require an illegal tag placement to effect the repeat). | 746 which would othewise require an illegal tag placement to effect the repeat). |
| 743 | 747 |
| 744 The expressions you may use in the attibute values may be one of the following | 748 The expressions you may use in the attibute values may be one of the following |
| 745 three forms: | 749 three forms: |
| 746 | 750 |
| 747 Path Expressions - eg. ``item/status/checklist`` | 751 **Path Expressions** - eg. ``item/status/checklist`` |
| 748 These are object attribute / item accesses. Roughly speaking, the path | 752 These are object attribute / item accesses. Roughly speaking, the path |
| 749 ``item/status/checklist`` is broken into parts ``item``, ``status`` | 753 ``item/status/checklist`` is broken into parts ``item``, ``status`` |
| 750 and ``checklist``. The ``item`` part is the root of the expression. | 754 and ``checklist``. The ``item`` part is the root of the expression. |
| 751 We then look for a ``status`` attribute on ``item``, or failing that, a | 755 We then look for a ``status`` attribute on ``item``, or failing that, a |
| 752 ``status`` item (as in ``item['status']``). If that | 756 ``status`` item (as in ``item['status']``). If that |
| 757 | 761 |
| 758 XXX | components of expressions | 762 XXX | components of expressions |
| 759 | 763 |
| 760 XXX "nothing" and "default" | 764 XXX "nothing" and "default" |
| 761 | 765 |
| 762 String Expressions - eg. ``string:hello ${user/name}`` | 766 **String Expressions** - eg. ``string:hello ${user/name}`` |
| 763 These expressions are simple string interpolations (though they can be just | 767 These expressions are simple string interpolations (though they can be just |
| 764 plain strings with no interpolation if you want. The expression in the | 768 plain strings with no interpolation if you want. The expression in the |
| 765 ``${ ... }`` is just a path expression as above. | 769 ``${ ... }`` is just a path expression as above. |
| 766 | 770 |
| 767 Python Expressions - eg. ``python: 1+1`` | 771 **Python Expressions** - eg. ``python: 1+1`` |
| 768 These expressions give the full power of Python. All the "root level" | 772 These expressions give the full power of Python. All the "root level" |
| 769 variables are available, so ``python:item.status.checklist()`` would be | 773 variables are available, so ``python:item.status.checklist()`` would be |
| 770 equivalent to ``item/status/checklist``, assuming that ``checklist`` is | 774 equivalent to ``item/status/checklist``, assuming that ``checklist`` is |
| 771 a method. | 775 a method. |
| 772 | 776 |
| 773 Information available to templates | 777 Information available to templates |
| 774 ---------------------------------- | 778 ---------------------------------- |
| 775 | 779 |
| 780 Note: this is implemented by roundup.cgi.templating.RoundupPageTemplate | |
| 781 | |
| 776 The following variables are available to templates. | 782 The following variables are available to templates. |
| 777 | 783 |
| 778 .. taken from roundup.cgi.templating.RoundupPageTemplate docstring | 784 **context** |
| 779 | |
| 780 *context* | |
| 781 The current context. This is either None, a | 785 The current context. This is either None, a |
| 782 `hyperdb class wrapper`_ or a `hyperdb item wrapper`_ | 786 `hyperdb class wrapper`_ or a `hyperdb item wrapper`_ |
| 783 *request* | 787 **request** |
| 784 Includes information about the current request, including: | 788 Includes information about the current request, including: |
| 785 - the url | 789 - the url |
| 786 - the current index information (``filterspec``, ``filter`` args, | 790 - the current index information (``filterspec``, ``filter`` args, |
| 787 ``properties``, etc) parsed out of the form. | 791 ``properties``, etc) parsed out of the form. |
| 788 - methods for easy filterspec link generation | 792 - methods for easy filterspec link generation |
| 789 - *user*, the current user item as an HTMLItem instance | 793 - *user*, the current user item as an HTMLItem instance |
| 790 - *form* | 794 - *form* |
| 791 The current CGI form information as a mapping of form argument | 795 The current CGI form information as a mapping of form argument |
| 792 name to value | 796 name to value |
| 793 *tracker* | 797 **tracker** |
| 794 The current tracker | 798 The current tracker |
| 795 *db* | 799 **db** |
| 796 The current database, through which db.config may be reached. | 800 The current database, through which db.config may be reached. |
| 797 *nothing* | 801 **nothing** |
| 798 This is a special variable - if an expression evaluates to this, then the | 802 This is a special variable - if an expression evaluates to this, then the |
| 799 tag (in the case of a tal:replace), its contents (in the case of | 803 tag (in the case of a tal:replace), its contents (in the case of |
| 800 tal:content) or some attributes (in the case of tal:attributes) will not | 804 tal:content) or some attributes (in the case of tal:attributes) will not |
| 801 appear in the the output. So for example:: | 805 appear in the the output. So for example:: |
| 802 | 806 |
| 804 | 808 |
| 805 would result in:: | 809 would result in:: |
| 806 | 810 |
| 807 <span>Hello, World!</span> | 811 <span>Hello, World!</span> |
| 808 | 812 |
| 809 *default* | 813 **default** |
| 810 Also a special variable - if an expression evaluates to this, then the | 814 Also a special variable - if an expression evaluates to this, then the |
| 811 existing HTML in the template will not be replaced or removed, it will | 815 existing HTML in the template will not be replaced or removed, it will |
| 812 remain. So:: | 816 remain. So:: |
| 813 | 817 |
| 814 <span tal:replace="default">Hello, World!</span> | 818 <span tal:replace="default">Hello, World!</span> |
| 815 | 819 |
| 816 would result in:: | 820 would result in:: |
| 817 | 821 |
| 818 <span>Hello, World!</span> | 822 <span>Hello, World!</span> |
| 819 | 823 |
| 820 *utils* | 824 **utils** |
| 821 This variable makes available some utility functions like batching. | 825 This variable makes available some utility functions like batching. |
| 822 | 826 |
| 823 The context variable | 827 The context variable |
| 824 ~~~~~~~~~~~~~~~~~~~~ | 828 ~~~~~~~~~~~~~~~~~~~~ |
| 825 | 829 |
| 1101 <tr tal:define="keywords db/keyword/list" | 1105 <tr tal:define="keywords db/keyword/list" |
| 1102 tal:repeat="start python:range(0, len(keywords), 4)"> | 1106 tal:repeat="start python:range(0, len(keywords), 4)"> |
| 1103 <td tal:define="batch python:utils.Batch(keywords, 4, start)" | 1107 <td tal:define="batch python:utils.Batch(keywords, 4, start)" |
| 1104 tal:repeat="keyword batch" tal:content="keyword/name">keyword here</td> | 1108 tal:repeat="keyword batch" tal:content="keyword/name">keyword here</td> |
| 1105 </tr> | 1109 </tr> |
| 1106 <tr><td colspan="4" style="border-top: 1px solid gray"> </td></tr> | |
| 1107 </table> | 1110 </table> |
| 1108 | 1111 |
| 1109 ... which will produce a table with four columns containing the items of the | 1112 ... which will produce a table with four columns containing the items of the |
| 1110 "keyword" class (well, their "name" anyway). | 1113 "keyword" class (well, their "name" anyway). |
| 1111 | 1114 |
