Mercurial > kallithea
changeset 5651:e97ed5aff9ad
diff: unify identical template parts
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 05 Jan 2016 16:56:39 +0100 |
parents | 76b9630e1e92 |
children | 6af24662e4a7 |
files | kallithea/templates/changeset/diff_block.html |
diffstat | 1 files changed, 25 insertions(+), 95 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/templates/changeset/diff_block.html Tue Jan 05 16:56:39 2016 +0100 +++ b/kallithea/templates/changeset/diff_block.html Tue Jan 05 16:56:39 2016 +0100 @@ -9,12 +9,33 @@ </div> <div class="diff-container" id="${'diff-container-%s' % (id(change))}"> %for id_fid, (a_rev, cs_rev, op, filename, diff, stats) in change.iteritems(): + ${diff_block_diffblock(id_fid, h.FID(cs_rev, filename), op, filename, diff, + c.repo_name, a_rev, 'rev', a_rev, + c.repo_name, cs_rev, 'rev', cs_rev)} +%endfor +</div> +</%def> + +<%def name="diff_block_simple(files, changes)"> +<div class="diff-collapse"> + <span target="${'diff-container-%s' % (id(changes))}" class="diff-collapse-button">↑ ${_('Collapse Diff')} ↑</span> +</div> +<div class="diff-container" id="${'diff-container-%s' % (id(changes))}"> + %for fid, ch, f, stat in files: <% - url_fid = h.FID(cs_rev, filename) - a_repo_name = cs_repo_name = c.repo_name - a_ref_type, a_ref_name = 'rev', a_rev - cs_ref_type, cs_ref_name = 'rev', cs_rev + op, filename, diff = changes[fid] %> + ${diff_block_diffblock(h.FID('', filename), None, op, filename, diff, + c.a_repo.repo_name, c.a_rev, c.a_ref_type, c.a_ref_name, + c.cs_repo.repo_name, c.cs_rev, c.cs_ref_type, c.cs_ref_name)} + %endfor +</div> +</%def> + +<%def name="diff_block_diffblock(id_fid, url_fid, op, filename, diff, + a_repo_name, a_rev, a_ref_type, a_ref_name, + cs_repo_name, cs_rev, cs_ref_type, cs_ref_name)" +> <div id="${id_fid}_target" style="clear:both;margin-top:25px"></div> <div id="${id_fid}" class="diffblock margined comm"> <div class="code-header"> @@ -85,97 +106,6 @@ %endif </div> </div> -%endfor -</div> -</%def> - -<%def name="diff_block_simple(files, changes)"> -<div class="diff-collapse"> - <span target="${'diff-container-%s' % (id(changes))}" class="diff-collapse-button">↑ ${_('Collapse Diff')} ↑</span> -</div> -<div class="diff-container" id="${'diff-container-%s' % (id(changes))}"> - %for fid, ch, f, stat in files: - <% - op, filename, diff = changes[fid] - id_fid = h.FID('', filename) - url_fid = '' # or None - a_rev, cs_rev = c.a_rev, c.cs_rev - a_repo_name, cs_repo_name = c.a_repo.repo_name, c.cs_repo.repo_name - a_ref_type, a_ref_name = c.a_ref_type, c.a_ref_name - cs_ref_type, cs_ref_name = c.cs_ref_type, c.cs_ref_name - %> - <div id="${id_fid}_target" style="clear:both;margin-top:25px"></div> - <div id="${id_fid}" class="diffblock margined comm"> - <div class="code-header"> - <div class="changeset_header"> - <div class="changeset_file"> - ${h.safe_unicode(filename)} | - ## TODO: link to ancestor and head of other instead of exactly other - %if op == 'A': - ${_('Added')} - <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a> - %elif op == 'M': - <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a> - <i class="icon-right"></i> - <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a> - %elif op == 'D': - ${_('Deleted')} - <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a> - %elif op == 'R': - ${_('Renamed')} - <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a> - <i class="icon-right"></i> - <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a> - %else: - ${op}??? - %endif - </div> - <div class="diff-actions"> - <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full diff for this file')}"> - <i class="icon-file-code"></i> - </a> - <a href="${h.url('files_diff_2way_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff1=a_rev,diff2=cs_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full side-by-side diff for this file')}"> - <i class="icon-docs"></i> - </a> - <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='raw')}" class="tooltip" title="${_('Raw diff')}"> - <i class="icon-diff"></i> - </a> - <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='download')}" class="tooltip" title="${_('Download diff')}"> - <i class="icon-floppy"></i> - </a> - ${c.ignorews_url(request.GET, url_fid)} - ${c.context_url(request.GET, url_fid)} - </div> - <span style="float:right;margin-top:-3px"> - <label> - ${_('Show inline comments')} - ${h.checkbox('',checked="checked",class_="show-inline-comments",id_for=url_fid)} - </label> - </span> - </div> - </div> - <div class="code-body full_f_path" data-f_path="${h.safe_unicode(filename)}"> - ${diff|n} - %if filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']: - <div class="btn btn-image-diff-show">Show images</div> - %if op == 'M': - <div id="${id_fid}_image-diff" class="btn btn-image-diff-swap" style="display:none">Press to swap images</div> - %endif - <div style="font-size: 0"> - %if op in 'DM': - <img id="${id_fid}_image-diff-img-a" class="img-diff img-diff-swapable" style="display:none" - realsrc="${h.url('files_raw_home',repo_name=a_repo_name,revision=a_rev,f_path=filename)}" /> - %endif - %if op in 'AM': - <img id="${id_fid}_image-diff-img-b" class="img-diff img-diff-swapable" style="display:none" - realsrc="${h.url('files_raw_home',repo_name=cs_repo_name,revision=cs_rev,f_path=filename)}" /> - %endif - </div> - %endif - </div> - </div> - %endfor -</div> </%def> <%def name="diff_block_js()">