Mercurial > libervia-web
diff libervia/web/pages/_browser/template.py @ 1619:a2cd4222c702
browser: Updates for new design:
This patch add code to handle the new design for chat.
New bridge method are used to invite users to MUC or get list of occupants.
A new modules is used for components, with a first one for collapsible cards.
rel 457
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 12 Apr 2025 00:21:45 +0200 |
parents | 9865013da86c |
children |
line wrap: on
line diff
--- a/libervia/web/pages/_browser/template.py Sat Oct 26 23:07:01 2024 +0200 +++ b/libervia/web/pages/_browser/template.py Sat Apr 12 00:21:45 2025 +0200 @@ -102,6 +102,20 @@ env.addFilter("bare_jid", _bare_jid) +def _initials(name: str) -> str: + """Return the uppercased initials of a name.""" + name_parts = name.strip().split() + if not name_parts: + initials = "??" + elif len(name_parts) == 1: + initials = name_parts[0][:2] + else: + initials = name_parts[0][0] + name_parts[1][0] + return initials.upper() + +env.addFilter("initials", _initials) + + def _next_gidx(value): """Use next current global index as suffix""" next_ = gidx.next(value) @@ -162,9 +176,9 @@ cls = kwargs.get('cls') return safe( '<svg class="svg-icon{cls}" xmlns="http://www.w3.org/2000/svg" ' - 'viewBox="0 0 100 100">\n' + 'viewBox="0 0 100 100" fill="currentColor">\n' ' <use href="#{name}"/>' - '</svg>\n'.format(name=name, cls=(" " + cls) if cls else "") + '</svg>\n'.format(name=name.replace(" ", "_"), cls=(" " + cls) if cls else "") ) env.addGlobal("icon", _icon_use) @@ -180,7 +194,9 @@ auto_new_fmt="relative", ) from js_modules.moment import moment - date = moment.unix(timestamp) + # FIXME: we use `window.moment` as workaround for + # https://github.com/brython-dev/brython/issues/2542 (see comments) + date = window.moment.unix(timestamp) if fmt == "auto_day": fmt, auto_limit, auto_old_fmt, auto_new_fmt = "auto", 0, "short", "HH:mm"