inline links in repo results
This commit is contained in:
@@ -20,30 +20,27 @@ class SearchResult(HorizontalGroup):
|
|||||||
|
|
||||||
Static {
|
Static {
|
||||||
width: auto;
|
width: auto;
|
||||||
|
link-style: bold;
|
||||||
|
link-color: $primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
author: str,
|
repo_data: dict
|
||||||
name: str,
|
|
||||||
description: str,
|
|
||||||
is_fork: bool,
|
|
||||||
updated_at: datetime
|
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.author = author
|
self.repo_data = repo_data
|
||||||
self.repo_name = name
|
self.author = repo_data["owner"]
|
||||||
self.description = description
|
self.repo_name = repo_data["name"]
|
||||||
self.is_fork = is_fork
|
self.description = repo_data["description"]
|
||||||
self.updated_at = updated_at.replace(tzinfo=None)
|
self.is_fork = repo_data["fork"]
|
||||||
|
self.updated_at = datetime.fromisoformat(repo_data["updated_at"]).replace(tzinfo=None)
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
updated_string = time_delta(datetime.now() - self.updated_at)
|
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):
|
class SearchScreen(Screen):
|
||||||
DEFAULT_CSS = """
|
DEFAULT_CSS = """
|
||||||
@@ -90,13 +87,7 @@ class SearchScreen(Screen):
|
|||||||
to_mount = []
|
to_mount = []
|
||||||
print(response.json())
|
print(response.json())
|
||||||
for result in response.json()["data"]:
|
for result in response.json()["data"]:
|
||||||
to_mount.append(SearchResult(
|
to_mount.append(SearchResult(result))
|
||||||
result["owner"]["login"],
|
|
||||||
result["name"],
|
|
||||||
result["description"],
|
|
||||||
result["fork"],
|
|
||||||
datetime.fromisoformat(result["updated_at"])
|
|
||||||
))
|
|
||||||
results.mount_all(to_mount)
|
results.mount_all(to_mount)
|
||||||
|
|
||||||
# self explanitory
|
# self explanitory
|
||||||
|
|||||||
Reference in New Issue
Block a user