miki

Miki: personal wiki with the fmd markup format
git clone https://wtenison.com/repo/miki.git
Log | Files | Refs | README | LICENSE

commit c8fab1bf4306efa366ff120e0c3f0cc737234a50
parent 6899ca04e284877554b91f3f448367eaa141515b
Author: weetat <wtenison@protonmail.com>
Date:   Thu, 27 Feb 2025 13:42:29 +0000

Drop unused lexer name and dead lookup code

Remove the name field from the fmd lexer and the commented-out data file
lookup in directories.go.

Diffstat:
Msrc/filesystem/directories.go | 45++++-----------------------------------------
Msrc/fmd/fmd.go | 4++--
Msrc/fmd/lexer.go | 5++---
Msrc/network/network.go | 2+-
4 files changed, 9 insertions(+), 47 deletions(-)

diff --git a/src/filesystem/directories.go b/src/filesystem/directories.go @@ -37,7 +37,7 @@ func MakeDirectoryPkg(directory string, depth SearchDepth, filePattern string) ( return _dirPkg, _retErr } - // Check and collect resource signature directory files. + // Check and collect directory files. _fileList, _err := os.ReadDir(_dirPkg.Root) if _err != nil { _retErr := fmt.Errorf("MakeDirectoryPkg:%s", _err) @@ -47,8 +47,8 @@ func MakeDirectoryPkg(directory string, depth SearchDepth, filePattern string) ( // A variable to store root sub-directory files. _subDirPkgDeps := []string{} - // Collete all valid files and/or sub-directory files. - for _, _f := range _fileList { + + for _, _f := range _fileList { // Collete all valid sub-directory files. // Recurse into valid sub-directory files. if _f.IsDir() && (depth > SEARCH_DEPTH_ZERO || depth == SEARCH_DEPTH_INF) { @@ -68,8 +68,7 @@ func MakeDirectoryPkg(directory string, depth SearchDepth, filePattern string) ( // Add to package dependencies list. _subDirPkgDeps = append(_subDirPkgDeps, _subDirPkg.DependencyFiles...) - } else { - // Add files that match pattern to dependency list. + } else { // Add files that match pattern to dependency list. if matches, _ := filepath.Match(filePattern, _f.Name()); matches { _dirPkg.DependencyFiles = append(_dirPkg.DependencyFiles, filepath.Join(_dirPkg.Root, _f.Name())) } @@ -80,40 +79,4 @@ func MakeDirectoryPkg(directory string, depth SearchDepth, filePattern string) ( _dirPkg.DependencyFiles = append(_dirPkg.DependencyFiles, _subDirPkgDeps...) return _dirPkg, nil - - // Check for atricle entry. - // TODO: Move to secure and refined interface. - - // _dataFiles, _err := os.ReadDir(Dirs["data"]) - // if _err != nil { - // _retErr := fmt.Errorf("MakeDirectoryPkg:%s", _err) - // return DirectoryPackage{}, _retErr - // } - - // for _, _df := range _dataFiles { - // _rootFile := strings.Split(resSig.Root, "/") - // _rootDataFile := _rootFile[len(_rootFile)-1] + ".fmd" - - // if _df.Name() == _rootDataFile { - // log.Printf("INFO\tMakeDirectoryPkg:df:%s, rootDataFile:%s", _df.Name(), _rootDataFile) - - // var _DataContainer struct { - // PageContent string - // } - - // _DataContainer.PageContent = fmd.WritFMDToHTMLString(filepath.Join(Dirs["data"], _rootDataFile)) - - // _resPkg.DependencyData = _DataContainer - // } - // } } - -// func AppendRootPathToFiles(root string, files []string) []string { -// var _appendedFileList []string - -// for _, _f := range files { -// _appendedFileList = append(_appendedFileList, filepath.Join(root, _f)) -// } - -// return _appendedFileList -// } diff --git a/src/fmd/fmd.go b/src/fmd/fmd.go @@ -12,7 +12,7 @@ func WriteFMDToHTMLFile(inputFile string, outputFile string) { log.Println("_ERROR\tfmd:WriteFMDToHTMLFile:ReadFile:", inputFile, ":", _err) } - _l := MakeLexer("RenderLexer", _fileBytes) + _l := MakeLexer(_fileBytes) _tokens := _l.Exec() @@ -33,7 +33,7 @@ func WritFMDToHTMLString(filePath string) string { log.Println("_ERROR\tfmd:WriteFMDToHTMLString:ReadFile:", filePath, ":", _err) } - _l := MakeLexer("RenderLexer", _fileBytes) + _l := MakeLexer(_fileBytes) _tokens := _l.Exec() diff --git a/src/fmd/lexer.go b/src/fmd/lexer.go @@ -36,14 +36,13 @@ var keywords = []string{ "b", "i", "h1", "h2", "h3", "h4", "h5", "h6", "@", "#", "col", "img", "_"} type lexer struct { - name string // for error output input []byte // text input to scan pos int // the start position for scanning tokens []token } -func MakeLexer(name string, input []byte) *lexer { - return &lexer{name: name, input: input, pos: 0} +func MakeLexer(input []byte) *lexer { + return &lexer{input: input, pos: 0} } func (l *lexer) Exec() []token { diff --git a/src/network/network.go b/src/network/network.go @@ -18,7 +18,7 @@ var serverInfo struct { func Init() { - //// GET SERVER INFO + //// GET SERVER INFO FROM SYSTEM type ServerInfo struct { Port string `json:"port"`