From cc2da06ac19ae47e489452ea152f248b5f86e382 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Wed, 4 Feb 2026 19:39:55 +1100 Subject: [PATCH] inline links in repo results --- screens/search_screen.py | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/screens/search_screen.py b/screens/search_screen.py index df75eb5..c9458d3 100644 --- a/screens/search_screen.py +++ b/screens/search_screen.py @@ -17,33 +17,30 @@ class SearchResult(HorizontalGroup): margin: 0 1; margin-top: 1; border: tall $surface; - + Static { width: auto; + link-style: bold; + link-color: $primary; } - - } """ def __init__( self, - author: str, - name: str, - description: str, - is_fork: bool, - updated_at: datetime + repo_data: dict ): super().__init__() - self.author = author - self.repo_name = name - self.description = description - self.is_fork = is_fork - self.updated_at = updated_at.replace(tzinfo=None) + self.repo_data = repo_data + self.author = repo_data["owner"] + self.repo_name = repo_data["name"] + self.description = repo_data["description"] + self.is_fork = repo_data["fork"] + self.updated_at = datetime.fromisoformat(repo_data["updated_at"]).replace(tzinfo=None) def compose(self) -> ComposeResult: updated_string = time_delta(datetime.now() - self.updated_at) - yield Static(f"[b]{self.author}[/] / [b]{self.repo_name}[/]{' [d]\[[blue]fork[/]]' if self.is_fork else ''}\n{self.description}\n[d]Updated {updated_string} ago") + yield Static(f"[@click='view_user({self.author["id"]})']{self.author["login"]}[/] / [@click=view_repo('')]{self.repo_name}[/]{' [d]\[[cyan]fork[/]]' if self.is_fork else ''}\n{self.description}\n[d]Updated {updated_string} ago") class SearchScreen(Screen): DEFAULT_CSS = """ @@ -90,13 +87,7 @@ class SearchScreen(Screen): to_mount = [] print(response.json()) for result in response.json()["data"]: - to_mount.append(SearchResult( - result["owner"]["login"], - result["name"], - result["description"], - result["fork"], - datetime.fromisoformat(result["updated_at"]) - )) + to_mount.append(SearchResult(result)) results.mount_all(to_mount) # self explanitory