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 |
|
-
|