Changeset 3730
- Timestamp:
- Sep 13, 2006, 6:30:26 PM (17 years ago)
- Location:
- sandbox/genshi
- Files:
-
- 4 edited
-
templates/revisionlog.txt (modified) (2 diffs)
-
templates/ticket_notify_email.txt (modified) (1 diff)
-
trac/notification.py (modified) (1 diff)
-
trac/web/chrome.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sandbox/genshi/templates/revisionlog.txt
r3725 r3730 1 <changelog xmlns:py="http://genshi.edgewall.org/" py:strip="">2 1 # 3 2 # ChangeLog for $path … … 5 4 # Generated by Trac $trac.version 6 5 # ${format_datetime} 7 # 8 <py:for each="item in items" py:with="change = changes[item.rev]"> 9 $change.date $change.author [$item.rev]<!--! 10 --><py:for each="idx, file in enumerate(change.files)"> 11 * $file (<py:choose test="change.actions[idx]"><!--! FIXME: much simpler solution with #M37 12 --><py:when test="'edit'">modified</py:when><!--! 13 --><py:when test="'add'">added</py:when><!--! 14 --><py:when test="'delete'">deleted</py:when><!--! 15 --><py:when test="'copy'">copied</py:when><!--! 16 --><py:when test="'move'">moved</py:when><!--! 17 --></py:choose>)</py:for> 6 #for item in items 7 #with change = changes[item.rev] 8 $change.date $change.author [$item.rev] 9 #for idx, file in enumerate(change.files) 10 * $file (${dict(edit='modified', add='added', delete='deleted', 11 copy='copied', move='moved')[change.actions[idx]]}) 12 #end 18 13 $change.message 19 </py:for>20 </changelog> 14 #end 15 #end -
sandbox/genshi/templates/ticket_notify_email.txt
r3725 r3730 1 <mail xmlns:py="http://genshi.edgewall.org/" py:strip=""><!--!2 3 Some notes about how to handle white-spaces in text templates:4 5 - every structure tag should be followed by a comment start: < ! - - !6 7 - every tag but the first should be preceeded by a comment end: - - >8 9 - text data following a new line will be inserted either directly,10 by first ending the comment then placing the content on the same11 line, or inserted after a newline, by first closing the comment,12 then placing the data on a line of its own.13 14 - after text data, a comment start should be started on a newline,15 which will effectively insert a newline.16 Sometimes though this is not wanted, for example when the data17 itself ends with a newline... (see $changes_body below)18 19 -->20 1 $ticket_body_hdr 21 2 $ticket_props 22 <!--! 23 --><py:choose test="ticket.new"><!--! 24 --><py:when test="True"><!--! 25 --> 3 #choose ticket.new 4 #when True 26 5 $ticket.description 27 <!--! 28 --></py:when><!--! 29 --><py:otherwise><!--! 30 --><py:if test="changes_body"><!--! 31 --> 6 #end 7 #otherwise 8 #if changes_body 32 9 Changes (by $change.author): 33 10 34 $changes_body<!--! 35 --></py:if><!--! 36 --><py:if test="changes_descr"><!--! 37 --> 11 $changes_body 12 #end 13 #if changes_descr 38 14 $changes_descr 39 15 -- 40 <!--! 41 --></py:if><!--! 42 --><py:if test="change.comment"><!--! 43 --> 44 Comment<py:if test="not changes_body"> (by $change.author)</py:if>: 16 #end 17 #if change.comment 18 19 Comment${not changes_body and '(by %s)' % change.author or ''}: 45 20 46 21 $change.comment 47 <!--! 48 --></py:if><!--! 49 --></py:otherwise><!--! 50 --></py:choose><!--! 51 --> 22 #end 23 #end 24 #end 25 52 26 -- 53 Ticket URL: <$ticket.link>54 $project.name <${abs_href}>27 Ticket URL: <$ticket.link> 28 $project.name <${abs_href}> 55 29 $project.descr 56 </mail> -
sandbox/genshi/trac/notification.py
r3725 r3730 97 97 self.db = env.get_db_cnx() 98 98 99 self.template = Chrome(self.env).load_template(self.template_name) 99 self.template = Chrome(self.env).load_template(self.template_name, 100 method='text') 100 101 self.data = {'CRLF': CRLF} 101 102 Chrome(self.env).populate_data(None, self.data) -
sandbox/genshi/trac/web/chrome.py
r3725 r3730 22 22 from genshi.builder import tag 23 23 from genshi.output import DocType 24 from genshi.template import TemplateLoader 24 from genshi.template import TemplateLoader, MarkupTemplate, TextTemplate 25 25 26 26 from trac import mimeview … … 419 419 from pprint import pformat 420 420 data['pprint'] = pformat 421 if req: 422 data['GENSHI_DEBUG'] = req.args.get('genshi_debug') 423 424 def load_template(self, filename, req=None, data=None): 425 """Retrieve a Template and optionally preset the template data""" 421 422 def load_template(self, filename, req=None, data=None, method=None): 423 """Retrieve a Template and optionally preset the template data. 424 425 If `req` and `data` are given, the `data` dictionary will be preset 426 with the "standard" Trac information and helper methods. 427 428 Also, if the optional `method` argument is set to `'text'`, a 429 TextTemplate instance will be created instead of a MarkupTemplate. 430 """ 426 431 if req and data: 427 432 self.populate_data(req, data) … … 429 434 self.templateloader = TemplateLoader(self.get_all_templates_dirs(), 430 435 auto_reload=self.auto_reload) 431 return self.templateloader.load(filename) 436 cls = method == 'text' and TextTemplate or MarkupTemplate 437 return self.templateloader.load(filename, cls=cls) 432 438 433 439 def render_response(self, req, template_name, content_type, data): 434 self.populate_data(req, data) 435 436 stream = self.load_template(template_name).generate(**data) 437 440 """Render the `template_name` using the `data` for the context. 441 442 The MIME `content_type` argument is used to choose the kind of template 443 used (TextTemplate if `'text/plain'`, MarkupTemplate otherwise), and 444 tweak the rendering process (use of XHTML Strict doctype if 445 `'text/html'` is given). 446 """ 438 447 if content_type is None: 439 448 content_type = 'text/html' 449 doctype = {'text/html': DocType.XHTML_STRICT}.get(content_type) 440 450 method = {'text/html': 'xhtml', 441 451 'text/plain': 'text'}.get(content_type, 'xml') 442 doctype = {'text/html': DocType.XHTML_STRICT}.get(content_type) 452 453 template = self.load_template(template_name, req, data, method=method) 454 stream = template.generate(**data) 443 455 444 456 if method == 'text': 445 457 return stream.render('text') 446 return stream.render(method, doctype=doctype) 458 else: 459 return stream.render(method, doctype=doctype)
Note:
See TracChangeset
for help on using the changeset viewer.
