Mercurial > libervia-web
view libervia/web/pages/forums/list/page_meta.py @ 1522:a44f77559279
installation: moved from `setup.py` to `pyproject.toml`:
- following backend change, installation is now using `pyproject.toml`, and legacy
`setup.py` as well as other legacy files have been deleted/updated.
- [hatch](https://hatch.pypa.io) is now used as main building tool. However, thanks to the
use of standards, other tools can be used too.
- `VERSION` file has been deleted, in favor or using directly `__version__`, in
`libervia/web/__init__.py`. Version can be updated directly from Hatch
- update .hgignore
- several dependencies version bump, with code update to adapt to changes.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 07 Jun 2023 15:28:10 +0200 |
parents | eb00d593801d |
children |
line wrap: on
line source
#!/usr/bin/env python3 from libervia.web.server.constants import Const as C from libervia.backend.core.log import getLogger from libervia.backend.core.i18n import _ from libervia.backend.tools.common import uri as xmpp_uri log = getLogger(__name__) import json """forum handling pages""" name = "forums" access = C.PAGES_ACCESS_PUBLIC template = "forum/overview.html" def parse_url(self, request): self.get_path_args( request, ["service", "node", "forum_key"], service="@jid", node="@", forum_key="", ) def add_breadcrumb(self, request, breadcrumbs): # we don't want breadcrumbs here as long as there is no forum discovery # because it will be the landing page for forums activity until then pass def get_links(self, forums): for forum in forums: try: uri = forum["uri"] except KeyError: pass else: uri = xmpp_uri.parse_xmpp_uri(uri) service = uri["path"] node = uri["node"] forum["http_url"] = self.get_page_by_name("forum_topics").get_url(service, node) if "sub-forums" in forum: get_links(self, forum["sub-forums"]) async def prepare_render(self, request): data = self.get_r_data(request) template_data = request.template_data service, node, key = data["service"], data["node"], data["forum_key"] profile = self.get_profile(request) or C.SERVICE_PROFILE try: forums_raw = await self.host.bridge_call( "forums_get", service.full() if service else "", node, key, profile ) except Exception as e: log.warning(_("Can't retrieve forums: {msg}").format(msg=e)) forums = [] else: forums = json.loads(forums_raw) get_links(self, forums) template_data["forums"] = forums