readmes should work now i think
This commit is contained in:
@@ -6,12 +6,13 @@
|
|||||||
content-align: left middle;
|
content-align: left middle;
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#buttons {
|
#buttons {
|
||||||
layout: horizontal;
|
layout: horizontal;
|
||||||
Button {
|
Button {
|
||||||
margin-left: 1;
|
margin-left: 1;
|
||||||
max-width: 13;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +57,10 @@
|
|||||||
Static {
|
Static {
|
||||||
width: 1fr;
|
width: 1fr;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
link-style: bold;
|
||||||
|
link-style-hover: underline bold;
|
||||||
|
link-background-hover: transparent;
|
||||||
|
pointer: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,4 +84,9 @@
|
|||||||
|
|
||||||
LoadingIndicator {
|
LoadingIndicator {
|
||||||
height: 1;
|
height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#readme {
|
||||||
|
border: panel $surface;
|
||||||
|
margin: 1 0 0 1;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
from textual.app import ComposeResult
|
from textual.app import ComposeResult
|
||||||
from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button
|
from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button, Markdown
|
||||||
from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
|
from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
|
||||||
from textual import work
|
from textual import work
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ from widgets import Navbar
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from human_readable import time_delta
|
from human_readable import time_delta
|
||||||
|
|
||||||
import requests
|
import requests, asyncio
|
||||||
|
|
||||||
|
|
||||||
class RepoViewScreen(Screen):
|
class RepoViewScreen(Screen):
|
||||||
@@ -114,7 +114,7 @@ class RepoViewScreen(Screen):
|
|||||||
|
|
||||||
most_recent_commit = commits_response.json()[0]
|
most_recent_commit = commits_response.json()[0]
|
||||||
files.add_columns(
|
files.add_columns(
|
||||||
f"[b]{most_recent_commit["author"]["login"]}[/]",
|
f"[b]{most_recent_commit["commit"]["author"]["name"]}[/]",
|
||||||
f"[r]{most_recent_commit["sha"][:10]}[/]",
|
f"[r]{most_recent_commit["sha"][:10]}[/]",
|
||||||
f"[d]{most_recent_commit["commit"]["message"]}"
|
f"[d]{most_recent_commit["commit"]["message"]}"
|
||||||
)
|
)
|
||||||
@@ -126,6 +126,7 @@ class RepoViewScreen(Screen):
|
|||||||
page_size = 50
|
page_size = 50
|
||||||
commit_data = {}
|
commit_data = {}
|
||||||
|
|
||||||
|
# loop over all the root commits until we get em' all
|
||||||
while True:
|
while True:
|
||||||
commits = requests.get(
|
commits = requests.get(
|
||||||
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
|
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
|
||||||
@@ -146,6 +147,9 @@ class RepoViewScreen(Screen):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
found_readme = False
|
||||||
|
readme: Markdown = self.query_one("#readme")
|
||||||
|
|
||||||
for file in files_response.json():
|
for file in files_response.json():
|
||||||
commit = commit_data[file["last_commit_sha"]]
|
commit = commit_data[file["last_commit_sha"]]
|
||||||
|
|
||||||
@@ -156,8 +160,21 @@ class RepoViewScreen(Screen):
|
|||||||
f"[d]{commit["commit"]["message"]}",
|
f"[d]{commit["commit"]["message"]}",
|
||||||
f"[d]Updated {time_delta(datetime.now() - commit_created_at)} ago"
|
f"[d]Updated {time_delta(datetime.now() - commit_created_at)} ago"
|
||||||
))
|
))
|
||||||
|
|
||||||
|
if file["name"].lower() == "readme.md":
|
||||||
|
found_readme = True
|
||||||
|
readme.border_title = file["name"]
|
||||||
|
|
||||||
|
readme_content = requests.get(
|
||||||
|
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/raw/{file["name"]}"
|
||||||
|
).text
|
||||||
|
self.app.call_from_thread(readme.update, readme_content or "Empty README")
|
||||||
|
|
||||||
files.add_rows(rows)
|
files.add_rows(rows)
|
||||||
|
|
||||||
|
if not found_readme:
|
||||||
|
readme.update("This repository has no `README.md` file.")
|
||||||
|
|
||||||
loading.display = False
|
loading.display = False
|
||||||
files.display = True
|
files.display = True
|
||||||
|
|
||||||
@@ -180,8 +197,9 @@ class RepoViewScreen(Screen):
|
|||||||
with HorizontalGroup():
|
with HorizontalGroup():
|
||||||
yield Static(f" {self.owner_name}/[b]{self.repo_name}[/]", id="title")
|
yield Static(f" {self.owner_name}/[b]{self.repo_name}[/]", id="title")
|
||||||
with Right(id="buttons"):
|
with Right(id="buttons"):
|
||||||
yield Button("Star [d](0)", variant="warning", flat=True)
|
yield Button(f"\uf005 Star [d]({data["stars_count"]})", variant="warning", flat=True)
|
||||||
yield Button("Watch [d](0)", flat=True)
|
yield Button(f"\uf418 Fork [d]({data["forks_count"]})", variant="primary", flat=True)
|
||||||
|
yield Button(f"\uea70 Watch [d]({data["watchers_count"]})", flat=True)
|
||||||
yield Tabs(
|
yield Tabs(
|
||||||
"\uf44f Code",
|
"\uf44f Code",
|
||||||
"\uebf8 Issues",
|
"\uebf8 Issues",
|
||||||
@@ -198,9 +216,9 @@ class RepoViewScreen(Screen):
|
|||||||
with HorizontalGroup(id="Code"):
|
with HorizontalGroup(id="Code"):
|
||||||
with VerticalGroup(id="commits"):
|
with VerticalGroup(id="commits"):
|
||||||
with HorizontalGroup(id="branch-info"):
|
with HorizontalGroup(id="branch-info"):
|
||||||
yield Static("\uf4b6 1 Commits")
|
yield Static(f"[@click='']\uf4b6 1 Commits[/]")
|
||||||
yield Static("\uf418 1 Branch")
|
yield Static(f"[@click='']\uf418 1 Branch[/]")
|
||||||
yield Static("\uf02b 0 Tags")
|
yield Static(f"[@click='']\uf02b 0 Tags[/]")
|
||||||
|
|
||||||
with HorizontalGroup(id="branch-options"):
|
with HorizontalGroup(id="branch-options"):
|
||||||
yield Select.from_values([
|
yield Select.from_values([
|
||||||
@@ -215,9 +233,13 @@ class RepoViewScreen(Screen):
|
|||||||
yield table
|
yield table
|
||||||
|
|
||||||
yield LoadingIndicator()
|
yield LoadingIndicator()
|
||||||
|
|
||||||
|
readme = Markdown(markdown="Loading...", id="readme")
|
||||||
|
readme.border_title = "\uf405 README.md"
|
||||||
|
yield readme
|
||||||
with Vertical(id="repo-info"):
|
with Vertical(id="repo-info"):
|
||||||
with HorizontalGroup():
|
with HorizontalGroup():
|
||||||
yield Input("Search code...", id="search-query")
|
yield Input(placeholder="Search code...", id="search-query")
|
||||||
yield Button("\uf002", flat=True, id="search-btn")
|
yield Button("\uf002", flat=True, id="search-btn")
|
||||||
yield Static("\n[b] Description")
|
yield Static("\n[b] Description")
|
||||||
yield Static("[d]" + data["description"], id="description")
|
yield Static("[d]" + data["description"], id="description")
|
||||||
@@ -58,7 +58,7 @@ class SearchScreen(Screen):
|
|||||||
width: 1fr;
|
width: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search-select {
|
Select {
|
||||||
width: 25;
|
width: 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,6 +100,7 @@ class SearchScreen(Screen):
|
|||||||
|
|
||||||
# self explanitory
|
# self explanitory
|
||||||
query_input.clear()
|
query_input.clear()
|
||||||
|
query_input.focus()
|
||||||
|
|
||||||
def on_input_submitted(self, event: Input.Submitted):
|
def on_input_submitted(self, event: Input.Submitted):
|
||||||
if event.input.id == "query":
|
if event.input.id == "query":
|
||||||
@@ -114,9 +115,21 @@ class SearchScreen(Screen):
|
|||||||
|
|
||||||
with HorizontalGroup(id="search-box"):
|
with HorizontalGroup(id="search-box"):
|
||||||
yield Input(placeholder="Search repos...", id="query")
|
yield Input(placeholder="Search repos...", id="query")
|
||||||
|
yield Select.from_values([
|
||||||
|
"Alphabetical",
|
||||||
|
"Creation date",
|
||||||
|
"Last updated",
|
||||||
|
"Size",
|
||||||
|
"ID"
|
||||||
|
], id="sort-select", allow_blank=False, value="Last updated")
|
||||||
|
yield Select.from_values([
|
||||||
|
"Ascending",
|
||||||
|
"Descending"
|
||||||
|
], id="order-select", allow_blank=False, value="Ascending")
|
||||||
yield Select.from_values([
|
yield Select.from_values([
|
||||||
"Repositories",
|
"Repositories",
|
||||||
], id="search-select", allow_blank=False)
|
"Users",
|
||||||
|
], id="search-select", allow_blank=False, value="Repositories")
|
||||||
|
|
||||||
with ScrollableContainer(id="results"):
|
with ScrollableContainer(id="results"):
|
||||||
yield LoadingIndicator()
|
yield LoadingIndicator()
|
||||||
Reference in New Issue
Block a user