Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
1618:5d9889f14012 | 1619:a2cd4222c702 |
---|---|
100 return str(jid.JID(str(full_jid)).bare) | 100 return str(jid.JID(str(full_jid)).bare) |
101 | 101 |
102 env.addFilter("bare_jid", _bare_jid) | 102 env.addFilter("bare_jid", _bare_jid) |
103 | 103 |
104 | 104 |
105 def _initials(name: str) -> str: | |
106 """Return the uppercased initials of a name.""" | |
107 name_parts = name.strip().split() | |
108 if not name_parts: | |
109 initials = "??" | |
110 elif len(name_parts) == 1: | |
111 initials = name_parts[0][:2] | |
112 else: | |
113 initials = name_parts[0][0] + name_parts[1][0] | |
114 return initials.upper() | |
115 | |
116 env.addFilter("initials", _initials) | |
117 | |
118 | |
105 def _next_gidx(value): | 119 def _next_gidx(value): |
106 """Use next current global index as suffix""" | 120 """Use next current global index as suffix""" |
107 next_ = gidx.next(value) | 121 next_ = gidx.next(value) |
108 return f"{value}{SCRIPT_SUFF}" if next_ == 0 else f"{value}_{SCRIPT_SUFF}{next_}" | 122 return f"{value}{SCRIPT_SUFF}" if next_ == 0 else f"{value}_{SCRIPT_SUFF}{next_}" |
109 | 123 |
160 if cls: | 174 if cls: |
161 kwargs = cls.to_dict() | 175 kwargs = cls.to_dict() |
162 cls = kwargs.get('cls') | 176 cls = kwargs.get('cls') |
163 return safe( | 177 return safe( |
164 '<svg class="svg-icon{cls}" xmlns="http://www.w3.org/2000/svg" ' | 178 '<svg class="svg-icon{cls}" xmlns="http://www.w3.org/2000/svg" ' |
165 'viewBox="0 0 100 100">\n' | 179 'viewBox="0 0 100 100" fill="currentColor">\n' |
166 ' <use href="#{name}"/>' | 180 ' <use href="#{name}"/>' |
167 '</svg>\n'.format(name=name, cls=(" " + cls) if cls else "") | 181 '</svg>\n'.format(name=name.replace(" ", "_"), cls=(" " + cls) if cls else "") |
168 ) | 182 ) |
169 | 183 |
170 env.addGlobal("icon", _icon_use) | 184 env.addGlobal("icon", _icon_use) |
171 | 185 |
172 | 186 |
178 fmt, date_only, auto_limit, auto_old_fmt, auto_new_fmt = get_args( | 192 fmt, date_only, auto_limit, auto_old_fmt, auto_new_fmt = get_args( |
179 args, fmt="short", date_only=False, auto_limit=7, auto_old_fmt="short", | 193 args, fmt="short", date_only=False, auto_limit=7, auto_old_fmt="short", |
180 auto_new_fmt="relative", | 194 auto_new_fmt="relative", |
181 ) | 195 ) |
182 from js_modules.moment import moment | 196 from js_modules.moment import moment |
183 date = moment.unix(timestamp) | 197 # FIXME: we use `window.moment` as workaround for |
198 # https://github.com/brython-dev/brython/issues/2542 (see comments) | |
199 date = window.moment.unix(timestamp) | |
184 | 200 |
185 if fmt == "auto_day": | 201 if fmt == "auto_day": |
186 fmt, auto_limit, auto_old_fmt, auto_new_fmt = "auto", 0, "short", "HH:mm" | 202 fmt, auto_limit, auto_old_fmt, auto_new_fmt = "auto", 0, "short", "HH:mm" |
187 | 203 |
188 if fmt == "auto": | 204 if fmt == "auto": |