tag

package
v0.0.0-...-876d392 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ALLFILE = USER | DATE | NAME

ALLFILE are all the types of tags that are associated with a File

View Source
const ALLSTORE = CONTENT | TOPIC | ACTION | RESOURCE | PROCESS

ALLSTORE are all the types of tags that are associated with a FileStore

View Source
const ALLSYNTH = TOPIC | ACTION | RESOURCE | PROCESS

ALLSYNTH is the combination of TOPIC, ACTION, RESOURCE, and PROCESS

View Source
const ALLTYPES = Type(math.MaxUint32)

ALLTYPES is the compound of all possible tag types

Variables

This section is empty.

Functions

func ScanWords

func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanWords causes a scanner to extract each alpha-numeric sequence

Types

type Data

type Data map[Type]map[string]interface{}

Data maps a tag type to an abitrary collection of string to string mappings

func (Data) Contains

func (d Data) Contains(oth Data) bool

Contains returns true if all data fields in the provided data match the fields in the original

func (Data) Copy

func (d Data) Copy() Data

Copy generates a new Data object with the same values as the original

func (Data) FilterType

func (d Data) FilterType(t Type) Data

FilterType returns a new instance of tag data that is a subset of keys defined by the type

func (Data) MarshalBSON

func (d Data) MarshalBSON() ([]byte, error)

MarshalBSON converts Data into a bson representation

func (*Data) UnmarshalBSON

func (d *Data) UnmarshalBSON(b []byte) error

UnmarshalBSON converts bson representation back into Data

type FileTag

type FileTag struct {
	Tag   `bson:",inline"`
	File  types.FileID  `bson:"file"`
	Owner types.OwnerID `bson:"owner"`
}

FileTag is a Tag tied to a File

func (FileTag) Pure

func (ft FileTag) Pure() FileTag

Pure filters out elements that are represented with StoreTag

func (FileTag) StoreTag

func (ft FileTag) StoreTag() StoreTag

StoreTag builds StoreTag from FileTag

func (FileTag) Update

func (ft FileTag) Update(oth FileTag) FileTag

Update creates a combination of the two tags

type StoreTag

type StoreTag struct {
	Tag   `bson:",inline"`
	Store types.StoreID `bson:"store"`
}

StoreTag is a Tag tied to a FileStore

func (StoreTag) Update

func (st StoreTag) Update(oth StoreTag) StoreTag

Update updates the StoreTag based on provided other StoreTag

type Tag

type Tag struct {
	Word string `bson:"word" json:"word"`
	Type Type   `bson:"type" json:"type"`
	Data Data   `bson:"data" json:"data"`
}

Tag is a combination of a word and a type to attach to a file or store Data is to store additional data about a particular tag

func BuildNameTags

func BuildNameTags(s string) (out []Tag, err error)

BuildNameTags converts a string into tags of that string and substrings that are alpha numeric sequences

func ExtractContentTags

func ExtractContentTags(content io.Reader) ([]Tag, error)

ExtractContentTags generates an array of tags for each unique word as defined by ScanWords

func (Tag) Update

func (t Tag) Update(oth Tag) Tag

Update adds or replaces data values in the passed tag

type Type

type Type uint32

Type is a byte flag for different kinds of tags

const (
	CONTENT Type = 1 << iota
	TOPIC
	ACTION
	RESOURCE
	PROCESS
)

Types of tags, bitwise or them together to make compound tags

const (
	// USER indicates a custom tag created by a user, ie a folder
	USER Type = (1 << 24) << iota
	// DATE is to record a mapping of a date to a file made by a user.
	DATE
	// NAME is to record tags based on the name of a file
	NAME
)
const (
	// SEARCH indicates that there are additional filter parameters within the Data to apply when searching tags
	SEARCH Type = (1 << 16) << iota
)

func DecodeType

func DecodeType(s string) (Type, error)

DecodeType converts String representation back to Type

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL