feat(tui): show IG urls as @username
This commit is contained in:
parent
b9e706e36e
commit
9f6e6327c5
1 changed files with 19 additions and 1 deletions
|
|
@ -95,7 +95,7 @@ fn list_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {
|
||||||
p.address.clone(),
|
p.address.clone(),
|
||||||
p.open_hours.clone(),
|
p.open_hours.clone(),
|
||||||
p.description.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),
|
||||||
Constraint::Fill(1),
|
Constraint::Fill(1),
|
||||||
|
Constraint::Fill(1),
|
||||||
];
|
];
|
||||||
|
|
||||||
let places_table = Table::new(places, widths)
|
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);
|
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] {
|
fn keybinding(key: &'static str, action: &'static str) -> [Span<'static>; 5] {
|
||||||
let black_bold = Style::new().black().on_gray().bold();
|
let black_bold = Style::new().black().on_gray().bold();
|
||||||
let red_bold = Style::new().red().on_gray().bold();
|
let red_bold = Style::new().red().on_gray().bold();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue