예제 #1
0
    def __init__(self, *, usernames: list[str]) -> None:
        super().__init__()

        with self.doc, e.Table(style=self._get_css("table")), e.Tr():

            for username in usernames:
                with e.Td():

                    with ce.Username(name=username):
                        e.Div(style=self._get_css("background1"))

                    e.Div(username, style=self._get_css("username"))

                    with ce.Username(name=username):
                        e.Div(style=self._get_css("background2"))
예제 #2
0
    def load_page(self, page: int) -> None:
        db = Database.open()
        with db.get_session() as session:
            stmt_last_page = self._stmt.with_only_columns(func.count())
            last_page = math.ceil(session.scalar(stmt_last_page) / 100)
            page = min(page, last_page)
            stmt_rs = self._stmt.limit(100).offset(100 * (page - 1))

            rs = session.execute(stmt_rs).all()

            with self.doc, e.Div(class_="pad"):
                e.H2(self._title)
                if not rs:
                    e.TextNode("No results found")
                    return

                with e.Div(class_="ladder"), e.Table():
                    with e.Tr():
                        for field_header, _ in self._fields:
                            e.Th(field_header)
                        e.Th(self._actions_header)

                    for row in rs:
                        with e.Tr():
                            for _, field in self._fields:
                                e.Td(
                                    str(getattr(row[0], field) or "")
                                    if isinstance(field, str) else field(row))

                            with e.Td(style=self._get_css("one_pixel_width")):
                                self._add_action_buttons(row)

                page_cmd = (f"/pm {self._botname}, {self._cmd_char}changepage "
                            f"{self._command}, {self._room.roomid}, ")
                for p in range(last_page):
                    with e.Button(p + 1, class_="option") as btn:
                        if page == p + 1:
                            btn.add_class("sel")
                            btn["disabled"] = True
                        else:
                            btn["name"] = "send"
                            btn["value"] = f"{page_cmd}{p + 1}"
예제 #3
0
파일: profile.py 프로젝트: prnss/cerbottana
    def __init__(
        self,
        *,
        avatar_dir: str,
        avatar_name: str,
        username: str,
        badges: list[d.Badges],
        description: str | None,
        pokemon_icon: str | None,
    ) -> None:
        super().__init__()

        with self.doc, e.Div():

            with e.Div(style=self._get_css("avatar")):
                e.Img(
                    src=(
                        "https://play.pokemonshowdown.com/sprites/"
                        f"{avatar_dir}/{avatar_name}.png"
                    ),
                    width=80,
                    height=80,
                )

            with e.Div(style=self._get_css("main")):
                ce.Username(username)
                e.Br()
                for badge in badges:
                    e.Img(
                        src=badge.image,
                        width=13,
                        height=13,
                        title=badge.label,
                        style=self._get_css("badge"),
                    )
                if description:
                    e.Hr(style=self._get_css("hr"))
                    e.Div(description, style=self._get_css("description"))

            if pokemon_icon:
                with e.Div(style=self._get_css("pokemon_icon")):
                    ce.Psicon(pokemon=pokemon_icon)
예제 #4
0
    def __init__(self, *, learnset_data: Learnset) -> None:
        super().__init__()

        if not learnset_data.methods:
            return

        with self.doc, e.Div(class_="ladder"):
            for method in sorted(learnset_data.methods.values()):
                with e.Details():
                    e.Summary(e.B(method.method.prose))
                    self._add_table(method)
예제 #5
0
    def __init__(self, *, encounters_data: Encounters) -> None:
        super().__init__()

        if not encounters_data.versions:
            return

        with self.doc, e.Div(class_="ladder"):
            for version in sorted(encounters_data.versions.values()):
                with e.Details():
                    e.Summary(e.B(version.version.name))
                    self._add_table(version)
예제 #6
0
async def tell(msg: Message) -> None:
    if not msg.arg:
        await msg.reply("Cosa devo inviare?")
        return

    author = msg.user.roomname(msg.parametrized_room)
    html = e.B(to_obfuscated_html(msg.arg)) + e.Br()
    html += e.Div(
        f"[inviato da {author}]",
        style="display: inline-block; color: #888; font-size: 8pt",
    )
    await msg.parametrized_room.send_htmlbox(html)