Documentation ¶
Overview ¶
Package meta provides the zettel specific type 'meta'.
Index ¶
- Constants
- Variables
- func BoolValue(value string) bool
- func CleanTag(tag string) string
- func ExpandTimestamp(value string) string
- func Inverse(name string) string
- func IsComputed(name string) bool
- func IsProperty(name string) bool
- func KeyIsValid(s string) bool
- func ListFromValue(value string) []string
- func NormalizeTag(tag string) string
- func RemoveNonGraphic(s string) string
- func TagsFromValue(value string) []string
- func TimeValue(value string) (time.Time, bool)
- type Arrangement
- type CountedCategories
- type CountedCategory
- type DescriptionKey
- type DescriptionType
- type Meta
- func (m *Meta) Clone() *Meta
- func (m *Meta) ComputedPairs() []Pair
- func (m *Meta) ComputedPairsRest() []Pair
- func (m *Meta) Delete(key string)
- func (m *Meta) Equal(o *Meta, allowComputed bool) bool
- func (m *Meta) Get(key string) (string, bool)
- func (m *Meta) GetBool(key string) bool
- func (m *Meta) GetDefault(key, def string) string
- func (m *Meta) GetList(key string) ([]string, bool)
- func (m *Meta) GetNumber(key string, def int64) int64
- func (m *Meta) GetTitle() string
- func (m *Meta) Length() int
- func (m *Meta) Map() map[string]string
- func (m *Meta) Pairs() []Pair
- func (m *Meta) PairsRest() []Pair
- func (m *Meta) Sanitize()
- func (m *Meta) Set(key, value string)
- func (m *Meta) SetList(key string, values []string)
- func (m *Meta) SetNonEmpty(key, value string)
- func (m *Meta) SetNow(key string)
- func (m *Meta) SetWord(key, word string)
- func (*Meta) Type(key string) *DescriptionType
- func (m *Meta) Write(w io.Writer) (int, error)
- func (m *Meta) WriteComputed(w io.Writer) (int, error)
- type Pair
- type UserRole
- type Visibility
Constants ¶
const ( SuffixKeyRole = "-role" SuffixKeyURL = "-url" )
Some constants for key suffixes that determine a type.
const ( SyntaxCSS = api.ValueSyntaxCSS SyntaxDraw = api.ValueSyntaxDraw SyntaxGif = api.ValueSyntaxGif SyntaxHTML = api.ValueSyntaxHTML SyntaxJPEG = "jpeg" SyntaxJPG = "jpg" SyntaxMarkdown = api.ValueSyntaxMarkdown SyntaxMD = api.ValueSyntaxMD SyntaxNone = api.ValueSyntaxNone SyntaxPlain = "plain" SyntaxPNG = "png" SyntaxSVG = api.ValueSyntaxSVG SyntaxSxn = api.ValueSyntaxSxn SyntaxText = api.ValueSyntaxText SyntaxTxt = "txt" SyntaxWebp = "webp" SyntaxZmk = api.ValueSyntaxZmk DefaultSyntax = SyntaxPlain )
Supported syntax values.
const NewPrefix = "new-"
NewPrefix is the prefix for metadata key in template zettel for creating new zettel.
Variables ¶
var ( TypeCredential = registerType(api.MetaCredential, false) TypeEmpty = registerType(api.MetaEmpty, false) TypeID = registerType(api.MetaID, false) TypeIDSet = registerType(api.MetaIDSet, true) TypeNumber = registerType(api.MetaNumber, false) TypeString = registerType(api.MetaString, false) TypeTagSet = registerType(api.MetaTagSet, true) TypeTimestamp = registerType(api.MetaTimestamp, false) TypeURL = registerType(api.MetaURL, false) TypeWord = registerType(api.MetaWord, false) TypeZettelmarkup = registerType(api.MetaZettelmarkup, false) )
Supported key types.
Functions ¶
func ExpandTimestamp ¶ added in v0.16.0
ExpandTimestamp makes a short-form timestamp larger.
func IsComputed ¶
IsComputed returns true, if key denotes a computed metadata key.
func IsProperty ¶
IsProperty returns true, if key denotes a property metadata value.
func KeyIsValid ¶
KeyIsValid returns true, if the string is a valid metadata key.
func ListFromValue ¶
ListFromValue transforms a string value into a list value.
func NormalizeTag ¶ added in v0.15.0
NormalizeTag adds a missing prefix "#" to the tag
func RemoveNonGraphic ¶
RemoveNonGraphic changes the given string not to include non-graphical characters. It is needed to sanitize meta data.
func TagsFromValue ¶ added in v0.16.0
TagsFromValue returns the value as a sequence of normalized tags.
Types ¶
type Arrangement ¶
Arrangement stores metadata within its categories. Typecally a category might be a tag name, a role name, a syntax value.
func CreateArrangement ¶
func CreateArrangement(metaList []*Meta, key string) Arrangement
CreateArrangement by inspecting a given key and use the found value as a category.
func (Arrangement) Counted ¶
func (a Arrangement) Counted() CountedCategories
Counted returns the list of categories, together with the number of metadata for each category.
type CountedCategories ¶
type CountedCategories []CountedCategory
CountedCategories is the list of CountedCategories. Every name must occur only once.
func (CountedCategories) Categories ¶
func (ccs CountedCategories) Categories() []string
Categories returns just the category names.
func (CountedCategories) SortByCount ¶
func (ccs CountedCategories) SortByCount()
SortByCount sorts the list by the count attribute, descending. If two counts are equal, elements are sorted by name.
func (CountedCategories) SortByName ¶
func (ccs CountedCategories) SortByName()
SortByName sorts the list by the name attribute. Since each name must occur only once, two CountedCategories cannot have the same name.
type CountedCategory ¶
CountedCategory contains of a name and the number how much this name occured somewhere.
type DescriptionKey ¶
type DescriptionKey struct { Name string Type *DescriptionType Inverse string // contains filtered or unexported fields }
DescriptionKey formally describes each supported metadata key.
func GetDescription ¶
func GetDescription(name string) DescriptionKey
GetDescription returns the key description object of the given key name.
func GetSortedKeyDescriptions ¶
func GetSortedKeyDescriptions() []*DescriptionKey
GetSortedKeyDescriptions delivers all metadata key descriptions as a slice, sorted by name.
func (*DescriptionKey) IsComputed ¶
func (kd *DescriptionKey) IsComputed() bool
IsComputed returns true, if metadata is computed and not set by the user.
func (*DescriptionKey) IsProperty ¶
func (kd *DescriptionKey) IsProperty() bool
IsProperty returns true, if metadata is a computed property.
type DescriptionType ¶
DescriptionType is a description of a specific key type.
func Type ¶
func Type(key string) *DescriptionType
Type returns a type hint for the given key. If no type hint is specified, TypeEmpty is returned.
func (DescriptionType) String ¶
func (t DescriptionType) String() string
String returns the string representation of the given type
type Meta ¶
Meta contains all meta-data of a zettel.
func NewFromInput ¶
NewFromInput parses the meta data of a zettel.
func NewWithData ¶
NewWithData creates metadata object with given data.
func (*Meta) ComputedPairs ¶
ComputedPairs returns all key/values pairs stored, in a specific order. First come the pairs with predefined keys: MetaTitleKey, MetaTagsKey, MetaSyntaxKey, MetaContextKey. Then all other pairs are append to the list, ordered by key.
func (*Meta) ComputedPairsRest ¶
ComputedPairsRest returns all key/values pairs stored, except the values with predefined keys. The pairs are ordered by key.
func (*Meta) Get ¶
Get retrieves the string value of a given key. The bool value signals, whether there was a value stored or not.
func (*Meta) GetDefault ¶
GetDefault retrieves the string value of the given key. If no value was stored, the given default value is returned.
func (*Meta) GetList ¶
GetList retrieves the string list value of a given key. The bool value signals, whether there was a value stored or not.
func (*Meta) GetTitle ¶
GetTitle returns the title of the metadata. It is the only key that has a defined default value: the string representation of the zettel identifier.
func (*Meta) Pairs ¶
Pairs returns not computed key/values pairs stored, in a specific order. First come the pairs with predefined keys: MetaTitleKey, MetaTagsKey, MetaSyntaxKey, MetaContextKey. Then all other pairs are append to the list, ordered by key.
func (*Meta) PairsRest ¶
PairsRest returns not computed key/values pairs stored, except the values with predefined keys. The pairs are ordered by key.
func (*Meta) Sanitize ¶
func (m *Meta) Sanitize()
Sanitize all metadata keys and values, so that they can be written safely into a file.
func (*Meta) SetNonEmpty ¶
SetNonEmpty stores the given value under the given key, if the value is non-empty. An empty value will delete the previous association.
func (*Meta) Type ¶
func (*Meta) Type(key string) *DescriptionType
Type returns a type hint for the given key. If no type hint is specified, TypeUnknown is returned.
type UserRole ¶
type UserRole int
UserRole enumerates the supported values of meta key 'user-role'.
const ( UserRoleUnknown UserRole UserRoleCreator UserRoleReader UserRoleWriter UserRoleOwner )
Supported values for user roles.
func GetUserRole ¶
GetUserRole role returns the user role of the given string.
type Visibility ¶
type Visibility int
Visibility enumerates the variations of the 'visibility' meta key.
const ( VisibilityUnknown Visibility VisibilityPublic VisibilityCreator VisibilityLogin VisibilityOwner VisibilityExpert )
Supported values for visibility.
func GetVisibility ¶
func GetVisibility(val string) Visibility
GetVisibility returns the visibility value of the given string
func (Visibility) String ¶
func (v Visibility) String() string