mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-09-22 04:35:55 -04:00
Added Info to Forum, polished Forums selector
This commit is contained in:
parent
42e9987d29
commit
6656710329
@ -43,7 +43,7 @@ func (a *Aggregator) ListForums() ([]forum.Forum, []error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sort.SliceStable(forums, func(i, j int) bool {
|
sort.SliceStable(forums, func(i, j int) bool {
|
||||||
return strings.Compare(forums[i].Name, forums[j].Name) == -1
|
return strings.Compare(forums[i].Title(), forums[j].Title()) == -1
|
||||||
})
|
})
|
||||||
|
|
||||||
return forums, errs
|
return forums, errs
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package forum
|
package forum
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
type Forum struct {
|
type Forum struct {
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
|
|
||||||
|
Info string
|
||||||
|
|
||||||
SysIDX int
|
SysIDX int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12,9 +16,9 @@ func (forum Forum) FilterValue() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (forum Forum) Title() string {
|
func (forum Forum) Title() string {
|
||||||
return forum.Name
|
return strings.Title(forum.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (forum Forum) Description() string {
|
func (forum Forum) Description() string {
|
||||||
return forum.ID
|
return forum.Info
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,8 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
|||||||
ID: strconv.Itoa(cat.ID),
|
ID: strconv.Itoa(cat.ID),
|
||||||
Name: cat.Name,
|
Name: cat.Name,
|
||||||
|
|
||||||
|
Info: cat.Description,
|
||||||
|
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -101,31 +101,37 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
|||||||
{
|
{
|
||||||
ID: "top",
|
ID: "top",
|
||||||
Name: "Top HN Stories",
|
Name: "Top HN Stories",
|
||||||
|
Info: "Top stories on Hacker News",
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "best",
|
ID: "best",
|
||||||
Name: "Best HN Stories",
|
Name: "Best HN Stories",
|
||||||
|
Info: "Best stories on Hacker News",
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "new",
|
ID: "new",
|
||||||
Name: "New HN Stories",
|
Name: "New HN Stories",
|
||||||
|
Info: "New stories on Hacker News",
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "ask",
|
ID: "ask",
|
||||||
Name: "Ask HN",
|
Name: "Ask HN",
|
||||||
|
Info: "Ask Hacker News about the world",
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "show",
|
ID: "show",
|
||||||
Name: "Show HN",
|
Name: "Show HN",
|
||||||
|
Info: "Show Hacker News something awesome",
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "jobs",
|
ID: "jobs",
|
||||||
Name: "Jobs HN",
|
Name: "Jobs HN",
|
||||||
|
Info: "... because we can't *all* become Astronauts",
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -142,6 +142,8 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
|||||||
ID: strconv.Itoa(i.Community.ID),
|
ID: strconv.Itoa(i.Community.ID),
|
||||||
Name: i.Community.Name,
|
Name: i.Community.Name,
|
||||||
|
|
||||||
|
Info: i.Community.Description.ValueOr(i.Community.Title),
|
||||||
|
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,9 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
|||||||
for _, tag := range *tags {
|
for _, tag := range *tags {
|
||||||
models = append(models, forum.Forum{
|
models = append(models, forum.Forum{
|
||||||
ID: tag.Tag,
|
ID: tag.Tag,
|
||||||
Name: tag.Description,
|
Name: tag.Tag,
|
||||||
|
|
||||||
|
Info: tag.Description,
|
||||||
|
|
||||||
SysIDX: sys.ID,
|
SysIDX: sys.ID,
|
||||||
})
|
})
|
||||||
|
@ -64,23 +64,31 @@ func (m Model) View() string {
|
|||||||
var row string
|
var row string
|
||||||
var spinner string = ""
|
var spinner string = ""
|
||||||
|
|
||||||
|
selectorWidth := 40
|
||||||
|
selectorTextLen := selectorWidth - 7
|
||||||
selector := lipgloss.NewStyle().
|
selector := lipgloss.NewStyle().
|
||||||
Foreground(lipgloss.Color("#7fffd4")).
|
Foreground(lipgloss.Color("#7fffd4")).
|
||||||
BorderForeground(lipgloss.Color("#7fffd4")).
|
BorderForeground(lipgloss.Color("#7fffd4")).
|
||||||
Border(lipgloss.NormalBorder()).
|
Border(lipgloss.NormalBorder()).
|
||||||
Padding(0, 1, 0, 1).
|
Padding(0, 1, 0, 1).
|
||||||
Width(40)
|
Width(selectorWidth)
|
||||||
|
|
||||||
curSysIdx := m.ctx.GetCurrentSystem()
|
curSysIdx := m.ctx.GetCurrentSystem()
|
||||||
var currentSystem string = "All"
|
var currentSystem string = "All"
|
||||||
if curSysIdx >= 0 {
|
if curSysIdx >= 0 {
|
||||||
currentSystem = (*m.ctx.Systems[curSysIdx]).Title()
|
currentSystem = (*m.ctx.Systems[curSysIdx]).Title()
|
||||||
|
if len(currentSystem) > selectorTextLen {
|
||||||
|
currentSystem = currentSystem[0:selectorTextLen]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
curForum := m.ctx.GetCurrentForum()
|
curForum := m.ctx.GetCurrentForum()
|
||||||
var currentForum string = "All"
|
var currentForum string = "All"
|
||||||
if curForum.ID != "" {
|
if curForum.ID != "" {
|
||||||
currentForum = curForum.Title()
|
currentForum = curForum.Title()
|
||||||
|
if len(currentForum) > selectorTextLen {
|
||||||
|
currentForum = currentForum[0:selectorTextLen]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
systemSelector := selector.Render(fmt.Sprintf("⏷ %s", currentSystem))
|
systemSelector := selector.Render(fmt.Sprintf("⏷ %s", currentSystem))
|
||||||
|
@ -110,6 +110,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case key.Matches(msg, m.keymap.NewPost):
|
case key.Matches(msg, m.keymap.NewPost):
|
||||||
i, ok := m.list.SelectedItem().(post.Post)
|
i, ok := m.list.SelectedItem().(post.Post)
|
||||||
if ok {
|
if ok {
|
||||||
|
m.focused = false // TODO: Refactor and use ToolKit
|
||||||
m.viewcache = m.buildView(false)
|
m.viewcache = m.buildView(false)
|
||||||
cmd := cmd.New(
|
cmd := cmd.New(
|
||||||
cmd.WinOpen,
|
cmd.WinOpen,
|
||||||
@ -124,6 +125,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
cmds = append(cmds, cmd.Tea())
|
cmds = append(cmds, cmd.Tea())
|
||||||
|
return m, tea.Batch(cmds...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@ func buildView(mi interface{}, cached bool) string {
|
|||||||
title += fmt.Sprintf(" to reply #%d", m.replyToIdx)
|
title += fmt.Sprintf(" to reply #%d", m.replyToIdx)
|
||||||
}
|
}
|
||||||
} else if m.action == "post" {
|
} else if m.action == "post" {
|
||||||
title = fmt.Sprintf("New Post in %s", m.iface.(*post.Post).Forum.Name)
|
p := m.iface.(*post.Post)
|
||||||
|
sysTitle := (*m.ctx.Systems[p.SysIDX]).Title()
|
||||||
|
title = fmt.Sprintf("New Post in %s on %s", p.Forum.Name, sysTitle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// textinputWidth := m.tk.ViewWidth() - 2
|
// textinputWidth := m.tk.ViewWidth() - 2
|
||||||
|
Loading…
Reference in New Issue
Block a user