from flask import make_response, render_template, request, session def render_page_template(name, route_data=None, **kwargs): """ Renders the page template with the given name as the response and returns its contents. """ # main_scripts = _list_files('build', 'js', js_bundle_name) # # use_cdn = app.config.get('USE_CDN', True) # if request.args.get('use_cdn') is not None: # use_cdn = request.args.get('use_cdn') == 'true' # # external_styles = get_external_css(local=not use_cdn) # external_scripts = get_external_javascript(local=not use_cdn) # # # Add Stripe checkout if billing is enabled. # if features.BILLING: # external_scripts.append('//checkout.stripe.com/checkout.js') # # def get_external_login_config(): # login_config = [] # for login_service in oauth_login.services: # login_config.append({ # 'id': login_service.service_id(), # 'title': login_service.service_name(), # 'config': login_service.get_public_config(), # 'icon': login_service.get_icon(), # }) # # return login_config # # def get_oauth_config(): # oauth_config = {} # for oauth_app in oauth_apps: # oauth_config[oauth_app.key_name] = oauth_app.get_public_config() # # return oauth_config # # contact_href = None # if len(app.config.get('CONTACT_INFO', [])) == 1: # contact_href = app.config['CONTACT_INFO'][0] # # version_number = '' # if not features.BILLING: # version_number = 'Quay %s' % __version__ # # scopes_set = {scope.scope: scope._asdict() for scope in scopes.app_scopes(app.config).values()} contents = render_template(name, route_data=route_data, # external_styles=external_styles, # external_scripts=external_scripts, # main_scripts=main_scripts, # feature_set=features.get_features(), # config_set=frontend_visible_config(app.config), # oauth_set=get_oauth_config(), # external_login_set=get_external_login_config(), # scope_set=scopes_set, # vuln_priority_set=PRIORITY_LEVELS, # enterprise_logo=app.config.get('ENTERPRISE_LOGO_URL', ''), # mixpanel_key=app.config.get('MIXPANEL_KEY', ''), # munchkin_key=app.config.get('MARKETO_MUNCHKIN_ID', ''), # recaptcha_key=app.config.get('RECAPTCHA_SITE_KEY', ''), # google_tagmanager_key=app.config.get('GOOGLE_TAGMANAGER_KEY', ''), # google_anaytics_key=app.config.get('GOOGLE_ANALYTICS_KEY', ''), # sentry_public_dsn=app.config.get('SENTRY_PUBLIC_DSN', ''), # is_debug=str(app.config.get('DEBUGGING', False)).lower(), # show_chat=features.SUPPORT_CHAT, # aci_conversion=features.ACI_CONVERSION, # has_billing=features.BILLING, # contact_href=contact_href, # hostname=app.config['SERVER_HOSTNAME'], # preferred_scheme=app.config['PREFERRED_URL_SCHEME'], # version_number=version_number, # current_year=datetime.datetime.now().year, **kwargs) resp = make_response(contents) resp.headers['X-FRAME-OPTIONS'] = 'DENY' return resp