checkpoint: show user's status action in timeline
Show if the user liked, bookmarked or boosted a status in the timeline view. Moved symbols from printer to const values in printer package.
This commit is contained in:
parent
cc1a33530b
commit
db84a3a608
5 changed files with 50 additions and 29 deletions
|
@ -125,11 +125,11 @@ func (p Printer) PrintAccountList(list model.AccountList) {
|
||||||
|
|
||||||
if list.Type == model.AccountListBlockedAccount {
|
if list.Type == model.AccountListBlockedAccount {
|
||||||
for ind := range list.Accounts {
|
for ind := range list.Accounts {
|
||||||
builder.WriteString("\n" + p.bullet + " " + list.Accounts[ind].Acct + " (" + list.Accounts[ind].ID + ")")
|
builder.WriteString("\n" + symbolBullet + " " + list.Accounts[ind].Acct + " (" + list.Accounts[ind].ID + ")")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ind := range list.Accounts {
|
for ind := range list.Accounts {
|
||||||
builder.WriteString("\n" + p.bullet + " " + p.fullDisplayNameFormat(list.Accounts[ind].DisplayName, list.Accounts[ind].Acct))
|
builder.WriteString("\n" + symbolBullet + " " + p.fullDisplayNameFormat(list.Accounts[ind].DisplayName, list.Accounts[ind].Acct))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (p Printer) PrintList(list model.List) {
|
||||||
|
|
||||||
if len(list.Accounts) > 0 {
|
if len(list.Accounts) > 0 {
|
||||||
for acct, name := range list.Accounts {
|
for acct, name := range list.Accounts {
|
||||||
builder.WriteString("\n" + p.bullet + " " + p.fullDisplayNameFormat(name, acct))
|
builder.WriteString("\n" + symbolBullet + " " + p.fullDisplayNameFormat(name, acct))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.WriteString("\n" + "None")
|
builder.WriteString("\n" + "None")
|
||||||
|
@ -40,7 +40,7 @@ func (p Printer) PrintLists(lists []model.List) {
|
||||||
builder.WriteString("\n" + p.headerFormat("LISTS"))
|
builder.WriteString("\n" + p.headerFormat("LISTS"))
|
||||||
|
|
||||||
for i := range lists {
|
for i := range lists {
|
||||||
builder.WriteString("\n" + p.bullet + " " + lists[i].Title + " (" + lists[i].ID + ")")
|
builder.WriteString("\n" + symbolBullet + " " + lists[i].Title + " (" + lists[i].ID + ")")
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.WriteString("\n")
|
builder.WriteString("\n")
|
||||||
|
|
|
@ -85,10 +85,10 @@ func (p Printer) pollMeter(votage float64) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
meter := "\n" + voteBlockColor + strings.Repeat(p.pollMeterSymbol, numVoteBlocks) + p.theme.reset
|
meter := "\n" + voteBlockColor + strings.Repeat(symbolPollMeter, numVoteBlocks) + p.theme.reset
|
||||||
|
|
||||||
if !p.noColor {
|
if !p.noColor {
|
||||||
meter += backgroundBlockColor + strings.Repeat(p.pollMeterSymbol, numBackgroundBlocks) + p.theme.reset
|
meter += backgroundBlockColor + strings.Repeat(symbolPollMeter, numBackgroundBlocks) + p.theme.reset
|
||||||
}
|
}
|
||||||
|
|
||||||
return meter
|
return meter
|
||||||
|
|
|
@ -15,6 +15,18 @@ import (
|
||||||
const (
|
const (
|
||||||
minTerminalWidth = 40
|
minTerminalWidth = 40
|
||||||
noMediaDescription = "This media attachment has no description."
|
noMediaDescription = "This media attachment has no description."
|
||||||
|
symbolBullet = "\u2022"
|
||||||
|
symbolPollMeter = "\u2501"
|
||||||
|
symbolSuccess = "\u2714"
|
||||||
|
symbolFailure = "\u2717"
|
||||||
|
symbolImage = "\uf03e"
|
||||||
|
symbolLiked = "\uf51f"
|
||||||
|
symbolNotLiked = "\uf41e"
|
||||||
|
symbolBookmarked = "\uf47a"
|
||||||
|
symbolNotBookmarked = "\uf461"
|
||||||
|
symbolBoosted = "\u2BAD"
|
||||||
|
dateFormat = "02 Jan 2006"
|
||||||
|
dateTimeFormat = "02 Jan 2006, 15:04 (MST)"
|
||||||
)
|
)
|
||||||
|
|
||||||
type theme struct {
|
type theme struct {
|
||||||
|
@ -26,6 +38,8 @@ type theme struct {
|
||||||
grey string
|
grey string
|
||||||
red string
|
red string
|
||||||
boldred string
|
boldred string
|
||||||
|
yellow string
|
||||||
|
boldyellow string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Printer struct {
|
type Printer struct {
|
||||||
|
@ -34,13 +48,6 @@ type Printer struct {
|
||||||
maxTerminalWidth int
|
maxTerminalWidth int
|
||||||
pager string
|
pager string
|
||||||
statusSeparator string
|
statusSeparator string
|
||||||
bullet string
|
|
||||||
pollMeterSymbol string
|
|
||||||
successSymbol string
|
|
||||||
failureSymbol string
|
|
||||||
dateFormat string
|
|
||||||
dateTimeFormat string
|
|
||||||
imageIcon string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPrinter(
|
func NewPrinter(
|
||||||
|
@ -57,6 +64,8 @@ func NewPrinter(
|
||||||
grey: "\033[90m",
|
grey: "\033[90m",
|
||||||
red: "\033[31m",
|
red: "\033[31m",
|
||||||
boldred: "\033[31;1m",
|
boldred: "\033[31;1m",
|
||||||
|
yellow: "\033[33m",
|
||||||
|
boldyellow: "\033[33;1m",
|
||||||
}
|
}
|
||||||
|
|
||||||
if maxTerminalWidth < minTerminalWidth {
|
if maxTerminalWidth < minTerminalWidth {
|
||||||
|
@ -69,29 +78,22 @@ func NewPrinter(
|
||||||
maxTerminalWidth: maxTerminalWidth,
|
maxTerminalWidth: maxTerminalWidth,
|
||||||
pager: pager,
|
pager: pager,
|
||||||
statusSeparator: strings.Repeat("\u2501", maxTerminalWidth),
|
statusSeparator: strings.Repeat("\u2501", maxTerminalWidth),
|
||||||
bullet: "\u2022",
|
|
||||||
pollMeterSymbol: "\u2501",
|
|
||||||
successSymbol: "\u2714",
|
|
||||||
failureSymbol: "\u2717",
|
|
||||||
dateFormat: "02 Jan 2006",
|
|
||||||
dateTimeFormat: "02 Jan 2006, 15:04 (MST)",
|
|
||||||
imageIcon: "\uf03e",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintSuccess(text string) {
|
func (p Printer) PrintSuccess(text string) {
|
||||||
success := p.theme.boldgreen + p.successSymbol + p.theme.reset
|
success := p.theme.boldgreen + symbolSuccess + p.theme.reset
|
||||||
if p.noColor {
|
if p.noColor {
|
||||||
success = p.successSymbol
|
success = symbolSuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
printToStdout(success + " " + text + "\n")
|
printToStdout(success + " " + text + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintFailure(text string) {
|
func (p Printer) PrintFailure(text string) {
|
||||||
failure := p.theme.boldred + p.failureSymbol + p.theme.reset
|
failure := p.theme.boldred + symbolFailure + p.theme.reset
|
||||||
if p.noColor {
|
if p.noColor {
|
||||||
failure = p.failureSymbol
|
failure = symbolFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
printToStderr(failure + " " + text + "\n")
|
printToStderr(failure + " " + text + "\n")
|
||||||
|
@ -135,11 +137,11 @@ func (p Printer) fullDisplayNameFormat(displayName, acct string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) formatDate(date time.Time) string {
|
func (p Printer) formatDate(date time.Time) string {
|
||||||
return date.Local().Format(p.dateFormat)
|
return date.Local().Format(dateFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) formatDateTime(date time.Time) string {
|
func (p Printer) formatDateTime(date time.Time) string {
|
||||||
return date.Local().Format(p.dateTimeFormat)
|
return date.Local().Format(dateTimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) print(text string) {
|
func (p Printer) print(text string) {
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (p Printer) PrintStatusList(list model.StatusList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, media := range mediaAttachments {
|
for _, media := range mediaAttachments {
|
||||||
builder.WriteString("\n\n" + p.imageIcon + " Media attachment: " + media.ID)
|
builder.WriteString("\n\n" + symbolImage + " Media attachment: " + media.ID)
|
||||||
builder.WriteString("\n Media type: " + media.Type + "\n ")
|
builder.WriteString("\n Media type: " + media.Type + "\n ")
|
||||||
|
|
||||||
description := media.Description
|
description := media.Description
|
||||||
|
@ -121,6 +121,25 @@ func (p Printer) PrintStatusList(list model.StatusList) {
|
||||||
builder.WriteString(utilities.WrapLines(description, "\n ", p.maxTerminalWidth-3))
|
builder.WriteString(utilities.WrapLines(description, "\n ", p.maxTerminalWidth-3))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boosted := symbolBoosted
|
||||||
|
if status.Reblogged {
|
||||||
|
boosted = p.theme.boldyellow + symbolBoosted + p.theme.reset
|
||||||
|
}
|
||||||
|
|
||||||
|
liked := symbolNotLiked
|
||||||
|
if status.Favourited {
|
||||||
|
liked = p.theme.boldyellow + symbolLiked + p.theme.reset
|
||||||
|
}
|
||||||
|
|
||||||
|
bookmarked := symbolNotBookmarked
|
||||||
|
if status.Bookmarked {
|
||||||
|
bookmarked = p.theme.boldyellow + symbolBookmarked + p.theme.reset
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.WriteString("\n\n" + boosted + " " + p.fieldFormat("boosted:") + " " + strconv.FormatBool(status.Bookmarked))
|
||||||
|
builder.WriteString("\n" + liked + " " + p.fieldFormat("liked:") + " " + strconv.FormatBool(status.Favourited))
|
||||||
|
builder.WriteString("\n" + bookmarked + " " + p.fieldFormat("bookmarked:") + " " + strconv.FormatBool(status.Bookmarked))
|
||||||
|
|
||||||
builder.WriteString(
|
builder.WriteString(
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
p.fieldFormat("Status ID:") + " " + statusID + "\t" +
|
p.fieldFormat("Status ID:") + " " + statusID + "\t" +
|
||||||
|
|
Loading…
Reference in a new issue