def render_page_template(name, route_data=None, js_bundle_name=DEFAULT_JS_BUNDLE_NAME, **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 = os.getenv("TESTING") == "true" external_styles = get_external_css(local=not use_cdn, exclude=FONT_AWESOME_4) external_scripts = get_external_javascript(local=not use_cdn) contents = render_template( name, route_data=route_data, main_scripts=main_scripts, external_styles=external_styles, external_scripts=external_scripts, config_set=frontend_visible_config(app.config), kubernetes_namespace=IS_KUBERNETES and get_k8s_namespace(), **kwargs, ) resp = make_response(contents) return resp
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, exclude=FONT_AWESOME_5) 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 has_contact = len(app.config.get("CONTACT_INFO", [])) > 0 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, registry_state=app.config.get("REGISTRY_STATE", "normal"), 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, 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(), aci_conversion=features.ACI_CONVERSION, has_billing=features.BILLING, onprem=not app.config.get("FEATURE_BILLING", False), contact_href=contact_href, has_contact=has_contact, hostname=app.config["SERVER_HOSTNAME"], preferred_scheme=app.config["PREFERRED_URL_SCHEME"], version_number=version_number, current_year=datetime.datetime.now().year, kubernetes_namespace=IS_KUBERNETES and QE_NAMESPACE, **kwargs) resp = make_response(contents) resp.headers["X-FRAME-OPTIONS"] = "DENY" return resp