-
Notifications
You must be signed in to change notification settings - Fork 0
/
zet.go
83 lines (77 loc) · 3.02 KB
/
zet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Package zet holds the central elements of this application.
//
// It contains three models (see model.go) that make the key concept of this application:
// * Zettel
// * Reference
// * Index
//
// It also holds all interfaces that are
//
// a) driving ports of the application therefore making clear what this application does and
// b) used in more than one package, so that from all other packages the dependencies point only to this package.
package zet
// Importer persists zettel content.
//
// Import takes one or more zettel contents and persists each content.
// In case of an error it returns the number of zettel contents already persisted until the occurrence of the error.
type Importer interface {
Import(path string) (int, error)
}
// Initiator supports starting with this personal knowledge management system.
//
// Init will create an empty zettelkasten.
//
// InitExample will download an example zettelkasten.
type Initiator interface {
Init() error
InitExample() error
}
// Exporter is the instance for accessing all functionality regarding
// entry points into your zettelkasten (so-called "views").
//
// CreateViews will create all access points into your zettelkasten.
type Exporter interface {
Export() error
}
// Validator is the instance for accessing all functionality regarding
// the consistency and health checks for your zettelkasten.
//
// Val returns all inconsistencies of your zettelkasten as the first parameter.
// Inconsistencies can be:
// - dead links
// - double ids
// - missing reference entry
//
// The second return parameter contains a potential error.
type Validator interface {
Val() ([]InconErr, error)
}
// Repo gives access to the content of your zettelkasten.
//
// GetZettel returns Zettel entities and all errors that occurred while fetching the zettel,
// e.g. parsing errors.
// The structure is always the same since the raw filenames get sorted by name before processing so that
// the order of links, etc. is always the same; therefore, the VIEWS structure also stays the same.
//
// GetIndex returns a Index that maps thematic entry topics to one or more ids.
//
// GetBibkeys returns a list of bibkeys representing literature references.
//
// Save takes a map[filename]content of zettel and saves these.
// filename is the name of the file that holds the thought. Content is the text content of your thought.
// In case of success it returns a nil error and the number of zettel persisted.
// In case of a failure, it returns the error and the number of zettel it has written until the error occurred.
type Repo interface {
GetZettel() ([]Zettel, []InconErr, error)
GetIndex() (Index, []InconErr, error)
GetBibkeys() ([]string, error)
Save(content map[string]string) (int, error)
}
// Parser handles all functionality regarding parsing from and
// sometimes to raw data like filenames, literature entries and index entries to zettel.
type Parser interface {
Content(string, []Zettel) (string, error)
Filename(string) (Zettel, error)
Index(content string) (Index, []InconErr)
Reference(d string) []string
}