From 6e7772016747ec09a3c3f669478c98992a37fbed Mon Sep 17 00:00:00 2001 From: rekushi <1+rekushi@noreply.flipnote.world> Date: Thu, 29 Oct 2026 04:41:36 +0000 Subject: [PATCH] feat(dsi): add a paginated channel directory List configured channels in a native menu with browsing and posting links. --- hatenadir/ds/v2-xx/channels.ugo.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 hatenadir/ds/v2-xx/channels.ugo.py diff --git a/hatenadir/ds/v2-xx/channels.ugo.py b/hatenadir/ds/v2-xx/channels.ugo.py new file mode 100644 index 0000000..b8c47cf --- /dev/null +++ b/hatenadir/ds/v2-xx/channels.ugo.py @@ -0,0 +1,20 @@ +from twisted.web import resource + +from DB import Database +from reximemo import dsi_url, make_menu, page_number, pagination_buttons + + +class PyResource(resource.Resource): + isLeaf = True + + def render_GET(self, request): + channels = Database.list_channels() + page = page_number(request, len(channels), 25) + buttons = [{"label": channel["title"], "url": dsi_url(request, f"ch/{channel['id']}.uls"), "icon": 101} + for channel in channels[(page - 1) * 25:page * 25]] + pager = pagination_buttons(request, "channels.uls", page, len(channels), 25) + before = [button for button in pager if button["label"].startswith("Previous")] + after = [button for button in pager if button["label"].startswith("Next")] + request.setHeader(b"content-type", b"text/plain") + return make_menu(layout=(2, 1), title="Channels", subtitle_bottom="Choose a channel to browse or post.", + left="Channels", right=str(len(channels)), buttons=before + buttons + after)