Documentation ¶
Index ¶
- func UnmarshalItems(data any) ([]any, bool)
- type Client
- type Collection
- type CollectionPage
- type Context
- func (c *Context) Add(vocabulary string) *ContextEntry
- func (c Context) Head() *ContextEntry
- func (c Context) IsEmpty() bool
- func (c Context) IsEmptyTail() bool
- func (c Context) Length() int
- func (c Context) MarshalJSON() ([]byte, error)
- func (c Context) Tail() Context
- func (c *Context) UnmarshalJSON(data []byte) error
- type ContextEntry
- func (entry ContextEntry) HasExtensions() bool
- func (entry ContextEntry) IsLanguageDefined() bool
- func (entry ContextEntry) IsVocabularyOnly() bool
- func (entry ContextEntry) MarshalJSON() ([]byte, error)
- func (entry *ContextEntry) WithExtension(key string, value string) *ContextEntry
- func (entry *ContextEntry) WithLanguage(language string) *ContextEntry
- type DefaultClient
- type Document
- func (document Document) Accuracy() float64
- func (document Document) Actor() Document
- func (document Document) Altitude() float64
- func (document Document) AnyOf() Document
- func (document Document) At(index int) Document
- func (document Document) Attachment() Document
- func (document Document) AttributedTo() Document
- func (document Document) Audience() Document
- func (document Document) Bcc() Document
- func (document Document) Blocked() Document
- func (document Document) Bool() bool
- func (document Document) Bto() Document
- func (document Document) Cc() Document
- func (document Document) Closed() Document
- func (document Document) Collection() Document
- func (document Document) Content() string
- func (document Document) Context() Document
- func (document Document) Copy() Document
- func (document Document) Current() Document
- func (document Document) Deleted() time.Time
- func (document Document) Describes() Document
- func (document Document) Document() Document
- func (document Document) Duration() string
- func (document Document) EndTime() time.Time
- func (document Document) First() Document
- func (document Document) Float() float64
- func (document Document) Followers() Document
- func (document Document) Following() Document
- func (document Document) ForceLoad() (Document, error)
- func (document Document) FormerType() string
- func (document Document) Generator() Document
- func (document Document) Get(key string) Document
- func (document Document) Head() Document
- func (document Document) Height() int
- func (document Document) Href() string
- func (document Document) Hreflang() string
- func (document Document) ID() string
- func (document Document) Icon() Image
- func (document Document) IconOrImage() Image
- func (document Document) Image() Image
- func (document Document) InReplyTo() Document
- func (document Document) Inbox() Document
- func (document Document) Instrument() Document
- func (document Document) Int() int
- func (document Document) IsArray() bool
- func (document Document) IsBool() bool
- func (document Document) IsEmptyTail() bool
- func (document Document) IsFloat() bool
- func (document Document) IsInt() bool
- func (document Document) IsInt64() bool
- func (document Document) IsMap() bool
- func (document Document) IsNil() bool
- func (document Document) IsString() bool
- func (document Document) Items() Document
- func (document Document) Last() Document
- func (document Document) Latitude() float64
- func (document Document) Len() int
- func (document Document) Liked() Document
- func (document Document) Load() (Document, error)
- func (document Document) Location() Document
- func (document Document) Longitude() float64
- func (document Document) Map() map[string]any
- func (document Document) MarshalJSON() ([]byte, error)
- func (document Document) MediaType() string
- func (document Document) Meta() *mapof.Any
- func (document *Document) MetaAdd(value mapof.Any)
- func (document Document) MetaBool(name string) bool
- func (document Document) MetaFloat(name string) float64
- func (document Document) MetaInt(name string) int
- func (document Document) MetaInt64(name string) int64
- func (document *Document) MetaSet(value mapof.Any)
- func (document *Document) MetaSetBool(name string, value bool)
- func (document *Document) MetaSetFloat(name string, value float64)
- func (document *Document) MetaSetInt(name string, value int)
- func (document *Document) MetaSetInt64(name string, value int64)
- func (document *Document) MetaSetString(name string, value string)
- func (document Document) MetaString(name string) string
- func (document Document) Name() string
- func (document Document) Next() Document
- func (document Document) NotNil() bool
- func (document Document) Object() Document
- func (document Document) OneOf() Document
- func (document Document) Origin() Document
- func (document Document) Outbox() Document
- func (document Document) PartOf() Document
- func (document Document) Prev() Document
- func (document Document) Preview() Document
- func (document Document) PublicKey() Document
- func (document Document) PublicKeyPEM() string
- func (document Document) Published() time.Time
- func (document Document) Radius() float64
- func (document Document) Rel() Document
- func (document Document) Relationship() string
- func (document Document) Replies() Document
- func (document Document) Result() Document
- func (document *Document) SetValue(value any)
- func (document Document) Slice() []any
- func (document Document) SliceOfDocuments() sliceof.Object[Document]
- func (document Document) StartIndex() int
- func (document Document) StartTime() time.Time
- func (document Document) String() string
- func (document Document) Subject() Document
- func (document Document) Summary() string
- func (document Document) Tag() Document
- func (document Document) Tail() Document
- func (document Document) Target() Document
- func (document Document) Time() time.Time
- func (document Document) To() Document
- func (document Document) TotalItems() int
- func (document Document) Type() string
- func (document Document) URL() string
- func (document Document) Units() string
- func (document *Document) UnmarshalJSON(bytes []byte) error
- func (document Document) Updated() time.Time
- func (document Document) Url() Document
- func (document Document) Value() any
- func (document Document) Width() int
- func (document *Document) WithOptions(options ...Option) *Document
- type Image
- func (image Image) HasDimensions() bool
- func (image Image) HasHeight() bool
- func (image Image) HasWidth() bool
- func (image Image) Height() int
- func (image Image) IsNil() bool
- func (image Image) MediaType() string
- func (image Image) NotNil() bool
- func (image Image) Summary() string
- func (image Image) URL() string
- func (image Image) Width() int
- type Iterator
- type Option
- type OrderedCollection
- type OrderedCollectionPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalItems ¶
Types ¶
type Client ¶ added in v0.4.0
type Client interface { // LoadActor returns a Document representing the Actor at the specified URI, which must // contain an "outbox" property. LoadActor(uri string) (Document, error) // LoadDocument returns a Document representing the specified URI LoadDocument(uri string, defaultValue map[string]any) (Document, error) }
func NewDefaultClient ¶ added in v0.4.0
func NewDefaultClient() Client
type Collection ¶
type Collection struct { Context Context `json:"@context,omitempty" bson:"context,omitempty"` ID string `json:"id,omitempty" bson:"id,omitempty"` Type string `json:"type,omitempty" bson:"type,omitempty"` Summary string `json:"summary,omitempty" bson:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems,omitempty" bson:"totalItems,omitempty"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance. Current string `json:"current,omitempty" bson:"current,omitempty"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty" bson:"first,omitempty"` // In a paged Collection, indicates the furthest preceding page of items in the collection. Last string `json:"last,omitempty" bson:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. Items []any `json:"items,omitempty" bson:"items,omitempty"` // Identifies the items contained in a collection. The items might be ordered or unordered. }
Collection is a subtype of Object that represents ordered or unordered sets of Object or Link instances. https://www.w3.org/ns/activitystreams#Collection
func NewCollection ¶ added in v0.3.0
func NewCollection() Collection
func (*Collection) UnmarshalJSON ¶
func (c *Collection) UnmarshalJSON(data []byte) error
func (*Collection) UnmarshalMap ¶
func (c *Collection) UnmarshalMap(data mapof.Any) error
type CollectionPage ¶
type CollectionPage struct { Context Context `json:"@context,omitempty" bson:"context,omitempty"` Type string `json:"type,omitempty" bson:"type,omitempty"` Summary string `json:"summary,omitempty" bson:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems,omitempty" bson:"totalItems,omitempty"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance. Current string `json:"current,omitempty" bson:"current,omitempty"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty" bson:"first,omitempty"` // In a paged Collection, indicates the furthest preceding page of items in the collection. Last string `json:"last,omitempty" bson:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. PartOf string `json:"partOf,omitempty" bson:"partOf,omitempty"` // dentifies the Collection to which a CollectionPage objects items belong. Prev string `json:"prev,omitempty" bson:"prev,omitempty"` // In a paged Collection, identifies the previous page of items. Next string `json:"next,omitempty" bson:"next,omitempty"` // In a paged Collection, indicates the next page of items. Items []any `json:"items,omitempty" bson:"items,omitempty"` // Identifies the items contained in a collection. The items might be ordered or unordered. }
CollectionPage is used to represent distinct subsets of items from a Collection. Refer to the Activity Streams 2.0 Core for a complete description of the CollectionPage object. https://www.w3.org/ns/activitystreams#CollectionPage
func NewCollectionPage ¶ added in v0.3.0
func NewCollectionPage() CollectionPage
func (*CollectionPage) UnmarshalJSON ¶
func (c *CollectionPage) UnmarshalJSON(data []byte) error
*****************************************
- JSON Marshalling *****************************************
func (*CollectionPage) UnmarshalMap ¶
func (c *CollectionPage) UnmarshalMap(data mapof.Any) error
type Context ¶
type Context []ContextEntry
func DefaultContext ¶
func DefaultContext() Context
DefaultContext represents the standard context defined by the W3C
func NewContext ¶
func (*Context) Add ¶
func (c *Context) Add(vocabulary string) *ContextEntry
Add puts a new ContextEntry into the list and returns a pointer to it so that additional properties can be set.
func (Context) Head ¶
func (c Context) Head() *ContextEntry
func (Context) IsEmptyTail ¶
func (Context) MarshalJSON ¶
func (*Context) UnmarshalJSON ¶
type ContextEntry ¶
type ContextEntry struct { Vocabulary string // The primary vocabulary represented by the context/document. Language string // The language Extensions map[string]string // a map of additional namespaces that are included in this context/document. }
ContextEntry https://www.w3.org/TR/json-ld/#the-context
func NewContextEntry ¶
func NewContextEntry(vocabulary string) ContextEntry
func (ContextEntry) HasExtensions ¶
func (entry ContextEntry) HasExtensions() bool
func (ContextEntry) IsLanguageDefined ¶
func (entry ContextEntry) IsLanguageDefined() bool
func (ContextEntry) IsVocabularyOnly ¶
func (entry ContextEntry) IsVocabularyOnly() bool
func (ContextEntry) MarshalJSON ¶
func (entry ContextEntry) MarshalJSON() ([]byte, error)
func (*ContextEntry) WithExtension ¶
func (entry *ContextEntry) WithExtension(key string, value string) *ContextEntry
func (*ContextEntry) WithLanguage ¶
func (entry *ContextEntry) WithLanguage(language string) *ContextEntry
type DefaultClient ¶ added in v0.4.0
type DefaultClient struct{}
func (DefaultClient) LoadActor ¶ added in v0.5.0
func (client DefaultClient) LoadActor(uri string) (Document, error)
func (DefaultClient) LoadDocument ¶ added in v0.5.0
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents a single ActivityStream document or document fragment. Due to the flexibility of ActivityStreams (and JSON-LD), this may be a data structure such as a `map[string]any`, `[]any`, or a primitive type, like a `string`, `float`, `int` or `bool`.
func NewDocument ¶
NewDocument creates a new Document object from a JSON-LD map[string]any
func NilDocument ¶
NilDocument returns a new, empty Document.
func (Document) Accuracy ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accuracy
func (Document) Altitude ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-altitude
func (Document) Audience ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audience
func (Document) Closed ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-closed
func (Document) Collection ¶ added in v0.5.0
Collection retrieves a JSON-LD document from a remote server, parses is, and returns a Document object.
func (Document) Content ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content
func (Document) Context ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-context
func (Document) Current ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-current
func (Document) Deleted ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-deleted
func (Document) Document ¶ added in v0.5.0
Document retrieves a JSON-LD document from a remote server, parses is, and returns a Document object.
func (Document) Duration ¶
TODO: Implement Durations per https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
func (Document) EndTime ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-endtime
func (Document) ForceLoad ¶ added in v0.4.2
ForceLoad retrieves a JSON-LD document from a remote server, regardless of whether we already have an ID or a full value.
func (Document) Head ¶
Head returns the first object in a slice. For all other document types, it returns the current document.
func (Document) Height ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-height
func (Document) Hreflang ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-hreflang
func (Document) IconOrImage ¶ added in v0.4.2
IconOrImage is a hybrid accessor that returns the "icon" property (if not nil), otherwise it returns the "image" property. This is useful for working with different ActivityPub objects, which may use either property.
func (Document) IsEmptyTail ¶
IsEmpty return TRUE if the current object is empty
func (Document) Items ¶
Items returns the items collection for this Document. If the document contains an "orderedItems" collection, then it is returned instead.
func (Document) Latitude ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-latitude
func (Document) Load ¶ added in v0.4.0
Map retrieves a JSON-LD document from a remote server, parses is, and returns a Document object.
func (Document) Location ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-location
func (Document) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface, and provides a custom marshalling into JSON -- essentially just aiming the marshaller at the Document's value.
func (Document) Meta ¶ added in v0.4.2
Meta returns a pointer to the metadata associated with this document.
func (Document) MetaFloat ¶ added in v0.5.0
MetaFloat returns a float64 from the document's metadata.
func (Document) MetaInt64 ¶ added in v0.5.0
MetaInt64 returns an int64 from the document's metadata.
func (*Document) MetaSet ¶ added in v0.5.0
MetaSet replaces the metadata associated with this document.
func (*Document) MetaSetBool ¶ added in v0.5.0
MetaSetBool sets a bool value in the document's metadata.
func (*Document) MetaSetFloat ¶ added in v0.5.0
MetaSetFloat sets a float64 value in the document's metadata.
func (*Document) MetaSetInt ¶ added in v0.5.0
MetaSetInt sets an int value in the document's metadata.
func (*Document) MetaSetInt64 ¶ added in v0.5.0
MetaSetInt64 sets an int64 value in the document's metadata.
func (*Document) MetaSetString ¶ added in v0.5.0
MetaSetString sets a string value in the document's metadata.
func (Document) MetaString ¶ added in v0.5.0
MetaString returns a string from the document's metadata.
func (Document) Object ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object
func (Document) Origin ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-origin
func (Document) PartOf ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-partof
func (Document) Preview ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-preview
func (Document) PublicKeyPEM ¶ added in v0.2.2
func (Document) Radius ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-radius
func (Document) Rel ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-rel Rel is expected to be a string, but this function returns a document because it may contain multiple values (rel:["canonical", "preview"])
func (Document) Replies ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-replies
func (Document) Result ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-result
func (Document) SliceOfDocuments ¶ added in v0.4.2
SliceOfDocuments transforms the current object into a slice of separate Document objects, one for each value in the current document array.
func (Document) Subject ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-subject
func (Document) Summary ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary TODO: Implement Language Maps
func (Document) Tail ¶
Tail returns all records after the first in a slice. For all other document types, it returns a nil document.
func (Document) Target ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-target
func (*Document) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface, and provides a custom un-marshalling from JSON -- essentially just aiming the unmashaller at the Document's value
func (Document) Updated ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-updated
func (*Document) WithOptions ¶ added in v0.4.2
type Image ¶ added in v0.4.2
type Image struct {
// contains filtered or unexported fields
}
https://www.w3.org/ns/activitystreams#Image
func NewImage ¶ added in v0.4.2
NewImage creates a new Image object from a JSON-LD value (string, map[string]any, or []any)
func (Image) HasDimensions ¶ added in v0.4.2
func (Image) Height ¶ added in v0.4.2
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-height
func (Image) MediaType ¶ added in v0.4.2
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype
func (Image) Summary ¶ added in v0.4.2
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary
type Iterator ¶ added in v0.4.0
type Iterator struct {
// contains filtered or unexported fields
}
Iterator allows transparent iteration over a Collection, OrderedCollection, and their corresponding pages (if present).
func NewIterator ¶ added in v0.4.0
NewIterator creates a new Iterator object from a Document or Document URI.
func (*Iterator) Error ¶ added in v0.4.0
Error returns any error that occurred during the iteration process.
func (*Iterator) HasNext ¶ added in v0.4.0
HasNext verifies that there is at least one more item remaining in the collection.
func (*Iterator) TotalItems ¶ added in v0.4.0
TotalItems returns the total number of items in the collection.
type Option ¶ added in v0.4.0
type Option func(*Document)
func WithClient ¶ added in v0.4.0
WithClient option sets the HTTP client that can load remote documents if necessary
type OrderedCollection ¶
type OrderedCollection struct { Context Context `json:"@context,omitempty" bson:"@context,omitempty"` ID string `json:"id,omitempty" bson:"id,omitempty"` Type string `json:"type,omitempty" bson:"type,omitempty"` Summary string `json:"summary,omitempty" bson:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems,omitempty" bson:"totalItems,omitempty"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance. OrderedItems []any `json:"orderedItems,omitempty" bson:"orderedItems,omitempty"` // Identifies the items contained in a collection. The items might be ordered or unordered. Current string `json:"current,omitempty" bson:"current,omitempty"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty" bson:"first,omitempty"` // In a paged Collection, indicates the furthest preceding page of items in the collection. Last string `json:"last,omitempty" bson:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. }
OrderedCollection is a subtype of Collection in which members of the logical collection are assumed to always be strictly ordered. https://www.w3.org/ns/activitystreams#OrderedCollection
func NewOrderedCollection ¶ added in v0.3.0
func NewOrderedCollection() OrderedCollection
func (*OrderedCollection) UnmarshalJSON ¶
func (c *OrderedCollection) UnmarshalJSON(data []byte) error
func (*OrderedCollection) UnmarshalMap ¶
func (c *OrderedCollection) UnmarshalMap(data mapof.Any) error
type OrderedCollectionPage ¶
type OrderedCollectionPage struct { Context Context `json:"@context,omitempty" bson:"context,omitempty"` Type string `json:"type,omitempty" bson:"type,omitempty"` Summary string `json:"summary,omitempty" bson:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems,omitempty" bson:"totalItems,omitempty"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance. Current string `json:"current,omitempty" bson:"current,omitempty"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty" bson:"first,omitempty"` // In a paged Collection, indicates the furthest preceding page of items in the collection. Last string `json:"last,omitempty" bson:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. StartIndex int `json:"startIndex,omitempty" bson:"startIndex,omitempty"` // A non-negative integer value identifying the relative position within the logical view of a strictly ordered collection. PartOf string `json:"partOf,omitempty" bson:"partOf,omitempty"` // dentifies the Collection to which a CollectionPage objects items belong. Prev string `json:"prev,omitempty" bson:"prev,omitempty"` // In a paged Collection, identifies the previous page of items. Next string `json:"next,omitempty" bson:"next,omitempty"` // In a paged Collection, indicates the next page of items. OrderedItems []any `json:"orderedItems,omitempty" bson:"orderedItems,omitempty"` // Identifies the items contained in a collection. The items might be ordered or unordered. }
OrderedCollectionPage is used to represent ordered subsets of items from an OrderedCollection. Refer to the Activity Streams 2.0 Core for a complete description of the OrderedCollectionPage object. https://www.w3.org/ns/activitystreams#OrderedCollectionPage
func NewOrderedCollectionPage ¶ added in v0.3.0
func NewOrderedCollectionPage() OrderedCollectionPage
func (*OrderedCollectionPage) UnmarshalJSON ¶
func (c *OrderedCollectionPage) UnmarshalJSON(data []byte) error
func (*OrderedCollectionPage) UnmarshalMap ¶
func (c *OrderedCollectionPage) UnmarshalMap(data mapof.Any) error