Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From v0.6.0 To v0.5.0
2022-08-22
| ||
09:31 | Version 0.6.1 ... (check-in: d953a740f6 user: stern tags: release, release-0.6, v0.6.1) | |
2022-08-12
| ||
09:31 | Increase version to 0.7.0-dev to begin next development cycle ... (check-in: 12f09c3193 user: stern tags: trunk) | |
2022-08-11
| ||
17:09 | Version 0.6.0 ... (check-in: d495df0b57 user: stern tags: trunk, release, v0.6.0) | |
17:03 | Upgrade to newest client ... (check-in: 9673c31db1 user: stern tags: trunk) | |
2022-08-02
| ||
08:33 | Create new branch named "release-0.5" ... (check-in: 2ccbcee00f user: stern tags: release-0.5) | |
2022-08-01
| ||
11:47 | Increase version to 0.6.0-dev to begin next development cycle ... (check-in: e61bb9ce88 user: stern tags: trunk) | |
2022-07-29
| ||
14:21 | Version 0.5.0 ... (check-in: 7138adfeb5 user: stern tags: trunk, release, v0.5.0) | |
14:05 | Adapt to new client version ... (check-in: 26b3fdba14 user: stern tags: trunk) | |
Changes to README.md.
︙ | ︙ | |||
19 20 21 22 23 24 25 | often connects to Zettelstore via its API. Some of the software packages may be experimental. The software, including the manual, is licensed under the [European Union Public License 1.2 (or later)](https://zettelstore.de/home/file?name=LICENSE.txt&ci=trunk). | | | 19 20 21 22 23 24 25 26 | often connects to Zettelstore via its API. Some of the software packages may be experimental. The software, including the manual, is licensed under the [European Union Public License 1.2 (or later)](https://zettelstore.de/home/file?name=LICENSE.txt&ci=trunk). [Stay tuned](https://twitter.com/zettelstore)… |
Changes to VERSION.
|
| | | 1 | 0.5.0 |
Changes to ast/ast.go.
︙ | ︙ | |||
80 81 82 83 84 85 86 | RefStateInvalid RefState = iota // Invalid Reference RefStateZettel // Reference to an internal zettel RefStateSelf // Reference to same zettel with a fragment RefStateFound // Reference to an existing internal zettel, URL is ajusted RefStateBroken // Reference to a non-existing internal zettel RefStateHosted // Reference to local hosted non-Zettel, without URL change RefStateBased // Reference to local non-Zettel, to be prefixed | < | 80 81 82 83 84 85 86 87 88 | RefStateInvalid RefState = iota // Invalid Reference RefStateZettel // Reference to an internal zettel RefStateSelf // Reference to same zettel with a fragment RefStateFound // Reference to an existing internal zettel, URL is ajusted RefStateBroken // Reference to a non-existing internal zettel RefStateHosted // Reference to local hosted non-Zettel, without URL change RefStateBased // Reference to local non-Zettel, to be prefixed RefStateExternal // Reference to external material ) |
Changes to ast/ref.go.
︙ | ︙ | |||
8 9 10 11 12 13 14 | // under this license. //----------------------------------------------------------------------------- package ast import ( "net/url" | < < < < > | < < < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | // under this license. //----------------------------------------------------------------------------- package ast import ( "net/url" "zettelstore.de/z/domain/id" ) // ParseReference parses a string and returns a reference. func ParseReference(s string) *Reference { switch s { case "", "00000000000000": return &Reference{URL: nil, Value: s, State: RefStateInvalid} } if state, ok := localState(s); ok { if state == RefStateBased { s = s[1:] } u, err := url.Parse(s) if err == nil { return &Reference{URL: u, Value: s, State: state} |
︙ | ︙ | |||
69 70 71 72 73 74 75 | } // String returns the string representation of a reference. func (r Reference) String() string { if r.URL != nil { return r.URL.String() } | < < < | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | } // String returns the string representation of a reference. func (r Reference) String() string { if r.URL != nil { return r.URL.String() } return r.Value } // IsValid returns true if reference is valid func (r *Reference) IsValid() bool { return r.State != RefStateInvalid } // IsZettel returns true if it is a referencen to a local zettel. |
︙ | ︙ |
Changes to box/box.go.
︙ | ︙ | |||
246 247 248 249 250 251 252 | } func (err *ErrNotAllowed) Error() string { if err.User == nil { if err.Zid.IsValid() { return fmt.Sprintf( "operation %q on zettel %v not allowed for not authorized user", | | > > > | > > | > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | } func (err *ErrNotAllowed) Error() string { if err.User == nil { if err.Zid.IsValid() { return fmt.Sprintf( "operation %q on zettel %v not allowed for not authorized user", err.Op, err.Zid.String()) } return fmt.Sprintf("operation %q not allowed for not authorized user", err.Op) } if err.Zid.IsValid() { return fmt.Sprintf( "operation %q on zettel %v not allowed for user %v/%v", err.Op, err.Zid.String(), err.User.GetDefault(api.KeyUserID, "?"), err.User.Zid.String()) } return fmt.Sprintf( "operation %q not allowed for user %v/%v", err.Op, err.User.GetDefault(api.KeyUserID, "?"), err.User.Zid.String()) } // Is return true, if the error is of type ErrNotAllowed. func (*ErrNotAllowed) Is(error) bool { return true } // ErrStarted is returned when trying to start an already started box. var ErrStarted = errors.New("box is already started") |
︙ | ︙ |
Changes to box/constbox/base.css.
︙ | ︙ | |||
99 100 101 102 103 104 105 | blockquote p { margin-bottom: .5rem } blockquote cite { font-style: normal } table { border-collapse: collapse; border-spacing: 0; max-width: 100%; } | < < | < > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | blockquote p { margin-bottom: .5rem } blockquote cite { font-style: normal } table { border-collapse: collapse; border-spacing: 0; max-width: 100%; } th,td { text-align: left; padding: .25rem .5rem; } td { border-bottom: 1px solid hsl(0, 0%, 85%) } thead th { border-bottom: 2px solid hsl(0, 0%, 70%) } tfoot th { border-top: 2px solid hsl(0, 0%, 70%) } main form { padding: 0 .5em; margin: .5em 0 0 0; } main form:after { content: "."; display: block; |
︙ | ︙ | |||
195 196 197 198 199 200 201 | padding: .5rem 1rem; } .zs-error { background-color: lightpink; border-style: none !important; font-weight: bold; } | | | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | padding: .5rem 1rem; } .zs-error { background-color: lightpink; border-style: none !important; font-weight: bold; } td.left,th.left { text-align:left } td.center,th.center { text-align:center } td.right,th.right { text-align:right } .zs-font-size-0 { font-size:75% } .zs-font-size-1 { font-size:83% } .zs-font-size-2 { font-size:100% } .zs-font-size-3 { font-size:117% } .zs-font-size-4 { font-size:150% } .zs-font-size-5 { font-size:200% } .zs-deprecated { border-style: dashed; padding: .2rem } |
︙ | ︙ |
Changes to box/constbox/info.mustache.
︙ | ︙ | |||
17 18 19 20 21 22 23 | <ul> {{#LocLinks}} {{#Valid}}<li><a href="{{{Zid}}}">{{Zid}}</a></li>{{/Valid}} {{^Valid}}<li>{{Zid}}</li>{{/Valid}} {{/LocLinks}} </ul> {{/HasLocLinks}} | < < < < < < < < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <ul> {{#LocLinks}} {{#Valid}}<li><a href="{{{Zid}}}">{{Zid}}</a></li>{{/Valid}} {{^Valid}}<li>{{Zid}}</li>{{/Valid}} {{/LocLinks}} </ul> {{/HasLocLinks}} {{#HasExtLinks}} <h3>External</h3> <ul> {{#ExtLinks}} <li><a href="{{{.}}}"{{{ExtNewWindow}}}>{{.}}</a></li> {{/ExtLinks}} </ul> |
︙ | ︙ |
Changes to box/constbox/listzettel.mustache.
1 2 3 | <header> <h1>{{Title}}</h1> </header> | < < < | 1 2 3 4 5 6 | <header> <h1>{{Title}}</h1> </header> <ul> {{#Metas}}<li><a href="{{{URL}}}">{{{Text}}}</a></li> {{/Metas}}</ul> |
Changes to cmd/cmd_run.go.
︙ | ︙ | |||
61 62 63 64 65 66 67 68 | ucAuthenticate := usecase.NewAuthenticate(authLog, authManager, authManager, boxManager) ucIsAuth := usecase.NewIsAuthenticated(ucLog, webSrv, authManager) ucCreateZettel := usecase.NewCreateZettel(ucLog, rtConfig, protectedBoxManager) ucGetMeta := usecase.NewGetMeta(protectedBoxManager) ucGetAllMeta := usecase.NewGetAllMeta(protectedBoxManager) ucGetZettel := usecase.NewGetZettel(protectedBoxManager) ucParseZettel := usecase.NewParseZettel(rtConfig, ucGetZettel) ucListMeta := usecase.NewListMeta(protectedBoxManager) | > < | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ucAuthenticate := usecase.NewAuthenticate(authLog, authManager, authManager, boxManager) ucIsAuth := usecase.NewIsAuthenticated(ucLog, webSrv, authManager) ucCreateZettel := usecase.NewCreateZettel(ucLog, rtConfig, protectedBoxManager) ucGetMeta := usecase.NewGetMeta(protectedBoxManager) ucGetAllMeta := usecase.NewGetAllMeta(protectedBoxManager) ucGetZettel := usecase.NewGetZettel(protectedBoxManager) ucParseZettel := usecase.NewParseZettel(rtConfig, ucGetZettel) ucEvaluate := usecase.NewEvaluate(rtConfig, ucGetZettel, ucGetMeta) ucListMeta := usecase.NewListMeta(protectedBoxManager) ucListSyntax := usecase.NewListSyntax(protectedBoxManager) ucListRoles := usecase.NewListRoles(protectedBoxManager) ucListTags := usecase.NewListTags(protectedBoxManager) ucZettelContext := usecase.NewZettelContext(protectedBoxManager, rtConfig) ucDelete := usecase.NewDeleteZettel(ucLog, protectedBoxManager) ucUpdate := usecase.NewUpdateZettel(ucLog, protectedBoxManager) ucRename := usecase.NewRenameZettel(ucLog, protectedBoxManager) |
︙ | ︙ |
Added cmd/fd_limit.go.
> > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //----------------------------------------------------------------------------- // Copyright (c) 2021 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- //go:build !darwin // +build !darwin package cmd func raiseFdLimit() error { return nil } |
Added cmd/fd_limit_raise.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 | //----------------------------------------------------------------------------- // Copyright (c) 2021 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- //go:build darwin // +build darwin package cmd import ( "fmt" "syscall" "zettelstore.de/z/kernel" ) const minFiles = 1048576 func raiseFdLimit() error { var rLimit syscall.Rlimit err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err != nil { return err } if rLimit.Cur >= minFiles { return nil } rLimit.Cur = minFiles if rLimit.Cur > rLimit.Max { rLimit.Cur = rLimit.Max } err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err != nil { return err } err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err != nil { return err } if rLimit.Cur < minFiles { msg := fmt.Sprintf("Make sure you have no more than %d files in all your boxes if you enabled notification\n", rLimit.Cur) kernel.Main.GetKernelLogger().Mandatory().Msg(msg) } return nil } |
Changes to cmd/main.go.
︙ | ︙ | |||
204 205 206 207 208 209 210 211 | ok = setConfigValue(ok, kernel.AuthService, kernel.AuthOwner, cfg.GetDefault(keyOwner, "")) ok = setConfigValue(ok, kernel.AuthService, kernel.AuthReadonly, cfg.GetBool(keyReadOnly)) ok = setConfigValue( ok, kernel.BoxService, kernel.BoxDefaultDirType, cfg.GetDefault(keyDefaultDirBoxType, kernel.BoxDirTypeNotify)) ok = setConfigValue(ok, kernel.BoxService, kernel.BoxURIs+"1", "dir:./zettel") for i := 1; ; i++ { | > | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | ok = setConfigValue(ok, kernel.AuthService, kernel.AuthOwner, cfg.GetDefault(keyOwner, "")) ok = setConfigValue(ok, kernel.AuthService, kernel.AuthReadonly, cfg.GetBool(keyReadOnly)) ok = setConfigValue( ok, kernel.BoxService, kernel.BoxDefaultDirType, cfg.GetDefault(keyDefaultDirBoxType, kernel.BoxDirTypeNotify)) ok = setConfigValue(ok, kernel.BoxService, kernel.BoxURIs+"1", "dir:./zettel") format := kernel.BoxURIs + "%v" for i := 1; ; i++ { key := fmt.Sprintf(format, i) val, found := cfg.Get(key) if !found { break } ok = setConfigValue(ok, kernel.BoxService, key, val) } |
︙ | ︙ | |||
261 262 263 264 265 266 267 268 269 270 271 272 273 274 | fmt.Fprintf(os.Stderr, "%s: %v\n", name, err) return 2 } kern := kernel.Main var createManager kernel.CreateBoxManagerFunc if command.Boxes { createManager = func(boxURIs []*url.URL, authManager auth.Manager, rtConfig config.Config) (box.Manager, error) { compbox.Setup(cfg) return manager.New(boxURIs, authManager, rtConfig) } } else { createManager = func([]*url.URL, auth.Manager, config.Config) (box.Manager, error) { return nil, nil } } | > > > > > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | fmt.Fprintf(os.Stderr, "%s: %v\n", name, err) return 2 } kern := kernel.Main var createManager kernel.CreateBoxManagerFunc if command.Boxes { err := raiseFdLimit() if err != nil { logger := kern.GetKernelLogger() logger.IfErr(err).Msg("Raising some limitions did not work") logger.Error().Msg("Prepare to encounter errors. Most of them can be mitigated. See the manual for details") kern.SetConfig(kernel.BoxService, kernel.BoxDefaultDirType, kernel.BoxDirTypeSimple) } createManager = func(boxURIs []*url.URL, authManager auth.Manager, rtConfig config.Config) (box.Manager, error) { compbox.Setup(cfg) return manager.New(boxURIs, authManager, rtConfig) } } else { createManager = func([]*url.URL, auth.Manager, config.Config) (box.Manager, error) { return nil, nil } } |
︙ | ︙ | |||
299 300 301 302 303 304 305 | fmt.Fprintf(os.Stderr, "%s: %v\n", name, err) } kern.Shutdown(true) return exitCode } // runSimple is called, when the user just starts the software via a double click | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | fmt.Fprintf(os.Stderr, "%s: %v\n", name, err) } kern.Shutdown(true) return exitCode } // runSimple is called, when the user just starts the software via a double click // or via a simple call ``./zettelstore`` on the command line. func runSimple() int { if _, err := searchAndReadConfiguration(); err == nil { return executeCommand(strRunSimple) } dir := "./zettel" if err := os.MkdirAll(dir, 0750); err != nil { fmt.Fprintf(os.Stderr, "Unable to create zettel directory %q (%s)\n", dir, err) |
︙ | ︙ |
Changes to docs/development/20210916194900.zettel.
1 2 3 4 5 6 7 8 | id: 20210916194900 title: Checklist for Release role: zettel syntax: zmk modified: 20220309105459 # Sync with the official repository #* ``fossil sync -u`` | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | id: 20210916194900 title: Checklist for Release role: zettel syntax: zmk modified: 20220309105459 # Sync with the official repository #* ``fossil sync -u`` # Make sure that all dependencies are up-to-date. #* ``cat go.mod`` # Clean up your Go workspace: #* ``go run tools/build.go clean`` (alternatively: ``make clean``). # All internal tests must succeed: #* ``go run tools/build.go relcheck`` (alternatively: ``make relcheck``). # The API tests must succeed on every development platform: |
︙ | ︙ | |||
30 31 32 33 34 35 36 | # On every platform (esp. macOS), the box with 10.000 zettel must run properly: #* ``./zettelstore -d DIR`` # Update files in directory ''www'' #* index.wiki #* download.wiki #* changes.wiki #* plan.wiki | | < | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # On every platform (esp. macOS), the box with 10.000 zettel must run properly: #* ``./zettelstore -d DIR`` # Update files in directory ''www'' #* index.wiki #* download.wiki #* changes.wiki #* plan.wiki # Set file ''VERSION'' to the new release version # Disable Fossil autosync mode: #* ``fossil setting autosync off`` # Commit the new release version: #* ``fossil commit --tag release --tag vVERSION -m "Version VERSION"`` #* **Important:** the tag must follow the given pattern, e.g. ''v0.0.15''. Otherwise client will not be able to import ''zettelkasten.de/z''. # Clean up your Go workspace: |
︙ | ︙ |
Changes to docs/manual/00001000000000.zettel.
1 2 3 4 5 | id: 00001000000000 title: Zettelstore Manual role: manual tags: #manual #zettelstore syntax: zmk | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | id: 00001000000000 title: Zettelstore Manual role: manual tags: #manual #zettelstore syntax: zmk modified: 20211027121716 * [[Introduction|00001001000000]] * [[Design goals|00001002000000]] * [[Installation|00001003000000]] * [[Configuration|00001004000000]] * [[Structure of Zettelstore|00001005000000]] * [[Layout of a zettel|00001006000000]] * [[Zettelmarkup|00001007000000]] * [[Other markup languages|00001008000000]] * [[Security|00001010000000]] * [[API|00001012000000]] * [[Web user interface|00001014000000]] * [[Troubleshooting|00001018000000]] * Frequently asked questions Licensed under the EUPL-1.2-or-later. |
Changes to docs/manual/00001004050000.zettel.
1 2 3 4 5 | id: 00001004050000 title: Command line parameters role: manual tags: #command #configuration #manual #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001004050000 title: Command line parameters role: manual tags: #command #configuration #manual #zettelstore syntax: zmk modified: 20211124141554 Zettelstore is not just a service that provides services of a zettelkasten. It allows to some tasks to be executed at the command line. Typically, the task (""sub-command"") will be given at the command line as the first parameter. If no parameter is given, the Zettelstore is called as ``` |
︙ | ︙ | |||
22 23 24 25 26 27 28 | === Sub-commands * [[``zettelstore help``|00001004050200]] lists all available sub-commands. * [[``zettelstore version``|00001004050400]] to display version information of Zettelstore. * [[``zettelstore run``|00001004051000]] to start the Zettelstore service. * [[``zettelstore run-simple``|00001004051100]] is typically called, when you start Zettelstore by a double.click in your GUI. * [[``zettelstore file``|00001004051200]] to render files manually without activated/running Zettelstore services. * [[``zettelstore password``|00001004051400]] to calculate data for [[user authentication|00001010040200]]. | < < | 22 23 24 25 26 27 28 | === Sub-commands * [[``zettelstore help``|00001004050200]] lists all available sub-commands. * [[``zettelstore version``|00001004050400]] to display version information of Zettelstore. * [[``zettelstore run``|00001004051000]] to start the Zettelstore service. * [[``zettelstore run-simple``|00001004051100]] is typically called, when you start Zettelstore by a double.click in your GUI. * [[``zettelstore file``|00001004051200]] to render files manually without activated/running Zettelstore services. * [[``zettelstore password``|00001004051400]] to calculate data for [[user authentication|00001010040200]]. |
Changes to docs/manual/00001006020000.zettel.
1 2 3 4 5 | id: 00001006020000 title: Supported Metadata Keys role: manual tags: #manual #meta #reference #zettel #zettelstore syntax: zmk | | | < < | 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 | id: 00001006020000 title: Supported Metadata Keys role: manual tags: #manual #meta #reference #zettel #zettelstore syntax: zmk modified: 20220628111132 Although you are free to define your own metadata, by using any key (according to the [[syntax|00001006010000]]), some keys have a special meaning that is enforced by Zettelstore. See the [[computed list of supported metadata keys|00000000000090]] for details. Most keys conform to a [[type|00001006030000]]. ; [!all-tags|''all-tags''] : A property (a computed values that is not stored) that contains both the value of [[''tags''|#tags]] together with all [[tags|00001007040000#tag]] that are specified within the content. ; [!back|''back''] : Is a property that contains the identifier of all zettel that reference the zettel of this metadata, that are not referenced by this zettel. Basically, it is the value of [[''backward''|#backward]], but without any zettel identifier that is contained in [[''forward''|#forward]]. ; [!backward|''backward''] : Is a property that contains the identifier of all zettel that reference the zettel of this metadata. References within invertible values are not included here, e.g. [[''precursor''|#precursor]]. ; [!box-number|''box-number''] : Is a computed value and contains the number of the box where the zettel was found. For all but the [[predefined zettel|00001005090000]], this number is equal to the number __X__ specified in startup configuration key [[''box-uri-__X__''|00001004010000#box-uri-x]]. ; [!copyright|''copyright''] : Defines a copyright string that will be encoded. If not given, the value ''default-copyright'' from the [[configuration zettel|00001004020000#default-copyright]] will be used. ; [!credential|''credential''] : Contains the hashed password, as it was emitted by [[``zettelstore password``|00001004051400]]. It is internally created by hashing the password, the [[zettel identifier|00001006050000]], and the value of the ''ident'' key. |
︙ | ︙ |
Changes to docs/manual/00001007000000.zettel.
1 2 3 4 5 | id: 00001007000000 title: Zettelmarkup role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001007000000 title: Zettelmarkup role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk modified: 20220113185501 Zettelmarkup is a rich plain-text based markup language for writing zettel content. Besides the zettel content, Zettelmarkup is also used for specifying the title of a zettel, regardless of the syntax of a zettel. Zettelmarkup supports the longevity of stored notes by providing a syntax that any person can easily read, as well as a computer. Zettelmarkup can be much easier parsed / consumed by a software compared to other markup languages. Writing a parser for [[Markdown|https://daringfireball.net/projects/markdown/syntax]] is quite challenging. |
︙ | ︙ | |||
30 31 32 33 34 35 36 | However, the Zettelstore supports CommonMark as a zettel syntax, so you can mix both Zettelmarkup zettel and CommonMark zettel in one store to get the best of both worlds. * [[General principles|00001007010000]] * [[Basic definitions|00001007020000]] * [[Block-structured elements|00001007030000]] * [[Inline-structured element|00001007040000]] * [[Attributes|00001007050000]] | < | < | 30 31 32 33 34 35 36 37 | However, the Zettelstore supports CommonMark as a zettel syntax, so you can mix both Zettelmarkup zettel and CommonMark zettel in one store to get the best of both worlds. * [[General principles|00001007010000]] * [[Basic definitions|00001007020000]] * [[Block-structured elements|00001007030000]] * [[Inline-structured element|00001007040000]] * [[Attributes|00001007050000]] * [[Summary of formatting characters|00001007060000]] |
Changes to docs/manual/00001007031100.zettel.
1 2 3 4 5 | id: 00001007031100 title: Zettelmarkup: Transclusion role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk | | | | > | > > | > > | > | > > > > | > > > > | > | > | | 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 | id: 00001007031100 title: Zettelmarkup: Transclusion role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk modified: 20220218133058 A transclusion allows to include the content of another zettel into the current zettel just by referencing the other zettel. The transclusion specification begins with three consecutive left curly bracket characters (""''{''"", U+007B) at the first position of a line and ends with three consecutive right curly bracket characters (""''}''"", U+007D). The curly brackets delimit the [[zettel identifier|00001006050000]] to be included. First, the referenced zettel is read. If it contains some transclusions itself, these will be expanded, recursively. When a recursion is detected, expansion does not take place. Instead an error message replaces the transclude specification. An error message is also given, if the zettel cannot be read or if too many transclusions are made. The maximum number of transclusion can be controlled by setting the value [[''max-transclusions''|00001004020000#max-transclusions]] of the runtime configuration zettel. If everything went well, the referenced, expanded zettel will replace the transclusion element. For example, to include the text of the Zettel titled ""Zettel identifier"", just specify its identifier [[''00001006050000''|00001006050000]] in the transclude element: ```zmk {{{00001006050000}}} ``` This will result in: :::example {{{00001006050000}}} ::: Please note: if the referenced zettel is changed, all transclusions will also change. This allows, for example, to create a bigger document just by transcluding smaller zettel. === See also [[Inline-mode transclusion|00001007040324]] does not work at the paragraph / block level, but is used for [[inline-structured elements|00001007040000]]. |
Deleted docs/manual/00001007031110.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007031140.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to docs/manual/00001007040000.zettel.
1 2 3 4 5 | id: 00001007040000 title: Zettelmarkup: Inline-Structured Elements role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001007040000 title: Zettelmarkup: Inline-Structured Elements role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk modified: 20220218131736 Most characters you type is concerned with inline-structured elements. The content of a zettel contains is many cases just ordinary text, lightly formatted. Inline-structured elements allow to format your text and add some helpful links or images. Sometimes, you want to enter characters that have no representation on your keyboard. ; Text formatting |
︙ | ︙ | |||
59 60 61 62 63 64 65 | Since some Unicode character are used quite often, a special notation is introduced for them: * Two consecutive hyphen-minus characters result in an __en-dash__ character. It is typically used in numeric ranges. ``pages 4--7`` will be rendered in HTML as: ::pages 4--7::{=example}. Alternative specifications are: ``–``, ``&x8211``, and ``–``. | > > > | 59 60 61 62 63 64 65 66 67 68 | Since some Unicode character are used quite often, a special notation is introduced for them: * Two consecutive hyphen-minus characters result in an __en-dash__ character. It is typically used in numeric ranges. ``pages 4--7`` will be rendered in HTML as: ::pages 4--7::{=example}. Alternative specifications are: ``–``, ``&x8211``, and ``–``. * Three consecutive full stop characters (""''.''"", U+002E) after a space result in an horizontal ellipsis character. ``to be continued ... later`` will be rendered in HTML as: ::to be continued, ... later::{=example}. Alternative specifications are: ``…``, ``&x8230``, and ``…``. |
Changes to docs/manual/00001007040310.zettel.
1 2 3 4 5 | id: 00001007040310 title: Zettelmarkup: Links role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk | | < < < < < < | < < < | | < | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | id: 00001007040310 title: Zettelmarkup: Links role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk modified: 20220218131639 There are two kinds of links, regardless of links to (internal) other zettel or to (external) material. Both kinds begin with two consecutive left square bracket characters (""''[''"", U+005B) and ends with two consecutive right square bracket characters (""'']''"", U+005D). The first form provides some text plus the link specification, delimited by a vertical bar character (""''|''"", U+007C): ``[[text|linkspecification]]``. The second form just provides a link specification between the square brackets. Its text is derived from the link specification, e.g. by interpreting the link specification as text: ``[[linkspecification]]``. The link specification for another zettel within the same Zettelstore is just the [[zettel identifier|00001006050000]]. To reference some content within a zettel, you can append a number sign character (""''#''"", U+0023) and the name of the mark to the zettel identifier. The resulting reference is called ""zettel reference"". To specify some material outside the Zettelstore, just use an normal Uniform Resource Identifier (URI) as defined by [[RFC\ 3986|https://tools.ietf.org/html/rfc3986]]. If the URL begins with the slash character (""/"", U+002F), or if it begins with ""./"" or with ""../"", i.e. without scheme, user info, and host name, the reference will be treated as a ""local reference"", otherwise as an ""external reference"". If the URL begins with two slash characters, it will be interpreted relative to the value of [[''url-prefix''|00001004010000#url-prefix]]. The text in the second form is just a sequence of [[inline elements|00001007040000]]. |
Changes to docs/manual/00001007040320.zettel.
1 2 3 4 5 | id: 00001007040320 title: Zettelmarkup: Inline Embedding / Transclusion role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk | | < | | 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 | id: 00001007040320 title: Zettelmarkup: Inline Embedding / Transclusion role: manual tags: #manual #zettelmarkup #zettelstore syntax: zmk modified: 20220218133039 To some degree, an specification for embedded material is conceptually not too far away from a specification for [[linked material|00001007040310]]. Both contain a reference specification and optionally some text. In contrast to a link, the specification of embedded material must currently resolve to some kind of real content. This content replaces the embed specification. An embed specification begins with two consecutive left curly bracket characters (""''{''"", U+007B) and ends with two consecutive right curly bracket characters (""''}''"", U+007D). The curly brackets delimits either a reference specification or some text, a vertical bar character and the link specification, similar to a link. One difference to a link: if the text was not given, an empty string is assumed. The reference must point to some content, either zettel content or URL-referenced content. If the referenced zettel does not exist, or is not readable, a [[spinning emoji|00000000040001]] is presented as a visual hint: Example: ``{{00000000000000}}`` will be rendered as ::{{00000000000000}}::{=example}. There are two kind of content: # [[image content|00001007040322]], # [[textual content|00001007040324]]. |
Added docs/manual/00001007060000.zettel.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | id: 00001007060000 title: Zettelmarkup: Summary of Formatting Characters role: manual tags: #manual #reference #zettelmarkup #zettelstore syntax: zmk modified: 20220311120759 The following table gives an overview about the use of all characters that begin a markup element. |= Character :|= [[Blocks|00001007030000]] <|= [[Inlines|00001007040000]] < | ''!'' | (free) | (free) | ''"'' | [[Verse block|00001007030700]] | [[Short inline quote|00001007040100]] | ''#'' | [[Ordered list|00001007030200]] | [[Tag|00001007040000]] | ''$'' | (reserved) | (reserved) | ''%'' | [[Comment block|00001007030900]] | [[Comment|00001007040000]] | ''&'' | (free) | [[Entity|00001007040000]] | ''\''' | (free) | [[Computer input|00001007040200]] | ''('' | (free) | (free) | '')'' | (free) | (free) | ''*'' | [[Unordered list|00001007030200]] | [[strongly emphasized text|00001007040100]] | ''+'' | (free) | (free) | '','' | (free) | [[Sub-scripted text|00001007040100]] | ''-'' | [[Horizontal rule|00001007030400]] | ""[[en-dash|00001007040000]]"" | ''.'' | (free) | [[Horizontal ellipsis|00001007040000]] | ''/'' | (free) | (free) | '':'' | [[Region block|00001007030800]] / [[description text|00001007030100]] | [[Inline region|00001007040100]] | '';'' | [[Description term|00001007030100]] | [[Small text|00001007040100]] | ''<'' | [[Quotation block|00001007030600]] | (free) | ''='' | [[Headings|00001007030300]] | [[Computer output|00001007040200]] | ''>'' | [[Quotation lists|00001007030200]] | [[Inserted text|00001007040100]] | ''?'' | (free) | (free) | ''@'' | [[Inline-Zettel block|00001007031200]] | [[Inline-zettel snippet|00001007040200#inline-zettel-snippet]] | ''['' | (reserved) | [[Linked material|00001007040300]], [[citation key|00001007040300]], [[footnote|00001007040300]], [[mark|00001007040300]] | ''\\'' | (blocked by inline meaning) | [[Escape character|00001007040000]] | '']'' | (reserved) | End of [[link|00001007040300]], [[citation key|00001007040300]], [[footnote|00001007040300]], [[mark|00001007040300]] | ''^'' | (free) | [[Super-scripted text|00001007040100]] | ''_'' | (free) | [[Emphasized text|00001007040100]] | ''`'' | [[Verbatim block|00001007030500]] | [[Literal text|00001007040200]] | ''{'' | [[Transclusion|00001007031100]] | [[Embedded material|00001007040300]], [[Attribute|00001007050000]] | ''|'' | [[Table row / table cell|00001007031000]] | Separator within link and [[embed|00001007040320]] formatting | ''}'' | End of [[Transclusion|00001007031100]] | End of embedded material, End of Attribute | ''~'' | [[Evaluation block|00001007031300]] | [[Deleted text|00001007040100]] |
Deleted docs/manual/00001007700000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007702000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007705000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007706000.zettel.
|
| < < < < < < < < < < |
Deleted docs/manual/00001007780000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007790000.zettel.
|
| < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007800000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007900000.zettel.
|
| < < < < < < < < < |
Deleted docs/manual/00001007903000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted docs/manual/00001007906000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to docs/manual/00001010070200.zettel.
1 2 3 4 5 | id: 00001010070200 title: Visibility rules for zettel role: manual tags: #authorization #configuration #manual #security #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001010070200 title: Visibility rules for zettel role: manual tags: #authorization #configuration #manual #security #zettelstore syntax: zmk modified: 20220304114501 For every zettel you can specify under which condition the zettel is visible to others. This is controlled with the metadata key [[''visibility''|00001006020000#visibility]]. The following values are supported: ; [!public|""public""] : The zettel is visible to everybody, even if the user is not authenticated. |
︙ | ︙ | |||
38 39 40 41 42 43 44 | In this case, the [[runtime configuration zettel|00001004020000]] is shown (its visibility is ""owner""). The [[startup configuration|00001004010000]] is not shown, because the associated computed zettel with identifier ''00000000000096'' is stored with the visibility ""expert"". If you want to show such a zettel, you must set ''expert-mode'' to true. === Examples Similar to the [[API|00001012051810]], you can easily create a zettel list based on the ''visibility'' metadata key: | | | | | | | 38 39 40 41 42 43 44 45 46 47 48 49 | In this case, the [[runtime configuration zettel|00001004020000]] is shown (its visibility is ""owner""). The [[startup configuration|00001004010000]] is not shown, because the associated computed zettel with identifier ''00000000000096'' is stored with the visibility ""expert"". If you want to show such a zettel, you must set ''expert-mode'' to true. === Examples Similar to the [[API|00001012051810]], you can easily create a zettel list based on the ''visibility'' metadata key: | public | [[//h?visibility=public]] | login | [[//h?visibility=login]] | creator | [[//h?visibility=creator]] | owner | [[//h?visibility=owner]] | expert | [[//h?visibility=expert]][^Only if [[''expert-mode''|00001004020000#expert-mode]] is enabled, this list will show some zettel.] |
Changes to docs/manual/00001012000000.zettel.
1 2 3 4 5 | id: 00001012000000 title: API role: manual tags: #api #manual #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012000000 title: API role: manual tags: #api #manual #zettelstore syntax: zmk modified: 20220627183444 The API (short for ""**A**pplication **P**rogramming **I**nterface"") is the primary way to communicate with a running Zettelstore. Most integration with other systems and services is done through the API. The [[web user interface|00001014000000]] is just an alternative, secondary way of interacting with a Zettelstore. === Background The API is HTTP-based and uses plain text and JSON as its main encoding format for exchanging messages between a Zettelstore and its client software. |
︙ | ︙ | |||
21 22 23 24 25 26 27 | * [[Provide an access token|00001012050600]] when doing an API call === Zettel lists * [[List metadata of all zettel|00001012051200]] * [[Shape the list of zettel metadata|00001012051800]] ** [[Selection of zettel|00001012051810]] ** [[Limit the list length|00001012051830]] | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | * [[Provide an access token|00001012050600]] when doing an API call === Zettel lists * [[List metadata of all zettel|00001012051200]] * [[Shape the list of zettel metadata|00001012051800]] ** [[Selection of zettel|00001012051810]] ** [[Limit the list length|00001012051830]] ** [[Content search|00001012051840]] ** [[Sort the list of zettel metadata|00001012052000]] * [[Map metadata values to lists of zettel identifier|00001012052400]] === Working with zettel * [[Create a new zettel|00001012053200]] * [[Retrieve metadata and content of an existing zettel|00001012053300]] * [[Retrieve metadata of an existing zettel|00001012053400]] |
︙ | ︙ |
Changes to docs/manual/00001012051800.zettel.
1 2 3 4 5 | id: 00001012051800 title: API: Shape the list of zettel metadata role: manual tags: #api #manual #zettelstore syntax: zmk | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | id: 00001012051800 title: API: Shape the list of zettel metadata role: manual tags: #api #manual #zettelstore syntax: zmk modified: 20211103162259 In most cases, it is not essential to list __all__ zettel. Typically, you are interested only in a subset of the zettel maintained by your Zettelstore. This is done by adding some query parameters to the general ''GET /j'' request. * [[Select|00001012051810]] just some zettel, based on metadata. * Only a specific amount of zettel will be selected by specifying [[a length and/or an offset|00001012051830]]. * [[Searching for specific content|00001012051840]], not just the metadata, is another way of selecting some zettel. * The resulting list can be [[sorted|00001012052000]] according to various criteria. |
Changes to docs/manual/00001012051810.zettel.
1 2 3 4 5 | id: 00001012051810 title: API: Select zettel based on their metadata role: manual tags: #api #manual #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012051810 title: API: Select zettel based on their metadata role: manual tags: #api #manual #zettelstore syntax: zmk modified: 20220218133305 Every query parameter that does __not__ begin with the low line character (""_"", U+005F) is treated as the name of a [[metadata|00001006010000]] key. According to the [[type|00001006030000]] of a metadata key, zettel are possibly selected. All [[supported|00001006020000]] metadata keys have a well-defined type. User-defined keys have the type ''e'' (string, possibly empty). For example, if you want to retrieve all zettel that contain the string ""API"" in its title, your request will be: |
︙ | ︙ | |||
49 50 51 52 53 54 55 | ```sh # curl 'http://127.0.0.1:23123/z?title=API' 00001012921000 API: JSON structure of an access token 00001012920500 Formats available by the API 00001012920000 Endpoints used by the API ... ``` | < < < | 49 50 51 52 53 54 55 | ```sh # curl 'http://127.0.0.1:23123/z?title=API' 00001012921000 API: JSON structure of an access token 00001012920500 Formats available by the API 00001012920000 Endpoints used by the API ... ``` |
Changes to docs/manual/00001012051840.zettel.
1 | id: 00001012051840 | | | | > > | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | id: 00001012051840 title: API: Shape the list of zettel metadata by searching the content role: manual tags: #api #manual #zettelstore syntax: zmk modified: 20211124182444 The query parameter ""''_s''"" allows to provide a string for a full-text search of all zettel. The search string will be normalized according to Unicode NKFD, ignoring everything except letters and numbers. If you want to search in a specific way, you must apply the [[simple search syntax|00001012051890]]. Otherwise, the content of each zettel is examined to just contain the words of the search string. You are allowed to specify this query parameter more than once. All results will be intersected, i.e. a zettel will be included into the list if all of the provided values match. This parameter loosely resembles the search form of the [[web user interface|00001014000000]]. |
Changes to docs/manual/00001012051890.zettel.
1 | id: 00001012051890 | | | | < < < > > | < < < < | 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 | id: 00001012051890 title: API: Search syntax (simple) role: manual tags: #api #manual #zettelstore syntax: zmk modified: 20220218130900 If the search string starts with the exclamation mark character (""!"", U+0021), it will be removed and the query matches all values that **do not match** the search string. In the next step, the first character of the search string will be inspected. If it contains one of the characters ""'':''"", ""''=''"", ""''>''"", ""''<''"", or ""''~''"", this will modify how the search will be performed. The character will be removed from the start of the search string. For example, assume the search string is ""def"": ; The colon character (""'':''"", U+003A) (or none of these characters) : This is the __default__ comparison. The comparison depends on the type of the underlying values. For a content search, it is equal to the tilde character ""''~''"", which returns true if a word within the content just contains the search string. For metadata, it depends on the key [[type|00001006030000]]. It you omit the the comparison character, the default comparison is also used. ; The tilde character (""''~''"", U+007E) : The inspected text[^Either all words of the zettel content and/or some metadata values] contains the search string. ""def"", ""defghi"", and ""abcdefghi"" are matching the search string. ; The equal sign character (""''=''"", U+003D) : The inspected text must contain a word that is equal to the search string. Only the word ""def"" matches the search string. ; The greater-than sign character (""''>''"", U+003E) : The inspected text must contain a word with the search string as a prefix. A word like ""def"" or ""defghi"" matches the search string. ; The less-than sign character (""''<''"", U+003C) : The inspected text must contain a word with the search string as a suffix. A word like ""def"" or ""abcdef"" matches the search string. If you want to include an initial ""''!''"" into the search string, you must prefix that with the escape character ""''\\''"". For example ""\\!abc"" will search for the string ""!abc"". A similar rule applies to the characters that specify the way how the search will be done. For example, ""!\\=abc"" will search for content that does not contains the string ""=abc"". |
Changes to docs/manual/00001012053900.zettel.
1 2 3 4 5 | id: 00001012053900 title: API: Retrieve unlinked references to an existing zettel role: manual tags: #api #manual #zettelstore syntax: zmk | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012053900 title: API: Retrieve unlinked references to an existing zettel role: manual tags: #api #manual #zettelstore syntax: zmk modified: 20220202112528 The value of a personal Zettelstore is determined in part by explicit connections between related zettel. If the number of zettel grow, some of these connections are missing. There are various reasons for this. Maybe, you forgot that a zettel exists. Or you add a zettel later, but forgot that previous zettel already mention its title. |
︙ | ︙ | |||
50 51 52 53 54 55 56 | you can specify the title phase to be searched for as a query parameter ''_phrase'': ```` # curl 'http://127.0.0.1:23123/u/00001007000000?phrase=markdown' {"id": "00001007000000","meta": {...},"list": [{"id": "00001008010000","meta": {...},"rights":62},{"id": "00001004020000","meta": {...},"rights":62}]} ```` | | < | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | you can specify the title phase to be searched for as a query parameter ''_phrase'': ```` # curl 'http://127.0.0.1:23123/u/00001007000000?phrase=markdown' {"id": "00001007000000","meta": {...},"list": [{"id": "00001008010000","meta": {...},"rights":62},{"id": "00001004020000","meta": {...},"rights":62}]} ```` In addition, you are allowed to specify all query parameter to [[select zettel based on their metadata|00001012051810]], to [[limit the length of the returned list|00001012051830]], and to [[sort the returned list|00001012052000]]. You are allowed to limit the search only for those zettel with some [[specific content|00001012051840]]. === Keys The following top-level JSON keys are returned: ; ''id'' : The [[zettel identifier|00001006050000]] for which the unlinked references were requested. ; ''meta'': : The metadata of the zettel, encoded as a JSON object. |
︙ | ︙ |
Changes to docs/manual/00001012070500.zettel.
1 2 | id: 00001012070500 title: Retrieve administrative data | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012070500 title: Retrieve administrative data role: zettel tags: #api #manual #zettelstore syntax: zmk modified: 20220304174027 The [[endpoint|00001012920000]] ''/x'' allows you to retrieve some (administrative) data. Currently, you can only request Zettelstore version data. ```` # curl 'http://127.0.0.1:23123/x' |
︙ | ︙ |
Changes to docs/manual/00001012080100.zettel.
1 2 | id: 00001012080100 title: API: Execute commands | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012080100 title: API: Execute commands role: zettel tags: #api #manual #zettelstore syntax: zmk modified: 20220103225956 The [[endpoint|00001012920000]] ''/x'' allows you to execute some (administrative) commands. To differentiate between the possible commands, you have to set the query parameter ''_cmd'' to a specific value: ; ''authenticated'' : [[Check for authentication|00001012080200]] ; ''refresh'' |
︙ | ︙ |
Changes to docs/manual/00001012080200.zettel.
1 2 | id: 00001012080200 title: API: Check for authentication | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012080200 title: API: Check for authentication role: zettel tags: #api #manual #zettelstore syntax: zmk modified: 20220103235531 API clients typically wants to know, whether [[authentication is enabled|00001010040100]] or not. If authentication is enabled, they present some form of user interface to get user name and password for the actual authentication. Then they try to [[obtain an access token|00001012050200]]. If authentication is disabled, these steps are not needed. To check for enabled authentication, you must send a HTTP POST request to the [[endpoint|00001012920000]] ''/x'' and you must specify the query parameter ''_cmd=authenticated''. |
︙ | ︙ |
Changes to docs/manual/00001012080500.zettel.
1 2 | id: 00001012080500 title: API: Refresh internal data | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001012080500 title: API: Refresh internal data role: zettel tags: #api #manual #zettelstore syntax: zmk modified: 20211230234431 Zettelstore maintains some internal data to allow faster operations. One example is the [[content search|00001012051840]] for a term: Zettelstore does not need to scan all zettel to find all occurrences for the term. Instead, all word are stored internally, with a list of zettel where they occur. Another example is the way to determine which zettel are stored in a [[ZIP file|00001004011200]]. |
︙ | ︙ |
Deleted docs/manual/00001017000000.zettel.
|
| < < < < < < < < < < < < < < < < < < < < |
Changes to docs/manual/00001018000000.zettel.
1 2 | id: 00001018000000 title: Troubleshooting | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | id: 00001018000000 title: Troubleshooting role: zettel tags: #manual #zettelstore syntax: zmk modified: 20220218125940 This page lists some problems and their solutions that may occur when using your Zettelstore. === Installation * **Problem:** When you double-click on the Zettelstore executable icon, macOS complains that Zettelstore is an application from an unknown developer. Therefore, it will not start Zettelstore. ** **Solution:** Press the ''Ctrl'' key while opening the context menu of the Zettelstore executable with a right-click. |
︙ | ︙ |
Changes to domain/meta/meta_test.go.
1 2 3 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // | | | 1 2 3 4 5 6 7 8 9 10 11 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- // Package meta provides the domain specific type 'meta'. |
︙ | ︙ | |||
36 37 38 39 40 41 42 | } } } func TestTitleHeader(t *testing.T) { t.Parallel() m := New(testID) | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | } } } func TestTitleHeader(t *testing.T) { t.Parallel() m := New(testID) if got, ok := m.Get(api.KeyTitle); ok || got != "" { t.Errorf("Title is not empty, but %q", got) } addToMeta(m, api.KeyTitle, " ") if got, ok := m.Get(api.KeyTitle); ok || got != "" { t.Errorf("Title is not empty, but %q", got) } const st = "A simple text" addToMeta(m, api.KeyTitle, " "+st+" ") if got, ok := m.Get(api.KeyTitle); !ok || got != st { t.Errorf("Title is not %q, but %q", st, got) } |
︙ | ︙ |
Changes to domain/meta/parse.go.
︙ | ︙ | |||
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | switch key { case "", api.KeyID: // Empty key and 'id' key will be ignored return } switch Type(key) { case TypeTagSet: addSet(m, key, strings.ToLower(v), func(s string) bool { return s[0] == '#' }) case TypeWord: m.Set(key, strings.ToLower(v)) case TypeWordSet: addSet(m, key, strings.ToLower(v), func(s string) bool { return true }) case TypeID: | > > > > | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | switch key { case "", api.KeyID: // Empty key and 'id' key will be ignored return } switch Type(key) { case TypeString, TypeZettelmarkup: if v != "" { addData(m, key, v) } case TypeTagSet: addSet(m, key, strings.ToLower(v), func(s string) bool { return s[0] == '#' }) case TypeWord: m.Set(key, strings.ToLower(v)) case TypeWordSet: addSet(m, key, strings.ToLower(v), func(s string) bool { return true }) case TypeID: |
︙ | ︙ |
Changes to domain/meta/parse_test.go.
︙ | ︙ | |||
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 | for i, tc := range td { m := parseMetaStr(tc.s) if got, ok := m.Get(api.KeyTitle); !ok || got != tc.e { t.Log(m) t.Errorf("TC=%d: expected %q, got %q", i, tc.e, got) } } } func TestNewFromInput(t *testing.T) { t.Parallel() testcases := []struct { input string exp []meta.Pair }{ {"", []meta.Pair{}}, {" a:b", []meta.Pair{{"a", "b"}}}, {"%a:b", []meta.Pair{}}, {"a:b\r\n\r\nc:d", []meta.Pair{{"a", "b"}}}, {"a:b\r\n%c:d", []meta.Pair{{"a", "b"}}}, {"% a:b\r\n c:d", []meta.Pair{{"c", "d"}}}, {"---\r\na:b\r\n", []meta.Pair{{"a", "b"}}}, {"---\r\na:b\r\n--\r\nc:d", []meta.Pair{{"a", "b"}, {"c", "d"}}}, {"---\r\na:b\r\n---\r\nc:d", []meta.Pair{{"a", "b"}}}, {"---\r\na:b\r\n----\r\nc:d", []meta.Pair{{"a", "b"}}}, | > > > > > < | 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 84 85 86 87 88 | for i, tc := range td { m := parseMetaStr(tc.s) if got, ok := m.Get(api.KeyTitle); !ok || got != tc.e { t.Log(m) t.Errorf("TC=%d: expected %q, got %q", i, tc.e, got) } } m := parseMetaStr(api.KeyTitle + ": ") if title, ok := m.Get(api.KeyTitle); ok { t.Errorf("Expected a missing title key, but got %q (meta=%v)", title, m) } } func TestNewFromInput(t *testing.T) { t.Parallel() testcases := []struct { input string exp []meta.Pair }{ {"", []meta.Pair{}}, {" a:b", []meta.Pair{{"a", "b"}}}, {"%a:b", []meta.Pair{}}, {"a:b\r\n\r\nc:d", []meta.Pair{{"a", "b"}}}, {"a:b\r\n%c:d", []meta.Pair{{"a", "b"}}}, {"% a:b\r\n c:d", []meta.Pair{{"c", "d"}}}, {"---\r\na:b\r\n", []meta.Pair{{"a", "b"}}}, {"---\r\na:b\r\n--\r\nc:d", []meta.Pair{{"a", "b"}, {"c", "d"}}}, {"---\r\na:b\r\n---\r\nc:d", []meta.Pair{{"a", "b"}}}, {"---\r\na:b\r\n----\r\nc:d", []meta.Pair{{"a", "b"}}}, } for i, tc := range testcases { meta := parseMetaStr(tc.input) if got := meta.Pairs(); !equalPairs(tc.exp, got) { t.Errorf("TC=%d: expected=%v, got=%v", i, tc.exp, got) } } |
︙ | ︙ |
Changes to encoder/encoder_inline_test.go.
︙ | ︙ | |||
122 123 124 125 126 127 128 | }, }, { descr: "Quotes formatting (german)", zmk: `""quotes""{lang=de}`, expect: expectMap{ encoderZJSON: `[{"":"Quote","a":{"lang":"de"},"i":[{"":"Text","s":"quotes"}]}]`, | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | }, }, { descr: "Quotes formatting (german)", zmk: `""quotes""{lang=de}`, expect: expectMap{ encoderZJSON: `[{"":"Quote","a":{"lang":"de"},"i":[{"":"Text","s":"quotes"}]}]`, encoderHTML: `<q lang="de">quotes</q>`, encoderSexpr: `((FORMAT-QUOTE (("lang" "de")) (TEXT "quotes")))`, encoderText: `quotes`, encoderZmk: `""quotes""{lang="de"}`, }, }, { descr: "Span formatting", |
︙ | ︙ | |||
166 167 168 169 170 171 172 | }, }, { descr: "HTML in Code formatting", zmk: "``<script `` abc", expect: expectMap{ encoderZJSON: `[{"":"Code","s":"<script "},{"":"Space"},{"":"Text","s":"abc"}]`, | | | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | }, }, { descr: "HTML in Code formatting", zmk: "``<script `` abc", expect: expectMap{ encoderZJSON: `[{"":"Code","s":"<script "},{"":"Space"},{"":"Text","s":"abc"}]`, encoderHTML: "<code><script\u00a0</code> abc", encoderSexpr: `((LITERAL-CODE () "<script ") (SPACE) (TEXT "abc"))`, encoderText: `<script abc`, encoderZmk: useZmk, }, }, { descr: "Input formatting", |
︙ | ︙ | |||
433 434 435 436 437 438 439 | descr: "Relative link", zmk: `[[R|../relative]]`, expect: expectMap{ encoderZJSON: `[{"":"Link","q":"local","s":"../relative","i":[{"":"Text","s":"R"}]}]`, encoderHTML: `<a href="../relative">R</a>`, encoderSexpr: `((LINK-HOSTED () "../relative" (TEXT "R")))`, encoderText: `R`, | < < < < < < < < < < < < < < < < < < < < < < | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | descr: "Relative link", zmk: `[[R|../relative]]`, expect: expectMap{ encoderZJSON: `[{"":"Link","q":"local","s":"../relative","i":[{"":"Text","s":"R"}]}]`, encoderHTML: `<a href="../relative">R</a>`, encoderSexpr: `((LINK-HOSTED () "../relative" (TEXT "R")))`, encoderText: `R`, encoderZmk: useZmk, }, }, { descr: "Dummy Embed", zmk: `{{abc}}`, expect: expectMap{ |
︙ | ︙ |
Changes to encoder/sexprenc/transform.go.
︙ | ︙ | |||
303 304 305 306 307 308 309 | ast.RefStateInvalid: sexpr.SymLinkInvalid, ast.RefStateZettel: sexpr.SymLinkZettel, ast.RefStateSelf: sexpr.SymLinkSelf, ast.RefStateFound: sexpr.SymLinkFound, ast.RefStateBroken: sexpr.SymLinkBroken, ast.RefStateHosted: sexpr.SymLinkHosted, ast.RefStateBased: sexpr.SymLinkBased, | < | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | ast.RefStateInvalid: sexpr.SymLinkInvalid, ast.RefStateZettel: sexpr.SymLinkZettel, ast.RefStateSelf: sexpr.SymLinkSelf, ast.RefStateFound: sexpr.SymLinkFound, ast.RefStateBroken: sexpr.SymLinkBroken, ast.RefStateHosted: sexpr.SymLinkHosted, ast.RefStateBased: sexpr.SymLinkBased, ast.RefStateExternal: sexpr.SymLinkExternal, } func (t *transformer) getLink(ln *ast.LinkNode) *sxpf.Pair { return sxpf.NewPair( mapGetS(mapRefStateLink, ln.Ref.State), sxpf.NewPair( |
︙ | ︙ | |||
395 396 397 398 399 400 401 | ast.RefStateInvalid: sexpr.SymRefStateInvalid, ast.RefStateZettel: sexpr.SymRefStateZettel, ast.RefStateSelf: sexpr.SymRefStateSelf, ast.RefStateFound: sexpr.SymRefStateFound, ast.RefStateBroken: sexpr.SymRefStateBroken, ast.RefStateHosted: sexpr.SymRefStateHosted, ast.RefStateBased: sexpr.SymRefStateBased, | < | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | ast.RefStateInvalid: sexpr.SymRefStateInvalid, ast.RefStateZettel: sexpr.SymRefStateZettel, ast.RefStateSelf: sexpr.SymRefStateSelf, ast.RefStateFound: sexpr.SymRefStateFound, ast.RefStateBroken: sexpr.SymRefStateBroken, ast.RefStateHosted: sexpr.SymRefStateHosted, ast.RefStateBased: sexpr.SymRefStateBased, ast.RefStateExternal: sexpr.SymRefStateExternal, } func getReference(ref *ast.Reference) *sxpf.Pair { return sxpf.NewPair( mapGetS(mapRefStateS, ref.State), sxpf.NewPair( |
︙ | ︙ | |||
455 456 457 458 459 460 461 | } func mapGetS[T comparable](m map[T]*sxpf.Symbol, k T) *sxpf.Symbol { if result, found := m[k]; found { return result } log.Println("MISS", k, m) | | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | } func mapGetS[T comparable](m map[T]*sxpf.Symbol, k T) *sxpf.Symbol { if result, found := m[k]; found { return result } log.Println("MISS", k, m) return sexpr.Smk.MakeSymbol(fmt.Sprintf("**%v:not-found**", k)) } func getBase64String(data []byte) *sxpf.String { var buf bytes.Buffer encoder := base64.NewEncoder(base64.StdEncoding, &buf) _, err := encoder.Write(data) if err == nil { |
︙ | ︙ |
Changes to encoder/zjsonenc/zjsonenc.go.
︙ | ︙ | |||
136 137 138 139 140 141 142 | case *ast.BreakNode: if n.Hard { v.writeNodeStart(zjson.TypeBreakHard) } else { v.writeNodeStart(zjson.TypeBreakSoft) } case *ast.LinkNode: | > | > > > > > > > > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | case *ast.BreakNode: if n.Hard { v.writeNodeStart(zjson.TypeBreakHard) } else { v.writeNodeStart(zjson.TypeBreakSoft) } case *ast.LinkNode: v.writeNodeStart(zjson.TypeLink) v.visitAttributes(n.Attrs) v.writeContentStart(zjson.NameString2) writeEscaped(&v.b, mapRefState[n.Ref.State]) v.writeContentStart(zjson.NameString) writeEscaped(&v.b, n.Ref.String()) if len(n.Inlines) > 0 { v.writeContentStart(zjson.NameInline) ast.Walk(v, &n.Inlines) } case *ast.EmbedRefNode: v.visitEmbedRef(n) case *ast.EmbedBLOBNode: v.visitEmbedBLOB(n) case *ast.CiteNode: v.writeNodeStart(zjson.TypeCitation) v.visitAttributes(n.Attrs) |
︙ | ︙ | |||
353 354 355 356 357 358 359 | ast.RefStateInvalid: zjson.RefStateInvalid, ast.RefStateZettel: zjson.RefStateZettel, ast.RefStateSelf: zjson.RefStateSelf, ast.RefStateFound: zjson.RefStateFound, ast.RefStateBroken: zjson.RefStateBroken, ast.RefStateHosted: zjson.RefStateHosted, ast.RefStateBased: zjson.RefStateBased, | < < < < < < < < < < < < < < < < < < | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | ast.RefStateInvalid: zjson.RefStateInvalid, ast.RefStateZettel: zjson.RefStateZettel, ast.RefStateSelf: zjson.RefStateSelf, ast.RefStateFound: zjson.RefStateFound, ast.RefStateBroken: zjson.RefStateBroken, ast.RefStateHosted: zjson.RefStateHosted, ast.RefStateBased: zjson.RefStateBased, ast.RefStateExternal: zjson.RefStateExternal, } func (v *visitor) visitEmbedRef(en *ast.EmbedRefNode) { v.writeNodeStart(zjson.TypeEmbed) v.visitAttributes(en.Attrs) v.writeContentStart(zjson.NameString) writeEscaped(&v.b, en.Ref.String()) if len(en.Inlines) > 0 { |
︙ | ︙ |
Changes to evaluator/evaluator.go.
︙ | ︙ | |||
26 27 28 29 30 31 32 | "zettelstore.de/z/domain" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" "zettelstore.de/z/input" "zettelstore.de/z/parser" "zettelstore.de/z/parser/cleaner" "zettelstore.de/z/parser/draw" | < < | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | "zettelstore.de/z/domain" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" "zettelstore.de/z/input" "zettelstore.de/z/parser" "zettelstore.de/z/parser/cleaner" "zettelstore.de/z/parser/draw" ) // Port contains all methods to retrieve zettel (or part of it) to evaluate a zettel. type Port interface { GetMeta(context.Context, id.Zid) (*meta.Meta, error) GetZettel(context.Context, id.Zid) (domain.Zettel, error) } // EvaluateZettel evaluates the given zettel in the given context, with the // given ports, and the given environment. func EvaluateZettel(ctx context.Context, port Port, rtConfig config.Config, zn *ast.ZettelNode) { if zn.Syntax == api.ValueSyntaxNone { // AST is empty, evaluate to a description list of metadata. |
︙ | ︙ | |||
115 116 117 118 119 120 121 | } func transcludeNode(bln *ast.BlockSlice, i int, bn ast.BlockNode) int { if ln, ok := bn.(*ast.BlockSlice); ok { *bln = replaceWithBlockNodes(*bln, i, *ln) return len(*ln) - 1 } | < < < < | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | } func transcludeNode(bln *ast.BlockSlice, i int, bn ast.BlockNode) int { if ln, ok := bn.(*ast.BlockSlice); ok { *bln = replaceWithBlockNodes(*bln, i, *ln) return len(*ln) - 1 } (*bln)[i] = bn return 0 } func replaceWithBlockNodes(bns []ast.BlockNode, i int, replaceBns []ast.BlockNode) []ast.BlockNode { if len(replaceBns) == 1 { bns[i] = replaceBns[0] |
︙ | ︙ | |||
189 190 191 192 193 194 195 | return makeBlockNode(errText) } switch ref.State { case ast.RefStateZettel: // Only zettel references will be evaluated. case ast.RefStateInvalid, ast.RefStateBroken: e.transcludeCount++ | | | < < < < > | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | return makeBlockNode(errText) } switch ref.State { case ast.RefStateZettel: // Only zettel references will be evaluated. case ast.RefStateInvalid, ast.RefStateBroken: e.transcludeCount++ return makeBlockNode(createInlineErrorText(ref, "Invalid", "or", "broken", "transclusion", "reference:")) case ast.RefStateSelf: e.transcludeCount++ return makeBlockNode(createInlineErrorText(ref, "Self", "transclusion", "reference:")) case ast.RefStateFound, ast.RefStateHosted, ast.RefStateBased, ast.RefStateExternal: return tn default: panic(fmt.Sprintf("Unknown state %v for reference %v", ref.State, ref)) } zid, err := id.Parse(ref.URL.Path) if err != nil { panic(err) } cost, ok := e.costMap[zid] zn := cost.zn if zn == e.marker { e.transcludeCount++ return makeBlockNode(createInlineErrorText(ref, "Recursive", "transclusion:")) } if !ok { zettel, err1 := e.port.GetZettel(box.NoEnrichContext(e.ctx), zid) if err1 != nil { e.transcludeCount++ return makeBlockNode(createInlineErrorText(ref, "Unable", "to", "get", "zettel:")) } ec := e.transcludeCount e.costMap[zid] = transcludeCost{zn: e.marker, ec: ec} zn = e.evaluateEmbeddedZettel(zettel) e.costMap[zid] = transcludeCost{zn: zn, ec: e.transcludeCount - ec} e.transcludeCount = 0 // No stack needed, because embedding is done left-recursive, depth-first. } e.transcludeCount++ if ec := cost.ec; ec > 0 { e.transcludeCount += cost.ec } return &zn.Ast } func (e *evaluator) checkMaxTransclusions(ref *ast.Reference) ast.InlineNode { if maxTrans := e.transcludeMax; e.transcludeCount > maxTrans { e.transcludeCount = maxTrans + 1 return createInlineErrorText(ref, "Too", "many", "transclusions", "(must", "be", "at", "most", strconv.Itoa(maxTrans)+",", "see", "runtime", "configuration", "key", "max-transclusions)") } |
︙ | ︙ | |||
300 301 302 303 304 305 306 | } func embedNode(is *ast.InlineSlice, i int, in ast.InlineNode) int { if ln, ok := in.(*ast.InlineSlice); ok { *is = replaceWithInlineNodes(*is, i, *ln) return len(*ln) - 1 } | < < < < | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | } func embedNode(is *ast.InlineSlice, i int, in ast.InlineNode) int { if ln, ok := in.(*ast.InlineSlice); ok { *is = replaceWithInlineNodes(*is, i, *ln) return len(*ln) - 1 } (*is)[i] = in return 0 } func replaceWithInlineNodes(ins ast.InlineSlice, i int, replaceIns ast.InlineSlice) ast.InlineSlice { if len(replaceIns) == 1 { ins[i] = replaceIns[0] |
︙ | ︙ | |||
375 376 377 378 379 380 381 | case ast.RefStateZettel: // Only zettel references will be evaluated. case ast.RefStateInvalid, ast.RefStateBroken: e.transcludeCount++ return createInlineErrorImage(en) case ast.RefStateSelf: e.transcludeCount++ | | | < < < | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | case ast.RefStateZettel: // Only zettel references will be evaluated. case ast.RefStateInvalid, ast.RefStateBroken: e.transcludeCount++ return createInlineErrorImage(en) case ast.RefStateSelf: e.transcludeCount++ return createInlineErrorText(ref, "Self", "embed", "reference:") case ast.RefStateFound, ast.RefStateHosted, ast.RefStateBased, ast.RefStateExternal: return en default: panic(fmt.Sprintf("Unknown state %v for reference %v", ref.State, ref)) } zid := mustParseZid(ref) zettel, err := e.port.GetZettel(box.NoEnrichContext(e.ctx), zid) if err != nil { e.transcludeCount++ return createInlineErrorImage(en) } if syntax := zettel.Meta.GetDefault(api.KeySyntax, ""); parser.IsImageFormat(syntax) { en.Syntax = syntax return en } else if !parser.IsTextParser(syntax) { // Not embeddable. e.transcludeCount++ return createInlineErrorText(ref, "Not", "embeddable (syntax="+syntax+"):") } cost, ok := e.costMap[zid] zn := cost.zn if zn == e.marker { e.transcludeCount++ return createInlineErrorText(ref, "Recursive", "transclusion:") } if !ok { ec := e.transcludeCount e.costMap[zid] = transcludeCost{zn: e.marker, ec: ec} zn = e.evaluateEmbeddedZettel(zettel) e.costMap[zid] = transcludeCost{zn: zn, ec: e.transcludeCount - ec} e.transcludeCount = 0 // No stack needed, because embedding is done left-recursive, depth-first. |
︙ | ︙ |
Changes to go.mod.
1 2 | module zettelstore.de/z | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | module zettelstore.de/z go 1.18 require ( codeberg.org/t73fde/sxpf v0.0.0-20220719090054-749a39d0a7a0 github.com/fsnotify/fsnotify v1.5.4 github.com/pascaldekloe/jwt v1.12.0 github.com/yuin/goldmark v1.4.13 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 golang.org/x/text v0.3.7 zettelstore.de/c v0.0.0-20220729135959-532261810eac ) require golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 // indirect |
Changes to go.sum.
1 2 3 4 5 6 7 8 9 10 11 | codeberg.org/t73fde/sxpf v0.0.0-20220719090054-749a39d0a7a0 h1:viya/OgeF16+i8caBPJmcLQhGpZodPh+/nxtJzSSO1s= codeberg.org/t73fde/sxpf v0.0.0-20220719090054-749a39d0a7a0/go.mod h1:4fAHEF3VH+ofbZkF6NzqiItTNy2X11tVCnZX99jXouA= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/pascaldekloe/jwt v1.12.0 h1:imQSkPOtAIBAXoKKjL9ZVJuF/rVqJ+ntiLGpLyeqMUQ= github.com/pascaldekloe/jwt v1.12.0/go.mod h1:LiIl7EwaglmH1hWThd/AmydNCnHf/mmfluBlNqHbk8U= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | codeberg.org/t73fde/sxpf v0.0.0-20220719090054-749a39d0a7a0 h1:viya/OgeF16+i8caBPJmcLQhGpZodPh+/nxtJzSSO1s= codeberg.org/t73fde/sxpf v0.0.0-20220719090054-749a39d0a7a0/go.mod h1:4fAHEF3VH+ofbZkF6NzqiItTNy2X11tVCnZX99jXouA= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/pascaldekloe/jwt v1.12.0 h1:imQSkPOtAIBAXoKKjL9ZVJuF/rVqJ+ntiLGpLyeqMUQ= github.com/pascaldekloe/jwt v1.12.0/go.mod h1:LiIl7EwaglmH1hWThd/AmydNCnHf/mmfluBlNqHbk8U= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68 h1:z8Hj/bl9cOV2grsOpEaQFUaly0JWN3i97mo3jXKJNp0= golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= zettelstore.de/c v0.0.0-20220729135959-532261810eac h1:T8GP4P8pHNfjQ2lXtpRXBmNF685xI0kraoou3tKqH2Y= zettelstore.de/c v0.0.0-20220729135959-532261810eac/go.mod h1:8wPlP6rYiXkfoCNE84K3bmhSAKHz15+xWSHMH26JAU0= |
Changes to input/input.go.
︙ | ︙ | |||
34 35 36 37 38 39 40 | inp.Next() return inp } // EOS = End of source const EOS = rune(-1) | | | | < < < < | | | | | | | | > > > | 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 | inp.Next() return inp } // EOS = End of source const EOS = rune(-1) // Next reads the next rune into inp.Ch. func (inp *Input) Next() { if inp.readPos < len(inp.Src) { inp.Pos = inp.readPos r, w := rune(inp.Src[inp.readPos]), 1 if r >= utf8.RuneSelf { r, w = utf8.DecodeRune(inp.Src[inp.readPos:]) } inp.readPos += w inp.Ch = r } else { inp.Pos = len(inp.Src) inp.Ch = EOS } } // Peek returns the rune following the most recently read rune without // advancing. If end-of-source was already found peek returns EOS. func (inp *Input) Peek() rune { return inp.PeekN(0) } |
︙ | ︙ | |||
74 75 76 77 78 79 80 | return ' ' } return r } return EOS } | < < < < < < < < < < < < < < < < < < < | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | return ' ' } return r } return EOS } // IsEOLEOS returns true if char is either EOS or EOL. func IsEOLEOS(ch rune) bool { switch ch { case EOS, '\n', '\r': return true } return false |
︙ | ︙ | |||
118 119 120 121 122 123 124 | case '\n': inp.Next() } } // SetPos allows to reset the read position. func (inp *Input) SetPos(pos int) { | < | | < | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | case '\n': inp.Next() } } // SetPos allows to reset the read position. func (inp *Input) SetPos(pos int) { inp.readPos = pos inp.Next() } // SkipToEOL reads until the next end-of-line. func (inp *Input) SkipToEOL() { for { switch inp.Ch { case EOS, '\n', '\r': |
︙ | ︙ |
Changes to input/input_test.go.
︙ | ︙ | |||
76 77 78 79 80 81 82 | got, ok := inp.ScanEntity() if ok { t.Errorf("%d: scanning %q was unexpected successful, got %q", i, tc, got) continue } } } | < < < < < < < < < < < < < < < < < < < < < < < < < < | 76 77 78 79 80 81 82 | got, ok := inp.ScanEntity() if ok { t.Errorf("%d: scanning %q was unexpected successful, got %q", i, tc, got) continue } } } |
Changes to input/runes.go.
1 2 3 4 5 6 7 8 9 10 11 12 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // // This file is part of Zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package input | < < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // // This file is part of Zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package input // IsSpace returns true if rune is a whitespace. func IsSpace(ch rune) bool { switch ch { case ' ', '\t': return true } return false } |
Changes to kernel/impl/box.go.
1 | //----------------------------------------------------------------------------- | | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | //----------------------------------------------------------------------------- // Copyright (c) 2021 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package impl import ( "context" "fmt" "io" "net/url" "sync" "zettelstore.de/z/box" "zettelstore.de/z/kernel" "zettelstore.de/z/logger" ) |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 | } } func (ps *boxService) GetLogger() *logger.Logger { return ps.logger } func (ps *boxService) Start(kern *myKernel) error { boxURIs := make([]*url.URL, 0, 4) for i := 1; ; i++ { | > | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | } } func (ps *boxService) GetLogger() *logger.Logger { return ps.logger } func (ps *boxService) Start(kern *myKernel) error { boxURIs := make([]*url.URL, 0, 4) format := kernel.BoxURIs + "%d" for i := 1; ; i++ { u := ps.GetNextConfig(fmt.Sprintf(format, i)) if u == nil { break } boxURIs = append(boxURIs, u.(*url.URL)) } ps.mxService.Lock() defer ps.mxService.Unlock() |
︙ | ︙ | |||
111 112 113 114 115 116 117 | func (ps *boxService) GetStatistics() []kernel.KeyValue { var st box.Stats ps.mxService.RLock() ps.manager.ReadStats(&st) ps.mxService.RUnlock() return []kernel.KeyValue{ | | | | | | | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | func (ps *boxService) GetStatistics() []kernel.KeyValue { var st box.Stats ps.mxService.RLock() ps.manager.ReadStats(&st) ps.mxService.RUnlock() return []kernel.KeyValue{ {Key: "Read-only", Value: fmt.Sprintf("%v", st.ReadOnly)}, {Key: "Managed boxes", Value: fmt.Sprintf("%v", st.NumManagedBoxes)}, {Key: "Zettel (total)", Value: fmt.Sprintf("%v", st.ZettelTotal)}, {Key: "Zettel (indexed)", Value: fmt.Sprintf("%v", st.ZettelIndexed)}, {Key: "Last re-index", Value: st.LastReload.Format("2006-01-02 15:04:05 -0700 MST")}, {Key: "Duration last re-index", Value: fmt.Sprintf("%vms", st.DurLastReload.Milliseconds())}, {Key: "Indexes since last re-index", Value: fmt.Sprintf("%v", st.IndexesSinceReload)}, {Key: "Indexed words", Value: fmt.Sprintf("%v", st.IndexedWords)}, {Key: "Indexed URLs", Value: fmt.Sprintf("%v", st.IndexedUrls)}, {Key: "Zettel enrichments", Value: fmt.Sprintf("%v", st.IndexUpdates)}, } } func (ps *boxService) DumpIndex(w io.Writer) { ps.manager.Dump(w) } |
︙ | ︙ |
Changes to kernel/impl/cfg.go.
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // under this license. //----------------------------------------------------------------------------- package impl import ( "context" "strings" "sync" "zettelstore.de/c/api" "zettelstore.de/z/box" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // under this license. //----------------------------------------------------------------------------- package impl import ( "context" "fmt" "strings" "sync" "zettelstore.de/c/api" "zettelstore.de/z/box" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" |
︙ | ︙ | |||
95 96 97 98 99 100 101 | } func (cs *configService) GetLogger() *logger.Logger { return cs.logger } func (cs *configService) Start(*myKernel) error { cs.logger.Info().Msg("Start Service") data := meta.New(id.ConfigurationZid) for _, kv := range cs.GetNextConfigList() { | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | } func (cs *configService) GetLogger() *logger.Logger { return cs.logger } func (cs *configService) Start(*myKernel) error { cs.logger.Info().Msg("Start Service") data := meta.New(id.ConfigurationZid) for _, kv := range cs.GetNextConfigList() { data.Set(kv.Key, fmt.Sprintf("%v", kv.Value)) } cs.mxService.Lock() cs.rtConfig = newConfig(cs.logger, data) cs.mxService.Unlock() return nil } |
︙ | ︙ |
Changes to kernel/impl/cmd.go.
︙ | ︙ | |||
484 485 486 487 488 489 490 | descr = descr[:pos] } value := samples[i].Value i++ var sVal string switch value.Kind() { case metrics.KindUint64: | | | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | descr = descr[:pos] } value := samples[i].Value i++ var sVal string switch value.Kind() { case metrics.KindUint64: sVal = fmt.Sprintf("%v", value.Uint64()) case metrics.KindFloat64: sVal = fmt.Sprintf("%v", value.Float64()) case metrics.KindFloat64Histogram: sVal = "(Histogramm)" case metrics.KindBad: sVal = "BAD" default: |
︙ | ︙ |
Changes to kernel/impl/config.go.
︙ | ︙ | |||
81 82 83 84 85 86 87 88 | defer cfg.mxConfig.Unlock() descr, ok := cfg.descr[key] if !ok { d, baseKey, num := cfg.getListDescription(key) if num < 0 { return false } for i := num + 1; ; i++ { | > | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | defer cfg.mxConfig.Unlock() descr, ok := cfg.descr[key] if !ok { d, baseKey, num := cfg.getListDescription(key) if num < 0 { return false } format := baseKey + "%d" for i := num + 1; ; i++ { k := fmt.Sprintf(format, i) if _, ok = cfg.next[k]; !ok { break } delete(cfg.next, k) } if num == 0 { return true |
︙ | ︙ | |||
179 180 181 182 183 184 185 186 | keys := make([]string, 0, len(cfg.descr)) for k, descr := range cfg.descr { if all || descr.canList { if !strings.HasSuffix(k, "-") { keys = append(keys, k) continue } for i := 1; ; i++ { | > | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | keys := make([]string, 0, len(cfg.descr)) for k, descr := range cfg.descr { if all || descr.canList { if !strings.HasSuffix(k, "-") { keys = append(keys, k) continue } format := k + "%d" for i := 1; ; i++ { key := fmt.Sprintf(format, i) val := getConfig(key) if val == nil { break } keys = append(keys, key) } } |
︙ | ︙ |
Changes to kernel/impl/web.go.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //----------------------------------------------------------------------------- // Copyright (c) 2021-2022 Detlef Stern // // This file is part of Zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package impl import ( "net" "strconv" "strings" "sync" "time" "zettelstore.de/z/kernel" | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //----------------------------------------------------------------------------- // Copyright (c) 2021-2022 Detlef Stern // // This file is part of Zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package impl import ( "fmt" "net" "strconv" "strings" "sync" "time" "zettelstore.de/z/kernel" |
︙ | ︙ | |||
128 129 130 131 132 133 134 | ws.mxService.Unlock() if kern.cfg.GetConfig(kernel.ConfigSimpleMode).(bool) { listenAddr := ws.GetNextConfig(kernel.WebListenAddress).(string) if idx := strings.LastIndexByte(listenAddr, ':'); idx >= 0 { ws.logger.Mandatory().Msg(strings.Repeat("--------------------", 3)) ws.logger.Mandatory().Msg("Open your browser and enter the following URL:") | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ws.mxService.Unlock() if kern.cfg.GetConfig(kernel.ConfigSimpleMode).(bool) { listenAddr := ws.GetNextConfig(kernel.WebListenAddress).(string) if idx := strings.LastIndexByte(listenAddr, ':'); idx >= 0 { ws.logger.Mandatory().Msg(strings.Repeat("--------------------", 3)) ws.logger.Mandatory().Msg("Open your browser and enter the following URL:") ws.logger.Mandatory().Msg(fmt.Sprintf(" http://localhost%v", listenAddr[idx:])) } } return nil } func (ws *webService) IsStarted() bool { |
︙ | ︙ |
Changes to logger/message.go.
1 | //----------------------------------------------------------------------------- | | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //----------------------------------------------------------------------------- // Copyright (c) 2021 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package logger import ( "context" "strconv" "sync" "zettelstore.de/c/api" "zettelstore.de/z/domain/id" ) |
︙ | ︙ | |||
119 120 121 122 123 124 125 | } } } } return m } | < < < < < < < < < < < | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | } } } } return m } // Zid adds a zettel identifier to the full message func (m *Message) Zid(zid id.Zid) *Message { return m.Bytes("zid", zid.Bytes()) } // Msg add the given text to the message and writes it to the log. func (m *Message) Msg(text string) { |
︙ | ︙ |
Changes to parser/cleaner/cleaner.go.
︙ | ︙ | |||
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | } func (cv *cleanVisitor) visitMark(mn *ast.MarkNode) { if !cv.doMark { cv.hasMark = true return } if mn.Mark == "" { mn.Slug = "" mn.Fragment = cv.addIdentifier("*", mn) return } if mn.Slug == "" { mn.Slug = strfun.Slugify(mn.Mark) | > > > > > > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | } func (cv *cleanVisitor) visitMark(mn *ast.MarkNode) { if !cv.doMark { cv.hasMark = true return } // if mn.Mark == "" && len(mn.Inlines) > 0 { // var buf bytes.Buffer // _, err := cv.textEnc.WriteInlines(&buf, &mn.Inlines) // if err == nil { // mn.Mark = buf.String() // } // } if mn.Mark == "" { mn.Slug = "" mn.Fragment = cv.addIdentifier("*", mn) return } if mn.Slug == "" { mn.Slug = strfun.Slugify(mn.Mark) |
︙ | ︙ | |||
105 106 107 108 109 110 111 | return newID } } } cv.ids[id] = node return id } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 112 113 114 115 116 117 118 | return newID } } } cv.ids[id] = node return id } |
Changes to parser/markdown/markdown.go.
︙ | ︙ | |||
10 11 12 13 14 15 16 | // Package markdown provides a parser for markdown. package markdown import ( "bytes" "fmt" | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // Package markdown provides a parser for markdown. package markdown import ( "bytes" "fmt" gm "github.com/yuin/goldmark" gmAst "github.com/yuin/goldmark/ast" gmText "github.com/yuin/goldmark/text" "zettelstore.de/c/attrs" "zettelstore.de/z/ast" |
︙ | ︙ | |||
176 177 178 179 180 181 182 | func (p *mdP) acceptList(node *gmAst.List) ast.ItemNode { kind := ast.NestedListUnordered var a attrs.Attributes if node.IsOrdered() { kind = ast.NestedListOrdered if node.Start != 1 { | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | func (p *mdP) acceptList(node *gmAst.List) ast.ItemNode { kind := ast.NestedListUnordered var a attrs.Attributes if node.IsOrdered() { kind = ast.NestedListOrdered if node.Start != 1 { a = a.Set("start", fmt.Sprintf("%d", node.Start)) } } items := make([]ast.ItemSlice, 0, node.ChildCount()) for child := node.FirstChild(); child != nil; child = child.NextSibling() { item, ok := child.(*gmAst.ListItem) if !ok { panic(fmt.Sprintf("Expected list item node, but got %v", child.Kind())) |
︙ | ︙ |
Changes to parser/parser.go.
︙ | ︙ | |||
106 107 108 109 110 111 112 | // ParseMetadata parses a string as Zettelmarkup, resulting in an inline slice. // Typically used to parse the title or other metadata of type Zettelmarkup. func ParseMetadata(value string) ast.InlineSlice { return ParseInlines(input.NewInput([]byte(value)), api.ValueSyntaxZmk) } | < < < < < < < < | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | // ParseMetadata parses a string as Zettelmarkup, resulting in an inline slice. // Typically used to parse the title or other metadata of type Zettelmarkup. func ParseMetadata(value string) ast.InlineSlice { return ParseInlines(input.NewInput([]byte(value)), api.ValueSyntaxZmk) } // ParseZettel parses the zettel based on the syntax. func ParseZettel(zettel domain.Zettel, syntax string, rtConfig config.Config) *ast.ZettelNode { m := zettel.Meta inhMeta := m if rtConfig != nil { inhMeta = rtConfig.AddDefaultValues(inhMeta) } |
︙ | ︙ |
Changes to parser/zettelmark/block.go.
︙ | ︙ | |||
636 637 638 639 640 641 642 | return nil, false } inp := cp.inp posA, posE := inp.Pos, 0 loop: for { switch inp.Ch { | | < < < < | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | return nil, false } inp := cp.inp posA, posE := inp.Pos, 0 loop: for { switch inp.Ch { case input.EOS, '\n', '\r', ' ': return nil, false case '\\': inp.Next() switch inp.Ch { case input.EOS, '\n', '\r': return nil, false } case '}': |
︙ | ︙ |
Changes to parser/zettelmark/inline.go.
︙ | ︙ | |||
9 10 11 12 13 14 15 | //----------------------------------------------------------------------------- package zettelmark import ( "bytes" "fmt" | < | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //----------------------------------------------------------------------------- package zettelmark import ( "bytes" "fmt" "zettelstore.de/z/ast" "zettelstore.de/z/input" ) // parseInlineSlice parses a sequence of Inlines until EOS. func (cp *zmkP) parseInlineSlice() (ins ast.InlineSlice) { |
︙ | ︙ | |||
162 163 164 165 166 167 168 | Attrs: attrs, }, true } } return nil, false } | < < < < | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | Attrs: attrs, }, true } } return nil, false } func (cp *zmkP) parseReference(closeCh rune) (ref string, is ast.InlineSlice, ok bool) { inp := cp.inp inp.Next() cp.skipSpace() pos := inp.Pos hasSpace, ok := cp.readReferenceToSep(closeCh) if !ok { |
︙ | ︙ | |||
189 190 191 192 193 194 195 | if in == nil { break } is = append(is, in) } cp.inp = inp inp.Next() | | < | | | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | if in == nil { break } is = append(is, in) } cp.inp = inp inp.Next() } else if hasSpace { return "", nil, false } else { inp.SetPos(pos) } cp.skipSpace() pos = inp.Pos if !cp.readReferenceToClose(closeCh) { return "", nil, false } ref = string(inp.Src[pos:inp.Pos]) inp.Next() if inp.Ch != closeCh { return "", nil, false } inp.Next() if len(is) == 0 { return ref, nil, true |
︙ | ︙ | |||
251 252 253 254 255 256 257 | } inp.Next() } } func (cp *zmkP) readReferenceToClose(closeCh rune) bool { inp := cp.inp | < | < < < < | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | } inp.Next() } } func (cp *zmkP) readReferenceToClose(closeCh rune) bool { inp := cp.inp for { switch inp.Ch { case input.EOS, '\n', '\r', ' ': return false case '\\': inp.Next() switch inp.Ch { case input.EOS, '\n', '\r': return false } case closeCh: |
︙ | ︙ |
Changes to parser/zettelmark/post-processor.go.
︙ | ︙ | |||
355 356 357 358 359 360 361 362 363 364 365 366 367 368 | ast.Walk(pp, in) } pp.processInlineSliceHead(is) toPos := pp.processInlineSliceCopy(is) toPos = pp.processInlineSliceTail(is, toPos) *is = (*is)[:toPos:toPos] } // processInlineSliceHead removes leading spaces and empty text. func (pp *postProcessor) processInlineSliceHead(is *ast.InlineSlice) { ins := *is for i, in := range ins { switch in := in.(type) { | > | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | ast.Walk(pp, in) } pp.processInlineSliceHead(is) toPos := pp.processInlineSliceCopy(is) toPos = pp.processInlineSliceTail(is, toPos) *is = (*is)[:toPos:toPos] pp.processInlineSliceInplace(is) } // processInlineSliceHead removes leading spaces and empty text. func (pp *postProcessor) processInlineSliceHead(is *ast.InlineSlice) { ins := *is for i, in := range ins { switch in := in.(type) { |
︙ | ︙ | |||
470 471 472 473 474 475 476 | return toPos } toPos-- ins[toPos] = nil // Kill node to enable garbage collection } return toPos } | > > > > > > > > > > > > | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | return toPos } toPos-- ins[toPos] = nil // Kill node to enable garbage collection } return toPos } func (*postProcessor) processInlineSliceInplace(is *ast.InlineSlice) { for _, in := range *is { if n, ok := in.(*ast.TextNode); ok { if n.Text == "..." { n.Text = "\u2026" } else if len(n.Text) == 4 && strings.IndexByte(",;:!?", n.Text[3]) >= 0 && n.Text[:3] == "..." { n.Text = "\u2026" + n.Text[3:] } } } } |
Changes to parser/zettelmark/zettelmark_test.go.
︙ | ︙ | |||
82 83 84 85 86 87 88 | {"\\\r\n", ""}, {"\\\r\ndef", "(PARA HB def)"}, {"\\a", "(PARA a)"}, {"\\aa", "(PARA aa)"}, {"a\\a", "(PARA aa)"}, {"\\+", "(PARA +)"}, {"\\ ", "(PARA \u00a0)"}, | > > > > > > > > | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | {"\\\r\n", ""}, {"\\\r\ndef", "(PARA HB def)"}, {"\\a", "(PARA a)"}, {"\\aa", "(PARA aa)"}, {"a\\a", "(PARA aa)"}, {"\\+", "(PARA +)"}, {"\\ ", "(PARA \u00a0)"}, {"...", "(PARA \u2026)"}, {"...,", "(PARA \u2026,)"}, {"...;", "(PARA \u2026;)"}, {"...:", "(PARA \u2026:)"}, {"...!", "(PARA \u2026!)"}, {"...?", "(PARA \u2026?)"}, {"...-", "(PARA ...-)"}, {"a...b", "(PARA a...b)"}, // {"http://a, http://b", "(PARA http://a, SP http://b)"}, }) } func TestSpace(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {" ", ""}, |
︙ | ︙ | |||
160 161 162 163 164 165 166 | {"[[\\]]]", "(PARA (LINK %5C%5D))"}, {"[[\\]|a]]", "(PARA (LINK a ]))"}, {"[[b\\]|a]]", "(PARA (LINK a b]))"}, {"[[\\]\\||a]]", "(PARA (LINK a ]|))"}, {"[[http://a]]", "(PARA (LINK http://a))"}, {"[[http://a|http://a]]", "(PARA (LINK http://a http://a))"}, {"[[[[a]]]]", "(PARA (LINK [[a) ]])"}, | < < < < | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | {"[[\\]]]", "(PARA (LINK %5C%5D))"}, {"[[\\]|a]]", "(PARA (LINK a ]))"}, {"[[b\\]|a]]", "(PARA (LINK a b]))"}, {"[[\\]\\||a]]", "(PARA (LINK a ]|))"}, {"[[http://a]]", "(PARA (LINK http://a))"}, {"[[http://a|http://a]]", "(PARA (LINK http://a http://a))"}, {"[[[[a]]]]", "(PARA (LINK [[a) ]])"}, }) } func TestCite(t *testing.T) { t.Parallel() checkTcs(t, TestCases{ {"[@", "(PARA [@)"}, |
︙ | ︙ |
Deleted search/parser.go.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted search/parser_test.go.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to search/print.go.
1 | //----------------------------------------------------------------------------- | | | | 1 2 3 4 5 6 7 8 9 10 11 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2021 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- // Package search provides a zettel search. |
︙ | ︙ | |||
22 23 24 25 26 27 28 | func (s *Search) String() string { var sb strings.Builder s.Print(&sb) return sb.String() } | | < | < > > | > < < < < < < | < | < | | < | < < < < < | | < < < < < < | | > | < < < < < < < < < < < < < < | < < < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | | | | | | | | | | | | | > | > > | | | | > > > | | > > | > | > | | | > > | | < | | > | | | < < < > | 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | func (s *Search) String() string { var sb strings.Builder s.Print(&sb) return sb.String() } // Print the search to a writer. func (s *Search) Print(w io.Writer) { if s == nil { return } if s.negate { io.WriteString(w, "NOT (") } space := false if len(s.search) > 0 { io.WriteString(w, "ANY") printSelectExprValues(w, s.search) space = true } for _, name := range maps.Keys(s.mvals) { if space { io.WriteString(w, " AND ") } io.WriteString(w, name) printSelectExprValues(w, s.mvals[name]) space = true } if s.negate { io.WriteString(w, ")") space = true } space = printOrder(w, s.order, s.descending, space) space = printPosInt(w, "OFFSET", s.offset, space) _ = printPosInt(w, "LIMIT", s.limit, space) } func printSelectExprValues(w io.Writer, values []expValue) { if len(values) == 0 { io.WriteString(w, " MATCH ANY") return } for j, val := range values { if j > 0 { io.WriteString(w, " AND") } if val.negate { io.WriteString(w, " NOT") } switch val.op { case cmpDefault: io.WriteString(w, " MATCH ") case cmpEqual: io.WriteString(w, " EQUAL ") case cmpPrefix: io.WriteString(w, " PREFIX ") case cmpSuffix: io.WriteString(w, " SUFFIX ") case cmpContains: io.WriteString(w, " CONTAINS ") default: io.WriteString(w, " MaTcH ") } if val.value == "" { io.WriteString(w, "ANY") } else { io.WriteString(w, val.value) } } } func printOrder(w io.Writer, order string, descending, withSpace bool) bool { if len(order) > 0 { switch order { case api.KeyID: // Ignore case RandomOrder: withSpace = printSpace(w, withSpace) io.WriteString(w, "RANDOM") default: withSpace = printSpace(w, withSpace) io.WriteString(w, "SORT ") io.WriteString(w, order) if descending { io.WriteString(w, " DESC") } } } return withSpace } func printPosInt(w io.Writer, key string, val int, space bool) bool { if val > 0 { space = printSpace(w, space) io.WriteString(w, key) w.Write(bsSpace) io.WriteString(w, strconv.Itoa(val)) } return space } var bsSpace = []byte{' '} func printSpace(w io.Writer, space bool) bool { if space { w.Write(bsSpace) } return true } |
Changes to search/search.go.
︙ | ︙ | |||
8 9 10 11 12 13 14 | // under this license. //----------------------------------------------------------------------------- // Package search provides a zettel search. package search import ( | < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // under this license. //----------------------------------------------------------------------------- // Package search provides a zettel search. package search import ( "math/rand" "sort" "strings" "sync" "zettelstore.de/c/api" "zettelstore.de/z/domain/id" |
︙ | ︙ | |||
58 59 60 61 62 63 64 | // Fields to be used for selecting preMatch MetaMatchFunc // Match that must be true mvals expMetaValues // Expected values for a meta datum search []expValue // Search string negate bool // Negate the result of the whole selecting process // Fields to be used for sorting | | > | | < < < < < < < < < < < < < < | > | 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 84 85 86 87 88 89 90 91 92 93 | // Fields to be used for selecting preMatch MetaMatchFunc // Match that must be true mvals expMetaValues // Expected values for a meta datum search []expValue // Search string negate bool // Negate the result of the whole selecting process // Fields to be used for sorting order string // Name of meta key. None given: use "id" descending bool // Sort by order, but descending offset int // <= 0: no offset limit int // <= 0: no limit } type expMetaValues map[string][]expValue // Clone the search value. func (s *Search) Clone() *Search { if s == nil { return nil } c := new(Search) c.preMatch = s.preMatch c.mvals = make(expMetaValues, len(s.mvals)) for k, v := range s.mvals { c.mvals[k] = v } c.search = append([]expValue{}, s.search...) c.negate = s.negate c.order = s.order c.descending = s.descending c.offset = s.offset c.limit = s.limit return c } // RandomOrder is a pseudo metadata key that selects a random order. const RandomOrder = "_random" |
︙ | ︙ | |||
149 150 151 152 153 154 155 | func (s *Search) AddExpr(key, value string) *Search { val := parseOp(strings.TrimSpace(value)) if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() | < < < < < > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | func (s *Search) AddExpr(key, value string) *Search { val := parseOp(strings.TrimSpace(value)) if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() if key == "" { s.addSearch(val) } else if s.mvals == nil { s.mvals = expMetaValues{key: {val}} } else { s.mvals[key] = append(s.mvals[key], val) } return s } func (s *Search) addSearch(val expValue) { if val.negate { val.op = val.op.negate() val.negate = false } |
︙ | ︙ | |||
216 217 218 219 220 221 222 | return expValue{value: s[1:], op: cmpContains, negate: negate} } return expValue{value: s, op: cmpDefault, negate: negate} } // SetNegate changes the search to reverse its selection. func (s *Search) SetNegate() *Search { | > | > > | > > | > | | < | < | < > | > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | return expValue{value: s[1:], op: cmpContains, negate: negate} } return expValue{value: s, op: cmpDefault, negate: negate} } // SetNegate changes the search to reverse its selection. func (s *Search) SetNegate() *Search { if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() s.negate = true return s } // AddPreMatch adds the pre-selection predicate. func (s *Search) AddPreMatch(preMatch MetaMatchFunc) *Search { if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() if pre := s.preMatch; pre == nil { s.preMatch = preMatch } else { s.preMatch = func(m *meta.Meta) bool { return preMatch(m) && pre(m) } } return s } // AddOrder adds the given order to the search object. func (s *Search) AddOrder(key string, descending bool) *Search { if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() if s.order != "" { panic("order field already set: " + s.order) } s.order = key s.descending = descending return s } // SetOffset sets the given offset of the search object. func (s *Search) SetOffset(offset int) *Search { if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() if offset < 0 { offset = 0 } s.offset = offset return s |
︙ | ︙ | |||
278 279 280 281 282 283 284 | s.mx.RLock() defer s.mx.RUnlock() return s.offset } // SetLimit sets the given limit of the search object. func (s *Search) SetLimit(limit int) *Search { | > | > | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | s.mx.RLock() defer s.mx.RUnlock() return s.offset } // SetLimit sets the given limit of the search object. func (s *Search) SetLimit(limit int) *Search { if s == nil { s = new(Search) } s.mx.Lock() defer s.mx.Unlock() if limit < 0 { limit = 0 } s.limit = limit return s |
︙ | ︙ | |||
311 312 313 314 315 316 317 | s.mx.RLock() defer s.mx.RUnlock() for key := range s.mvals { if meta.IsComputed(key) { return true } } | < | < < < < | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | s.mx.RLock() defer s.mx.RUnlock() for key := range s.mvals { if meta.IsComputed(key) { return true } } return meta.IsComputed(s.order) } // RetrieveAndCompileMatch queries the search index and returns a predicate // for its results and returns a matching predicate. func (s *Search) RetrieveAndCompileMatch(searcher Searcher) (RetrievePredicate, MetaMatchFunc) { if s == nil { return alwaysIncluded, matchAlways |
︙ | ︙ | |||
422 423 424 425 426 427 428 | } if s == nil { sort.Slice(metaList, func(i, j int) bool { return metaList[i].Zid > metaList[j].Zid }) return metaList } | | | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | } if s == nil { sort.Slice(metaList, func(i, j int) bool { return metaList[i].Zid > metaList[j].Zid }) return metaList } if s.order == "" { sort.Slice(metaList, createSortFunc(api.KeyID, true, metaList)) } else if s.order == RandomOrder { rand.Shuffle(len(metaList), func(i, j int) { metaList[i], metaList[j] = metaList[j], metaList[i] }) } else { sort.Slice(metaList, createSortFunc(s.order, s.descending, metaList)) } if s.offset > 0 { if s.offset > len(metaList) { return nil } metaList = metaList[s.offset:] |
︙ | ︙ |
Changes to template/mustache.go.
︙ | ︙ | |||
125 126 127 128 129 130 131 | } type parseError struct { line int message string } | | > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | } type parseError struct { line int message string } func (p parseError) Error() string { return fmt.Sprintf("line %d: %s", p.line, p.message) } // Tags returns the mustache tags for the given template func (tmpl *Template) Tags() []Tag { return extractTags(tmpl.nodes) } func extractTags(nodes []node) []Tag { |
︙ | ︙ |
Changes to tests/client/client_test.go.
︙ | ︙ | |||
70 71 72 73 74 75 76 | t.Parallel() c := getClient() query := url.Values{api.QueryKeyEncoding: {api.EncodingHTML}} // Client must remove "html" for i, tc := range testdata { t.Run(fmt.Sprintf("User %d/%q", i, tc.user), func(tt *testing.T) { c.SetAuth(tc.user, tc.user) | | < < < | | < < < < | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | t.Parallel() c := getClient() query := url.Values{api.QueryKeyEncoding: {api.EncodingHTML}} // Client must remove "html" for i, tc := range testdata { t.Run(fmt.Sprintf("User %d/%q", i, tc.user), func(tt *testing.T) { c.SetAuth(tc.user, tc.user) q, l, err := c.ListZettelJSON(context.Background(), query) if err != nil { tt.Error(err) return } if q != "" { tt.Errorf("Query should be empty, but is %q", q) } got := len(l) if got != tc.exp { tt.Errorf("List of length %d expected, but got %d\n%v", tc.exp, got, l) } }) } q, l, err := c.ListZettelJSON(context.Background(), url.Values{api.KeyRole: {api.ValueRoleConfiguration}}) if err != nil { t.Error(err) return } expQ := "role MATCH configuration" if q != expQ { t.Errorf("Query should be %q, but is %q", expQ, q) } got := len(l) if got != configRoleZettel { t.Errorf("List of length %d expected, but got %d\n%v", configRoleZettel, got, l) } pl, err := c.ListZettel(context.Background(), url.Values{api.KeyRole: {api.ValueRoleConfiguration}}) if err != nil { |
︙ | ︙ |
Changes to tests/client/embed_test.go.
︙ | ︙ | |||
65 66 67 68 69 70 71 | } content, err = c.GetEvaluatedZettel(context.Background(), abc10000Zid, api.EncoderHTML) if err != nil { t.Error(err) return } | | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | } content, err = c.GetEvaluatedZettel(context.Background(), abc10000Zid, api.EncoderHTML) if err != nil { t.Error(err) return } checkContentContains(t, abc10000Zid, string(content), "Too\u00a0many\u00a0transclusions") } func TestZettelTransclusionNoPrivilegeEscalation(t *testing.T) { t.Parallel() c := getClient() c.SetAuth("reader", "reader") |
︙ | ︙ | |||
88 89 90 91 92 93 94 | } content, err := c.GetEvaluatedZettel(context.Background(), abc10Zid, api.EncoderHTML) if err != nil { t.Error(err) return } | | < < | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | } content, err := c.GetEvaluatedZettel(context.Background(), abc10Zid, api.EncoderHTML) if err != nil { t.Error(err) return } checkContentContains(t, abc10Zid, string(content), "Error placeholder") } func stringHead(s string) string { const maxLen = 40 if len(s) <= maxLen { return s } |
︙ | ︙ | |||
131 132 133 134 135 136 137 | for zid, errZid := range recursiveZettel { content, err := c.GetEvaluatedZettel(context.Background(), zid, api.EncoderHTML) if err != nil { t.Error(err) continue } sContent := string(content) | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | for zid, errZid := range recursiveZettel { content, err := c.GetEvaluatedZettel(context.Background(), zid, api.EncoderHTML) if err != nil { t.Error(err) continue } sContent := string(content) checkContentContains(t, zid, sContent, "Recursive\u00a0transclusion") checkContentContains(t, zid, sContent, string(errZid)) } } func TestNothingToTransclude(t *testing.T) { t.Parallel() c := getClient() c.SetAuth("owner", "owner") |
︙ | ︙ | |||
165 166 167 168 169 170 171 | const selfEmbedZid = api.ZettelID("20211020185400") content, err := c.GetEvaluatedZettel(context.Background(), selfEmbedZid, api.EncoderHTML) if err != nil { t.Error(err) return } | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | const selfEmbedZid = api.ZettelID("20211020185400") content, err := c.GetEvaluatedZettel(context.Background(), selfEmbedZid, api.EncoderHTML) if err != nil { t.Error(err) return } checkContentContains(t, selfEmbedZid, string(content), "Self\u00a0embed\u00a0reference") } func checkContentContains(t *testing.T, zid api.ZettelID, content, expected string) { if !strings.Contains(content, expected) { t.Helper() t.Errorf("Zettel %q should contain %q, but does not: %q", zid, expected, content) } } |
Changes to usecase/authenticate.go.
1 2 3 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package usecase import ( "context" "math/rand" "time" "zettelstore.de/c/api" "zettelstore.de/z/auth" "zettelstore.de/z/auth/cred" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" |
︙ | ︙ | |||
46 47 48 49 50 51 52 | token: token, port: port, ucGetUser: NewGetUser(authz, port), } } // Run executes the use case. | < < < | | | | | 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 84 | token: token, port: port, ucGetUser: NewGetUser(authz, port), } } // Run executes the use case. func (uc *Authenticate) Run(ctx context.Context, ident, credential string, d time.Duration, k auth.TokenKind) ([]byte, error) { identMeta, err := uc.ucGetUser.Run(ctx, ident) defer addDelay(time.Now(), 500*time.Millisecond, 100*time.Millisecond) if identMeta == nil || err != nil { uc.log.Info().Str("ident", ident).Err(err).Msg("No user with given ident found") compensateCompare() return nil, err } if hashCred, ok := identMeta.Get(api.KeyCredential); ok { ok, err = cred.CompareHashAndCredential(hashCred, identMeta.Zid, ident, credential) if err != nil { uc.log.Info().Str("ident", ident).Err(err).Msg("Error while comparing credentials") return nil, err } if ok { token, err2 := uc.token.GetToken(identMeta, d, k) if err2 != nil { uc.log.Info().Str("ident", ident).Err(err).Msg("Unable to produce authentication token") return nil, err2 } uc.log.Info().Str("user", ident).Msg("Successful") return token, nil } uc.log.Info().Str("ident", ident).Msg("Credentials don't match") return nil, nil } uc.log.Info().Str("ident", ident).Msg("No credential stored") compensateCompare() return nil, nil } |
︙ | ︙ |
Changes to usecase/evaluate.go.
︙ | ︙ | |||
16 17 18 19 20 21 22 | "zettelstore.de/z/ast" "zettelstore.de/z/config" "zettelstore.de/z/domain" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" "zettelstore.de/z/evaluator" "zettelstore.de/z/parser" | < < | < | 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 | "zettelstore.de/z/ast" "zettelstore.de/z/config" "zettelstore.de/z/domain" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" "zettelstore.de/z/evaluator" "zettelstore.de/z/parser" ) // Evaluate is the data for this use case. type Evaluate struct { rtConfig config.Config getZettel GetZettel getMeta GetMeta } // NewEvaluate creates a new use case. func NewEvaluate(rtConfig config.Config, getZettel GetZettel, getMeta GetMeta) Evaluate { return Evaluate{ rtConfig: rtConfig, getZettel: getZettel, getMeta: getMeta, } } // Run executes the use case. func (uc *Evaluate) Run(ctx context.Context, zid id.Zid, syntax string) (*ast.ZettelNode, error) { zettel, err := uc.getZettel.Run(ctx, zid) if err != nil { |
︙ | ︙ | |||
59 60 61 62 63 64 65 | // RunMetadata executes the use case for a metadata value. func (uc *Evaluate) RunMetadata(ctx context.Context, value string) ast.InlineSlice { is := parser.ParseMetadata(value) evaluator.EvaluateInline(ctx, uc, uc.rtConfig, &is) return is } | < < < < < < < < < < < < | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | // RunMetadata executes the use case for a metadata value. func (uc *Evaluate) RunMetadata(ctx context.Context, value string) ast.InlineSlice { is := parser.ParseMetadata(value) evaluator.EvaluateInline(ctx, uc, uc.rtConfig, &is) return is } // GetMeta retrieves the metadata of a given zettel identifier. func (uc *Evaluate) GetMeta(ctx context.Context, zid id.Zid) (*meta.Meta, error) { return uc.getMeta.Run(ctx, zid) } // GetZettel retrieves the full zettel of a given zettel identifier. func (uc *Evaluate) GetZettel(ctx context.Context, zid id.Zid) (domain.Zettel, error) { return uc.getZettel.Run(ctx, zid) } |
Changes to web/adapter/api/get_parsed_zettel.go.
︙ | ︙ | |||
49 50 51 52 53 54 55 | func (a *API) writeEncodedZettelPart( w http.ResponseWriter, zn *ast.ZettelNode, evalMeta encoder.EvalMetaFunc, enc api.EncodingEnum, encStr string, part partType, ) { encdr := encoder.Create(enc) if encdr == nil { | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | func (a *API) writeEncodedZettelPart( w http.ResponseWriter, zn *ast.ZettelNode, evalMeta encoder.EvalMetaFunc, enc api.EncodingEnum, encStr string, part partType, ) { encdr := encoder.Create(enc) if encdr == nil { adapter.BadRequest(w, fmt.Sprintf("Zettel %q not available in encoding %q", zn.Meta.Zid.String(), encStr)) return } var err error var buf bytes.Buffer switch part { case partZettel: _, err = encdr.WriteZettel(&buf, zn, evalMeta) |
︙ | ︙ |
Changes to web/adapter/api/get_zettel_list.go.
︙ | ︙ | |||
41 42 43 44 45 46 47 | Rights: a.getRights(ctx, m), }) } var buf bytes.Buffer err = encodeJSONData(&buf, api.ZettelListJSON{ Query: s.String(), | < | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | Rights: a.getRights(ctx, m), }) } var buf bytes.Buffer err = encodeJSONData(&buf, api.ZettelListJSON{ Query: s.String(), List: result, }) if err != nil { a.log.Fatal().Err(err).Msg("Unable to store meta list in buffer") http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } |
︙ | ︙ |
Changes to web/adapter/api/login.go.
1 2 3 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // | | | 1 2 3 4 5 6 7 8 9 10 11 | //----------------------------------------------------------------------------- // Copyright (c) 2020-2022 Detlef Stern // // This file is part of zettelstore. // // Zettelstore is licensed under the latest version of the EUPL (European Union // Public License). Please see file LICENSE.txt for your rights and obligations // under this license. //----------------------------------------------------------------------------- package api |
︙ | ︙ | |||
29 30 31 32 33 34 35 | err := a.writeJSONToken(w, "freeaccess", 24*366*10*time.Hour) a.log.IfErr(err).Msg("Login/free") return } var token []byte if ident, cred := retrieveIdentCred(r); ident != "" { var err error | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | err := a.writeJSONToken(w, "freeaccess", 24*366*10*time.Hour) a.log.IfErr(err).Msg("Login/free") return } var token []byte if ident, cred := retrieveIdentCred(r); ident != "" { var err error token, err = ucAuth.Run(r.Context(), ident, cred, a.tokenLifetime, auth.KindJSON) if err != nil { a.reportUsecaseError(w, err) return } } if len(token) == 0 { w.Header().Set("WWW-Authenticate", `Bearer realm="Default"`) |
︙ | ︙ |
Changes to web/adapter/request.go.
︙ | ︙ | |||
48 49 50 51 52 53 54 | } } return 0, false } // GetSearch retrieves the specified search and sorting options from a query. func GetSearch(q url.Values) (s *search.Search) { | < < < | > | 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 | } } return 0, false } // GetSearch retrieves the specified search and sorting options from a query. func GetSearch(q url.Values) (s *search.Search) { for key, values := range q { switch key { case api.QueryKeySort, api.QueryKeyOrder: s = extractOrderFromQuery(values, s) case api.QueryKeyOffset: s = extractOffsetFromQuery(values, s) case api.QueryKeyLimit: s = extractLimitFromQuery(values, s) case api.QueryKeyNegate: s = s.SetNegate() case api.QueryKeySearch: s = setCleanedQueryValues(s, "", values) default: if meta.KeyIsValid(key) { s = setCleanedQueryValues(s, key, values) } } } return s |
︙ | ︙ |
Changes to web/adapter/webui/create_zettel.go.
︙ | ︙ | |||
55 56 57 58 59 60 61 | m := origZettel.Meta title := parser.ParseMetadata(m.GetTitle()) textTitle, err2 := encodeInlinesText(&title, wui.gentext) if err2 != nil { wui.reportError(ctx, w, err2) return } | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | m := origZettel.Meta title := parser.ParseMetadata(m.GetTitle()) textTitle, err2 := encodeInlinesText(&title, wui.gentext) if err2 != nil { wui.reportError(ctx, w, err2) return } htmlTitle, err2 := wui.getSimpleHTMLEncoder().InlinesString(&title, false) if err2 != nil { wui.reportError(ctx, w, err2) return } wui.renderZettelForm(ctx, w, createZettel.PrepareNew(origZettel), textTitle, htmlTitle, roleData, syntaxData) } } |
︙ | ︙ |
Changes to web/adapter/webui/get_info.go.
︙ | ︙ | |||
74 75 76 77 78 79 80 | func(val string) ast.InlineSlice { return evaluate.RunMetadata(ctx, val) }, enc) metaData[i] = metaDataInfo{p.Key, buf.String()} } summary := collect.References(zn) | | < < < < < | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | func(val string) ast.InlineSlice { return evaluate.RunMetadata(ctx, val) }, enc) metaData[i] = metaDataInfo{p.Key, buf.String()} } summary := collect.References(zn) locLinks, extLinks := splitLocExtLinks(append(summary.Links, summary.Embeds...)) textTitle := wui.encodeTitleAsText(ctx, zn.InhMeta, evaluate) phrase := q.Get(api.QueryKeyPhrase) if phrase == "" { phrase = textTitle } phrase = strings.TrimSpace(phrase) unlinkedMeta, err := unlinkedRefs.Run( ctx, phrase, adapter.AddUnlinkedRefsToSearch(nil, zn.InhMeta)) if err != nil { wui.reportError(ctx, w, err) return } unLinks := wui.buildHTMLMetaList(ctx, unlinkedMeta, evaluate) shadowLinks := getShadowLinks(ctx, zid, getAllMeta) endnotes, err := enc.BlocksString(&ast.BlockSlice{}) if err != nil { endnotes = "" } |
︙ | ︙ | |||
123 124 125 126 127 128 129 | CanRename bool RenameURL string CanDelete bool DeleteURL string MetaData []metaDataInfo HasLocLinks bool LocLinks []localLink | < < | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | CanRename bool RenameURL string CanDelete bool DeleteURL string MetaData []metaDataInfo HasLocLinks bool LocLinks []localLink HasExtLinks bool ExtLinks []string ExtNewWindow string UnLinks []simpleLink UnLinksPhrase string QueryKeyPhrase string EvalMatrix []matrixLine |
︙ | ︙ | |||
153 154 155 156 157 158 159 | CanRename: wui.canRename(ctx, user, zn.Meta), RenameURL: wui.NewURLBuilder('b').SetZid(apiZid).String(), CanDelete: wui.canDelete(ctx, user, zn.Meta), DeleteURL: wui.NewURLBuilder('d').SetZid(apiZid).String(), MetaData: metaData, HasLocLinks: len(locLinks) > 0, LocLinks: locLinks, | < < | | | | < | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | CanRename: wui.canRename(ctx, user, zn.Meta), RenameURL: wui.NewURLBuilder('b').SetZid(apiZid).String(), CanDelete: wui.canDelete(ctx, user, zn.Meta), DeleteURL: wui.NewURLBuilder('d').SetZid(apiZid).String(), MetaData: metaData, HasLocLinks: len(locLinks) > 0, LocLinks: locLinks, HasExtLinks: len(extLinks) > 0, ExtLinks: extLinks, ExtNewWindow: htmlAttrNewWindow(len(extLinks) > 0), UnLinks: unLinks, UnLinksPhrase: phrase, QueryKeyPhrase: api.QueryKeyPhrase, EvalMatrix: wui.infoAPIMatrix('v', zid), ParseMatrix: wui.infoAPIMatrixPlain('p', zid), HasShadowLinks: len(shadowLinks) > 0, ShadowLinks: shadowLinks, Endnotes: endnotes, }) } } type localLink struct { Valid bool Zid string } func splitLocExtLinks(links []*ast.Reference) (locLinks []localLink, extLinks []string) { if len(links) == 0 { return nil, nil } for _, ref := range links { if ref.State == ast.RefStateSelf { continue } if ref.IsZettel() { continue } if ref.IsExternal() { extLinks = append(extLinks, ref.String()) continue } locLinks = append(locLinks, localLink{ref.IsValid(), ref.String()}) } return locLinks, extLinks } func (wui *WebUI) infoAPIMatrix(key byte, zid id.Zid) []matrixLine { encodings := encoder.GetEncodings() encTexts := make([]string, 0, len(encodings)) for _, f := range encodings { encTexts = append(encTexts, f.String()) |
︙ | ︙ |
Changes to web/adapter/webui/get_zettel.go.
︙ | ︙ | |||
39 40 41 42 43 44 45 | if err != nil { wui.reportError(ctx, w, err) return } enc := wui.createZettelEncoder() | | | < | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | if err != nil { wui.reportError(ctx, w, err) return } enc := wui.createZettelEncoder() metaHeader := enc.MetaString(zn.InhMeta, func(value string) ast.InlineSlice { return evaluate.RunMetadata(ctx, value) }) textTitle := wui.encodeTitleAsText(ctx, zn.InhMeta, evaluate) htmlTitle := encodeTitleAsHTML(ctx, zn.InhMeta, evaluate, enc, false) htmlContent, err := enc.BlocksString(&zn.Ast) if err != nil { wui.reportError(ctx, w, err) return } var roleCSSURL string cssZid, err := wui.retrieveCSSZidFromRole(ctx, *zn.InhMeta) |
︙ | ︙ |
Changes to web/adapter/webui/htmlgen.go.
︙ | ︙ | |||
19 20 21 22 23 24 25 | "zettelstore.de/c/html" "zettelstore.de/c/sexpr" "zettelstore.de/z/ast" "zettelstore.de/z/domain/meta" "zettelstore.de/z/encoder" "zettelstore.de/z/encoder/sexprenc" "zettelstore.de/z/encoder/textenc" | < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | "zettelstore.de/c/html" "zettelstore.de/c/sexpr" "zettelstore.de/z/ast" "zettelstore.de/z/domain/meta" "zettelstore.de/z/encoder" "zettelstore.de/z/encoder/sexprenc" "zettelstore.de/z/encoder/textenc" "zettelstore.de/z/strfun" ) // Builder allows to build new URLs for the web service. type urlBuilder interface { GetURLPrefix() string NewURLBuilder(key byte) *api.URLBuilder |
︙ | ︙ | |||
51 52 53 54 55 56 57 | env: env, } env.Builtins.Set(sexpr.SymTag, sxpf.NewBuiltin("tag", true, 0, -1, gen.generateTag)) env.Builtins.Set(sexpr.SymLinkZettel, sxpf.NewBuiltin("linkZ", true, 2, -1, gen.generateLinkZettel)) env.Builtins.Set(sexpr.SymLinkFound, sxpf.NewBuiltin("linkZ", true, 2, -1, gen.generateLinkZettel)) env.Builtins.Set(sexpr.SymLinkBased, sxpf.NewBuiltin("linkB", true, 2, -1, gen.generateLinkBased)) | < | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | env: env, } env.Builtins.Set(sexpr.SymTag, sxpf.NewBuiltin("tag", true, 0, -1, gen.generateTag)) env.Builtins.Set(sexpr.SymLinkZettel, sxpf.NewBuiltin("linkZ", true, 2, -1, gen.generateLinkZettel)) env.Builtins.Set(sexpr.SymLinkFound, sxpf.NewBuiltin("linkZ", true, 2, -1, gen.generateLinkZettel)) env.Builtins.Set(sexpr.SymLinkBased, sxpf.NewBuiltin("linkB", true, 2, -1, gen.generateLinkBased)) env.Builtins.Set(sexpr.SymLinkExternal, sxpf.NewBuiltin("linkE", true, 2, -1, gen.generateLinkExternal)) f, err := env.Builtins.LookupForm(sexpr.SymEmbed) if err != nil { panic(err) } b := f.(*sxpf.Builtin) |
︙ | ︙ | |||
130 131 132 133 134 135 136 | g.env.WriteEndnotes() } g.env.ReplaceWriter(nil) return buf.String(), g.env.GetError() } // InlinesString writes an inline slice to the writer | | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | g.env.WriteEndnotes() } g.env.ReplaceWriter(nil) return buf.String(), g.env.GetError() } // InlinesString writes an inline slice to the writer func (g *htmlGenerator) InlinesString(is *ast.InlineSlice, noLink bool) (string, error) { if is == nil || len(*is) == 0 { return "", nil } return html.EvaluateInline(g.env, sexprenc.GetSexpr(is), !noLink, noLink), nil } func (g *htmlGenerator) generateTag(senv sxpf.Environment, args *sxpf.Pair, _ int) (sxpf.Value, error) { if !sxpf.IsNil(args) { env := senv.(*html.EncEnvironment) s := env.GetString(args) if env.IgnoreLinks() { |
︙ | ︙ | |||
170 171 172 173 174 175 176 | return nil, nil } func (g *htmlGenerator) generateLinkBased(senv sxpf.Environment, args *sxpf.Pair, _ int) (sxpf.Value, error) { env := senv.(*html.EncEnvironment) if a, refValue, ok := html.PrepareLink(env, args); ok { u := g.builder.NewURLBuilder('/').SetRawLocal(refValue) | < < < < < < < < < < | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | return nil, nil } func (g *htmlGenerator) generateLinkBased(senv sxpf.Environment, args *sxpf.Pair, _ int) (sxpf.Value, error) { env := senv.(*html.EncEnvironment) if a, refValue, ok := html.PrepareLink(env, args); ok { u := g.builder.NewURLBuilder('/').SetRawLocal(refValue) html.WriteLink(env, args, a.Set("href", u.String()), refValue, "") } return nil, nil } func (g *htmlGenerator) generateLinkExternal(senv sxpf.Environment, args *sxpf.Pair, _ int) (sxpf.Value, error) { env := senv.(*html.EncEnvironment) |
︙ | ︙ |
Changes to web/adapter/webui/htmlmeta.go.
︙ | ︙ | |||
60 61 62 63 64 65 66 | case meta.TypeURL: writeURL(w, value) case meta.TypeWord: wui.writeWord(w, key, value) case meta.TypeWordSet: wui.writeWordSet(w, key, meta.ListFromValue(value)) case meta.TypeZettelmarkup: | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | case meta.TypeURL: writeURL(w, value) case meta.TypeWord: wui.writeWord(w, key, value) case meta.TypeWordSet: wui.writeWordSet(w, key, meta.ListFromValue(value)) case meta.TypeZettelmarkup: io.WriteString(w, encodeZmkMetadata(value, evalMetadata, gen, false)) default: html.Escape(w, value) fmt.Fprintf(w, " <b>(Unhandled type: %v, key: %v)</b>", kt, key) } } func writeCredential(w io.Writer, val string) { html.Escape(w, val) } |
︙ | ︙ | |||
167 168 169 170 171 172 173 174 175 | return "", -1 } return "", 0 } return wui.encodeTitleAsText(ctx, m, evaluate), 1 } } func (wui *WebUI) encodeTitleAsText(ctx context.Context, m *meta.Meta, evaluate *usecase.Evaluate) string { | > > > > > > > > > > > > > | | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | return "", -1 } return "", 0 } return wui.encodeTitleAsText(ctx, m, evaluate), 1 } } func encodeTitleAsHTML( ctx context.Context, m *meta.Meta, evaluate *usecase.Evaluate, gen *htmlGenerator, noLink bool, ) string { plainTitle := m.GetTitle() return encodeZmkMetadata( plainTitle, func(val string) ast.InlineSlice { return evaluate.RunMetadata(ctx, val) }, gen, noLink) } func (wui *WebUI) encodeTitleAsText(ctx context.Context, m *meta.Meta, evaluate *usecase.Evaluate) string { plainTitle := m.GetTitle() is := evaluate.RunMetadata(ctx, plainTitle) result, err := encodeInlinesText(&is, wui.gentext) if err != nil { return err.Error() } return result } func encodeZmkMetadata(value string, evalMetadata evalMetadataFunc, gen *htmlGenerator, noLink bool) string { is := evalMetadata(value) result, err := gen.InlinesString(&is, noLink) if err != nil { return err.Error() } return result } |
Changes to web/adapter/webui/lists.go.
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 | // under this license. //----------------------------------------------------------------------------- package webui import ( "bytes" "net/http" "net/url" "sort" "strconv" "zettelstore.de/c/api" | > < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // under this license. //----------------------------------------------------------------------------- package webui import ( "bytes" "context" "net/http" "net/url" "sort" "strconv" "zettelstore.de/c/api" "zettelstore.de/z/box" "zettelstore.de/z/domain/id" "zettelstore.de/z/domain/meta" "zettelstore.de/z/search" "zettelstore.de/z/usecase" "zettelstore.de/z/web/adapter" ) |
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | func (wui *WebUI) renderZettelList( w http.ResponseWriter, r *http.Request, listMeta usecase.ListMeta, evaluate *usecase.Evaluate, ) { query := r.URL.Query() s := adapter.GetSearch(query) ctx := r.Context() if !s.EnrichNeeded() { ctx = box.NoEnrichContext(ctx) } metaList, err := listMeta.Run(ctx, s) if err != nil { wui.reportError(ctx, w, err) return } user := wui.getUser(ctx) | > > | < | < < | | < < < | | 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 84 | func (wui *WebUI) renderZettelList( w http.ResponseWriter, r *http.Request, listMeta usecase.ListMeta, evaluate *usecase.Evaluate, ) { query := r.URL.Query() s := adapter.GetSearch(query) ctx := r.Context() title := wui.listTitleSearch(s) if !s.EnrichNeeded() { ctx = box.NoEnrichContext(ctx) } metaList, err := listMeta.Run(ctx, s) if err != nil { wui.reportError(ctx, w, err) return } user := wui.getUser(ctx) metas := wui.buildHTMLMetaList(ctx, metaList, evaluate) var base baseData wui.makeBaseData(ctx, wui.rtConfig.GetDefaultLang(), wui.rtConfig.GetSiteName(), "", user, &base) wui.renderTemplate(ctx, w, id.ListTemplateZid, &base, struct { Title string Metas []simpleLink }{ Title: title, Metas: metas, }) } type roleInfo struct { Text string URL string } |
︙ | ︙ | |||
201 202 203 204 205 206 207 | limit := getIntParameter(q, api.QueryKeyLimit, 200) metaList, err := getContext.Run(ctx, zid, dir, depth, limit) if err != nil { wui.reportError(ctx, w, err) return } apiZid := api.ZettelID(zid.String()) | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | limit := getIntParameter(q, api.QueryKeyLimit, 200) metaList, err := getContext.Run(ctx, zid, dir, depth, limit) if err != nil { wui.reportError(ctx, w, err) return } apiZid := api.ZettelID(zid.String()) metaLinks := wui.buildHTMLMetaList(ctx, metaList, evaluate) depths := []string{"2", "3", "4", "5", "6", "7", "8", "9", "10"} depthLinks := make([]simpleLink, len(depths)) depthURL := wui.NewURLBuilder('k').SetZid(apiZid) for i, depth := range depths { depthURL.ClearQuery() switch dir { case usecase.ZettelContextBackward: |
︙ | ︙ | |||
249 250 251 252 253 254 255 | } func (wui *WebUI) listTitleSearch(s *search.Search) string { if s == nil { return wui.rtConfig.GetSiteName() } var buf bytes.Buffer | | | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | } func (wui *WebUI) listTitleSearch(s *search.Search) string { if s == nil { return wui.rtConfig.GetSiteName() } var buf bytes.Buffer s.Print(&buf) return buf.String() } // buildHTMLMetaList builds a zettel list based on a meta list for HTML rendering. func (wui *WebUI) buildHTMLMetaList(ctx context.Context, metaList []*meta.Meta, evaluate *usecase.Evaluate) []simpleLink { metas := make([]simpleLink, 0, len(metaList)) encHTML := wui.getSimpleHTMLEncoder() for _, m := range metaList { metas = append(metas, simpleLink{ Text: encodeTitleAsHTML(ctx, m, evaluate, encHTML, true), URL: wui.NewURLBuilder('h').SetZid(api.ZettelID(m.Zid.String())).String(), }) } return metas } |
Changes to web/adapter/webui/login.go.
︙ | ︙ | |||
55 56 57 58 59 60 61 | } ctx := r.Context() ident, cred, ok := adapter.GetCredentialsViaForm(r) if !ok { wui.reportError(ctx, w, adapter.NewErrBadRequest("Unable to read login form")) return } | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | } ctx := r.Context() ident, cred, ok := adapter.GetCredentialsViaForm(r) if !ok { wui.reportError(ctx, w, adapter.NewErrBadRequest("Unable to read login form")) return } token, err := ucAuth.Run(ctx, ident, cred, wui.tokenLifetime, auth.KindHTML) if err != nil { wui.reportError(ctx, w, err) return } if token == nil { wui.renderLoginForm(wui.clearToken(ctx, w), w, true) return |
︙ | ︙ |
Changes to web/adapter/webui/webui.go.
︙ | ︙ | |||
332 333 334 335 336 337 338 | if err2 != nil { continue } if !wui.policy.CanRead(user, m) { continue } title := m.GetTitle() | | | | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | if err2 != nil { continue } if !wui.policy.CanRead(user, m) { continue } title := m.GetTitle() astTitle := parser.ParseMetadata(title) menuTitle, err2 := wui.getSimpleHTMLEncoder().InlinesString(&astTitle, false) if err2 != nil { menuTitle, err2 = encodeInlinesText(&astTitle, wui.gentext) if err2 != nil { menuTitle = title } } result = append(result, simpleLink{ |
︙ | ︙ |
Changes to web/server/impl/router.go.
︙ | ︙ | |||
106 107 108 109 110 111 112 | rt.mux.Handle(pattern, handler) } func (rt *httpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Something may panic. Ensure a kernel log. defer func() { if reco := recover(); reco != nil { | | | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | rt.mux.Handle(pattern, handler) } func (rt *httpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Something may panic. Ensure a kernel log. defer func() { if reco := recover(); reco != nil { rt.log.Error().Str("Method", r.Method).Str("URL", r.URL.String()).Str("ip", getCallerIP(r)).Msg("Recover context") kernel.Main.LogRecover("Web", reco) } }() var withDebug bool if msg := rt.log.Debug(); msg.Enabled() { withDebug = true w = &traceResponseWriter{original: w} msg.Str("method", r.Method).Str("uri", r.RequestURI).Str("ip", getCallerIP(r)).Msg("ServeHTTP") } if prefixLen := len(rt.urlPrefix); prefixLen > 1 { if len(r.URL.Path) < prefixLen || r.URL.Path[:prefixLen] != rt.urlPrefix { http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) if withDebug { rt.log.Debug().Int("sc", int64(w.(*traceResponseWriter).statusCode)).Msg("/ServeHTTP/prefix") |
︙ | ︙ | |||
173 174 175 176 177 178 179 | if rt.ur == nil { // No auth needed return r } k := auth.KindJSON t := getHeaderToken(r) if len(t) == 0 { | | | | | > > > > > > > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | if rt.ur == nil { // No auth needed return r } k := auth.KindJSON t := getHeaderToken(r) if len(t) == 0 { rt.log.Debug().Str("ip", getCallerIP(r)).Msg("no jwt token found") k = auth.KindHTML t = getSessionToken(r) } if len(t) == 0 { rt.log.Sense().Str("ip", getCallerIP(r)).Msg("no auth token found in request") return r } tokenData, err := rt.auth.CheckToken(t, k) if err != nil { rt.log.Sense().Err(err).Str("ip", getCallerIP(r)).Msg("invalid auth token") return r } ctx := r.Context() user, err := rt.ur.GetUser(ctx, tokenData.Zid, tokenData.Ident) if err != nil { rt.log.Sense().Zid(tokenData.Zid).Str("ident", tokenData.Ident).Err(err).Str("ip", getCallerIP(r)).Msg("auth user not found") return r } return r.WithContext(updateContext(ctx, user, &tokenData)) } func getCallerIP(r *http.Request) string { if from := r.Header.Get("X-Forwarded-For"); from != "" { return from } return r.RemoteAddr } func getSessionToken(r *http.Request) []byte { cookie, err := r.Cookie(sessionName) if err != nil { return nil } return []byte(cookie.Value) |
︙ | ︙ |
Changes to www/changes.wiki.
1 2 | <title>Change Log</title> | < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <title>Change Log</title> <a name="0_6_0"></a> <h2>Changes for Version 0.6.0 (pending)</h2> <a name="0_5_0"></a> <h2>Changes for Version 0.5.0 (2022-07-29)</h2> * Removed zettel syntax “draw”. The new default syntax for inline zettel is now “text”. A drawing can now be made by using the “evaluation block” syntax (see below) by setting the generic attribute to “draw”. (breaking: zettelmarkup, api, webui) * If authentication is enabled, a secret of at least 16 bytes must be set in |
︙ | ︙ |
Changes to www/download.wiki.
1 2 3 4 5 6 7 8 9 10 11 | <title>Download</title> <h1>Download of Zettelstore Software</h1> <h2>Foreword</h2> * Zettelstore is free/libre open source software, licensed under EUPL-1.2-or-later. * The software is provided as-is. * There is no guarantee that it will not damage your system. * However, it is in use by the main developer since March 2020 without any damage. * It may be useful for you. It is useful for me. * Take a look at the [https://zettelstore.de/manual/|manual] to know how to start and use it. <h2>ZIP-ped Executables</h2> | | | | | | | | | 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 | <title>Download</title> <h1>Download of Zettelstore Software</h1> <h2>Foreword</h2> * Zettelstore is free/libre open source software, licensed under EUPL-1.2-or-later. * The software is provided as-is. * There is no guarantee that it will not damage your system. * However, it is in use by the main developer since March 2020 without any damage. * It may be useful for you. It is useful for me. * Take a look at the [https://zettelstore.de/manual/|manual] to know how to start and use it. <h2>ZIP-ped Executables</h2> Build: <code>v0.5.0</code> (2022-07-29). * [/uv/zettelstore-0.5.0-linux-amd64.zip|Linux] (amd64) * [/uv/zettelstore-0.5.0-linux-arm.zip|Linux] (arm6, e.g. Raspberry Pi) * [/uv/zettelstore-0.5.0-windows-amd64.zip|Windows] (amd64) * [/uv/zettelstore-0.5.0-darwin-amd64.zip|macOS] (amd64) * [/uv/zettelstore-0.5.0-darwin-arm64.zip|macOS] (arm64, aka Apple silicon) Unzip the appropriate file, install and execute Zettelstore according to the manual. <h2>Zettel for the manual</h2> As a starter, you can download the zettel for the manual [/uv/manual-0.5.0.zip|here]. Just unzip the contained files and put them into your zettel folder or configure a file box to read the zettel directly from the ZIP file. |
Changes to www/index.wiki.
︙ | ︙ | |||
18 19 20 21 22 23 24 | [https://zettelstore.de/client|Zettelstore Client] provides client software to access Zettelstore via its API more easily, [https://zettelstore.de/contrib|Zettelstore Contrib] contains contributed software, which often connects to Zettelstore via its API. Some of the software packages may be experimental. | | | | | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | [https://zettelstore.de/client|Zettelstore Client] provides client software to access Zettelstore via its API more easily, [https://zettelstore.de/contrib|Zettelstore Contrib] contains contributed software, which often connects to Zettelstore via its API. Some of the software packages may be experimental. [https://twitter.com/zettelstore|Stay tuned]… <hr> <h3>Latest Release: 0.5.0 (2022-07-29)</h3> * [./download.wiki|Download] * [./changes.wiki#0_5_0|Change summary] * [/timeline?p=v0.5.0&bt=v0.4&y=ci|Check-ins for version 0.5.0], [/vdiff?to=v0.5.0&from=v0.4|content diff] * [/timeline?df=v0.5.0&y=ci|Check-ins derived from the 0.5.0 release], [/vdiff?from=v0.5.0&to=trunk|content diff] * [./plan.wiki|Limitations and planned improvements] * [/timeline?t=release|Timeline of all past releases] <hr> <h2>Build instructions</h2> Just install [https://golang.org/dl/|Go] and some Go-based tools. Please read the [./build.md|instructions] for details. |
︙ | ︙ |
Changes to www/plan.wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <title>Limitations and planned improvements</title> Here is a list of some shortcomings of Zettelstore. They are planned to be solved. <h3>Serious limitations</h3> * Content with binary data (e.g. a GIF, PNG, or JPG file) cannot be created nor modified via the standard web interface. As a workaround, you should put your file into the directory where your zettel are stored. Make sure that the file name starts with unique 14 digits that make up the zettel identifier. * … <h3>Smaller limitations</h3> * Quoted attribute values are not yet supported in Zettelmarkup: <code>{key="value with space"}</code>. * The horizontal tab character (<tt>U+0009</tt>) is not supported. * Missing support for citation keys. | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <title>Limitations and planned improvements</title> Here is a list of some shortcomings of Zettelstore. They are planned to be solved. <h3>Serious limitations</h3> * Content with binary data (e.g. a GIF, PNG, or JPG file) cannot be created nor modified via the standard web interface. As a workaround, you should put your file into the directory where your zettel are stored. Make sure that the file name starts with unique 14 digits that make up the zettel identifier. * Automatic lists are not supported in Zettelmarkup. * … <h3>Smaller limitations</h3> * Quoted attribute values are not yet supported in Zettelmarkup: <code>{key="value with space"}</code>. * The horizontal tab character (<tt>U+0009</tt>) is not supported. * Missing support for citation keys. |
︙ | ︙ |