api

package
v0.0.0-...-8851141 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: EUPL-1.2 Imports: 3 Imported by: 0

Documentation

Overview

Package api contains common definitions used for client and server.

Index

Constants

View Source
const (
	// System zettel
	ZidVersion              = ZettelID("00000000000001")
	ZidHost                 = ZettelID("00000000000002")
	ZidOperatingSystem      = ZettelID("00000000000003")
	ZidLicense              = ZettelID("00000000000004")
	ZidAuthors              = ZettelID("00000000000005")
	ZidDependencies         = ZettelID("00000000000006")
	ZidLog                  = ZettelID("00000000000007")
	ZidMemory               = ZettelID("00000000000008")
	ZidBoxManager           = ZettelID("00000000000020")
	ZidMetadataKey          = ZettelID("00000000000090")
	ZidParser               = ZettelID("00000000000092")
	ZidStartupConfiguration = ZettelID("00000000000096")
	ZidConfiguration        = ZettelID("00000000000100")

	// WebUI HTML templates are in the range 10000..19999
	ZidBaseTemplate   = ZettelID("00000000010100")
	ZidLoginTemplate  = ZettelID("00000000010200")
	ZidListTemplate   = ZettelID("00000000010300")
	ZidZettelTemplate = ZettelID("00000000010401")
	ZidInfoTemplate   = ZettelID("00000000010402")
	ZidFormTemplate   = ZettelID("00000000010403")
	ZidRenameTemplate = ZettelID("00000000010404")
	ZidDeleteTemplate = ZettelID("00000000010405")
	ZidErrorTemplate  = ZettelID("00000000010700")

	// WebUI sxn code zettel are in the range 19000..19999
	ZidSxnStart = ZettelID("00000000019000")
	ZidSxnBase  = ZettelID("00000000019990")

	// CSS-related zettel are in the range 20000..29999
	ZidBaseCSS = ZettelID("00000000020001")
	ZidUserCSS = ZettelID("00000000025001")

	// WebUI image zettel are in the range 40000..49999
	ZidEmoji = ZettelID("00000000040001")

	// Other sxn code zettel are in the range 50000..59999
	ZidSxnPrelude = ZettelID("00000000059900")

	// Predefined Zettelmarkup zettel are in the range 60000..69999
	ZidRoleZettelZettel        = ZettelID("00000000060010")
	ZidRoleConfigurationZettel = ZettelID("00000000060020")
	ZidRoleRoleZettel          = ZettelID("00000000060030")
	ZidRoleTagZettel           = ZettelID("00000000060040")

	// Range 90000...99999 is reserved for zettel templates
	ZidTOCNewTemplate    = ZettelID("00000000090000")
	ZidTemplateNewZettel = ZettelID("00000000090001")
	ZidTemplateNewRole   = ZettelID("00000000090004")
	ZidTemplateNewTag    = ZettelID("00000000090003")
	ZidTemplateNewUser   = ZettelID("00000000090002")

	ZidDefaultHome = ZettelID("00010000000000")
)

Predefined Zettel Identifier

View Source
const (
	MetaCredential   = "Credential"
	MetaEmpty        = "EString"
	MetaID           = "Identifier"
	MetaIDSet        = "IdentifierSet"
	MetaNumber       = "Number"
	MetaString       = "String"
	MetaTagSet       = "TagSet"
	MetaTimestamp    = "Timestamp"
	MetaURL          = "URL"
	MetaWord         = "Word"
	MetaZettelmarkup = "Zettelmarkup"
)

Values of the metadata key/value type.

View Source
const (
	KeyID           = "id"
	KeyTitle        = "title"
	KeyRole         = "role"
	KeyTags         = "tags"
	KeySyntax       = "syntax"
	KeyAuthor       = "author"
	KeyBack         = "back"
	KeyBackward     = "backward"
	KeyBoxNumber    = "box-number"
	KeyCopyright    = "copyright"
	KeyCreated      = "created"
	KeyCredential   = "credential"
	KeyDead         = "dead"
	KeyExpire       = "expire"
	KeyFolge        = "folge"
	KeyFolgeRole    = "folge-role"
	KeyForward      = "forward"
	KeyLang         = "lang"
	KeyLicense      = "license"
	KeyModified     = "modified"
	KeyPrecursor    = "precursor"
	KeyPredecessor  = "predecessor"
	KeyPublished    = "published"
	KeyQuery        = "query"
	KeyReadOnly     = "read-only"
	KeySubordinates = "subordinates"
	KeySuccessors   = "successors"
	KeySuperior     = "superior"
	KeySummary      = "summary"
	KeyURL          = "url"
	KeyUselessFiles = "useless-files"
	KeyUserID       = "user-id"
	KeyUserRole     = "user-role"
	KeyVisibility   = "visibility"
)

Predefined general Metadata keys

View Source
const (
	ValueFalse             = "false"
	ValueTrue              = "true"
	ValueLangEN            = "en"
	ValueRoleConfiguration = "configuration"
	ValueRoleTag           = "tag"
	ValueRoleRole          = "role"
	ValueRoleZettel        = "zettel"
	ValueSyntaxCSS         = "css"
	ValueSyntaxDraw        = "draw"
	ValueSyntaxGif         = "gif"
	ValueSyntaxHTML        = "html"
	ValueSyntaxMarkdown    = "markdown"
	ValueSyntaxMD          = "md"
	ValueSyntaxNone        = "none"
	ValueSyntaxSVG         = "svg"
	ValueSyntaxSxn         = "sxn"
	ValueSyntaxText        = "text"
	ValueSyntaxZmk         = "zmk"
	ValueUserRoleCreator   = "creator"
	ValueUserRoleOwner     = "owner"
	ValueUserRoleReader    = "reader"
	ValueUserRoleWriter    = "writer"
	ValueVisibilityCreator = "creator"
	ValueVisibilityExpert  = "expert"
	ValueVisibilityLogin   = "login"
	ValueVisibilityOwner   = "owner"
	ValueVisibilityPublic  = "public"
)

Predefined Metadata values

View Source
const (
	MethodMove = "MOVE" // HTTP method for renaming a zettel

	HeaderAccept      = "Accept"
	HeaderContentType = "Content-Type"
	HeaderDestination = "Destination"
	HeaderLocation    = "Location"
)

Additional HTTP constants.

View Source
const (
	QueryKeyCommand   = "cmd"
	QueryKeyEncoding  = "enc"
	QueryKeyParseOnly = "parseonly"
	QueryKeyPart      = "part"
	QueryKeyPhrase    = "phrase"
	QueryKeyQuery     = "q"
	QueryKeyRole      = "role"
	QueryKeySeed      = "_seed"
	QueryKeyTag       = "tag"
)

Values for HTTP query parameter.

View Source
const (
	EncodingHTML  = "html"
	EncodingMD    = "md"
	EncodingSHTML = "shtml"
	EncodingSz    = "sz"
	EncodingText  = "text"
	EncodingZMK   = "zmk"

	EncodingPlain = "plain"
	EncodingData  = "data"
)

Supported encoding values.

View Source
const (
	PartMeta    = "meta"
	PartContent = "content"
	PartZettel  = "zettel"
)

Supported part values.

View Source
const (
	CommandAuthenticated = Command("authenticated")
	CommandRefresh       = Command("refresh")
)

Supported command values

View Source
const (
	BackwardDirective = "BACKWARD"
	ContextDirective  = "CONTEXT"
	CostDirective     = "COST"
	ForwardDirective  = "FORWARD"
	FullDirective     = "FULL"
	IdentDirective    = "IDENT"
	ItemsDirective    = "ITEMS"
	MaxDirective      = "MAX"
	LimitDirective    = "LIMIT"
	OffsetDirective   = "OFFSET"
	OrDirective       = "OR"
	OrderDirective    = "ORDER"
	PhraseDirective   = "PHRASE"
	PickDirective     = "PICK"
	RandomDirective   = "RANDOM"
	ReverseDirective  = "REVERSE"
	UnlinkedDirective = "UNLINKED"

	ActionSeparator = "|"

	AtomAction     = "ATOM"
	KeysAction     = "KEYS"
	MinAction      = "MIN"
	MaxAction      = "MAX"
	NumberedAction = "NUMBERED"
	RedirectAction = "REDIRECT"
	ReIndexAction  = "REINDEX"
	RSSAction      = "RSS"
	TitleAction    = "TITLE"

	ExistOperator    = "?"
	ExistNotOperator = "!?"

	SearchOperatorNot        = "!"
	SearchOperatorEqual      = "="
	SearchOperatorNotEqual   = "!="
	SearchOperatorHas        = ":"
	SearchOperatorHasNot     = "!:"
	SearchOperatorPrefix     = "["
	SearchOperatorNoPrefix   = "!["
	SearchOperatorSuffix     = "]"
	SearchOperatorNoSuffix   = "!]"
	SearchOperatorMatch      = "~"
	SearchOperatorNoMatch    = "!~"
	SearchOperatorLess       = "<"
	SearchOperatorNotLess    = "!<"
	SearchOperatorGreater    = ">"
	SearchOperatorNotGreater = "!>"
)

