caret

[ACTIVE] a command line tool for browsing Lobsters in your terminal
git clone git://git.figbert.com/caret.git
Log | Files | Refs | README | LICENSE

commit 9288c310ad115342e99a09a8aff791875d1b97f4
parent d8cef5ababdcdad75b59cad81dd9ec95c5177791
Author: FIGBERT <figbert@figbert.com>
Date:   Thu,  5 Oct 2023 16:15:28 -0700

Add adaptive tag color + url icons to line items

Diffstat:
Mitem.go | 21+++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/item.go b/item.go @@ -22,14 +22,18 @@ func (i item) Title() string { if err != nil { return i.post.Headline } - displayURL := ui.SecondaryText().Render(fmt.Sprintf("(%s)", parsedURL.Hostname())) - return fmt.Sprintf("%s %s", i.post.Headline, displayURL) + inline := " ☶ " + if u := parsedURL.Hostname(); u != "" { + inline = fmt.Sprintf(" (%s)", u) + } + + return fmt.Sprintf("%s%s", i.post.Headline, ui.Gray().Render(inline)) } func (itm item) Description() string { created := utils.TimeFromAPI(itm.post.CreatedAt) - intro := ui.SecondaryText().Render( + intro := ui.Gray().Render( fmt.Sprintf( "%d upvotes via %s | %s | ", itm.post.Score, itm.post.User.Username, humanize.Time(created), @@ -38,13 +42,18 @@ func (itm item) Description() string { var tags strings.Builder for i, t := range itm.post.Tags { - tags.WriteString(ui.TagText().Render(t)) + switch t { + case "video", "pdf", "slides", "show", "meta", "ask": + tags.WriteString(ui.Purple().Render(t)) + default: + tags.WriteString(ui.Orange().Render(t)) + } if i != len(itm.post.Tags)-1 { - tags.WriteString(ui.SecondaryText().Render(", ")) + tags.WriteString(ui.Gray().Render(", ")) } } - comments := ui.SecondaryText().Render(fmt.Sprintf(" | %d comments", itm.post.CommentCount)) + comments := ui.Gray().Render(fmt.Sprintf(" | %d comments", itm.post.CommentCount)) return intro + tags.String() + comments }