Documentation ¶
Overview ¶
Package domain provides domain specific types, constants, and functions.
Package domain provides domain specific types, constants, and functions.
Index ¶
- Constants
- func BoolValue(value string) bool
- func IsValidID(s string) bool
- func KeyIsValid(key string) bool
- func KeyType(key string) byte
- func ListFromValue(value string) []string
- type Content
- type Meta
- func (m *Meta) Clone() *Meta
- func (m *Meta) Delete(key string)
- func (m *Meta) Equal(o *Meta) bool
- func (m *Meta) Freeze()
- func (m *Meta) Get(key string) (string, bool)
- func (m *Meta) GetBool(key string) bool
- func (m *Meta) GetDefault(key string, def string) string
- func (m *Meta) GetList(key string) ([]string, bool)
- func (m *Meta) GetListOrNil(key string) []string
- func (m *Meta) IsFrozen() bool
- func (m *Meta) Pairs() []MetaPair
- func (m *Meta) PairsRest() []MetaPair
- func (m *Meta) Set(key, value string)
- func (m *Meta) SetList(key string, values []string)
- func (m *Meta) Type(key string) byte
- func (m *Meta) Write(w io.Writer) (int, error)
- func (m *Meta) WriteAsHeader(w io.Writer) (int, error)
- type MetaPair
- type Zettel
- type ZettelID
Constants ¶
const ( MetaKeyID = "id" MetaKeyTitle = "title" MetaKeyTags = "tags" MetaKeySyntax = "syntax" MetaKeyRole = "role" MetaKeyCopyright = "copyright" MetaKeyCred = "cred" MetaKeyDefaultCopyright = "default-copyright" MetaKeyDefaultLang = "default-lang" MetaKeyDefaultLicense = "default-license" MetaKeyDefaultRole = "default-role" MetaKeyDefaultSyntax = "default-syntax" MetaKeyDefaultTitle = "default-title" MetaKeyIconMaterial = "icon-material" MetaKeyIdent = "ident" MetaKeyLang = "lang" MetaKeyLicense = "license" MetaKeyOwner = "owner" MetaKeySiteName = "site-name" MetaKeyStart = "start" MetaKeyURL = "url" MetaKeyYAMLHeader = "yaml-header" MetaKeyZettelFileSyntax = "zettel-file-syntax" )
Predefined keys.
const ( MetaValueSyntax = "zmk" MetaValueTitle = "Untitled" )
Predefined default values.
const ( MetaTypeBool = 'b' MetaTypeCred = 'c' MetaTypeEmpty = 'e' MetaTypeID = 'i' MetaTypeString = 's' MetaTypeTagSet = 'T' MetaTypeURL = 'u' MetaTypeUnknown = '\000' MetaTypeWord = 'w' MetaTypeWordSet = 'W' )
Supported key types.
const ( ConfigurationID = ZettelID("00000000000000") BaseTemplateID = ZettelID("00000000010100") LoginTemplateID = ZettelID("00000000010200") ListTemplateID = ZettelID("00000000010300") DetailTemplateID = ZettelID("00000000010401") InfoTemplateID = ZettelID("00000000010402") FormTemplateID = ZettelID("00000000010403") RenameTemplateID = ZettelID("00000000010404") DeleteTemplateID = ZettelID("00000000010405") RolesTemplateID = ZettelID("00000000010500") TagsTemplateID = ZettelID("00000000010600") BaseCSSID = ZettelID("00000000020001") MaterialIconID = ZettelID("00000000030001") )
Some important ZettelIDs
const RegexpID = "[0-9]{14}"
RegexpID contains the regexp string that determines a valid zettel id.
Variables ¶
This section is empty.
Functions ¶
func BoolValue ¶
BoolValue returns the value interpreted as a bool.
func IsValidID ¶
IsValidID returns true, if string is a valid zettel ID.
func KeyIsValid ¶
KeyIsValid returns true, the the key is a valid string.
func KeyType ¶
KeyType returns a type hint for the given key. If no type hint is specified, MetaTypeUnknown is returned.
Types ¶
type Content ¶
type Content string
Content is just the uninterpreted content of a zettel.
func (Content) AsBytes ¶
AsBytes returns the content itself is a byte slice.
type Meta ¶
Meta contains all meta-data of a zettel.
func NewMetaFromInput ¶
NewMetaFromInput parses the meta data of a zettel.
func (*Meta) Clone ¶
Clone returns a new copy of the same meta data that is not frozen.
func (*Meta) Freeze ¶
func (m *Meta) Freeze()
Freeze defines frozen meta data, i.e. changing them will result in a panic.
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) GetBool ¶
GetBool returns the boolean value of the given key.
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) GetListOrNil ¶
GetListOrNil retrieves the string list value of a given key. If there was nothing stores, a nil list is returned.
func (*Meta) IsFrozen ¶
IsFrozen returns whether meta can be changed or not.
func (*Meta) Pairs ¶
Pairs 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) PairsRest ¶
PairsRest returns all key/values pairs stored, except the values with predefined keys. The pairs are ordered by key.
func (*Meta) Set ¶
Set stores the given string value under the given key.
func (*Meta) SetList ¶
SetList stores the given string list value under the given key.
func (*Meta) Type ¶
Type returns a type hint for the given key. If no type hint is specified, MetaTypeUnknown is returned.
func (*Meta) Write ¶
Write writes a zettel meta to a writer.
type MetaPair ¶
MetaPair is one key-value-pair of a Zettel meta.
type Zettel ¶
type Zettel struct { Meta *Meta // Some additional meta-data. Content Content // The content of the zettel itself. }
Zettel is the main data object of a zettelstore.