feat(tui): show IG urls as @username #55

Merged
pitbuster merged 1 commit from ig-url into main 2025-06-15 01:00:59 -04:00

View file

@ -95,7 +95,7 @@ fn list_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {
p.address.clone(),
p.open_hours.clone(),
p.description.clone(),
p.url.clone().unwrap_or_default(),
url(p.url.as_ref().map(|u| u.as_ref())),
])
});
@ -108,6 +108,7 @@ fn list_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {
Constraint::Fill(1),
Constraint::Fill(1),
Constraint::Fill(1),
Constraint::Fill(1),
];
let places_table = Table::new(places, widths)
@ -176,6 +177,23 @@ fn footer_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {
f.render_widget(keybindings, area);
}
fn url(url: Option<&str>) -> String {
match url {
Some(url) => {
if url.starts_with("https://instagram.com/") {
format!(
"@{}",
url.trim_start_matches("https://instagram.com/")
.trim_end_matches("/")
)
} else {
url.to_owned()
}
}
None => String::new(),
}
}
fn keybinding(key: &'static str, action: &'static str) -> [Span<'static>; 5] {
let black_bold = Style::new().black().on_gray().bold();
let red_bold = Style::new().red().on_gray().bold();