gallery app
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Arnas Udovic 2025-01-12 00:47:25 +02:00
parent b6c528a103
commit eb56e5c923
4 changed files with 43 additions and 3 deletions

View file

@ -1,8 +1,12 @@
package main
import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strings"
zord_tree "g.arns.lt/zordsdavini/zord-tree"
)
@ -12,8 +16,43 @@ var config = zord_tree.NewConfig(
"__a",
customMeta,
[]string{"\\.sync_.{12}\\.db"},
map[string]zord_tree.AppCallback{"gallery": gallery},
)
func gallery(dir string, content string, info os.FileInfo) (string, error) {
if info.Name() != "index.md" {
return content, nil
}
fullPath := path.Join(dir, info.Name())
_, _, fileMeta, err := zord_tree.GetFileParams(fullPath, meta)
if err != nil {
return content, err
}
if !strings.HasPrefix(fileMeta["app"], "gallery") {
return content, nil
}
entries, err := os.ReadDir(dir)
if err != nil {
return content, err
}
content += "\n"
for _, e := range entries {
if e.Name() != "index.md" {
content += fmt.Sprintf(
"![%s](%s)\n",
strings.TrimSuffix(e.Name(), filepath.Ext(e.Name())),
e.Name(),
)
}
}
return content, nil
}
func Collect() {
log.Println("Collect: start")
if _, err := os.Stat(source); os.IsNotExist(err) {

2
go.mod
View file

@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.23.1
require (
g.arns.lt/zordsdavini/zord-tree v0.6.0
g.arns.lt/zordsdavini/zord-tree v0.7.4
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.1
)

4
go.sum
View file

@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
g.arns.lt/zordsdavini/abcex/v4 v4.0.4 h1:idjvgkCjrjZfDxLyOcX7lCIdIndISDAkj77VCvhu8/c=
g.arns.lt/zordsdavini/abcex/v4 v4.0.4/go.mod h1:/+//gYSUtJrdsmTtWNoffRO4xD1BuPRUMGW4ynet7iE=
g.arns.lt/zordsdavini/zord-tree v0.6.0 h1:kSe+aVbjgwCQBzlSZAmZZH9yIR1LDwQlA7tlPLPiQSs=
g.arns.lt/zordsdavini/zord-tree v0.6.0/go.mod h1:RcL5OsThsfPkgWlnnillOZuTt9tx0REEHyE4tf82wOk=
g.arns.lt/zordsdavini/zord-tree v0.7.4 h1:iqS/SsM1prO15aSUJxiwVTDdPyKHbphUBsSdwb/NmUE=
g.arns.lt/zordsdavini/zord-tree v0.7.4/go.mod h1:RcL5OsThsfPkgWlnnillOZuTt9tx0REEHyE4tf82wOk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

View file

@ -13,6 +13,7 @@ var (
"lang",
"copyright",
"created",
"app",
} //_ = zord_tree.PopulateTree(cfg.MdTree.Path, cfg.MdTree.DPath, meta)
customMeta = make(map[string]func() string)
)