Changes between Version 18 and Version 19 of EggCookingTutorial/AdvancedEggCooking
- Timestamp:
- Nov 3, 2016, 2:32:11 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
EggCookingTutorial/AdvancedEggCooking
v18 v19 16 16 }}} 17 17 18 In that directory create a new file ''helloworld. cs'':18 In that directory create a new file ''helloworld.html'': 19 19 {{{#!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"> 22 26 23 <div id="content" class="helloworld"> 24 <h1>Hello world!</h1> 25 </div> 27 <xi:include href="layout.html" /> 26 28 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> 28 38 }}} 29 39 … … 59 69 {{{#!python 60 70 def process_request(self, req): 61 return 'helloworld. cs', None71 return 'helloworld.html', {}, None 62 72 }}} 63 73 … … 66 76 # ITemplateProvider methods 67 77 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""" 71 79 72 80 from pkg_resources import resource_filename … … 79 87 80 88 from trac.core import * 89 from trac.util.html import html 81 90 from trac.web.chrome import INavigationContributor, ITemplateProvider 82 91 from trac.web.main import IRequestHandler 83 from trac.util import escape, Markup84 92 85 class UserbaseModule(Component):93 class HelloworldPlugin(Component): 86 94 implements(INavigationContributor, IRequestHandler, ITemplateProvider) 87 95 88 96 # INavigationContributor methods 89 def get_active_navigation_item(self, req):97 def get_active_navigation_item(self, _): 90 98 return 'helloworld' 91 99 92 100 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())) 95 103 96 104 # IRequestHandler methods … … 98 106 return req.path_info == '/helloworld' 99 107 100 def process_request(self, req):101 return 'helloworld. cs', None108 def process_request(self, _): 109 return 'helloworld.html', {}, None 102 110 103 111 # ITemplateProvider methods 104 112 def get_templates_dirs(self): 105 """Return a list of directories containing the provided ClearSilver 106 templates. 107 """ 113 """ provide template dir """ 108 114 109 115 from pkg_resources import resource_filename … … 126 132 packages=['helloworld'], 127 133 entry_points={'trac.plugins': '%s = helloworld' % PACKAGE}, 128 package_data={'helloworld': ['templates/*. cs']},134 package_data={'helloworld': ['templates/*.html']}, 129 135 ) 130 136 }}}