big refacto

This commit is contained in:
GitBluub
2024-05-05 18:51:54 +02:00
parent 76a8209b90
commit bed5152899
8 changed files with 496 additions and 283 deletions
-48
View File
@@ -4,18 +4,9 @@ import (
"fmt"
"time"
"github.com/charmbracelet/bubbles/key"
"github.com/google/uuid"
)
type Feed struct {
Id uuid.UUID `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
FaviconUrl string `json:"faviconUrl"`
Tags []string `json:"tags"`
}
type Entry struct {
Id uuid.UUID `json:"id"`
ArticleTitle string `json:"title"`
@@ -42,42 +33,3 @@ func (e Entry) Title() string {
func (e Entry) Description() string {
return fmt.Sprintf("%s", "my desc") // TODO: real description (tags and author + date ?)
}
type ListKeyMap struct {
Query key.Binding
BookmarkToggle key.Binding
ReadToggle key.Binding
ReadLaterToggle key.Binding
IgnoreToggle key.Binding
PreviewPost key.Binding
}
func NewListKeyMap() *ListKeyMap {
return &ListKeyMap{
PreviewPost: key.NewBinding(
key.WithKeys("enter"),
key.WithHelp("enter", "preview post"),
),
Query: key.NewBinding(
key.WithKeys("/"),
key.WithHelp("/", "query posts"),
),
BookmarkToggle: key.NewBinding(
key.WithKeys("b"),
key.WithHelp("b", "toggle bookmarked"),
),
ReadToggle: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "toggle mark as read"),
),
IgnoreToggle: key.NewBinding(
key.WithKeys("x", "d"),
key.WithHelp("d/x", "ignore post"),
),
ReadLaterToggle: key.NewBinding(
key.WithKeys("m"),
key.WithHelp("m", "add to read later"),
),
}
}
+27
View File
@@ -0,0 +1,27 @@
package models
import (
"fmt"
"github.com/google/uuid"
)
type Feed struct {
Id uuid.UUID `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
FaviconUrl string `json:"faviconUrl"`
Tags []string `json:"tags"`
}
func (f Feed) FilterValue() string {
return f.Name
}
func (f Feed) Title() string {
return f.Name
}
func (f Feed) Description() string {
return fmt.Sprintf("%s", "my desc") // TODO: real description (tags, submitter, error status, last sync)
}