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

Reviewed-on: #55
Co-authored-by: Felipe Contreras Salinas <felipe@bstr.cl>
Co-committed-by: Felipe Contreras Salinas <felipe@bstr.cl>
This commit is contained in:
Felipe 2025-06-15 01:00:58 -04:00 committed by Felipe
parent b9e706e36e
commit 93fb08e310
Signed by: Ludwig
GPG key ID: 441A26F83D31FAFF

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();