Documentation ¶
Index ¶
- func UnmarshalItems(data any) ([]any, bool)
- type Cache
- 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) 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) Array() []any
- func (document Document) Attachment() Document
- func (document Document) AttributedTo() Document
- func (document Document) Audience() Document
- func (document Document) Bcc() Document
- func (document Document) Bool() bool
- 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) Float() float64
- 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) 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) 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) Load() (Document, error)
- 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) 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) 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) TargetID() string
- 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
- type Iterator
- type Option
- type OrderedCollection
- type OrderedCollectionPage
Constants ¶
This section is empty.
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 Client ¶ added in v0.4.0
func NewDefaultClient ¶ added in v0.4.0
func NewDefaultClient() Client
type Collection ¶
type Collection struct { Context Context `json:"@context"` Type string `json:"type"` Summary string `json:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"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"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. Items []any `json:"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"` Type string `json:"type"` Summary string `json:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"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"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. PartOf string `json:"partOf,omitempty"` // dentifies the Collection to which a CollectionPage objects items belong. Prev string `json:"prev,omitempty"` // In a paged Collection, identifies the previous page of items. Next string `json:"next,omitempty"` // 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 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{}
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) 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) Items ¶
Items returns the items collection for this Document. If the document contains an "orderedItems" collection, then it is returned instead.
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) 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) PublicKeyPEM ¶ added in v0.2.2
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
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 OrderedCollection ¶
type OrderedCollection struct { Context Context `json:"@context"` Type string `json:"type"` Summary string `json:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"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"` // Identifies the items contained in a collection. The items might be ordered or unordered. Current string `json:"current,omitempty"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"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"` Type string `json:"type"` Summary string `json:"summary,omitempty"` // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided. TotalItems int `json:"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"` // In a paged Collection, indicates the page that contains the most recently updated member items. First string `json:"first,omitempty"` // In a paged Collection, indicates the furthest preceeding page of items in the collection. Last string `json:"last,omitempty"` // In a paged Collection, indicates the furthest proceeding page of the collection. StartIndex int `json:"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"` // dentifies the Collection to which a CollectionPage objects items belong. Prev string `json:"prev,omitempty"` // In a paged Collection, identifies the previous page of items. Next string `json:"next,omitempty"` // 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 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