chore: planning next refactor
This commit is contained in:
@@ -67,8 +67,6 @@ Each pipeline is a list of operations, the first field in an operation should be
|
||||
|
||||
For each incoming item this will render the given path template with the item metadata and write the content to disk.
|
||||
|
||||
|
||||
|
||||
- `use: <operation>`
|
||||
|
||||
This will apply the provided operations to the incoming items, for now available operations are
|
||||
@@ -155,3 +153,21 @@ Each pipeline is a list of operations, the first field in an operation should be
|
||||
key: <key to use for sorting>
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
- `cabret.go` — all abstract types and functions
|
||||
|
||||
- `path/` — handles path patterns and templates
|
||||
|
||||
- `config/` — contains config structure definitions and handles loading from YAML
|
||||
|
||||
- `cmd/cabret` — module that puts it all together in a CLI application
|
||||
|
||||
- `operation/` — module containing all operations
|
||||
|
||||
(_TODO_):
|
||||
|
||||
- `exec/ -> runner/` — a module that depends on `config`, `parse` and `operations` and evaluates operations.
|
||||
|
||||
- `pipeline/ -> {parse/, runner/}`
|
||||
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package operation
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// "log"
|
||||
// "mime"
|
||||
// "path/filepath"
|
||||
// "strings"
|
||||
|
||||
// "github.com/aziis98/cabret"
|
||||
// "github.com/aziis98/cabret/operation/template"
|
||||
// )
|
||||
|
||||
// func init() {
|
||||
// registerType("template", &Template{})
|
||||
// }
|
||||
|
||||
// type Template struct {
|
||||
// // TemplatePatterns is a list of glob patterns of templates that will be loaded
|
||||
// TemplatePatterns []string
|
||||
// }
|
||||
|
||||
// func (op *Template) Load(config map[string]any) error {
|
||||
// if v, ok := config[ShortFormValueKey]; ok {
|
||||
// globPatternsStr, ok := v.(string)
|
||||
// if !ok {
|
||||
// return fmt.Errorf(`expected a comma separated list of glob patterns but got "%v" of type %T`, v, v)
|
||||
// }
|
||||
|
||||
// globPatterns := strings.Split(globPatternsStr, ",")
|
||||
// for _, pat := range globPatterns {
|
||||
// op.TemplatePatterns = append(op.TemplatePatterns, strings.TrimSpace(pat))
|
||||
// }
|
||||
|
||||
// return nil
|
||||
// }
|
||||
// if v, ok := config["paths"]; ok {
|
||||
// globPatterns, ok := v.([]string)
|
||||
// if !ok {
|
||||
// return fmt.Errorf(`expected a list of glob patterns but got "%v" of type %T`, v, v)
|
||||
// }
|
||||
|
||||
// for _, pat := range globPatterns {
|
||||
// op.TemplatePatterns = append(op.TemplatePatterns, strings.TrimSpace(pat))
|
||||
// }
|
||||
|
||||
// return nil
|
||||
// }
|
||||
// if v, ok := config["path"]; ok {
|
||||
// globPatternStr, ok := v.(string)
|
||||
// if !ok {
|
||||
// return fmt.Errorf(`expected a glob pattern but got "%v" of type %T`, v, v)
|
||||
// }
|
||||
|
||||
// op.TemplatePatterns = []string{strings.TrimSpace(globPatternStr)}
|
||||
|
||||
// return nil
|
||||
// }
|
||||
|
||||
// return fmt.Errorf(`invalid config for "template": %#v`, config)
|
||||
// }
|
||||
|
||||
// func (op *Template) ProcessList(contents []cabret.Content) ([]cabret.Content, error) {
|
||||
// // expand glob patterns
|
||||
// tmplFiles := []string{}
|
||||
// for _, pat := range op.TemplatePatterns {
|
||||
// files, err := filepath.Glob(strings.TrimSpace(pat))
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// tmplFiles = append(tmplFiles, files...)
|
||||
// }
|
||||
|
||||
// // create template
|
||||
// tmpl, err := template.ParseFiles(tmplFiles...)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// log.Printf(`[operation.Layout] rendering into layout "%s"`, strings.Join(op.TemplatePatterns, ", "))
|
||||
|
||||
// ctx := map[string]any{}
|
||||
// ctx["Items"] = contents
|
||||
// data, err := tmpl.Render(ctx)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// return []cabret.Content{
|
||||
// {
|
||||
// Type: mime.TypeByExtension(filepath.Ext(tmplFiles[0])),
|
||||
// Data: data,
|
||||
// Metadata: ctx,
|
||||
// },
|
||||
// }, nil
|
||||
// }
|
||||
Reference in New Issue
Block a user