Changes between Version 17 and Version 18 of EggCookingTutorial/AdvancedEggCooking


Ignore:
Timestamp:
Jan 25, 2016, 8:18:47 PM (8 years ago)
Author:
figaro
Comment:

Cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • EggCookingTutorial/AdvancedEggCooking

    v17 v18  
    11[[TOC(heading=Egg Cooking Tutorial, EggCookingTutorial/BasicEggCooking, EggCookingTutorial/AdvancedEggCooking, EggCookingTutorial/AdvancedEggCooking2, EggCookingTutorial/publish)]]
    22
    3 = Cook even better eggs =
     3= Cook even better eggs
    44
    5 After you read [wiki:EggCookingTutorial/BasicEggCooking EggCookingTutorial/BasicEggCooking] and created your first egg, it's time to make it a bit better.
     5After you read [wiki:EggCookingTutorial/BasicEggCooking] and created your first egg, it's time to make it a bit better.
    66
    77First we integrate our output to other Trac layout in form of !ClearSilver template.
    88
    9 == Adding template ==
     9== Adding template
    1010
    1111To have a template we need a directory and of course the template itself. We will keep the same simple "Hello world!" text, but this time we will integrate our fine words into a Trac layout.
    1212
    1313For that we need to create one additional directory:
    14 {{{
     14{{{#!sh
    1515./helloworld-plugin/helloworld/templates/
    1616}}}
    1717
    1818In that directory create a new file ''helloworld.cs'':
    19 {{{
    20 #!text/html
     19{{{#!text/html
    2120<?cs include "header.cs" ?>
    2221<?cs include "macros.cs" ?>
     
    3130Now you have created the template for the plugin.
    3231
    33 == Tell Trac where template is ==
     32== Tell Trac where the template is
    3433
    35 Trac doesn't know where your template is so you have to tell it. This is done by implementing the ITemplateProvider interface in ''helloworld.py''.
     34Trac doesn't know where your template is, so you have to tell it. This is done by implementing the ITemplateProvider interface in ''helloworld.py''.
    3635
    3736So you change few lines as following:
    3837
    39 Line 4 is changed from
    40 {{{
    41 #!python
     38Line 4 is changed from:
     39{{{#!python
    4240from trac.web.chrome import INavigationContributor
    4341}}}
    44 to
    45 {{{
    46 #!python
     42
     43to:
     44{{{#!python
    4745from trac.web.chrome import INavigationContributor, ITemplateProvider
    4846}}}
    4947
    50 Line 9 is changed from
    51 {{{
    52 #!python
     48Line 9 is changed from:
     49{{{#!python
    5350    implements(INavigationContributor, IRequestHandler)
    5451}}}
    55 {{{
    56 #!python
     52
     53to:
     54{{{#!python
    5755    implements(INavigationContributor, IRequestHandler, ITemplateProvider)
    5856}}}
    5957
    60 Starting from line 23 old ''process_request'' method is replaced by
    61 {{{
    62 #!python
     58Starting from line 23 old ''process_request'' method is replaced by:
     59{{{#!python
    6360    def process_request(self, req):
    6461        return 'helloworld.cs', None
    6562}}}
    6663
    67 And to end of file you need to tell where your template is located
    68 {{{
    69 #!python
     64And to end of file you need to tell where your template is located:
     65{{{#!python
    7066    # ITemplateProvider methods
    7167    def get_templates_dirs(self):
     
    7874}}}
    7975
    80 Complete version of ''helloworld.py'':
    81 {{{
    82 #!python
     76And the complete version of ''helloworld.py'' then becomes:
     77{{{#!python
    8378# Helloworld plugin
    8479
     
    116111}}}
    117112
    118 == Copy template to egg ==
     113== Copy template to egg
    119114
    120115Finally you have to include the new template directory in an egg.
    121116
    122117So change ''setup.py'' to be like:
    123 {{{
    124 #!python
     118{{{#!python
    125119from setuptools import setup
    126120
     
    136130}}}
    137131
    138 == Building and deploying ==
     132== Building and deploying
    139133
    140134Building and deployment goes exactly the same as it did in the previous tutorial [wiki:EggCookingTutorial/BasicEggCooking#Firstdeployment EggCookingTutorial/BasicEggCooking].
     
    142136Now you should see a big "Hello world!" integrated into your Trac layout when you press that fancy button in the main navigation bar.
    143137
    144 == Aftermath ==
     138== Aftermath
    145139
    146 Now that you have added a basic template for your plugin let's add the final twist, putting some static content like a stylesheet and an image. Continue to [wiki:EggCookingTutorial/AdvancedEggCooking2 EggCookingTutorial/AdvancedEggCooking2]
     140Now that you have added a basic template for your plugin let's add the final twist, putting some static content like a stylesheet and an image. Continue to [wiki:EggCookingTutorial/AdvancedEggCooking2].
    147141
    148 
    149 
    150