Supported search operator representations

View Source
const InvalidZID = ""

InvalidZID is an invalif zettel identifier

View Source
const LengthZid = len(ZidDefaultHome)

LengthZid factors the constant length of a zettel identifier

View Source
const QueryPrefix = "query:"

QueryPrefix is the prefix that denotes a query expression within a reference.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate map[string][]ZettelID

Aggregate maps metadata keys to list of zettel identifier.

type Command

type Command string

Command to be executed atthe Zettelstore

type EncodingEnum

type EncodingEnum uint8

EncodingEnum lists all valid encoder keys.

const (
	EncoderUnknown EncodingEnum = iota
	EncoderHTML
	EncoderMD
	EncoderSHTML
	EncoderSz
	EncoderText
	EncoderZmk

	EncoderPlain
	EncoderData
)

Values for EncoderEnum

func Encoder

func Encoder(encoding string) EncodingEnum

Encoder returns the internal encoder code for the given encoding string.

func (EncodingEnum) String

func (e EncodingEnum) String() string

String representation of an encoder key.

type MetaRights

type MetaRights struct {
	Meta   ZettelMeta
	Rights ZettelRights
}

MetaRights contains the metadata of a zettel, and its rights.

type URLBuilder

type URLBuilder struct {
	// contains filtered or unexported fields
}

URLBuilder should be used to create zettelstore URLs.

func NewURLBuilder

func NewURLBuilder(prefix string, key byte) *URLBuilder

NewURLBuilder creates a new URL builder with the given prefix and key.

func (*URLBuilder) AppendKVQuery

func (ub *URLBuilder) AppendKVQuery(key, value string) *URLBuilder

AppendKVQuery adds a new key/value query parameter

func (*URLBuilder) AppendPath

func (ub *URLBuilder) AppendPath(p string) *URLBuilder

AppendPath adds a new path element

func (*URLBuilder) AppendQuery

func (ub *URLBuilder) AppendQuery(value string) *URLBuilder

AppendQuery adds a new query

func (*URLBuilder) ClearQuery

func (ub *URLBuilder) ClearQuery() *URLBuilder

ClearQuery removes all query parameters.

func (*URLBuilder) Clone

func (ub *URLBuilder) Clone() *URLBuilder

Clone an URLBuilder

func (*URLBuilder) SetFragment

func (ub *URLBuilder) SetFragment(s string) *URLBuilder

SetFragment stores the fragment

func (*URLBuilder) SetRawLocal

func (ub *URLBuilder) SetRawLocal(rawLocal string) *URLBuilder

SetRawLocal sets everything that follows the prefix / key.

func (*URLBuilder) SetZid

func (ub *URLBuilder) SetZid(zid ZettelID) *URLBuilder

SetZid sets the zettel identifier.

func (*URLBuilder) String

func (ub *URLBuilder) String() string

String produces a string value.

type ZettelData

type ZettelData struct {
	Meta     ZettelMeta
	Rights   ZettelRights
	Encoding string
	Content  string
}

ZettelData contains all data for a zettel.

type ZettelID

type ZettelID string

ZettelID contains the identifier of a zettel. It is a string with 14 digits.

func (ZettelID) IsValid

func (zid ZettelID) IsValid() bool

IsValid returns true, if the idenfifier contains 14 digits.

type ZettelMeta

type ZettelMeta map[string]string

ZettelMeta is a map containg the metadata of a zettel.

type ZettelRights

type ZettelRights uint8

ZettelRights is an integer that encode access rights for a zettel.

const (
	ZettelCanNone   ZettelRights = 1 << iota
	ZettelCanCreate              // Current user is allowed to create a new zettel
	ZettelCanRead                // Requesting user is allowed to read the zettel
	ZettelCanWrite               // Requesting user is allowed to update the zettel
	ZettelCanRename              // Requesting user is allowed to provide the zettel with a new identifier
	ZettelCanDelete              // Requesting user is allowed to delete the zettel
	ZettelMaxRight               // Sentinel value
)

Values for ZettelRights, can be or-ed

type ZidMetaRights

type ZidMetaRights struct {
	ID     ZettelID
	Meta   ZettelMeta
	Rights ZettelRights
}

ZidMetaRights contains the identifier, the metadata of a zettel, and its rights.

Jump to

Keyboard shortcuts

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