Documentation
¶
Overview ¶
Package site implements Standard.site lexicons in Go.
Publication is the implementation of site.standard.publication.
Document is the implementation of site.standard.document.
Subscription is the implementation of site.standard.graph.subscription.
See the xrpc package to learn how to use them.
Extending lexicons ¶
Standard lexicons are designed to be extended. You can extend them by declaring a new type embedding them:
type CustomPublication struct {
site.Publication
// your custom fields
}
You should not reimplement xrpc.Record, because the embedded struct already implements it.
Index ¶
- Variables
- func GetDocumentVerificationTag(repo *atproto.DID, rkey atproto.RecordKey) template.HTML
- func GetPublicationVerificationURI(path string) string
- func HandlePublicationVerification(repo *atproto.DID, rkey atproto.RecordKey) http.Handler
- type Contributor
- type Document
- func (d *Document) Collection() *atproto.NSID
- func (d *Document) MarshalMap() (any, error)
- func (d *Document) PublicationURL(ctx context.Context, client xrpc.Client) (*url.URL, error)
- func (d *Document) UnmarshalJSON(b []byte) error
- func (d *Document) Verify(ctx context.Context, client *http.Client, pubURL *url.URL, did *atproto.DID, ...) (bool, error)
- type ErrInvalidCollection
- type Preferences
- type Publication
- type RGB
- type RGBA
- type Recommend
- type Subscription
- type Theme
- type URL
Constants ¶
This section is empty.
Variables ¶
var ( CollectionDocument = collectionDocument.Build() CollectionContributor = collectionDocument.Fragment("contributor").Build() )
var ( CollectionSubscription = collectionGraph.Name("subscription").Build() CollectionRecommend = collectionGraph.Name("recommend").Build() )
var ( // CollectionBase is the base NSID for Standard.site. CollectionBase = atproto.NewNSIDBuilder("site.standard") CollectionBlob = "blob" )
var ( CollectionTheme = CollectionBase.SubAuthority("theme") CollectionThemeBasic = CollectionTheme.Name("basic").Build() CollectionThemeColor = CollectionTheme.Name("color") CollectionThemeColorRGB = CollectionThemeColor.Fragment("rgb").Build() CollectionThemeColorRGBA = CollectionThemeColor.Fragment("rgba").Build() )
var CollectionPublication = CollectionBase.Name("publication").Build()
Functions ¶
func GetDocumentVerificationTag ¶
GetDocumentVerificationTag returns the HTML link tag checked during the verification of the Document.
func GetPublicationVerificationURI ¶
GetPublicationVerificationURI returns the URI called during the verification of the Publication.
path must be empty if the Publication is located at the domain root. path must start with a slash.
func HandlePublicationVerification ¶
HandlePublicationVerification returns an http.Handler used during the verification of the Publication.
Types ¶
type Contributor ¶
type Contributor struct {
// DID of the [Contributor].
DID *atproto.DID `json:"did"`
// Role of the [Contributor] in the [Document].
// Max length: 1000.
// Max graphemes: 100.
Role string `json:"role,omitempty"`
// DisplayName overrides the name of the [Contributor].
// Max length: 1000.
// Max graphemes: 100.
DisplayName string `json:"displayName,omitempty"`
}
Contributor of a Document.
func (*Contributor) Collection ¶
func (c *Contributor) Collection() *atproto.NSID
type Document ¶
type Document struct {
// Site points to a [Publication] record `at://` or a [Publication.URL] `https://` for loose documents.
// Avoid trailing slashes.
Site *URL `json:"site"`
// Title of the [Document].
// Max length: 5000.
// Max graphemes: 500.
Title string `json:"title"`
// PublishedAt is the [time.Time] of the [Document]'s publish time.
PublishedAt time.Time `json:"publishedAt"`
// Path is combined with [Document.Site] or [Publication.URL] to construct a canonical URL to the document.
// A slash should be included at the beginning of this value.
Path *string `json:"path,omitempty"`
// A brief Description or excerpt from the [Document].
// Max length: 30000.
// Max graphemes: 3000.
Description *string `json:"description,omitempty"`
// CoverImage to used for thumbnail or cover.
// Less than 1MB in size.
CoverImage *xrpc.Blob `json:"coverImage,omitempty"`
// Content is an [xrpc.Union] used to define the [Document]'s content.
Content *xrpc.Union `json:"content,omitempty"`
// TextContent is a plaintext representation of the [Document.Content].
// Should not contain markdown or other formatting.
TextContent string `json:"textContent,omitempty"`
// BlueskyPostRef is a strong reference to a Bluesky post.
// Useful to keep track of comments off-platform.
BlueskyPostRef *xrpc.StrongRef `json:"bskyPostRef,omitempty"`
// Tags is an array of strings used to tag or categorize the [Document].
// Avoid prepending tags with hashtags.
// Max length: 1280.
// Max graphemes: 128.
Tags []string `json:"tags,omitempty"`
// Contributors who helped for the [Document].
Contributors []*Contributor `json:"contributors,omitempty"`
// Links describes relationships between this document and external resources.
Links *xrpc.Union `json:"links,omitempty"`
// UpdatedAt is the [time.Time] of the [Document]'s last edit.
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
}
Document may be standalone or associated with a Publication. This xrpc.Record can be used to store a document's content and its associated metadata.
func (*Document) PublicationURL ¶
PublicationURL returns the url.URL of the linked Publication.
Prefer using [GetRecord] if you plan to retrieve the record. Under the hood, this method retrieves the Publication record if Document.Site is an [ATURL].
type ErrInvalidCollection ¶
type ErrInvalidCollection struct {
// contains filtered or unexported fields
}
func (ErrInvalidCollection) Error ¶
func (err ErrInvalidCollection) Error() string
type Preferences ¶
type Preferences struct {
// ShowInDiscover decides whether the [Publication] should appear in discovery feeds.
ShowInDiscover bool `json:"showInDiscover"`
}
Preferences of the Publication.
type Publication ¶
type Publication struct {
// Base URL of the [Publication].
// This value will be combined with the [Document.Path] to construct a full URL for the document.
// Avoid trailing slashes.
URL *url.URL `json:"-"`
// Name of the [Publication].
// Max length: 5000.
// Max graphemes: 500.
Name string `json:"name"`
// Icon to identify the [Publication].
// Must be a square image and should be at least 256x256.
Icon *xrpc.Blob `json:"icon,omitempty"`
// Description of the [Publication].
// Max length: 30000.
// Max graphemes: 3000.
Description *string `json:"description,omitempty"`
// Simplified theme for tools and apps to utilize when displaying content.
BasicTheme *Theme `json:"basicTheme,omitempty"`
// Platform-specific [Preferences] for the [Publication], including discovery and visibility settings.
Preferences *Preferences `json:"preferences,omitempty"`
}
Publication represents a collection of [Document]s published to the web. It includes important information about a publication including its location on the web, theming information, user Preferences, and more.
The Publication [Record] is not a requirement, but is recommended when publishing collections of related [Document]s.
func (*Publication) Collection ¶
func (p *Publication) Collection() *atproto.NSID
func (*Publication) MarshalMap ¶
func (p *Publication) MarshalMap() (any, error)
func (*Publication) UnmarshalJSON ¶
func (p *Publication) UnmarshalJSON(b []byte) error
type RGBA ¶
type RGBA struct {
RGB
// Alpha is the alpha channel where 0 is transparent and 100 is opaque.
Alpha uint8 `json:"a"`
}
RGBA represents a color.RGBA.
See also RGB.
type Recommend ¶
type Subscription ¶
type Subscription struct {
// Publication is an AT-URI reference to the publication record being subscribed to.
// E.g., `at://did:plc:abc123/site.standard.publication/xyz789`.
Publication atproto.RawURI `json:"publication"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
}
Subscription enable users to follow publications and receive updates about new content. They represent the social connection between readers and the publications they're interested in.
func (*Subscription) Collection ¶
func (s *Subscription) Collection() *atproto.NSID
type Theme ¶
type Theme struct {
// Background is the color used for content background.
Background *RGB `json:"background"`
// Foreground is the color used for content text.
Foreground *RGB `json:"foreground"`
// Accent is the color used for links and button backgrounds.
Accent *RGB `json:"accent"`
// AccentForeground is the color used for button text.
AccentForeground *RGB `json:"accentForeground"`
}
Theme ensures [Publication]s maintain their visual identity across different reading applications and platforms by defining core colors for content display.
type URL ¶
type URL struct {
// contains filtered or unexported fields
}
URL represents an url.URL that may be an atproto.RawURI.
Source Files
¶
- doc.go
- document.go
- graph.go
- lexicons.go
- publication.go
- theme.go
- url.go