Changeset 6357
- Timestamp:
- Dec 18, 2007, 7:15:46 PM (16 years ago)
- Location:
- trunk/trac
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/trac/admin/templates/admin.html
r6324 r6357 13 13 14 14 <py:match path="body" once="true"><body> 15 <div id="ctxtnav" class="nav"></div>16 17 15 <div id="content" class="admin"> 18 16 <h1>Administration</h1> -
trunk/trac/admin/web_ui.py
r6326 r6357 33 33 from trac.util.translation import _ 34 34 from trac.web import HTTPNotFound, IRequestHandler 35 from trac.web.chrome import add_script, add_stylesheet, Chrome, \35 from trac.web.chrome import add_script, add_stylesheet, add_warning, Chrome, \ 36 36 INavigationContributor, ITemplateProvider 37 37 … … 319 319 req.redirect(req.href.admin(cat, page)) 320 320 else: 321 req.warning(_('Permission "%(action)s" was already granted ' 322 'to "%(subject)s"', action=action, 323 subject=subject)) 321 add_warning(req, 322 _('Permission "%(action)s" was already granted ' 323 'to "%(subject)s"', action=action, 324 subject=subject)) 324 325 325 326 # Add subject to group … … 332 333 req.redirect(req.href.admin(cat, page)) 333 334 else: 334 req.warning(_('"%(subject)s" was already added to group ' 335 '"%(group)s"', subject=subject, group=group)) 335 add_warning(req, 336 _('"%(subject)s" was already added to group ' 337 '"%(group)s"', subject=subject, group=group)) 336 338 337 339 # Remove permissions action -
trunk/trac/attachment.py
r6286 r6357 38 38 from trac.util.translation import _ 39 39 from trac.web import HTTPBadRequest, IRequestHandler 40 from trac.web.chrome import add_link, add_stylesheet, INavigationContributor 40 from trac.web.chrome import add_link, add_stylesheet, add_ctxtnav, \ 41 INavigationContributor 41 42 from trac.web.href import Href 42 43 from trac.wiki.api import IWikiSyntaxProvider … … 393 394 394 395 add_stylesheet(req, 'common/css/code.css') 396 add_ctxtnav(req, _('Back to %(parent)s', 397 parent=get_resource_name(self.env, parent)), 398 req.chrome['links']['up'][0]['href']) 395 399 return 'attachment.html', data, None 396 400 -
trunk/trac/mimeview/api.py
r6236 r6357 661 661 662 662 def _render_source(self, context, stream, annotations, marks=None): 663 from trac.web.chrome import add_warning 663 664 annotators, labels, titles = {}, {}, {} 664 665 for annotator in self.annotators: … … 686 687 self.log.warning("Can't use annotator '%s': %s" % 687 688 (a, e.message)) 688 context.req.warning(tag.strong("Can't use ", tag.em(a),689 add_warning(context.req, tag.strong("Can't use ", tag.em(a), 689 690 " annotator:") + 690 691 tag.pre(e.message)) -
trunk/trac/prefs/templates/prefs.html
r6324 r6357 13 13 14 14 <py:match path="body" once="true"><body> 15 <div id="ctxtnav" class="nav"></div>16 17 15 <div id="content" class="prefs"> 18 16 <h1>Preferences</h1> -
trunk/trac/search/templates/search.html
r5779 r6357 37 37 38 38 <body> 39 <div id="ctxtnav" class="nav"></div>40 41 39 <div id="content" class="search"> 42 40 -
trunk/trac/templates/about.html
r6311 r6357 17 17 18 18 <body> 19 <div id="ctxtnav" class="nav"></div>20 21 19 <div id="content" class="about"> 22 20 -
trunk/trac/templates/attachment.html
r6286 r6357 13 13 <body py:with="parent = attachments and attachments.parent or 14 14 attachment.resource.parent"> 15 16 <div id="ctxtnav" class="nav">17 <h2>Attachment Navigation</h2>18 <ul>19 <li class="last">20 <a href="${chrome.links.up[0].href}">${_("Back to %(parent)s", parent=name_of(parent))}</a>21 </li>22 </ul>23 </div>24 25 15 <div py:choose="mode" id="content" class="attachment"> 26 16 <py:when test="'new'"> -
trunk/trac/templates/diff_view.html
r6139 r6357 14 14 15 15 <body> 16 <div id="ctxtnav" class="nav" py:with="realm = resource.realm.capitalize()">17 <h2>$realm Navigation</h2>18 ${prevnext_nav('Change', realm + ' History')}19 <hr />20 </div>21 22 16 <div id="content" class="${resource.realm}"> 23 17 <h1 py:choose="">Changes -
trunk/trac/templates/error.html
r6327 r6357 83 83 84 84 <body> 85 <div id="ctxtnav" class="nav"></div>86 87 85 <div id="content" class="error"> 88 86 <py:choose test="type"> -
trunk/trac/templates/history_view.html
r6139 r6357 12 12 13 13 <body> 14 <div id="ctxtnav" class="nav" py:with="realm = resource.realm.capitalize()">15 <h2>$realm Navigation</h2>16 <ul>17 <li class="last"><a href="${url_of(resource)}">Back to ${name_of(resource)}</a></li>18 </ul>19 </div>20 21 14 <div id="content" class="ticket"> 22 15 <h1>Change History for <a href="${url_of(resource)}">${name_of(resource)}</a></h1> -
trunk/trac/templates/layout.html
r6311 r6357 54 54 </div> 55 55 ${navigation('mainnav')} 56 <div id="warning" py:if="req and req.warnings" class="system-message">57 <py:choose test="len(req.warnings)">58 <py:when test="1">59 <strong>Warning:</strong> ${req.warnings[0]}60 </py:when>61 <py:otherwise>62 <strong>Warnings:</strong>63 <ul><li py:for="w in req.warnings">$w</li></ul>64 </py:otherwise>65 </py:choose>66 </div>67 56 68 57 <div id="main"> 58 <div id="ctxtnav" class="nav"> 59 <h2>Context Navigation</h2> 60 <ul> 61 <li py:for="i, elm in enumerate(chrome.ctxtnav)" class="${i == 0 and 'first ' or None}${i+1 == len(chrome.ctxtnav) and 'last' or None}">$elm</li> 62 </ul> 63 <hr /> 64 </div> 65 <div id="warning" py:if="chrome.warnings" class="system-message"> 66 <py:choose test="len(chrome.warnings)"> 67 <py:when test="1"> 68 <strong>Warning:</strong> ${chrome.warnings[0]} 69 </py:when> 70 <py:otherwise> 71 <strong>Warnings:</strong> 72 <ul><li py:for="w in chrome.warnings">$w</li></ul> 73 </py:otherwise> 74 </py:choose> 75 </div> 76 69 77 ${select('*|text()')} 70 78 -
trunk/trac/ticket/api.py
r6243 r6357 83 83 See `apply_action_side_effects` for that. If the latter indeed triggers 84 84 some side-effects, it is advised to emit a warning 85 (`req.warning(reason)`) when this method is called in preview mode. 85 (`trac.web.chrome.add_warning(req, reason)`) when this method is called 86 in preview mode. 86 87 87 88 This method will only be called if the controller claimed to handle -
trunk/trac/ticket/query.py
r6172 r6357 38 38 from trac.web import IRequestHandler 39 39 from trac.web.href import Href 40 from trac.web.chrome import add_ link, add_script, add_stylesheet, \40 from trac.web.chrome import add_ctxtnav, add_link, add_script, add_stylesheet, \ 41 41 INavigationContributor, Chrome 42 42 from trac.wiki.api import IWikiSyntaxProvider, parse_args … … 761 761 self.env.is_component_enabled(ReportModule): 762 762 data['report_href'] = req.href.report() 763 add_ctxtnav(req, _('Available Reports'), req.href.report()) 764 add_ctxtnav(req, _('Custom Query')) 763 765 if query.id: 764 766 cursor = db.cursor() -
trunk/trac/ticket/report.py
r6245 r6357 34 34 from trac.util.translation import _ 35 35 from trac.web.api import IRequestHandler, RequestDone 36 from trac.web.chrome import add_ link, add_stylesheet, INavigationContributor, \37 Chrome36 from trac.web.chrome import add_ctxtnav, add_link, add_stylesheet, \ 37 INavigationContributor, Chrome 38 38 from trac.wiki import IWikiSyntaxProvider, WikiParser 39 39 … … 99 99 100 100 if id != -1 or action == 'new': 101 add_ctxtnav(req, _('Available Reports'), href=req.href.report()) 101 102 add_link(req, 'up', req.href.report(), _('Available Reports')) 103 else: 104 add_ctxtnav(req, _('Available Reports')) 102 105 103 106 # Kludge: only show link to custom query if the query module is actually … … 106 109 if 'TICKET_VIEW' in req.perm and \ 107 110 self.env.is_component_enabled(QueryModule): 111 add_ctxtnav(req, _('Custom Query'), href=req.href.query()) 108 112 data['query_href'] = req.href.query() 109 113 else: -
trunk/trac/ticket/roadmap.py
r6329 r6357 39 39 from trac.timeline.api import ITimelineEventProvider 40 40 from trac.web import IRequestHandler 41 from trac.web.chrome import add_link, add_stylesheet, INavigationContributor 41 from trac.web.chrome import add_link, add_stylesheet, add_warning, \ 42 INavigationContributor 42 43 from trac.wiki.api import IWikiSyntaxProvider 43 44 from trac.wiki.formatter import format_to_html … … 604 605 warnings = [] 605 606 def warn(msg): 606 req.warning(msg)607 add_warning(req, msg) 607 608 warnings.append(msg) 608 609 -
trunk/trac/ticket/templates/milestone_delete.html
r5755 r6357 18 18 19 19 <body> 20 <div id="ctxtnav" class="nav"></div>21 22 20 <div id="content" class="milestone"> 23 21 <h1>Delete Milestone ${milestone.name}</h1> -
trunk/trac/ticket/templates/milestone_edit.html
r5755 r6357 32 32 33 33 <body> 34 <div id="ctxtnav" class="nav"></div>35 36 34 <div id="content" class="milestone"> 37 35 <py:choose test="milestone.exists"> -
trunk/trac/ticket/templates/milestone_view.html
r6321 r6357 19 19 20 20 <body> 21 <div id="ctxtnav" class="nav"></div>22 23 21 <div id="content" class="milestone"> 24 22 <h1>Milestone ${milestone.name}</h1> -
trunk/trac/ticket/templates/query.html
r6139 r6357 23 23 24 24 <body> 25 <div id="ctxtnav" class="nav">26 <ul py:if="report_href">27 <li class="first"><a href="$report_href">Available Reports</a></li>28 <li class="last">Custom Query</li>29 </ul>30 </div>31 32 25 <py:def function="num_matches(v)"> 33 26 <span class="numrows">(${v or 'No'} match${v != 1 and 'es' or ''})</span> -
trunk/trac/ticket/templates/report_delete.html
r6324 r6357 11 11 12 12 <body> 13 <div id="ctxtnav" class="nav">14 <h2>Report Navigation</h2>15 <ul>16 <li class="first">17 <a py:strip="not chrome.links.up" href="${chrome.links.up[0].href}">Available Reports</a>18 </li>19 <li py:if="query_href" class="last"><a href="$query_href">Custom Query</a></li>20 </ul>21 </div>22 23 13 <div id="content" class="report"> 24 14 <h1>$report.title</h1> -
trunk/trac/ticket/templates/report_edit.html
r5755 r6357 11 11 12 12 <body> 13 <div id="ctxtnav" class="nav">14 <h2>Report Navigation</h2>15 <ul>16 <li class="first">17 <a py:strip="not chrome.links.up" href="${chrome.links.up[0].href}">Available Reports</a>18 </li>19 <li py:if="query_href" class="last"><a href="$query_href">Custom Query</a></li>20 </ul>21 </div>22 23 13 <div id="content" class="report"> 24 14 -
trunk/trac/ticket/templates/report_view.html
r6172 r6357 11 11 12 12 <body> 13 <div id="ctxtnav" class="nav">14 <h2>Report Navigation</h2>15 <ul>16 <li class="first">17 <a py:strip="'up' not in chrome.links" href="${chrome.links.up[0].href}">Available Reports</a>18 </li>19 <li py:if="query_href" class="last"><a href="$query_href">Custom Query</a></li>20 </ul>21 </div>22 23 13 <div id="content" class="report"> 24 14 -
trunk/trac/ticket/templates/roadmap.html
r6139 r6357 14 14 15 15 <body> 16 17 <div id="ctxtnav" class="nav"></div>18 19 16 <div id="content" class="roadmap"> 20 17 <h1>Roadmap</h1> -
trunk/trac/ticket/templates/ticket.html
r6285 r6357 47 47 48 48 <body> 49 <div id="ctxtnav" class="nav" py:with="links = chrome.links">50 <h2>Ticket Navigation</h2>51 ${prevnext_nav('Ticket', 'Back to Query')}52 </div>53 54 49 <py:def function="commentref(prefix, cnum)"> 55 50 <a href="#comment:$cnum"><small>$prefix$cnum</small></a> -
trunk/trac/ticket/web_ui.py
r6334 r6357 46 46 from trac.versioncontrol.diff import get_diff_options, diff_blocks 47 47 from trac.web import IRequestHandler 48 from trac.web.chrome import add_link, add_script, add_stylesheet, Chrome, \ 48 from trac.web.chrome import add_link, add_script, add_stylesheet, \ 49 add_warning, add_ctxtnav, prevnext_nav, Chrome, \ 49 50 INavigationContributor, ITemplateProvider 50 51 from trac.wiki.formatter import format_to … … 445 446 valid = False 446 447 for problem in problems: 447 req.warning(problem) 448 req.warning(tag(tag.p('Please review your configuration, ' 448 add_warning(req, problem) 449 add_warning(req, 450 tag(tag.p('Please review your configuration, ' 449 451 'probably starting with'), 450 452 tag.pre('[trac]\nworkflow = ...\n'), … … 530 532 add_link(req, 'alternate', conversion_href, conversion[1], 531 533 conversion[4], format) 534 535 prevnext_nav(req, _('Ticket'), _('Back to Query')) 532 536 533 537 return 'ticket.html', data, None … … 611 615 'history': history}) 612 616 617 add_ctxtnav(req, 'Back to Ticket #%s'%ticket.id, req.href.ticket(ticket.id)) 613 618 return 'history_view.html', data, None 614 619 … … 753 758 _('Version %(num)s', num=next_version)) 754 759 760 prevnext_nav(req, _('Change'), _('Ticket History')) 755 761 add_stylesheet(req, 'common/css/diff.css') 756 762 add_script(req, 'common/js/diff.js') … … 824 830 if ticket.exists and ticket._old: 825 831 if 'TICKET_CHGPROP' not in req.perm: 826 req.warning(_("No permission to change ticket fields."))832 add_warning(req, _("No permission to change ticket fields.")) 827 833 ticket.values = ticket._old 828 834 valid = False … … 831 837 'field_reporter' in ticket._old: 832 838 if 'TICKET_ADMIN' not in req.perm: 833 req.warning(_("No permissions to change ticket "839 add_warning(req, _("No permissions to change ticket " 834 840 "fields.")) 835 841 ticket.values = ticket._old … … 840 846 if not ('TICKET_CHGPROP' in req.perm or \ 841 847 'TICKET_APPEND' in req.perm): 842 req.warning(_("No permissions to add a comment."))848 add_warning(req, _("No permissions to add a comment.")) 843 849 valid = False 844 850 … … 846 852 if ticket.exists and (ticket._old or comment): 847 853 if req.args.get('ts') != str(ticket.time_changed): 848 req.warning(_("Sorry, can not save your changes. "854 add_warning(req, _("Sorry, can not save your changes. " 849 855 "This ticket has been modified by someone else " 850 856 "since you started")) … … 853 859 # Always require a summary 854 860 if not ticket['summary']: 855 req.warning(_('Tickets must contain a summary.'))861 add_warning(req, _('Tickets must contain a summary.')) 856 862 valid = False 857 863 … … 867 873 if value: 868 874 if value not in field['options']: 869 req.warning('"%s" is not a valid value for '875 add_warning(req, '"%s" is not a valid value for ' 870 876 'the %s field.' % (value, name)) 871 877 valid = False 872 878 elif not field.get('optional', False): 873 req.warning('field %s must be set' % name)879 add_warning(req, 'field %s must be set' % name) 874 880 valid = False 875 881 876 882 # Validate description length 877 883 if len(ticket['description'] or '') > self.max_description_size: 878 req.warning(_('Ticket description is too long (must be less than ' 879 '%(num)s characters)', num=self.max_description_size)) 884 add_warning(req, _('Ticket description is too long (must be less ' 885 'than %(num)s characters)', 886 num=self.max_description_size)) 880 887 valid = False 881 888 … … 897 904 valid = False 898 905 if field: 899 req.warning(_("The ticket field '%(field)s' is invalid: " 900 "%(message)s", field=field, message=message)) 906 add_warning(req, _("The ticket field '%(field)s' is " 907 "invalid: %(message)s", 908 field=field, message=message)) 901 909 else: 902 req.warning(message)910 add_warning(req, message) 903 911 return valid 904 912 -
trunk/trac/timeline/templates/timeline.html
r6158 r6357 12 12 13 13 <body> 14 <div id="ctxtnav" class="nav">15 <h2>Navigation</h2>16 ${prevnext_nav('Period')}17 </div>18 19 14 <div id="content" class="timeline"> 20 15 -
trunk/trac/timeline/web_ui.py
r6297 r6357 37 37 from trac.util.translation import _ 38 38 from trac.web import IRequestHandler, IRequestFilter 39 from trac.web.chrome import add_link, add_stylesheet, Chrome, \39 from trac.web.chrome import add_link, add_stylesheet, prevnext_nav, Chrome, \ 40 40 INavigationContributor, ITemplateProvider 41 41 … … 201 201 daysback=daysback), 202 202 _('Next period')) 203 prevnext_nav(req, 'Period') 203 204 204 205 return 'timeline.html', data, None -
trunk/trac/util/presentation.py
r5810 r6357 13 13 # history and logs, available at http://trac.edgewall.org/log/. 14 14 15 """Vario s utility functions and classes that support common presentation15 """Various utility functions and classes that support common presentation 16 16 tasks such as grouping or pagination. 17 17 """ -
trunk/trac/versioncontrol/api.py
r6273 r6357 74 74 75 75 def pre_process_request(self, req, handler): 76 from trac.web.chrome import Chrome 76 from trac.web.chrome import Chrome, add_warning 77 77 if handler is not Chrome(self.env): 78 78 try: 79 79 self.get_repository(req.authname).sync() 80 80 except TracError, e: 81 req.warning(_("Can't synchronize with the repository "81 add_warning(req, _("Can't synchronize with the repository " 82 82 "(%(error)s)", error=e.message)) 83 83 return handler -
trunk/trac/versioncontrol/templates/browser.html
r6184 r6357 36 36 37 37 <body> 38 <div id="ctxtnav" class="nav">39 <ul>40 <li class="first"><a href="${href.changeset(rev, created_path)}">Last Change</a></li>41 <li py:if="file" py:choose="">42 <a py:when="file.annotate" href="${href.browser(created_path, rev=rev)}"43 title="View file without annotations">44 Normal</a>45 <a py:otherwise="" href="${href.browser(created_path, rev=rev, annotate=1)}"46 title="Annotate each line with the last changed revision (this can be time consuming...)">47 Annotate</a>48 </li>49 <li class="last"><a href="${href.log(path, rev=stickyrev)}">Revision Log</a></li>50 </ul>51 </div>52 53 38 <div id="content" class="browser"> 54 39 -
trunk/trac/versioncontrol/templates/changeset.html
r6139 r6357 17 17 18 18 <body> 19 <div id="ctxtnav" class="nav">20 <h2>Navigation</h2>21 <py:choose>22 <py:when test="changeset">23 ${prevnext_nav(changeset and restricted and 'Change' or 'Changeset')}24 </py:when>25 <ul py:otherwise="">26 <li class="last">27 <a href="${href.changeset(old_rev, old_path, old=new_rev, old_path=new_path)}">Reverse Diff</a>28 </li>29 </ul>30 </py:choose>31 </div>32 33 19 <div id="content" class="changeset"> 34 20 <div id="title" py:choose=""> -
trunk/trac/versioncontrol/templates/diff_form.html
r4821 r6357 16 16 17 17 <body> 18 <div id="ctxtnav" class="nav"></div>19 20 18 <div id="content" class="changeset"> 21 19 <div id="title"> -
trunk/trac/versioncontrol/templates/revisionlog.html
r6139 r6357 12 12 13 13 <body> 14 <div id="ctxtnav" class="nav">15 <ul py:with="prev = chrome.links.get('prev'); next = chrome.links.get('next')">16 <li class="first${not (prev or next) and ' last' or ''}">17 <a href="${href.browser(path)}">View Latest Revision</a>18 </li>19 <li py:if="prev" class="${not next and 'last' or None}">20 ← <a title="${prev[0].title}" href="${prev[0].href}">Newer Revisions</a>21 </li>22 <li py:if="next" class="last">23 <a title="${next[0].title}" href="${next[0].href}">Older Revisions</a> →24 </li>25 </ul>26 </div>27 28 14 <div id="content" class="log"> 29 15 <h1>${browser_path_links(path_links)}</h1> -
trunk/trac/versioncontrol/web_ui/browser.py
r6139 r6357 36 36 from trac.util.translation import _ 37 37 from trac.web import IRequestHandler, RequestDone 38 from trac.web.chrome import add_ link, add_script, add_stylesheet, \39 INavigationContributor38 from trac.web.chrome import add_ctxtnav, add_link, add_script, add_stylesheet, \ 39 prevnext_nav, INavigationContributor 40 40 from trac.wiki.api import IWikiSyntaxProvider 41 41 from trac.wiki.formatter import format_to_html, format_to_oneliner … … 365 365 self.config['changeset'].getbool('wiki_format_messages') 366 366 } 367 add_ctxtnav(req, tag.a(_('Last Change'), 368 href=req.href.changeset(node.rev, node.created_path))) 369 if node.isfile: 370 if data['file']['annotate']: 371 add_ctxtnav(req, _('Normal'), 372 title=_('View file without annotations'), 373 href=req.href.browser(node.created_path, 374 rev=node.rev)) 375 else: 376 add_ctxtnav(req, _('Annotate'), 377 title=_('Annotate each line with the last ' 378 'changed revision ' 379 '(this can be time consuming...)'), 380 href=req.href.browser(node.created_path, 381 rev=node.rev, 382 annotate=1)) 383 384 add_ctxtnav(req, _('Revision Log'), 385 href=req.href.log(path, rev=rev)) 367 386 368 387 xhr = req.get_header('X-Requested-With') == 'XMLHttpRequest' -
trunk/trac/versioncontrol/web_ui/changeset.py
r6332 r6357 45 45 DefaultPropertyRenderer 46 46 from trac.web import IRequestHandler, RequestDone 47 from trac.web.chrome import add_ link, add_script, add_stylesheet, \48 INavigationContributor, Chrome47 from trac.web.chrome import add_ctxtnav, add_link, add_script, add_stylesheet, \ 48 prevnext_nav, INavigationContributor, Chrome 49 49 from trac.wiki import IWikiSyntaxProvider, WikiParser 50 50 from trac.wiki.formatter import format_to_html … … 338 338 add_stylesheet(req, 'common/css/diff.css') 339 339 add_stylesheet(req, 'common/css/code.css') 340 if chgset: 341 if restricted: 342 prevnext_nav(req, _('Change')) 343 else: 344 prevnext_nav(req, _('Changeset')) 345 else: 346 rev_href = req.href.changeset(old, old_path, old=new, 347 old_path=new_path) 348 add_ctxtnav(req, _('Reverse Diff'), href=rev_href) 349 340 350 return 'changeset.html', data, None 341 351 -
trunk/trac/versioncontrol/web_ui/log.py
r6202 r6357 20 20 import urllib 21 21 22 from genshi.core import Markup 23 from genshi.builder import tag 24 22 25 from trac.config import IntOption 23 26 from trac.core import * … … 33 36 from trac.versioncontrol.web_ui.util import * 34 37 from trac.web import IRequestHandler 35 from trac.web.chrome import add_ link, add_stylesheet, INavigationContributor, \36 Chrome38 from trac.web.chrome import add_ctxtnav, add_link, add_stylesheet, \ 39 INavigationContributor, Chrome 37 40 from trac.wiki import IWikiSyntaxProvider, WikiParser 38 41 … … 242 245 add_link(req, 'alternate', changelog_href, _('ChangeLog'), 'text/plain') 243 246 247 add_ctxtnav(req, _('View Latest Revision'), 248 href=req.href.browser(path)) 249 if 'next' in req.chrome['links']: 250 next = req.chrome['links']['next'][0] 251 add_ctxtnav(req, tag.span(tag.a(_('Older Revisions'), 252 href=next['href']), 253 Markup(' →'))) 254 244 255 return 'revisionlog.html', data, None 245 256 -
trunk/trac/web/api.py
r6240 r6357 162 162 self.abs_href = Href(self.base_url) 163 163 164 self.warnings = []165 166 164 def __getattr__(self, name): 167 165 """Performs lazy attribute lookup by delegating to the functions in the … … 427 425 self._write(data) 428 426 429 def warning(self, msg):430 self.warnings.append(msg)431 432 427 # Internal methods 433 428 -
trunk/trac/web/chrome.py
r6172 r6357 42 42 from trac.util.datefmt import pretty_timedelta, format_datetime, format_date, \ 43 43 format_time, http_date, utc 44 from trac.util.translation import _ 44 45 from trac.web.api import IRequestHandler, ITemplateStreamFilter, HTTPNotFound 45 46 from trac.web.href import Href 46 47 from trac.wiki import IWikiSyntaxProvider 47 48 from trac.wiki.formatter import format_to, format_to_html, format_to_oneliner 48 49 49 50 50 def add_link(req, rel, href, title=None, mimetype=None, classname=None): … … 106 106 """Deprecated: use `add_script()` instead.""" 107 107 add_script(req, filename, mimetype='text/javascript') 108 109 def add_warning(req, msg, *args): 110 """Add a non-fatal warning to the request object. 111 When rendering pages, any warnings will be rendered to the user.""" 112 req.chrome['warnings'].append(msg % args) 113 114 def add_ctxtnav(req, elm_or_label, href=None, title=None): 115 """Add an entry to the current page's ctxtnav bar. 116 """ 117 if href: 118 elm = tag.a(elm_or_label, href=href, title=title) 119 else: 120 elm = elm_or_label 121 req.chrome.setdefault('ctxtnav', []).append(elm) 122 123 # ???: Does this belong in trac.util somewhere? <NPK> 124 def prevnext_nav(req, label, uplabel=None): 125 """Add Previous/Up/Next navigation links 126 127 `req` a Request object 128 `label` the label to use after the Previous/Next words 129 `uplabel` the label to use for the Up link 130 """ 131 links = req.chrome['links'] 132 133 if 'prev' not in links and \ 134 'up' not in links and \ 135 'next' not in links: 136 # Short circuit 137 return 138 139 if 'prev' in links: 140 link = links['prev'][0] 141 add_ctxtnav(req, 142 tag.span(Markup('← '), 143 tag.a(_('Previous %(label)s', label=label), 144 href=link['href'], 145 title=link['title'], 146 class_='prev' 147 ))) 148 else: 149 add_ctxtnav(req, 150 tag.span(_('Previous %(label)s', label=label), 151 class_='missing')) 152 153 if uplabel and 'up' in links: 154 link = links['up'][0] 155 add_ctxtnav(req, tag.a(uplabel, 156 href=link['href'], 157 title=link['title'])) 158 159 if 'next' in links: 160 link = links['next'][0] 161 add_ctxtnav(req, 162 tag.span(tag.a(_('Next %(label)s', label=label), 163 href=link['href'], 164 title=link['title'], 165 class_='next'), 166 Markup(' →'))) 167 else: 168 add_ctxtnav(req, 169 tag.span(_('Next %(label)s', label=label), class_='missing')) 108 170 109 171 … … 338 400 self.log.debug('Prepare chrome data for request') 339 401 340 chrome = {'links': {}, 'scripts': [] }402 chrome = {'links': {}, 'scripts': [], 'ctxtnav': [], 'warnings': []} 341 403 342 404 # This is ugly... we can't pass the real Request object to the -
trunk/trac/wiki/templates/wiki_delete.html
r6139 r6357 11 11 12 12 <body> 13 <div id="ctxtnav" class="nav">14 <h2>Wiki Navigation</h2>15 <ul>16 <li><a href="${href.wiki('WikiStart')}">Start Page</a></li>17 <li><a href="${href.wiki('TitleIndex')}">Index</a></li>18 <li><a href="${href.wiki(page.name, action='history')}">History</a></li>19 <li class="last">20 <a href="${req.href.wiki(page.name, action='diff', version=page.version)}">Last Change</a>21 </li>22 </ul>23 <hr />24 </div>25 26 13 <div id="content" class="wiki" 27 14 py:with=" -
trunk/trac/wiki/templates/wiki_edit.html
r6139 r6357 23 23 24 24 <body> 25 <div id="ctxtnav" class="nav">26 <h2>Wiki Navigation</h2>27 <ul>28 <li><a href="${href.wiki('WikiStart')}">Start Page</a></li>29 <li><a href="${href.wiki('TitleIndex')}">Index</a></li>30 <li><a href="${href.wiki(page.name, action='history')}">History</a></li>31 <li class="last">32 <a href="${href.wiki(page.name, action='diff')}">Last Change</a>33 </li>34 </ul>35 <hr />36 </div>37 25 <div id="content" class="wiki"> 38 26 -
trunk/trac/wiki/templates/wiki_view.html
r6139 r6357 18 18 19 19 <body> 20 <div id="ctxtnav" class="nav">21 <h2>Wiki Navigation</h2>22 <py:choose>23 <py:when test="version">24 ${prevnext_nav('Version', 'View Latest Version')}25 </py:when>26 <ul py:otherwise="">27 <li><a href="${href.wiki('WikiStart')}">Start Page</a></li>28 <li><a href="${href.wiki('TitleIndex')}">Index</a></li>29 <li><a href="${href.wiki(page.name, action='history')}">History</a></li>30 <li class="last">31 <a href="${href.wiki(page.name, action='diff', version=page.version)}">Last Change</a>32 </li>33 </ul>34 </py:choose>35 <hr />36 </div>37 38 20 <div id="content" class="wiki"> 39 21 -
trunk/trac/wiki/web_ui.py
r6239 r6357 21 21 import re 22 22 23 from genshi.core import Markup 23 24 from genshi.builder import tag 24 25 … … 36 37 from trac.versioncontrol.diff import get_diff_options, diff_blocks 37 38 from trac.web.chrome import add_link, add_script, add_stylesheet, \ 39 add_ctxtnav, prevnext_nav, \ 38 40 INavigationContributor, ITemplateProvider 39 41 from trac.web import IRequestHandler … … 283 285 data.update({'new_version': version, 'old_version': old_version, 284 286 'num_versions': num_versions}) 287 self._wiki_ctxtnav(req, page) 285 288 return 'wiki_delete.html', data, None 286 289 … … 360 363 'diff': diff_data, 361 364 }) 365 prevnext_nav(req, _('Change'), _('Wiki History')) 362 366 return 'wiki_diff.html', data, None 363 367 … … 413 417 'action': 'preview', 'merge': action == 'merge', 414 418 'longcol': 'Version', 'shortcol': 'v'}) 415 419 420 self._wiki_ctxtnav(req, page) 416 421 return 'wiki_edit.html', data, None 417 422 … … 437 442 }) 438 443 data.update({'history': history, 'resource': page.resource}) 444 add_ctxtnav(req, 'Back to '+page.name, req.href.wiki(page.name)) 439 445 return 'history_view.html', data, None 440 446 … … 500 506 _('Version %(num)s', num=next_version)) 501 507 508 # Add ctxtnav entries 509 if version: 510 prevnext_nav(req, _('Version'), _('View Latest Version')) 511 else: 512 self._wiki_ctxtnav(req, page) 513 502 514 context = Context.from_request(req, page.resource) 503 515 data.update({ … … 510 522 }) 511 523 return 'wiki_view.html', data, None 524 525 def _wiki_ctxtnav(self, req, page): 526 """Add the normal wiki ctxtnav entries.""" 527 add_ctxtnav(req, _('Start Page'), req.href.wiki('WikiStart')) 528 add_ctxtnav(req, _('Index'), req.href.wiki('TitleIndex')) 529 add_ctxtnav(req, _('History'), req.href.wiki(page.name, 530 action='history')) 531 add_ctxtnav(req, _('Last Change'), req.href.wiki(page.name, 532 action='diff', 533 version=page.version)) 512 534 513 535 # ITimelineEventProvider methods
Note:
See TracChangeset
for help on using the changeset viewer.