Show More
@@ -365,6 +365,18 b' def attach_context_attributes(context, r' | |||
|
365 | 365 | # Fix this and remove it from base controller. |
|
366 | 366 | # context.repo_name = get_repo_slug(request) # can be empty |
|
367 | 367 | |
|
368 | diffmode = 'sideside' | |
|
369 | if request.GET.get('diffmode'): | |
|
370 | if request.GET['diffmode'] == 'unified': | |
|
371 | diffmode = 'unified' | |
|
372 | elif request.session.get('diffmode'): | |
|
373 | diffmode = request.session['diffmode'] | |
|
374 | ||
|
375 | context.diffmode = diffmode | |
|
376 | ||
|
377 | if request.session.get('diffmode') != diffmode: | |
|
378 | request.session['diffmode'] = diffmode | |
|
379 | ||
|
368 | 380 | context.csrf_token = auth.get_csrf_token() |
|
369 | 381 | context.backends = rhodecode.BACKENDS.keys() |
|
370 | 382 | context.backends.sort() |
@@ -107,6 +107,15 b' def pylons_url_current(*args, **kw):' | |||
|
107 | 107 | url.current = pylons_url_current |
|
108 | 108 | |
|
109 | 109 | |
|
110 | def url_replace(**qargs): | |
|
111 | """ Returns the current request url while replacing query string args """ | |
|
112 | ||
|
113 | request = get_current_request() | |
|
114 | new_args = request.GET.mixed() | |
|
115 | new_args.update(qargs) | |
|
116 | return url('', **new_args) | |
|
117 | ||
|
118 | ||
|
110 | 119 | def asset(path, ver=None): |
|
111 | 120 | """ |
|
112 | 121 | Helper to generate a static asset file path for rhodecode assets |
@@ -35,16 +35,10 b" return h.url('', **new_args)" | |||
|
35 | 35 | ruler_at_chars=0, |
|
36 | 36 | )"> |
|
37 | 37 | <% |
|
38 | # TODO: dan: move this to an argument - and set a cookie so that it is saved | |
|
39 | # default option for future requests | |
|
40 | diff_mode = request.GET.get('diffmode', 'sideside') | |
|
41 | if diff_mode not in ('sideside', 'unified'): | |
|
42 | diff_mode = 'sideside' | |
|
43 | ||
|
44 | 38 | collapse_all = len(diffset.files) > collapse_when_files_over |
|
45 | 39 | %> |
|
46 | 40 | |
|
47 |
%if diff |
|
|
41 | %if c.diffmode == 'sideside': | |
|
48 | 42 | <style> |
|
49 | 43 | .wrapper { |
|
50 | 44 | max-width: 1600px !important; |
@@ -73,35 +67,33 b' collapse_all = len(diffset.files) > coll' | |||
|
73 | 67 | |
|
74 | 68 | <div class="diffset"> |
|
75 | 69 | <div class="diffset-heading"> |
|
76 | %if diffset.files: | |
|
77 | 70 | <div class="pull-right"> |
|
78 | 71 | <div class="btn-group"> |
|
79 | 72 | <a |
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
73 | class="btn ${c.diffmode == 'sideside' and 'btn-primary'} tooltip" | |
|
74 | title="${_('View side by side')}" | |
|
75 | href="${h.url_replace(diffmode='sideside')}"> | |
|
83 | 76 | <span>${_('Side by Side')}</span> |
|
84 | 77 | </a> |
|
85 | 78 | <a |
|
86 |
|
|
|
87 |
|
|
|
79 | class="btn ${c.diffmode == 'unified' and 'btn-primary'} tooltip" | |
|
80 | title="${_('View unified')}" href="${h.url_replace(diffmode='unified')}"> | |
|
88 | 81 | <span>${_('Unified')}</span> |
|
89 | 82 | </a> |
|
90 | 83 | </div> |
|
91 | 84 | </div> |
|
92 | 85 | <div class="pull-left"> |
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
86 | <div class="btn-group"> | |
|
87 | <a | |
|
88 | class="btn" | |
|
89 | href="#" | |
|
90 | onclick="$('input[class=filediff-collapse-state]').prop('checked', false); return false">${_('Expand All')}</a> | |
|
91 | <a | |
|
92 | class="btn" | |
|
93 | href="#" | |
|
94 | onclick="$('input[class=filediff-collapse-state]').prop('checked', true); return false">${_('Collapse All')}</a> | |
|
95 | </div> | |
|
103 | 96 | </div> |
|
104 | %endif | |
|
105 | 97 | <h2 style="padding: 5px; text-align: center;"> |
|
106 | 98 | %if diffset.limited_diff: |
|
107 | 99 | ${ungettext('%(num)s file changed', '%(num)s files changed', diffset.changed_files) % {'num': diffset.changed_files}} |
@@ -132,11 +124,11 b' collapse_all = len(diffset.files) > coll' | |||
|
132 | 124 | ${diff_ops(filediff)} |
|
133 | 125 | </label> |
|
134 | 126 | ${diff_menu(filediff)} |
|
135 |
<table class="cb cb-diff-${diff |
|
|
127 | <table class="cb cb-diff-${c.diffmode} code-highlight ${over_lines_changed_limit and 'cb-collapsed' or ''}"> | |
|
136 | 128 | %if not filediff.hunks: |
|
137 | 129 | %for op_id, op_text in filediff['patch']['stats']['ops'].items(): |
|
138 | 130 | <tr> |
|
139 |
<td class="cb-text cb-${op_class(op_id)}" ${diff |
|
|
131 | <td class="cb-text cb-${op_class(op_id)}" ${c.diffmode == 'unified' and 'colspan=3' or 'colspan=4'}> | |
|
140 | 132 | %if op_id == DEL_FILENODE: |
|
141 | 133 | ${_('File was deleted')} |
|
142 | 134 | %elif op_id == BIN_FILENODE: |
@@ -150,7 +142,7 b' collapse_all = len(diffset.files) > coll' | |||
|
150 | 142 | %endif |
|
151 | 143 | %if over_lines_changed_limit: |
|
152 | 144 | <tr class="cb-warning cb-collapser"> |
|
153 |
<td class="cb-text" ${diff |
|
|
145 | <td class="cb-text" ${c.diffmode == 'unified' and 'colspan=3' or 'colspan=4'}> | |
|
154 | 146 | ${_('This diff has been collapsed as it changes many lines, (%i lines changed)' % lines_changed)} |
|
155 | 147 | <a href="#" class="cb-expand" |
|
156 | 148 | onclick="$(this).closest('table').removeClass('cb-collapsed'); return false;">${_('Show them')} |
@@ -163,29 +155,29 b' collapse_all = len(diffset.files) > coll' | |||
|
163 | 155 | %endif |
|
164 | 156 | %if filediff.patch['is_limited_diff']: |
|
165 | 157 | <tr class="cb-warning cb-collapser"> |
|
166 |
<td class="cb-text" ${diff |
|
|
158 | <td class="cb-text" ${c.diffmode == 'unified' and 'colspan=3' or 'colspan=4'}> | |
|
167 | 159 | ${_('The requested commit is too big and content was truncated.')} <a href="${link_for(fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a> |
|
168 | 160 | </td> |
|
169 | 161 | </tr> |
|
170 | 162 | %endif |
|
171 | 163 | %for hunk in filediff.hunks: |
|
172 | 164 | <tr class="cb-hunk"> |
|
173 |
<td ${diff |
|
|
165 | <td ${c.diffmode == 'unified' and 'colspan=2' or ''}> | |
|
174 | 166 | ## TODO: dan: add ajax loading of more context here |
|
175 | 167 | ## <a href="#"> |
|
176 | 168 | <i class="icon-more"></i> |
|
177 | 169 | ## </a> |
|
178 | 170 | </td> |
|
179 |
<td ${diff |
|
|
171 | <td ${c.diffmode == 'sideside' and 'colspan=3' or ''}> | |
|
180 | 172 | @@ |
|
181 | 173 | -${hunk.source_start},${hunk.source_length} |
|
182 | 174 | +${hunk.target_start},${hunk.target_length} |
|
183 | 175 | ${hunk.section_header} |
|
184 | 176 | </td> |
|
185 | 177 | </tr> |
|
186 |
%if diff |
|
|
178 | %if c.diffmode == 'unified': | |
|
187 | 179 | ${render_hunk_lines_unified(hunk)} |
|
188 |
%elif diff |
|
|
180 | %elif c.diffmode == 'sideside': | |
|
189 | 181 | ${render_hunk_lines_sideside(hunk)} |
|
190 | 182 | %else: |
|
191 | 183 | <tr class="cb-line"> |
General Comments 0
You need to be logged in to leave comments.
Login now