Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Refactor to make revive tool happy (and me) |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6f8452996beff7ded43bf24ea353078e |
User & Date: | stern 2024-09-27 16:05:51 |
Context
2024-09-27
| ||
16:35 | Add revive tool to tools; add some missing comments ... (Leaf check-in: a64decfa47 user: stern tags: trunk) | |
16:05 | Refactor to make revive tool happy (and me) ... (check-in: 6f8452996b user: stern tags: trunk) | |
2024-09-26
| ||
16:47 | Reread zettel id mapping zettel when updated ... (check-in: 0073087bde user: stern tags: trunk) | |
Changes
Changes to box/compbox/compbox.go.
︙ | ︙ | |||
28 29 30 31 32 33 34 | "zettelstore.de/z/zettel/id" "zettelstore.de/z/zettel/meta" ) func init() { manager.Register( " comp", | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | "zettelstore.de/z/zettel/id" "zettelstore.de/z/zettel/meta" ) func init() { manager.Register( " comp", func(_ *url.URL, cdata *manager.ConnectData) (box.ManagedBox, error) { return getCompBox(cdata.Number, cdata.Enricher, cdata.Mapper), nil }) } type compBox struct { log *logger.Logger number int |
︙ | ︙ |
Changes to box/constbox/constbox.go.
︙ | ︙ | |||
29 30 31 32 33 34 35 | "zettelstore.de/z/zettel/id" "zettelstore.de/z/zettel/meta" ) func init() { manager.Register( " const", | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | "zettelstore.de/z/zettel/id" "zettelstore.de/z/zettel/meta" ) func init() { manager.Register( " const", func(_ *url.URL, cdata *manager.ConnectData) (box.ManagedBox, error) { return &constBox{ log: kernel.Main.GetLogger(kernel.BoxService).Clone(). Str("box", "const").Int("boxnum", int64(cdata.Number)).Child(), number: cdata.Number, zettel: constZettelMap, enricher: cdata.Enricher, }, nil |
︙ | ︙ |
Changes to box/helper.go.
︙ | ︙ | |||
43 44 45 46 47 48 49 | // GetQueryBool is a helper function to extract bool values from a box URI. func GetQueryBool(u *url.URL, key string) bool { _, ok := u.Query()[key] return ok } // GetQueryInt is a helper function to extract int values of a specified range from a box URI. | | | | | | | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | // GetQueryBool is a helper function to extract bool values from a box URI. func GetQueryBool(u *url.URL, key string) bool { _, ok := u.Query()[key] return ok } // GetQueryInt is a helper function to extract int values of a specified range from a box URI. func GetQueryInt(u *url.URL, key string, minVal, defVal, maxVal int) int { sVal := u.Query().Get(key) if sVal == "" { return defVal } iVal, err := strconv.Atoi(sVal) if err != nil { return defVal } if iVal < minVal { return minVal } if iVal > maxVal { return maxVal } return iVal } |
Changes to box/manager/box.go.
︙ | ︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | if bx.HasZettel(ctx, zid) { return true } } return false } func (mgr *Manager) GetMeta(ctx context.Context, zid id.Zid) (*meta.Meta, error) { mgr.mgrLog.Debug().Zid(zid).Msg("GetMeta") if err := mgr.checkContinue(ctx); err != nil { return nil, err } m, err := mgr.idxStore.GetMeta(ctx, zid) if err != nil { return nil, err } mgr.Enrich(ctx, m, 0) return m, nil } // SelectMeta returns all zettel meta data that match the selection | > > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | if bx.HasZettel(ctx, zid) { return true } } return false } // GetMeta returns just the metadata of the zettel with the given identifier. func (mgr *Manager) GetMeta(ctx context.Context, zid id.Zid) (*meta.Meta, error) { mgr.mgrLog.Debug().Zid(zid).Msg("GetMeta") if err := mgr.checkContinue(ctx); err != nil { return nil, err } m, err := mgr.idxStore.GetMeta(ctx, zid) if err != nil { // TODO: Call GetZettel and return just metadata, in case the index is not complete. return nil, err } mgr.Enrich(ctx, m, 0) return m, nil } // SelectMeta returns all zettel meta data that match the selection |
︙ | ︙ |
Changes to box/notify/directory.go.
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | // dsCreated --Start--> dsStarting // dsStarting --last list notification--> dsWorking // dsWorking --directory missing--> dsMissing // dsMissing --last list notification--> dsWorking // --Stop--> dsStopping type DirServiceState uint8 const ( DsCreated DirServiceState = iota DsStarting // Reading inital scan DsWorking // Initial scan complete, fully operational DsMissing // Directory is missing DsStopping // Service is shut down ) | > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | // dsCreated --Start--> dsStarting // dsStarting --last list notification--> dsWorking // dsWorking --directory missing--> dsMissing // dsMissing --last list notification--> dsWorking // --Stop--> dsStopping type DirServiceState uint8 // Constants for DirServiceState const ( DsCreated DirServiceState = iota DsStarting // Reading inital scan DsWorking // Initial scan complete, fully operational DsMissing // Directory is missing DsStopping // Service is shut down ) |
︙ | ︙ |
Changes to cmd/zettelstore/main.go.
︙ | ︙ | |||
17 18 19 20 21 22 23 | import ( "os" "zettelstore.de/z/cmd" ) // Version variable. Will be filled by build process. | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 | import ( "os" "zettelstore.de/z/cmd" ) // Version variable. Will be filled by build process. var version string func main() { exitCode := cmd.Main("Zettelstore", version) os.Exit(exitCode) } |
Changes to evaluator/list.go.
︙ | ︙ | |||
31 32 33 34 35 36 37 | "zettelstore.de/z/query" "zettelstore.de/z/zettel/meta" ) // QueryAction transforms a list of metadata according to query actions into a AST nested list. func QueryAction(ctx context.Context, q *query.Query, ml []*meta.Meta, rtConfig config.Config) (ast.BlockNode, int) { ap := actionPara{ | | | | | | | | | | | 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 | "zettelstore.de/z/query" "zettelstore.de/z/zettel/meta" ) // QueryAction transforms a list of metadata according to query actions into a AST nested list. func QueryAction(ctx context.Context, q *query.Query, ml []*meta.Meta, rtConfig config.Config) (ast.BlockNode, int) { ap := actionPara{ ctx: ctx, q: q, ml: ml, kind: ast.NestedListUnordered, minVal: -1, maxVal: -1, title: rtConfig.GetSiteName(), } actions := q.Actions() if len(actions) == 0 { return ap.createBlockNodeMeta("") } acts := make([]string, 0, len(actions)) for i, act := range actions { if strings.HasPrefix(act, api.NumberedAction[0:1]) { ap.kind = ast.NestedListOrdered continue } if strings.HasPrefix(act, api.MinAction) { if num, err := strconv.Atoi(act[3:]); err == nil && num > 0 { ap.minVal = num continue } } if strings.HasPrefix(act, api.MaxAction) { if num, err := strconv.Atoi(act[3:]); err == nil && num > 0 { ap.maxVal = num continue } } if act == api.TitleAction && i+1 < len(actions) { ap.title = strings.Join(actions[i+1:], " ") break } |
︙ | ︙ | |||
100 101 102 103 104 105 106 | if bn != nil && numItems == 0 && firstUnknowAct == strings.ToUpper(firstUnknowAct) { bn, numItems = ap.createBlockNodeMeta("") } return bn, numItems } type actionPara struct { | | | | | | | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | if bn != nil && numItems == 0 && firstUnknowAct == strings.ToUpper(firstUnknowAct) { bn, numItems = ap.createBlockNodeMeta("") } return bn, numItems } type actionPara struct { ctx context.Context q *query.Query ml []*meta.Meta kind ast.NestedListKind minVal int maxVal int title string } func (ap *actionPara) createBlockNodeWord(key string) (ast.BlockNode, int) { var buf bytes.Buffer ccs, bufLen := ap.prepareCatAction(key, &buf) if len(ccs) == 0 { return nil, 0 |
︙ | ︙ | |||
170 171 172 173 174 175 176 | ) buf.Truncate(bufLen) } return &ast.ParaNode{Inlines: para}, len(ccs) } func (ap *actionPara) limitTags(ccs meta.CountedCategories) meta.CountedCategories { | | | | | | | | | 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 | ) buf.Truncate(bufLen) } return &ast.ParaNode{Inlines: para}, len(ccs) } func (ap *actionPara) limitTags(ccs meta.CountedCategories) meta.CountedCategories { if minVal, maxVal := ap.minVal, ap.maxVal; minVal > 0 || maxVal > 0 { if minVal < 0 { minVal = ccs[len(ccs)-1].Count } if maxVal < 0 { maxVal = ccs[0].Count } if ccs[len(ccs)-1].Count < minVal || maxVal < ccs[0].Count { temp := make(meta.CountedCategories, 0, len(ccs)) for _, cat := range ccs { if minVal <= cat.Count && cat.Count <= maxVal { temp = append(temp, cat) } } return temp } } return ccs |
︙ | ︙ |
Changes to kernel/impl/cmd.go.
︙ | ︙ | |||
140 141 142 143 144 145 146 | "bye": { "end this session", func(*cmdSession, string, []string) bool { return false }, }, "config": {"show configuration keys", cmdConfig}, "crlf": { "toggle crlf mode", | | | | | | 140 141 142 143 144 145 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 198 199 200 201 202 203 204 | "bye": { "end this session", func(*cmdSession, string, []string) bool { return false }, }, "config": {"show configuration keys", cmdConfig}, "crlf": { "toggle crlf mode", func(sess *cmdSession, _ string, _ []string) bool { if len(sess.eol) == 1 { sess.eol = []byte{'\r', '\n'} sess.println("crlf is on") } else { sess.eol = []byte{'\n'} sess.println("crlf is off") } return true }, }, "dump-index": {"writes the content of the index", cmdDumpIndex}, "dump-recover": {"show data of last recovery", cmdDumpRecover}, "echo": { "toggle echo mode", func(sess *cmdSession, _ string, _ []string) bool { sess.echo = !sess.echo if sess.echo { sess.println("echo is on") } else { sess.println("echo is off") } return true }, }, "end-profile": {"stop profiling", cmdEndProfile}, "env": {"show environment values", cmdEnvironment}, "get-config": {"show current configuration data", cmdGetConfig}, "header": { "toggle table header", func(sess *cmdSession, _ string, _ []string) bool { sess.header = !sess.header if sess.header { sess.println("header are on") } else { sess.println("header are off") } return true }, }, "log-level": {"get/set log level", cmdLogLevel}, "metrics": {"show Go runtime metrics", cmdMetrics}, "next-config": {"show next configuration data", cmdNextConfig}, "profile": {"start profiling", cmdProfile}, "refresh": {"refresh box data", cmdRefresh}, "restart": {"restart service", cmdRestart}, "services": {"show available services", cmdServices}, "set-config": {"set next configuration data", cmdSetConfig}, "shutdown": { "shutdown Zettelstore", func(sess *cmdSession, _ string, _ []string) bool { sess.kern.Shutdown(false); return false }, }, "start": {"start service", cmdStart}, "stat": {"show service statistics", cmdStat}, "stop": {"stop service", cmdStop}, } func cmdHelp(sess *cmdSession, _ string, _ []string) bool { |
︙ | ︙ |
Changes to kernel/impl/config.go.
︙ | ︙ | |||
229 230 231 232 233 234 235 | case '0', 'f', 'F', 'n', 'N': return false, nil } return true, nil } func parseInt64(val string) (any, error) { | | > < < > | > < < > | 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 | case '0', 'f', 'F', 'n', 'N': return false, nil } return true, nil } func parseInt64(val string) (any, error) { u64, err := strconv.ParseInt(val, 10, 64) if err == nil { return u64, nil } return nil, err } func parseZid(val string) (any, error) { zid, err := id.Parse(val) if err == nil { return zid, nil } return id.Invalid, err } func parseInvalidZid(val string) (any, error) { zid, _ := id.Parse(val) return zid, nil } |
Changes to kernel/impl/impl.go.
︙ | ︙ | |||
547 548 549 550 551 552 553 | // --- The kernel as a service ------------------------------------------- type kernelService struct { kernel *myKernel } | | | | | | | | | | | | | | | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | // --- The kernel as a service ------------------------------------------- type kernelService struct { kernel *myKernel } func (*kernelService) Initialize(*logger.Logger) {} func (ks *kernelService) GetLogger() *logger.Logger { return ks.kernel.logger } func (*kernelService) ConfigDescriptions() []serviceConfigDescription { return nil } func (*kernelService) SetConfig(string, string) error { return errAlreadyFrozen } func (*kernelService) GetCurConfig(string) interface{} { return nil } func (*kernelService) GetNextConfig(string) interface{} { return nil } func (*kernelService) GetCurConfigList(bool) []kernel.KeyDescrValue { return nil } func (*kernelService) GetNextConfigList() []kernel.KeyDescrValue { return nil } func (*kernelService) GetStatistics() []kernel.KeyValue { return nil } func (*kernelService) Freeze() {} func (*kernelService) Start(*myKernel) error { return nil } func (*kernelService) SwitchNextToCur() {} func (*kernelService) IsStarted() bool { return true } func (*kernelService) Stop(*myKernel) {} |
Changes to kernel/impl/web.go.
︙ | ︙ | |||
43 44 45 46 47 48 49 | func (ws *webService) Initialize(logger *logger.Logger) { ws.logger = logger ws.descr = descriptionMap{ kernel.WebAssetDir: { "Asset file directory", func(val string) (any, error) { val = filepath.Clean(val) | > | < < > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | func (ws *webService) Initialize(logger *logger.Logger) { ws.logger = logger ws.descr = descriptionMap{ kernel.WebAssetDir: { "Asset file directory", func(val string) (any, error) { val = filepath.Clean(val) finfo, err := os.Stat(val) if err == nil && finfo.IsDir() { return val, nil } return nil, err }, true, }, kernel.WebBaseURL: { "Base URL", func(val string) (any, error) { if _, err := url.Parse(val); err != nil { |
︙ | ︙ |
Changes to tests/markdown_test.go.
︙ | ︙ | |||
84 85 86 87 88 89 90 | return parser.ParseBlocks(input.NewInput([]byte(markdown)), nil, meta.SyntaxMarkdown, hi) } func testAllEncodings(t *testing.T, tc markdownTestCase, ast *ast.BlockSlice) { var sb strings.Builder testID := tc.Example*100 + 1 for _, enc := range encodings { | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | return parser.ParseBlocks(input.NewInput([]byte(markdown)), nil, meta.SyntaxMarkdown, hi) } func testAllEncodings(t *testing.T, tc markdownTestCase, ast *ast.BlockSlice) { var sb strings.Builder testID := tc.Example*100 + 1 for _, enc := range encodings { t.Run(fmt.Sprintf("Encode %v %v", enc, testID), func(*testing.T) { encoder.Create(enc, &encoder.CreateParameter{Lang: api.ValueLangEN}).WriteBlocks(&sb, ast) sb.Reset() }) } } func testZmkEncoding(t *testing.T, tc markdownTestCase, ast *ast.BlockSlice) { |
︙ | ︙ |
Changes to tools/htmllint/htmllint.go.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //----------------------------------------------------------------------------- // Copyright (c) 2023-present 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. // // SPDX-License-Identifier: EUPL-1.2 // SPDX-FileCopyrightText: 2023-present Detlef Stern //----------------------------------------------------------------------------- package main import ( "context" "flag" "fmt" "log" | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //----------------------------------------------------------------------------- // Copyright (c) 2023-present 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. // // SPDX-License-Identifier: EUPL-1.2 // SPDX-FileCopyrightText: 2023-present Detlef Stern //----------------------------------------------------------------------------- // Package main provides a tool to check the validity of HTML zettel documents. package main import ( "context" "flag" "fmt" "log" |
︙ | ︙ | |||
57 58 59 60 61 62 63 | msgCount := 0 fmt.Fprintf(os.Stderr, "Now checking: %s\n", kd.text) for _, zid := range zidsToUse(zids, perm, kd.sampleSize) { var nmsgs int nmsgs, err = validateHTML(client, kd.uc, api.ZettelID(zid)) if err != nil { fmt.Fprintf(os.Stderr, "* error while validating zettel %v with: %v\n", zid, err) | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | msgCount := 0 fmt.Fprintf(os.Stderr, "Now checking: %s\n", kd.text) for _, zid := range zidsToUse(zids, perm, kd.sampleSize) { var nmsgs int nmsgs, err = validateHTML(client, kd.uc, api.ZettelID(zid)) if err != nil { fmt.Fprintf(os.Stderr, "* error while validating zettel %v with: %v\n", zid, err) msgCount++ } else { msgCount += nmsgs } } if msgCount == 1 { fmt.Fprintln(os.Stderr, "==> found 1 possible issue") } else if msgCount > 1 { |
︙ | ︙ |
Changes to web/adapter/api/get_data.go.
︙ | ︙ | |||
19 20 21 22 23 24 25 | "t73f.de/r/sx" "zettelstore.de/z/usecase" "zettelstore.de/z/zettel/id" ) // MakeGetDataHandler creates a new HTTP handler to return zettelstore data. func (a *API) MakeGetDataHandler(ucVersion usecase.Version) http.Handler { | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | "t73f.de/r/sx" "zettelstore.de/z/usecase" "zettelstore.de/z/zettel/id" ) // MakeGetDataHandler creates a new HTTP handler to return zettelstore data. func (a *API) MakeGetDataHandler(ucVersion usecase.Version) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { version := ucVersion.Run() err := a.writeObject(w, id.Invalid, sx.MakeList( sx.Int64(version.Major), sx.Int64(version.Minor), sx.Int64(version.Patch), sx.MakeString(version.Info), sx.MakeString(version.Hash), |
︙ | ︙ |
Changes to web/adapter/api/get_zettel.go.
︙ | ︙ | |||
47 48 49 50 51 52 53 | } q := r.URL.Query() part := getPart(q, partContent) ctx := r.Context() switch enc, encStr := getEncoding(r, q); enc { case api.EncoderPlain: | | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | } q := r.URL.Query() part := getPart(q, partContent) ctx := r.Context() switch enc, encStr := getEncoding(r, q); enc { case api.EncoderPlain: a.writePlainData(ctx, w, zid, part, getZettel) case api.EncoderData: a.writeSzData(ctx, w, zid, part, getZettel) default: var zn *ast.ZettelNode var em func(value string) ast.InlineSlice if q.Has(api.QueryKeyParseOnly) { zn, err = parseZettel.Run(ctx, zid, q.Get(api.KeySyntax)) em = parser.ParseMetadata |
︙ | ︙ | |||
73 74 75 76 77 78 79 | return } a.writeEncodedZettelPart(ctx, w, zn, em, enc, encStr, part) } }) } | | | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | return } a.writeEncodedZettelPart(ctx, w, zn, em, enc, encStr, part) } }) } func (a *API) writePlainData(ctx context.Context, w http.ResponseWriter, zid id.Zid, part partType, getZettel usecase.GetZettel) { var buf bytes.Buffer var contentType string var err error z, err := getZettel.Run(box.NoEnrichContext(ctx), zid) if err != nil { a.reportUsecaseError(w, err) |
︙ | ︙ | |||
113 114 115 116 117 118 119 | return } if err = writeBuffer(w, &buf, contentType); err != nil { a.log.Error().Err(err).Zid(zid).Msg("Write Plain data") } } | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | return } if err = writeBuffer(w, &buf, contentType); err != nil { a.log.Error().Err(err).Zid(zid).Msg("Write Plain data") } } func (a *API) writeSzData(ctx context.Context, w http.ResponseWriter, zid id.Zid, part partType, getZettel usecase.GetZettel) { z, err := getZettel.Run(ctx, zid) if err != nil { a.reportUsecaseError(w, err) return } var obj sx.Object switch part { |
︙ | ︙ |
Changes to web/adapter/api/query.go.
︙ | ︙ | |||
100 101 102 103 104 105 106 | if err = writeBuffer(w, &buf, contentType); err != nil { a.log.Error().Err(err).Msg("write result buffer") } }) } func queryAction(w io.Writer, enc zettelEncoder, ml []*meta.Meta, actions []string) error { | | | | | | | | 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | if err = writeBuffer(w, &buf, contentType); err != nil { a.log.Error().Err(err).Msg("write result buffer") } }) } func queryAction(w io.Writer, enc zettelEncoder, ml []*meta.Meta, actions []string) error { minVal, maxVal := -1, -1 if len(actions) > 0 { acts := make([]string, 0, len(actions)) for _, act := range actions { if strings.HasPrefix(act, api.MinAction) { if num, err := strconv.Atoi(act[3:]); err == nil && num > 0 { minVal = num continue } } if strings.HasPrefix(act, api.MaxAction) { if num, err := strconv.Atoi(act[3:]); err == nil && num > 0 { maxVal = num continue } } acts = append(acts, act) } for _, act := range acts { if act == api.KeysAction { return encodeKeysArrangement(w, enc, ml, act) } switch key := strings.ToLower(act); meta.Type(key) { case meta.TypeWord, meta.TypeTagSet: return encodeMetaKeyArrangement(w, enc, ml, key, minVal, maxVal) } } } return enc.writeMetaList(w, ml) } func encodeKeysArrangement(w io.Writer, enc zettelEncoder, ml []*meta.Meta, act string) error { arr := make(meta.Arrangement, 128) for _, m := range ml { for k := range m.Map() { arr[k] = append(arr[k], m) } } return enc.writeArrangement(w, act, arr) } func encodeMetaKeyArrangement(w io.Writer, enc zettelEncoder, ml []*meta.Meta, key string, minVal, maxVal int) error { arr0 := meta.CreateArrangement(ml, key) arr := make(meta.Arrangement, len(arr0)) for k0, ml0 := range arr0 { if len(ml0) < minVal || (maxVal > 0 && len(ml0) > maxVal) { continue } arr[k0] = ml0 } return enc.writeArrangement(w, key, arr) } |
︙ | ︙ |
Changes to web/adapter/webui/favicon.go.
︙ | ︙ | |||
18 19 20 21 22 23 24 25 | "net/http" "os" "path/filepath" "zettelstore.de/z/web/adapter" ) func (wui *WebUI) MakeFaviconHandler(baseDir string) http.Handler { | > | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | "net/http" "os" "path/filepath" "zettelstore.de/z/web/adapter" ) // MakeFaviconHandler creates a HTTP handler to retrieve the favicon. func (wui *WebUI) MakeFaviconHandler(baseDir string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { filename := filepath.Join(baseDir, "favicon.ico") f, err := os.Open(filename) if err != nil { wui.log.Debug().Err(err).Msg("Favicon not found") http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) return } |
︙ | ︙ |
Changes to zettel/id/set.go.
︙ | ︙ | |||
283 284 285 286 287 288 289 | } // ----- unchecked base operations func newFromSlice(seq Slice) *Set { if l := len(seq); l == 0 { return nil | < < > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | } // ----- unchecked base operations func newFromSlice(seq Slice) *Set { if l := len(seq); l == 0 { return nil } return &Set{seq: seq} } func (s *Set) add(zid Zid) { if pos, found := s.find(zid); !found { s.seq = slices.Insert(s.seq, pos, zid) } } |
︙ | ︙ |