Skip to content

Commit

Permalink
Merge pull request #91 from zediious/routes-newinstance
Browse files Browse the repository at this point in the history
Check if site avatar exists
  • Loading branch information
zediious authored Oct 31, 2023
2 parents a447256 + 332794e commit 6070168
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions raptorWeb/raptormc/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ def _get_page_routes():
site_info: SiteInformation.objects = SiteInformation.objects.get_or_create(pk=1)[0]

current_routes: list = []

try:
site_avatar_url = f"{WEB_PROTO}://{DOMAIN_NAME}/{site_info.avatar_image.url}"
except ValueError:
site_avatar_url = f"{WEB_PROTO}://{DOMAIN_NAME}/static/image/no_user.webp"

if request.path == '/':
return {
"og_color": site_info.main_color,
"og_url": f"{WEB_PROTO}://{DOMAIN_NAME}",
"og_image": f"{WEB_PROTO}://{DOMAIN_NAME}/{site_info.avatar_image.url}",
"og_image": f"{WEB_PROTO}://{DOMAIN_NAME}/{site_avatar_url}",
"og_title": f"{site_info.brand_name} | Home",
"og_desc": site_info.meta_description
}
Expand All @@ -104,7 +109,7 @@ def _get_page_routes():
try:
user_avatar = route.user.user_profile_info.profile_picture.url
except ValueError:
user_avatar = site_info.avatar_image.url
user_avatar = site_avatar_url

return {
"og_user": route.user,
Expand All @@ -120,7 +125,7 @@ def _get_page_routes():
"og_page": route.page,
"og_color": site_info.main_color,
"og_url": f"{WEB_PROTO}://{DOMAIN_NAME}/{route.page.get_absolute_url()}",
"og_image": f"{WEB_PROTO}://{DOMAIN_NAME}/{site_info.avatar_image.url}",
"og_image": f"{WEB_PROTO}://{DOMAIN_NAME}/{site_avatar_url}",
"og_title": f"{site_info.brand_name} | {route.page.name}",
"og_desc": route.page.meta_description
}
Expand All @@ -138,7 +143,7 @@ def _get_page_routes():
return {
"og_color": site_info.main_color,
"og_url": f"{WEB_PROTO}://{DOMAIN_NAME}/{path}",
"og_image": f"{WEB_PROTO}://{DOMAIN_NAME}/{site_info.avatar_image.url}",
"og_image": f"{WEB_PROTO}://{DOMAIN_NAME}/{site_avatar_url}",
"og_title": f"{site_info.brand_name} | {path.title()}",
"og_desc": text_content
}
Expand Down

0 comments on commit 6070168

Please sign in to comment.