Код: Выделить всё
weblate-1 | gunicorn stderr | [2025-01-21 12:41:08,913: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/weblate.svg'
weblate-1 | gunicorn stderr | [2025-01-21 12:41:08,918: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/wrench.svg'
weblate-1 | gunicorn stderr | [2025-01-21 12:41:08,919: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/plus.svg'
weblate-1 | gunicorn stderr | [2025-01-21 12:41:08,923: WARNING/1540] Could not load icon: FileNotFoundError: [Errno 2] No such file or directory: '/app/cache/static/icons/dots.svg'
ИЗМЕНИТЬ
Логика тега шаблона по умолчанию выглядит следующим образом:
Код: Выделить всё
weblate/weblate/utils/templatetags/icon.pyКод: Выделить всё
@register.simple_tag()
def icon(name):
"""
Inlines SVG icon.
Inlining is necessary to be able to apply CSS styles on the path.
"""
if not name:
msg = "Empty icon name"
raise ValueError(msg)
if name not in CACHE:
if name.startswith("state/"):
icon_file = os.path.join(settings.STATIC_ROOT, name)
else:
icon_file = os.path.join(settings.STATIC_ROOT, "icons", name)
try:
with open(icon_file) as handle:
CACHE[name] = mark_safe(handle.read()) # noqa: S308
except OSError:
report_error("Could not load icon")
return ""
return CACHE[name]
Код: Выделить всё
weblate_customization/templatetags/icon.pyКод: Выделить всё
@register.simple_tag()
def icon(name: str) -> str:
"""
Inlines SVG icon.
Inlining is necessary to be able to apply CSS styles on the path.
"""
if not name:
msg = "Empty icon name"
raise ValueError(msg)
if name not in CACHE:
if name.startswith("state/"):
icon_url = os.path.join(settings.STATIC_URL, name)
else:
icon_url = os.path.join(settings.STATIC_URL, "icons", name)
try:
icon_file = request.urlopen(icon_url)
except OSError:
report_error("Could not load icon")
return ""
else:
CACHE[name] = ""
for line in icon_file.readlines():
CACHE[name] += line
return mark_safe(CACHE[name])
Я не могу переименовать его во что-то вроде «new_icon» и перезаписать шаблоны, поскольку шаблоны берутся из базового образа Docker, а также из самого модуля weblate.utils, где теги шаблона определяются и регистрируются.
Подробнее здесь: https://stackoverflow.com/questions/793 ... plate-tags
Мобильная версия