mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-22 07:10:59 +00:00
Fix static file URLs
This commit is contained in:
parent
8ffe4bc145
commit
5bc9ff39ac
3 changed files with 20 additions and 5 deletions
|
@ -35,8 +35,8 @@ class Account(Schema):
|
|||
note: str
|
||||
avatar: str
|
||||
avatar_static: str
|
||||
header: str
|
||||
header_static: str
|
||||
header: str | None = Field(...)
|
||||
header_static: str | None = Field(...)
|
||||
locked: bool
|
||||
fields: list[AccountField]
|
||||
emojis: list[CustomEmoji]
|
||||
|
|
16
core/uris.py
16
core/uris.py
|
@ -1,6 +1,7 @@
|
|||
from urllib.parse import urljoin
|
||||
|
||||
from django.conf import settings
|
||||
from django.templatetags.static import static
|
||||
|
||||
|
||||
class RelativeAbsoluteUrl:
|
||||
|
@ -32,3 +33,18 @@ class AutoAbsoluteUrl(RelativeAbsoluteUrl):
|
|||
else:
|
||||
absolute_prefix = f"https://{settings.MAIN_DOMAIN}/"
|
||||
self.absolute = urljoin(absolute_prefix, self.relative)
|
||||
|
||||
|
||||
class StaticAbsoluteUrl(RelativeAbsoluteUrl):
|
||||
"""
|
||||
Creates static URLs given only the static-relative path
|
||||
"""
|
||||
|
||||
def __init__(self, path: str):
|
||||
static_url = static(path)
|
||||
if "://" in static_url:
|
||||
super().__init__(static_url)
|
||||
else:
|
||||
super().__init__(
|
||||
urljoin(f"https://{settings.MAIN_DOMAIN}/", static_url), static_url
|
||||
)
|
||||
|
|
|
@ -7,7 +7,6 @@ import urlman
|
|||
from asgiref.sync import async_to_sync, sync_to_async
|
||||
from django.db import IntegrityError, models
|
||||
from django.template.defaultfilters import linebreaks_filter
|
||||
from django.templatetags.static import static
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import lazy
|
||||
|
||||
|
@ -17,7 +16,7 @@ from core.ld import canonicalise, format_ld_date, get_list, media_type_from_file
|
|||
from core.models import Config
|
||||
from core.signatures import HttpSignature, RsaKeys
|
||||
from core.uploads import upload_namer
|
||||
from core.uris import AutoAbsoluteUrl, RelativeAbsoluteUrl
|
||||
from core.uris import AutoAbsoluteUrl, RelativeAbsoluteUrl, StaticAbsoluteUrl
|
||||
from stator.models import State, StateField, StateGraph, StatorModel
|
||||
from users.models.domain import Domain
|
||||
from users.models.system_actor import SystemActor
|
||||
|
@ -156,7 +155,7 @@ class Identity(StatorModel):
|
|||
elif self.icon_uri:
|
||||
return AutoAbsoluteUrl(f"/proxy/identity_icon/{self.pk}/")
|
||||
else:
|
||||
return RelativeAbsoluteUrl(static("img/unknown-icon-128.png"))
|
||||
return StaticAbsoluteUrl("img/unknown-icon-128.png")
|
||||
|
||||
def local_image_url(self) -> RelativeAbsoluteUrl | None:
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue