Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_struct_org_logo(self):
"""
Gets logo for structured data using a fallback.
"""
if self.struct_org_logo:
return self.struct_org_logo
else:
layout_settings = LayoutSettings.for_site(self.get_site())
if layout_settings.logo:
return layout_settings.logo
return None
# Prepend the site's root URL except for when MEDIA_URL already
# looks like a full URL.
protocol = re.compile(r'^(\w[\w\.\-\+]*:)*//')
if protocol.match(settings.MEDIA_URL):
base_url = ''
else:
base_url = context['request'].site.root_url
if page:
if page.og_image:
return base_url + page.og_image.get_rendition('original').url
elif page.cover_image:
return base_url + page.cover_image.get_rendition('original').url
if LayoutSettings.for_site(context['request'].site).logo:
layout_settings = LayoutSettings.for_site(context['request'].site)
return base_url + layout_settings.logo.get_rendition('original').url
return None
# Fixes #240 https://github.com/coderedcorp/coderedcms/issues/240
# Prepend the site's root URL except for when MEDIA_URL already
# looks like a full URL.
protocol = re.compile(r'^(\w[\w\.\-\+]*:)*//')
if protocol.match(settings.MEDIA_URL):
base_url = ''
else:
base_url = context['request'].site.root_url
if page:
if page.og_image:
return base_url + page.og_image.get_rendition('original').url
elif page.cover_image:
return base_url + page.cover_image.get_rendition('original').url
if LayoutSettings.for_site(context['request'].site).logo:
layout_settings = LayoutSettings.for_site(context['request'].site)
return base_url + layout_settings.logo.get_rendition('original').url
return None
def get_navbar_css(context):
layout = LayoutSettings.for_site(context['request'].site)
fixed = "fixed-top" if layout.navbar_fixed else ""
return " ".join([
fixed,
layout.navbar_collapse_mode,
layout.navbar_color_scheme,
layout.navbar_format,
layout.navbar_class
])