summaryrefslogtreecommitdiff
path: root/internal/entry/entry.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-31 22:50:00 +0200
committerPaul Buetow <paul@buetow.org>2024-10-31 22:50:00 +0200
commitedfbee2da241372271d2a32cff8ab7409e910727 (patch)
tree2d3abe6ce6187661cb90f0620751f4821b1552c0 /internal/entry/entry.go
parent84e72c59d507cbd7347465c38044e9199ee7903a (diff)
restructure
Diffstat (limited to 'internal/entry/entry.go')
-rw-r--r--internal/entry/entry.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/entry/entry.go b/internal/entry/entry.go
index be3bb80..d757632 100644
--- a/internal/entry/entry.go
+++ b/internal/entry/entry.go
@@ -9,6 +9,7 @@ import (
"strings"
"time"
+ "codeberg.org/snonux/gos/internal/config"
"codeberg.org/snonux/gos/internal/oi"
"codeberg.org/snonux/gos/internal/prompt"
"codeberg.org/snonux/gos/internal/timestamp"
@@ -18,7 +19,7 @@ type State int
const (
Unknown State = iota
- Inboxed // TODO: Implement
+ Inboxed
Queued
Posted
)
@@ -152,6 +153,15 @@ func (e Entry) HasTag(tag string) bool {
return slices.Contains(e.simpleTags, tag)
}
+// Valid tags are: share:foo[,...]
+// whereas foo can be a supported plutform such as linkedin, mastodon, etc.
+// foo can also be prefixed with - to exclude it. See unit tests for examples.
+func (e Entry) ExcludedByTags(args config.Args, platform string) (bool, error) {
+ s, err := newShareTags(args, e.Path)
+ return slices.Contains(s.excludes, strings.ToLower(platform)) ||
+ !slices.Contains(s.includes, strings.ToLower(platform)), err
+}
+
func (e Entry) Edit() error {
if err := prompt.EditFile(e.Path); err != nil {
return err
@@ -163,6 +173,14 @@ func (e Entry) Remove() error {
return os.Remove(e.Path)
}
+func (e Entry) FileAction(question string) error {
+ content, _, err := e.Content()
+ if err != nil {
+ return err
+ }
+ return prompt.FileAction(question, content, e.Path)
+}
+
func extractURLs(input string) []string {
urlPattern := `(http://|https://|ftp://)[^\s]+`
re := regexp.MustCompile(urlPattern)