Projet

Général

Profil

0001-misc-remove-old-mobile-mode-25942.patch

Frédéric Péters, 14 juillet 2019 19:49

Télécharger (3,91 ko)

Voir les différences:

Subject: [PATCH] misc: remove old mobile mode (#25942)

 wcs/middleware.py       | 16 ----------------
 wcs/qommon/publisher.py | 28 ----------------------------
 2 files changed, 44 deletions(-)
wcs/middleware.py
54 54

  
55 55
        request._publisher = pub
56 56

  
57
        # if a ?toggle-mobile query string is passed, we explicitely set the
58
        # mode and reload the current page.
59
        if compat_request.get_query() == 'toggle-mobile':
60
            response = HttpResponseRedirect(compat_request.get_path())
61
            if pub.config.session_cookie_path:
62
                path = pub.config.session_cookie_path
63
            else:
64
                path = compat_request.get_environ('SCRIPT_NAME')
65
                if not path.endswith('/'):
66
                    path += '/'
67
            if compat_request.response.page_template_key == 'mobile':
68
                response.set_cookie('mobile', 'false', path=path)
69
            else:
70
                response.set_cookie('mobile', 'true', path=path)
71
            return response
72

  
73 57
        # handle session_var_<xxx> in query strings, add them to session and
74 58
        # redirect to same URL without the parameters
75 59
        if compat_request.get_method() == 'GET' and compat_request.form:
wcs/qommon/publisher.py
485 485
        '''
486 486
        self.site_options = None  # reset at the beginning of a request
487 487
        canonical_hostname = request.get_server(clean = False).lower().split(':')[0].rstrip('.')
488
        for prefix in ['mobile', 'm']:
489
            if canonical_hostname.startswith(prefix + '.') or \
490
                    canonical_hostname.startswith(prefix + '-'):
491
                canonical_hostname = canonical_hostname[len(prefix)+1:]
492
                break
493 488
        script_name = request.get_header('SCRIPT_NAME', '').strip('/')
494 489
        self.app_dir = os.path.join(self.APP_DIR, canonical_hostname)
495 490

  
......
538 533
                                os.path.split(self.app_dir)[-1].replace('+', '-').replace('.', '-')))
539 534

  
540 535
        self.initialize_app_dir()
541

  
542
        # determine appropriate theme variant
543
        canonical_hostname = request.get_server(False).lower().split(':')[0].rstrip('.')
544
        override_template_keys = {'m': 'mobile'}
545
        for prefix in ['mobile', 'm']:
546
            if canonical_hostname.startswith(prefix + '.') or \
547
                    canonical_hostname.startswith(prefix + '-'):
548
                request.response.page_template_key = override_template_keys.get(prefix, prefix)
549
                break
550

  
551 536
        self.set_config(request)
552 537

  
553
        if request.get_cookie('mobile') == 'false':
554
            # if the mobile mode is explicitely disabled, we will use the
555
            # default theme variant
556
            request.response.page_template_key = None
557
        elif request.get_cookie('mobile') == 'true':
558
            # if the mobile mode is explicitely asked, we will use the mobile
559
            # theme variant
560
            request.response.page_template_key = 'mobile'
561
        elif request.has_mobile_user_agent():
562
            # if a mobile user agent is detected and there are no explicit
563
            # direction, we will use the mobile theme variant
564
            request.response.page_template_key = 'mobile'
565

  
566 538
        if request.get_environ('QOMMON_PAGE_TEMPLATE_KEY'):
567 539
            request.response.page_template_key = request.get_environ('QOMMON_PAGE_TEMPLATE_KEY')
568 540

  
569
-