Documentation
¶
Overview ¶
Package blogroll provides functionality for managing blogroll metadata.
Package blogroll provides functionality for managing blogroll metadata.
Index ¶
- type AvatarResult
- type AvatarSource
- type Metadata
- type UpdateResult
- type Updater
- func (u *Updater) DiscoverAvatar(ctx context.Context, siteURL, resource string) (*AvatarResult, error)
- func (u *Updater) FetchMetadata(ctx context.Context, feedURL string) (*Metadata, error)
- func (u *Updater) FetchMetadataWithResource(ctx context.Context, feedURL, resource string) (*Metadata, error)
- type WebFingerLink
- type WebFingerResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvatarResult ¶ added in v0.7.0
type AvatarResult struct {
URL string `json:"url"`
Source AvatarSource `json:"source"`
}
AvatarResult contains the discovered avatar URL and its source.
type AvatarSource ¶ added in v0.7.0
type AvatarSource string
AvatarSource indicates where an avatar URL was discovered.
const ( // AvatarSourceConfig indicates avatar was configured explicitly. AvatarSourceConfig AvatarSource = "config" // AvatarSourceHCard indicates avatar was discovered from h-card u-photo. AvatarSourceHCard AvatarSource = "h-card" // AvatarSourceWebFinger indicates avatar was discovered from WebFinger rel=avatar. AvatarSourceWebFinger AvatarSource = "webfinger" // AvatarSourceWellKnown indicates avatar was discovered from /.well-known/avatar. AvatarSourceWellKnown AvatarSource = "well-known" // AvatarSourceFeed indicates avatar was discovered from feed logo/icon. AvatarSourceFeed AvatarSource = "feed" // AvatarSourceOpenGraph indicates avatar was discovered from og:image. AvatarSourceOpenGraph AvatarSource = "opengraph" // AvatarSourceFavicon indicates avatar was discovered from favicon. AvatarSourceFavicon AvatarSource = "favicon" )
type Metadata ¶
type Metadata struct {
// From OpenGraph
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
ImageURL string `json:"image_url,omitempty"`
SiteURL string `json:"site_url,omitempty"`
// Author information
Author string `json:"author,omitempty"`
// Avatar (person/site representative image)
// Distinct from ImageURL which may be an article/page image
AvatarURL string `json:"avatar_url,omitempty"`
AvatarSource AvatarSource `json:"avatar_source,omitempty"`
// From feed
FeedTitle string `json:"feed_title,omitempty"`
FeedDescription string `json:"feed_description,omitempty"`
FeedAuthor string `json:"feed_author,omitempty"`
FeedImageURL string `json:"feed_image_url,omitempty"`
LastUpdated *time.Time `json:"last_updated,omitempty"`
// Source tracking
Source string `json:"source,omitempty"` // "opengraph", "meta", "feed"
}
Metadata represents extracted metadata from a website.
type UpdateResult ¶
type UpdateResult struct {
FeedURL string `json:"feed_url"`
Handle string `json:"handle,omitempty"`
OldMetadata *Metadata `json:"old_metadata,omitempty"`
NewMetadata *Metadata `json:"new_metadata,omitempty"`
Updated bool `json:"updated"`
Error string `json:"error,omitempty"`
}
UpdateResult contains the result of updating a single feed's metadata.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater handles fetching and extracting metadata from external sites.
func NewUpdater ¶
NewUpdater creates a new Updater with the given timeout.
func (*Updater) DiscoverAvatar ¶ added in v0.7.0
func (u *Updater) DiscoverAvatar(ctx context.Context, siteURL, resource string) (*AvatarResult, error)
DiscoverAvatar attempts to discover an avatar URL for a site using multiple methods. It tries in this order: 1. h-card u-photo from the site's homepage 2. WebFinger rel=avatar (if resource handle is provided) 3. /.well-known/avatar endpoint
Returns nil if no avatar is discovered.
func (*Updater) FetchMetadata ¶
FetchMetadata fetches metadata from a site URL or feed URL. It tries multiple sources in order: OpenGraph, HTML meta tags, feed metadata. Additionally, it attempts avatar discovery via h-card, WebFinger, and .well-known/avatar.
func (*Updater) FetchMetadataWithResource ¶ added in v0.7.0
func (u *Updater) FetchMetadataWithResource(ctx context.Context, feedURL, resource string) (*Metadata, error)
FetchMetadataWithResource fetches metadata and attempts avatar discovery. The resource parameter is used for WebFinger lookups (e.g., "acct:user@example.com").
type WebFingerLink ¶ added in v0.7.0
type WebFingerLink struct {
Rel string `json:"rel"`
Type string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
}
WebFingerLink represents a link in a WebFinger response.
type WebFingerResponse ¶ added in v0.7.0
type WebFingerResponse struct {
Subject string `json:"subject"`
Aliases []string `json:"aliases,omitempty"`
Links []WebFingerLink `json:"links,omitempty"`
}
WebFingerResponse represents a WebFinger JRD response.