Documentation ¶
Index ¶
- Constants
- func UnmarshalItems(data any) ([]any, bool)
- type Cache
- 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 Document
- func (document Document) Accuracy() float64
- func (document Document) Activity() Document
- func (document Document) Actor() Document
- func (document Document) ActorID() string
- func (document Document) Altitude() float64
- func (document Document) AnyOf() Document
- func (document Document) AsBool() bool
- func (document Document) AsFloat() float64
- func (document Document) AsInt() int
- func (document Document) AsObject() (Document, error)
- func (document Document) AsString() string
- func (document Document) AsTime() time.Time
- func (document Document) Attachment() Document
- func (document Document) AttributedTo() Document
- func (document Document) Audience() Document
- func (document Document) Bcc() Document
- func (document Document) Bto() Document
- func (document Document) Cc() Document
- func (document Document) Closed() Document
- func (document Document) Content() string
- func (document Document) Context() Document
- func (document Document) Current() Document
- func (document Document) Deleted() time.Time
- func (document Document) Describes() Document
- func (document Document) Duration() string
- func (document Document) EndTime() time.Time
- func (document Document) First() Document
- 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() Document
- func (document Document) IconURL() string
- func (document Document) Image() Document
- func (document Document) ImageURL() string
- func (document Document) InReplyTo() Document
- func (document Document) Instrument() Document
- 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) IsNil() bool
- func (document Document) IsObject() bool
- func (document Document) IsString() bool
- func (document Document) Items() Document
- func (document Document) Last() Document
- func (document Document) Latitude() float64
- func (document Document) Location() Document
- func (document Document) Longitude() float64
- func (document Document) MarshalJSON() ([]byte, error)
- func (document Document) MediaType() string
- func (document Document) Name() string
- func (document Document) Next() Document
- func (document Document) Object() Document
- func (document Document) ObjectID() string
- func (document Document) OneOf() Document
- func (document Document) Origin() Document
- func (document Document) PartOf() Document
- func (document Document) Prev() Document
- func (document Document) Preview() Document
- 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) StartIndex() int
- func (document Document) StartTime() time.Time
- 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) TargetID() string
- 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
- type OrderedCollection
- type OrderedCollectionPage
Constants ¶
const TypeCollection = "Collection"
const TypeCollectionPage = "CollectionPage"
const TypeOrderedCollection = "OrderedCollection"
const TypeOrderedCollectionPage = "OrderedCollectionPage"
Variables ¶
This section is empty.
Functions ¶
func UnmarshalItems ¶
Types ¶
type Cache ¶
Cache is a simple interace for caching JSON-LD documents. There is a default implementation in the "cache" package, but this can be replaced with any other implementation.
type Collection ¶
type Collection struct { Context Context `json:"@context"` Type string `json:"type"` Summary string `json:"summary"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems"` // 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"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last"` // In a paged Collection, indicates the furthest proceeding page of the collection. Items []any `json:"items"` // 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 (*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"` Type string `json:"type"` Summary string `json:"summary"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems"` // 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"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last"` // In a paged Collection, indicates the furthest proceeding page of the collection. PartOf string `json:"partOf"` // dentifies the Collection to which a CollectionPage objects items belong. Prev string `json:"prev"` // In a paged Collection, identifies the previous page of items. Next string `json:"next"` // In a paged Collection, indicates the next page of items. Items []any `json:"items"` // 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 (*CollectionPage) UnmarshalJSON ¶
func (c *CollectionPage) UnmarshalJSON(data []byte) error
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 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 (Document) AsObject ¶
AsObject retrieves a JSON-LD document from a remote server, parses is, and returns a Document object.
func (Document) Attachment ¶
func (Document) AttributedTo ¶
func (Document) Duration ¶
TODO: Implement Durations per https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
func (Document) FormerType ¶
func (Document) Head ¶
Head returns the first object in a slice. For all other document types, it returns the current document.
func (Document) Instrument ¶
func (Document) IsEmptyTail ¶
IsEmpty return TRUE if the current object is empty
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) 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) Relationship ¶
func (Document) StartIndex ¶
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) TotalItems ¶
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) Url ¶
TODO: HIGH: Special handling for URL properties strings => {href: <string>} https://www.w3.org/TR/activitystreams-vocabulary/#dfn-url
type OrderedCollection ¶
type OrderedCollection struct { Context Context `json:"@context"` Type string `json:"type"` Summary string `json:"summary"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems"` // 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"` // Identifies the items contained in a collection. The items might be ordered or unordered. Current string `json:"current"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last"` // 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 (*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"` Type string `json:"type"` Summary string `json:"summary"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"totalItems"` // 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"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last"` // In a paged Collection, indicates the furthest proceeding page of the collection. StartIndex int `json:"startIndex"` // A non-negative integer value identifying the relative position within the logical view of a strictly ordered collection. PartOf string `json:"partOf"` // dentifies the Collection to which a CollectionPage objects items belong. Prev string `json:"prev"` // In a paged Collection, identifies the previous page of items. Next string `json:"next"` // In a paged Collection, indicates the next page of items. OrderedItems []any `json:"orderedItems"` // 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 (*OrderedCollectionPage) UnmarshalJSON ¶
func (c *OrderedCollectionPage) UnmarshalJSON(data []byte) error
func (*OrderedCollectionPage) UnmarshalMap ¶
func (c *OrderedCollectionPage) UnmarshalMap(data mapof.Any) error