Skip to content

Commit

Permalink
Render release/listing URLs as rich markdown links
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Nov 12, 2024
1 parent 84ed809 commit e1e2bcd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions discodos/ctrl/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from sqlite3 import Row
from datetime import datetime
from rich.table import Table as rich_table
from rich.markdown import Markdown
from textual.app import App
from textual.containers import Horizontal, Vertical, VerticalScroll
from textual.widgets import DataTable, Digits, Footer, Label, Static, RichLog
Expand Down Expand Up @@ -189,6 +190,8 @@ def _two_column_view(self, details_dict, translate_keys=None):
# Highlight/fix/replace some values first
values_replaced = {}
for key, value in details_dict.items():
if key in ["d_sales_release_url", "d_sales_url"]:
value = Markdown(f"[View in browser]({value})")
if key == "d_sales_allow_offers":
value = "Yes" if value in [1, True] else "No"
elif key == "status" and value == "Sold":
Expand All @@ -209,6 +212,9 @@ def _two_column_view(self, details_dict, translate_keys=None):

# The final creation of the Rich table
for key, value in final_details.items():
if isinstance(value, Markdown):
table.add_row(f"[bold]{key}[/bold]", value)
continue
# Format key bold and value normal font (or as we manipulated it above)
table.add_row(f"[bold]{key}[/bold]", str(value))
return table
Expand Down

0 comments on commit e1e2bcd

Please sign in to comment.