diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -365,6 +365,18 @@ def attach_context_attributes(context, r # Fix this and remove it from base controller. # context.repo_name = get_repo_slug(request) # can be empty + diffmode = 'sideside' + if request.GET.get('diffmode'): + if request.GET['diffmode'] == 'unified': + diffmode = 'unified' + elif request.session.get('diffmode'): + diffmode = request.session['diffmode'] + + context.diffmode = diffmode + + if request.session.get('diffmode') != diffmode: + request.session['diffmode'] = diffmode + context.csrf_token = auth.get_csrf_token() context.backends = rhodecode.BACKENDS.keys() context.backends.sort() diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -107,6 +107,15 @@ def pylons_url_current(*args, **kw): url.current = pylons_url_current +def url_replace(**qargs): + """ Returns the current request url while replacing query string args """ + + request = get_current_request() + new_args = request.GET.mixed() + new_args.update(qargs) + return url('', **new_args) + + def asset(path, ver=None): """ Helper to generate a static asset file path for rhodecode assets diff --git a/rhodecode/templates/codeblocks/diffs.html b/rhodecode/templates/codeblocks/diffs.html --- a/rhodecode/templates/codeblocks/diffs.html +++ b/rhodecode/templates/codeblocks/diffs.html @@ -35,16 +35,10 @@ return h.url('', **new_args) ruler_at_chars=0, )"> <% -# TODO: dan: move this to an argument - and set a cookie so that it is saved -# default option for future requests -diff_mode = request.GET.get('diffmode', 'sideside') -if diff_mode not in ('sideside', 'unified'): - diff_mode = 'sideside' - collapse_all = len(diffset.files) > collapse_when_files_over %> -%if diff_mode == 'sideside': +%if c.diffmode == 'sideside':