Changes between Version 18 and Version 19 of EggCookingTutorial/AdvancedEggCooking


Ignore:
Timestamp:
Nov 3, 2016, 2:32:11 PM (7 years ago)
Author:
Jeffrey.Ratcliffe@…
Comment:

port from ClearSilver to Genshi templates

Legend:

Unmodified
Added
Removed
Modified
  • EggCookingTutorial/AdvancedEggCooking

    v18 v19  
    1616}}}
    1717
    18 In that directory create a new file ''helloworld.cs'':
     18In that directory create a new file ''helloworld.html'':
    1919{{{#!text/html
    20 <?cs include "header.cs" ?>
    21 <?cs include "macros.cs" ?>
     20<!DOCTYPE html
     21          PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     22          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     23<html xmlns="http://www.w3.org/1999/xhtml"
     24      xmlns:py="http://genshi.edgewall.org/"
     25      xmlns:xi="http://www.w3.org/2001/XInclude">
    2226
    23 <div id="content" class="helloworld">
    24  <h1>Hello world!</h1>
    25 </div>
     27  <xi:include href="layout.html" />
    2628
    27 <?cs include "footer.cs" ?>
     29  <head><title>Hello world!</title></head>
     30
     31  <body>
     32    <div id="content">
     33      <h1>Hello world!</h1>
     34    </div>
     35  </body>
     36
     37</html>
    2838}}}
    2939
     
    5969{{{#!python
    6070    def process_request(self, req):
    61         return 'helloworld.cs', None
     71        return 'helloworld.html', {}, None
    6272}}}
    6373
     
    6676    # ITemplateProvider methods
    6777    def get_templates_dirs(self):
    68         """Return a list of directories containing the provided ClearSilver
    69         templates.
    70         """
     78        """Return a list of directories containing the templates"""
    7179
    7280        from pkg_resources import resource_filename
     
    7987
    8088from trac.core import *
     89from trac.util.html import html
    8190from trac.web.chrome import INavigationContributor, ITemplateProvider
    8291from trac.web.main import IRequestHandler
    83 from trac.util import escape, Markup
    8492
    85 class UserbaseModule(Component):
     93class HelloworldPlugin(Component):
    8694    implements(INavigationContributor, IRequestHandler, ITemplateProvider)
    8795
    8896    # INavigationContributor methods
    89     def get_active_navigation_item(self, req):
     97    def get_active_navigation_item(self, _):
    9098        return 'helloworld'
    9199
    92100    def get_navigation_items(self, req):
    93         yield 'mainnav', 'helloworld', Markup('<a href="%s">Hello</a>' %(
    94                 self.env.href.helloworld() ))
     101        yield('mainnav', 'helloworld',
     102              html.a('Hello', href=req.href.helloworld()))
    95103
    96104    # IRequestHandler methods
     
    98106        return req.path_info == '/helloworld'
    99107
    100     def process_request(self, req):
    101         return 'helloworld.cs', None
     108    def process_request(self, _):
     109        return 'helloworld.html', {}, None
    102110
    103111    # ITemplateProvider methods
    104112    def get_templates_dirs(self):
    105         """Return a list of directories containing the provided ClearSilver
    106         templates.
    107         """
     113        """ provide template dir """
    108114
    109115        from pkg_resources import resource_filename
     
    126132      packages=['helloworld'],
    127133      entry_points={'trac.plugins': '%s = helloworld' % PACKAGE},
    128       package_data={'helloworld': ['templates/*.cs']},
     134      package_data={'helloworld': ['templates/*.html']},
    129135)
    130136}}}