diff options
Diffstat (limited to 'internal/queue')
| -rw-r--r-- | internal/queue/inlinetags.go | 12 | ||||
| -rw-r--r-- | internal/queue/inlinetags_test.go | 5 | ||||
| -rw-r--r-- | internal/queue/queue.go | 5 |
3 files changed, 15 insertions, 7 deletions
diff --git a/internal/queue/inlinetags.go b/internal/queue/inlinetags.go index bf147b1..11f05c2 100644 --- a/internal/queue/inlinetags.go +++ b/internal/queue/inlinetags.go @@ -10,6 +10,7 @@ import ( "codeberg.org/snonux/gos/internal/oi" ) +// TODO: Don't treat it as inline tags when there are other characters tan [a-z,.] // Extracts the inline tags into the filepath and removes them from the content. func extractInlineTags(filePath string) (string, error) { content, err := oi.SlurpAndTrim(filePath) @@ -34,7 +35,10 @@ func extractInlineTags(filePath string) (string, error) { } func extractInlineTagsToFilePath(filePath, content string) (string, string, error) { - tags, newContent := extractInlineTagsFromContent(content) + tags, newContent, err := extractInlineTagsFromContent(content) + if err != nil { + return filePath, content, err + } if len(tags) == 0 { return filePath, content, nil } @@ -48,7 +52,7 @@ func extractInlineTagsToFilePath(filePath, content string) (string, string, erro return newFilePath, newContent, nil } -func extractInlineTagsFromContent(content string) ([]string, string) { +func extractInlineTagsFromContent(content string) ([]string, string, error) { parts := strings.Split(content, " ") // If the first word of the content contains a dot or comma and there are // more than 2 elems, then there are inline tags! @@ -58,8 +62,8 @@ func extractInlineTagsFromContent(content string) ([]string, string) { tags = append(tags, strings.Split(elem, ",")...) } if len(tags) > 1 { - return tags, strings.Join(parts[1:], " ") + return tags, strings.Join(parts[1:], " "), nil } } - return []string{}, content + return []string{}, content, nil } diff --git a/internal/queue/inlinetags_test.go b/internal/queue/inlinetags_test.go index 5b22fe6..8b85cb2 100644 --- a/internal/queue/inlinetags_test.go +++ b/internal/queue/inlinetags_test.go @@ -41,7 +41,10 @@ func TestExtractInlineTagsFromContent(t *testing.T) { for input, expectedTags := range table { t.Run(input, func(t *testing.T) { - tags, contentWithoutTags := extractInlineTagsFromContent(input) + tags, contentWithoutTags, err := extractInlineTagsFromContent(input) + if err != nil { + t.Error(err) + } if len(tags) != len(expectedTags) { t.Errorf("expected %d inline tags (%v) but got %d (%v)", len(expectedTags), expectedTags, len(tags), tags) diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 40cc084..aa63c71 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -11,6 +11,7 @@ import ( "codeberg.org/snonux/gos/internal/config" "codeberg.org/snonux/gos/internal/entry" "codeberg.org/snonux/gos/internal/oi" + "codeberg.org/snonux/gos/internal/platforms" "codeberg.org/snonux/gos/internal/timestamp" ) @@ -110,8 +111,8 @@ func queuePlatforms(args config.Args) error { } // Queue ./db/queued/*.txt.STAMP.queued to ./db/platforms/PLATFORM/*.txt.STAMP.queued -func queuePlatform(en entry.Entry, gosDir, platform string) error { - destDir := filepath.Join(gosDir, "db/platforms", strings.ToLower(platform)) +func queuePlatform(en entry.Entry, gosDir string, platform platforms.Platform) error { + destDir := filepath.Join(gosDir, "db/platforms", platform.String()) destPath := filepath.Join(destDir, filepath.Base(en.Path)) postedFile := fmt.Sprintf("%s.posted", strings.TrimSuffix(destPath, ".queued")) |
