Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/trac/templates/ |
Upload File : |
{# Copyright (C) 2006-2021 Edgewall Software This software is licensed as described in the file COPYING, which you should have received as part of this distribution. The terms are also available at https://trac.edgewall.org/wiki/TracLicense. This software consists of voluntary contributions made by many individuals. For the exact contribution history, see the revision history and logs, available at https://trac.edgewall.org/. #} {# Arguments: - changes -- a list of diff items, each being a dict containing information about changes for one file: .href - link for the title (optional) .title - tooltip for the title link (optional) .comments - annotation for the change (optional) .new and .old - information about the files being diffed .path - path of the file .rev - rev of the file (for 'sidebyside') .shortrev - abbreviated form of rev of the file (for 'inline') .href - link to the full file (optional) .props - a list of property changes .name - name of the property .diff - rendered difference .old - old value of the property .new - new value for the property (both .old and .new have .name, .value and .rendered properties) .diffs - a sequence of list of blocks Each block being a dict: .type - one of 'unmod', 'add', 'rem' or 'mod' .base and .changed - information about lines from old and new content .lines - the lines .offset - position within the file .diffs_title - a sequence of titles for the list of blocks Note: integrate this into .diffs for 0.12 or 1.0. - diff -- dict specifying diff style and options .style - can be 'sidebyside' (4 columns) or 'inline' (3 columns) .options - contexlines, various ignore... - longcol -- "long" column header; e.g. 'Revision' or 'File' or '' (for 'sidebyside') - shortcol -- "short" column header: e.g. 'r' or '' (for 'inline') - no_id -- skip generation of id attributes in h2 headings #} <div class="diff"> # if changes|selectattr('diffs') or changes|selectattr('props'): <ul class="entries"> # for item in changes: # set old = item.old # set new = item.new # if item and (item.diffs or item.props or 'comments' in item): <li class="entry"> # set comments = item.get('comments') <h2${{'id': 'file%s' % loop.index0 if not no_id}|htmlattr}> # if new.path: <a${{'href': item.get('href', new.get('href')), 'title': item.get('title', new.get('title')) }|htmlattr}>${new.path}</a> # else: # endif </h2> # if comments: <pre>${comments}</pre> # endif # macro prop_name(name, attrs) <strong ${attrs|htmlattr}>${name}</strong> # endmacro # macro render_property(prop) # if prop.rendered: ${prop.rendered.content} # elif istext(prop.value): <em><code>${prop.value}</code></em> # else: ${prop.value} # endif # endmacro # if item.props: <ul class="props"> # for prop in item.props: # if prop.diff: ${prop.diff} # endif # set one = prop.old or prop.new # set both = prop.old and prop.new # if one: <li> # set name_attrs = one.rendered and one.rendered.name_attributes # set name = one.rendered.name if one.rendered else prop.name # if both: # trans name = prop_name(name, name_attrs), old = render_property(prop.old), new = render_property(prop.new) Property ${name} changed from ${old} to ${new} # endtrans # elif not prop.old: # trans name = prop_name(name, name_attrs), value = render_property(prop.new) Property ${name} set to ${value} # endtrans # else: # trans name = prop_name(name, name_attrs) Property ${name} deleted # endtrans # endif </li> # endif # endfor </ul> # endif # if item.diffs and item.diffs[0]: <table class="trac-diff ${diff.style}" cellspacing="0"> # with # set fromline = item.diffs[0][0].base.offset+1 # set toline = item.diffs[0][0].changed.offset+1 # if diff.style == 'sidebyside': <colgroup class="l"> <col class="lineno"/><col class="content"/> </colgroup> <colgroup class="r"> <col class="lineno"/><col class="content"/> </colgroup> <thead> <tr> <th colspan="2"> # if 'href' in old: <a title="${old.get('title')}" href="${old.get('href')}#L${fromline}">${longcol} ${old.rev}</a> # else: ${longcol} ${old.rev} # endif </th> <th colspan="2"> # if 'href' in new: <a title="${new.get('title')}" href="${new.get('href')}#L${toline}">${longcol} ${new.rev}</a> # else: ${longcol} ${new.rev} # endif </th> </tr> </thead> # elif diff.style == 'inline': <colgroup> <col class="lineno"/><col class="lineno"/><col class="content"/> </colgroup> <thead> <tr> <th title="${longcol} ${old.rev}"> # if 'href' in old: <a title="${old.get('title')}" href="${old.get('href')}#L${fromline}" >${shortcol}${old.shortrev}</a> # else: ${shortcol}${old.shortrev} # endif </th> <th title="${longcol} ${new.rev}"> # if 'href' in new: <a title="${new.get('title')}" href="${new.get('href')}#L${toline}" >${shortcol}${new.shortrev}</a> # else: ${shortcol}${new.shortrev} # endif </th> <td> # if 'diffs_title' in item: <em>${item.diffs_title[0]}</em> # endif </td> </tr> </thead> # endif # endwith # for blocks in item.diffs: # for block in blocks: <tbody class="${block.type}"> # if block.type == 'unmod': ## Show identical lines on both "sides" # for line in block.base.lines: <tr> # set from_n = block.base.offset + loop.index # set to_n = block.changed.offset + loop.index # set clines = block.changed.lines # if diff.style == 'sidebyside': <th>${from_n}</th><td class="l"><span>${line}</span></td> <th>${to_n}</th><td class="r"><span>${ clines[loop.index0] if loop.index0 is lessthan(len(clines)) }</span></td> # elif diff.style == 'inline': <th>${from_n}</th><th>${to_n}</th><td class="l"><span>${line}</span></td> # endif </tr> # endfor # elif block.type == 'add': ## Show only added lines, on the "right side" # for line in block.changed.lines: <tr${{'class': first_last(loop.index0, block.changed.lines) if diff.style == 'inline' }|htmlattr}> # set to_n = block.changed.offset + loop.index # if diff.style == 'sidebyside': <th> </th><td class="l"></td> <th>${to_n}</th><td class="r"><ins>${line}</ins></td> # elif diff.style == 'inline': <th> </th><th>${to_n}</th><td class="r"><ins>${line}</ins></td> # endif </tr> # endfor # elif block.type == 'rem': ## Show only deleted lines, on the "left side" # for line in block.base.lines: <tr${{'class': first_last(loop.index0, block.base.lines) if diff.style == 'inline' }|htmlattr}> # set from_n = block.base.offset + loop.index # if diff.style == 'sidebyside': <th>${from_n}</th><td class="l"><del>${line}</del></td> <th> </th><td class="r"></td> # elif diff.style == 'inline': <th>${from_n}</th><th> </th>{# #}<td class="l"><del>${line}</del></td> # endif </tr> # endfor # elif 'mod': ## Show edited lines, on both "sides" # if diff.style == 'sidebyside': # if len(block.base.lines) >= len(block.changed.lines): # for line in block.base.lines: <tr> <th>${block.base.offset + loop.index}</th> <td class="l"><span>${line}</span></td> # set within_change = loop.index0 is lessthan(len(block.changed.lines)) <th>${block.changed.offset + loop.index if within_change else ' '|safe}</th> <td class="r">{% if within_change %}<span>${block.changed.lines[loop.index0]}</span>{% endif %}</td> </tr> # endfor # else: ## ## there are more changed lines than original lines # for line in block.changed.lines: <tr> # set within_change = loop.index0 is lessthan(len(block.base.lines)) <th>${block.base.offset + loop.index if within_change else ' '|safe}</th> <td class="l">{% if within_change %}<span>${block.base.lines[loop.index0]}</span>{% endif %}</td> <th>${block.changed.offset + loop.index}</th> <td class="r"><span>${line}</span></td> </tr> # endfor # endif # elif diff.style == 'inline': ## First show the "old" lines # for line in block.base.lines: <tr${{'class': 'first' if loop.first}|htmlattr}> <th>${block.base.offset + loop.index}</th><th> </th>{# #}<td class="l"><span>${line}</span></td> </tr> # endfor ## Then show the "new" lines # for line in block.changed.lines: <tr${{'class': 'last' if loop.index == len(block.changed.lines) }|htmlattr}> <th> </th><th>${block.changed.offset + loop.index}</th>{# #}<td class="r"><span>${line}</span></td> </tr> # endfor # endif # endif </tbody> # endfor # if loop.index is lessthan(len(item.diffs)): <tbody class="skipped"> # with # set fromline = item.diffs[loop.index][0].base.offset + 1 # set toline = item.diffs[loop.index][0].changed.offset + 1 # if diff.style == 'sidebyside': <tr> <th><a href="${old.href}#L${fromline}">…</a></th>{# #}<td> </td> <th><a href="${new.href}#L${toline}">…</a></th>{# #}<td> </td> </tr> # elif diff.style == 'inline': <tr> <th><a href="${old.href}#L${fromline}">…</a></th> <th><a href="${new.href}#L${toline}">…</a></th> <td> # if 'diffs_title' in item: <em>${item.diffs_title[loop.index]}</em> # endif </td> </tr> # endif # endwith </tbody> # endif # endfor </table> ## jinjacheck: "thead colgroup thead" OK # endif </li> # endif # endfor </ul> # endif </div>