Documentation
¶
Index ¶
- Constants
- Variables
- type BlogosphereClient
- func (c *BlogosphereClient) FeedLabels() []string
- func (c *BlogosphereClient) FeedNames() []string
- func (c *BlogosphereClient) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
- func (c *BlogosphereClient) FetchStoryIDs(feed string) ([]int, error)
- func (c *BlogosphereClient) Name() string
- func (c *BlogosphereClient) StoryURL(item *Item) string
- type CachedSource
- type Client
- func (c *Client) FeedLabels() []string
- func (c *Client) FeedNames() []string
- func (c *Client) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
- func (c *Client) FetchComments(item *Item) ([]*Item, error)
- func (c *Client) FetchItem(id int) (*Item, error)
- func (c *Client) FetchItems(ids []int) ([]*Item, error)
- func (c *Client) FetchStoryIDs(feed string) ([]int, error)
- func (c *Client) Name() string
- func (c *Client) StoryURL(item *Item) string
- type Comment
- type Item
- type LobstersClient
- func (c *LobstersClient) FeedLabels() []string
- func (c *LobstersClient) FeedNames() []string
- func (c *LobstersClient) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
- func (c *LobstersClient) FetchStoryIDs(feed string) ([]int, error)
- func (c *LobstersClient) Name() string
- func (c *LobstersClient) StoryURL(item *Item) string
- type RedditClient
- func (c *RedditClient) FeedLabels() []string
- func (c *RedditClient) FeedNames() []string
- func (c *RedditClient) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
- func (c *RedditClient) FetchStoryIDs(feed string) ([]int, error)
- func (c *RedditClient) Name() string
- func (c *RedditClient) StoryURL(item *Item) string
- type Source
- type UpdateInfo
Constants ¶
const ( BlogosphereFeedRecent = "" // Default front page BlogosphereFeedTechnology = "technology" // /category/technology BlogosphereFeedPersonal = "personal" // /category/personal )
Blogosphere feed types (correspond to URL paths)
const ( FeedTop = "topstories" FeedNew = "newstories" FeedBest = "beststories" FeedAsk = "askstories" FeedShow = "showstories" )
Feed types
const ( LobstersFeedHottest = "" // Default front page LobstersFeedNewest = "newest" // /newest LobstersFeedRecent = "recent" // /recent (recently active) )
Lobste.rs feed types (correspond to URL paths)
const ( RedditFeedHot = "hot" RedditFeedNew = "new" RedditFeedTop = "top" RedditFeedRising = "rising" RedditFeedBest = "best" )
Reddit feed types (correspond to URL paths)
Variables ¶
var BlogosphereFeedLabels = []string{"Recent", "Technology", "Personal"}
var BlogosphereFeedNames = []string{BlogosphereFeedRecent, BlogosphereFeedTechnology, BlogosphereFeedPersonal}
var LobstersFeedLabels = []string{"Hot", "New", "Recent"}
var LobstersFeedNames = []string{LobstersFeedHottest, LobstersFeedNewest, LobstersFeedRecent}
var RedditFeedLabels = []string{"Hot", "New", "Top", "Rising", "Best"}
var RedditFeedNames = []string{RedditFeedHot, RedditFeedNew, RedditFeedTop, RedditFeedRising, RedditFeedBest}
Functions ¶
This section is empty.
Types ¶
type BlogosphereClient ¶ added in v0.9.0
type BlogosphereClient struct {
CachedSource
// contains filtered or unexported fields
}
BlogosphereClient scrapes text.blogosphere.app
func NewBlogosphereClient ¶ added in v0.9.0
func NewBlogosphereClient() *BlogosphereClient
NewBlogosphereClient creates a new Blogosphere scraping client
func (*BlogosphereClient) FeedLabels ¶ added in v0.9.0
func (c *BlogosphereClient) FeedLabels() []string
FeedLabels returns the display labels for feeds
func (*BlogosphereClient) FeedNames ¶ added in v0.9.0
func (c *BlogosphereClient) FeedNames() []string
FeedNames returns the available feed names
func (*BlogosphereClient) FetchCommentTree ¶ added in v0.9.0
func (c *BlogosphereClient) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
FetchCommentTree returns empty since Blogosphere has no comments
func (*BlogosphereClient) FetchStoryIDs ¶ added in v0.9.0
func (c *BlogosphereClient) FetchStoryIDs(feed string) ([]int, error)
FetchStoryIDs fetches story "IDs" for a feed
func (*BlogosphereClient) Name ¶ added in v0.9.0
func (c *BlogosphereClient) Name() string
Name returns the display name of the source
func (*BlogosphereClient) StoryURL ¶ added in v0.9.0
func (c *BlogosphereClient) StoryURL(item *Item) string
StoryURL returns the URL for viewing a story
type CachedSource ¶ added in v0.9.0
type CachedSource struct {
// contains filtered or unexported fields
}
CachedSource provides throttling and in-memory story caching shared by sources that fetch stories in bulk (Lobsters, Reddit).
func NewCachedSource ¶ added in v0.9.0
func NewCachedSource(minDelay time.Duration) CachedSource
NewCachedSource creates a CachedSource with the given throttle delay.
func (*CachedSource) FetchItem ¶ added in v0.9.0
func (c *CachedSource) FetchItem(id int) (*Item, error)
FetchItem fetches a cached item by pseudo-ID.
func (*CachedSource) FetchItems ¶ added in v0.9.0
func (c *CachedSource) FetchItems(ids []int) ([]*Item, error)
FetchItems fetches multiple cached items by pseudo-ID.
func (*CachedSource) StoreItems ¶ added in v0.9.0
func (c *CachedSource) StoreItems(items []*Item) []int
StoreItems clears the cache and stores items with 1-indexed pseudo-IDs. Returns the generated IDs.
func (*CachedSource) Throttle ¶ added in v0.9.0
func (c *CachedSource) Throttle()
Throttle ensures we don't make requests too quickly.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the HN API client
func (*Client) FeedLabels ¶
FeedLabels returns the display labels for feeds
func (*Client) FetchCommentTree ¶
FetchCommentTree fetches the full comment tree for a story
func (*Client) FetchComments ¶
FetchComments fetches all comments for a story recursively
func (*Client) FetchItems ¶
FetchItems fetches multiple items concurrently
func (*Client) FetchStoryIDs ¶
FetchStoryIDs fetches the list of story IDs for a given feed
type Item ¶
type Item struct {
ID int `json:"id"`
Type string `json:"type"`
By string `json:"by"`
Time int64 `json:"time"`
Text string `json:"text"`
URL string `json:"url"`
Title string `json:"title"`
Score int `json:"score"`
Kids []int `json:"kids"`
Parent int `json:"parent"`
Descendants int `json:"descendants"`
Deleted bool `json:"deleted"`
Dead bool `json:"dead"`
}
Item represents a news item (story, comment, job, poll)
type LobstersClient ¶
type LobstersClient struct {
CachedSource
// contains filtered or unexported fields
}
LobstersClient scrapes lobste.rs
func NewLobstersClient ¶
func NewLobstersClient() *LobstersClient
NewLobstersClient creates a new Lobste.rs scraping client
func (*LobstersClient) FeedLabels ¶
func (c *LobstersClient) FeedLabels() []string
FeedLabels returns the display labels for feeds
func (*LobstersClient) FeedNames ¶
func (c *LobstersClient) FeedNames() []string
FeedNames returns the available feed names
func (*LobstersClient) FetchCommentTree ¶
func (c *LobstersClient) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
FetchCommentTree fetches comments for a story
func (*LobstersClient) FetchStoryIDs ¶
func (c *LobstersClient) FetchStoryIDs(feed string) ([]int, error)
FetchStoryIDs fetches story "IDs" for a feed
func (*LobstersClient) Name ¶
func (c *LobstersClient) Name() string
Name returns the display name of the source
func (*LobstersClient) StoryURL ¶
func (c *LobstersClient) StoryURL(item *Item) string
StoryURL returns the URL for viewing a story on Lobste.rs
type RedditClient ¶ added in v0.5.0
type RedditClient struct {
CachedSource
// contains filtered or unexported fields
}
RedditClient fetches data from Reddit's JSON API
func NewRedditClient ¶ added in v0.5.0
func NewRedditClient(subreddit string) *RedditClient
NewRedditClient creates a new Reddit API client for a subreddit
func (*RedditClient) FeedLabels ¶ added in v0.5.0
func (c *RedditClient) FeedLabels() []string
FeedLabels returns the display labels for feeds
func (*RedditClient) FeedNames ¶ added in v0.5.0
func (c *RedditClient) FeedNames() []string
FeedNames returns the available feed names
func (*RedditClient) FetchCommentTree ¶ added in v0.5.0
func (c *RedditClient) FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
FetchCommentTree fetches comments for a story
func (*RedditClient) FetchStoryIDs ¶ added in v0.5.0
func (c *RedditClient) FetchStoryIDs(feed string) ([]int, error)
FetchStoryIDs fetches story "IDs" for a feed
func (*RedditClient) Name ¶ added in v0.5.0
func (c *RedditClient) Name() string
Name returns the display name of the source
func (*RedditClient) StoryURL ¶ added in v0.5.0
func (c *RedditClient) StoryURL(item *Item) string
StoryURL returns the URL for viewing a story on Reddit
type Source ¶
type Source interface {
// Name returns the display name of the source
Name() string
// FeedNames returns the available feed names for this source
FeedNames() []string
// FeedLabels returns the display labels for feeds (for UI tabs)
FeedLabels() []string
// FetchStoryIDs fetches the list of story IDs for a given feed
// For sources without IDs (like Lobste.rs), this returns page-based pseudo-IDs
FetchStoryIDs(feed string) ([]int, error)
// FetchItem fetches a single item by ID
FetchItem(id int) (*Item, error)
// FetchItems fetches multiple items by ID
FetchItems(ids []int) ([]*Item, error)
// FetchCommentTree fetches the comment tree for a story
FetchCommentTree(item *Item, maxDepth int) ([]*Comment, error)
// StoryURL returns the URL for viewing a story on the source's website
StoryURL(item *Item) string
}
Source represents a news source (HN, Lobste.rs, etc.)
type UpdateInfo ¶ added in v0.7.0
UpdateInfo contains information about an available update
func CheckForUpdate ¶ added in v0.7.0
func CheckForUpdate(currentVersion string) *UpdateInfo
CheckForUpdate checks if a newer version is available It uses a cached result if checked within the last 24 hours
func (*UpdateInfo) FormatUpdateMessage ¶ added in v0.7.0
func (u *UpdateInfo) FormatUpdateMessage() string
FormatUpdateMessage returns a formatted message for the status bar
func (*UpdateInfo) HasUpdate ¶ added in v0.7.0
func (u *UpdateInfo) HasUpdate() bool
HasUpdate returns true if a newer version is available