entry

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package entry defines the core feed entry types for Signal output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateID

func GenerateID(url string, date time.Time) string

GenerateID creates a unique ID for an entry based on URL and date.

Types

type Discussion

type Discussion struct {
	Platform string `json:"platform"`           // "hackernews", "reddit", "lobsters", etc.
	URL      string `json:"url"`                // Full URL to the discussion
	ID       string `json:"id,omitempty"`       // Platform-specific ID (e.g., HN item ID)
	Score    int    `json:"score,omitempty"`    // Upvotes/points at time of capture
	Comments int    `json:"comments,omitempty"` // Comment count at time of capture
}

Discussion represents a link to a discussion forum.

type Entry

type Entry struct {
	ID           string       `json:"id"`
	Title        string       `json:"title"`
	URL          string       `json:"url"`
	Author       string       `json:"author,omitempty"`
	Date         time.Time    `json:"date"`
	Feed         FeedMeta     `json:"feed"`
	Tags         []string     `json:"tags,omitempty"`
	Summary      string       `json:"summary,omitempty"`
	Content      string       `json:"content,omitempty"`
	Image        string       `json:"image,omitempty"`        // Main image URL
	ImageAlt     string       `json:"imageAlt,omitempty"`     // Alt text for image
	Source       *Source      `json:"source,omitempty"`       // Platform source metadata
	IsPriority   bool         `json:"isPriority,omitempty"`   // Hand-curated priority link
	PriorityRank int          `json:"priorityRank,omitempty"` // Ordering for priority links
	Discussions  []Discussion `json:"discussions,omitempty"`  // Links to discussions (HN, Reddit, etc.)
}

Entry represents a single feed entry in the aggregated output.

type Feed

type Feed struct {
	Generated   time.Time `json:"generated"`
	Title       string    `json:"title,omitempty"`
	Description string    `json:"description,omitempty"`
	HomeURL     string    `json:"homeUrl,omitempty"`
	Entries     []Entry   `json:"entries"`
}

Feed represents the complete aggregated feed output.

func NewFeed

func NewFeed(title, description, homeURL string) *Feed

NewFeed creates a new Feed with the current generation time.

func ReadJSON

func ReadJSON(filename string) (*Feed, error)

ReadJSON reads a feed from a JSON file.

func (*Feed) AddEntry

func (f *Feed) AddEntry(e Entry)

AddEntry adds an entry to the feed.

func (*Feed) Deduplicate

func (f *Feed) Deduplicate()

Deduplicate removes duplicate entries based on URL. When duplicates are found, it merges discussions and prefers priority entries.

func (*Feed) FilterByTags

func (f *Feed) FilterByTags(tags []string) []Entry

FilterByTags returns entries that match any of the given tags.

func (*Feed) SortByDate

func (f *Feed) SortByDate()

SortByDate sorts entries by date, newest first.

func (*Feed) ToJSONFeed

func (f *Feed) ToJSONFeed() *jsonfeed.Feed

ToJSONFeed converts the internal Feed to a JSON Feed 1.1 format.

func (*Feed) WriteJSON

func (f *Feed) WriteJSON(filename string) error

WriteJSON writes the feed to a JSON file.

func (*Feed) WriteJSONFeed

func (f *Feed) WriteJSONFeed(filename string) error

WriteJSONFeed writes the feed in JSON Feed 1.1 format.

type FeedMeta

type FeedMeta struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	IconURL string `json:"iconUrl,omitempty"`
}

FeedMeta contains metadata about the source feed.

type Source

type Source struct {
	Platform string `json:"platform"`         // "linkedin", "twitter", "mastodon", etc.
	Author   string `json:"author,omitempty"` // Platform-specific author name/handle
	PostID   string `json:"postId,omitempty"` // Platform-specific post ID
}

Source represents metadata about the content source platform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL