Skip to content

Commit

Permalink
add process
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwei committed Mar 27, 2024
1 parent b2d9b35 commit 42cb449
Show file tree
Hide file tree
Showing 93 changed files with 7,147 additions and 50 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/gorilla/schema v1.2.1 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/nilslice/jwt v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/philhofer/fwd v1.0.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -39,9 +40,12 @@ require (
github.com/tidwall/sjson v1.2.5 // indirect
github.com/tinylib/msgp v1.1.0 // indirect
github.com/willf/bitset v1.1.10 // indirect
github.com/yuin/goldmark v1.7.0 // indirect
go.etcd.io/bbolt v1.3.9 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -104,8 +106,15 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
github.com/steveyen/gtreap v0.1.0 h1:CjhzTa274PyJLJuMZwIzCO1PfC00oRa8d1Kc78bFXJM=
github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7Z4dM9/Y=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tebeka/snowball v0.4.2/go.mod h1:4IfL14h1lvwZcp1sfXuuc7/7yCsvVffTWxWxCLfFpYg=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
Expand All @@ -124,6 +133,8 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc=
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.7.0 h1:EfOIvIMZIzHdB/R/zVrikYLPPwJlfMcNczJFMs1m6sA=
github.com/yuin/goldmark v1.7.0/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI=
go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE=
Expand All @@ -132,6 +143,8 @@ golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -156,3 +169,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
26 changes: 8 additions & 18 deletions internal/application/ssg.go
Original file line number Diff line number Diff line change
@@ -1,50 +1,40 @@
package application

import (
"fmt"
cfFact "github.com/gohugonet/hugoverse/internal/domain/config/factory"
chFact "github.com/gohugonet/hugoverse/internal/domain/contenthub/factory"
fsFact "github.com/gohugonet/hugoverse/internal/domain/fs/factory"
"path"
mdFact "github.com/gohugonet/hugoverse/internal/domain/module/factory"
)

func GenerateStaticSite(projPath string) error {
c, err := cfFact.NewConfigFromPath(path.Join(projPath, "config.toml"))
c, err := cfFact.NewConfigFromPath(projPath)
if err != nil {
return err
}

ch, err := chFact.New(
&themeProvider{
name: c.GetString("theme"),
},
)
mods, err := mdFact.New(c.GetString("theme"))
if err != nil {
return err
}

fs, err := fsFact.New(&fsDir{
workingDir: c.GetString("workingDir"),
publishDir: c.GetString("publishDir"),
}, ch.Modules)
}, mods)

ch, err := chFact.New(fs)
if err != nil {
return err
}

fmt.Println(ch, fs)
if err := ch.Process(); err != nil {
return err
}

return nil
}

type themeProvider struct {
name string
}

func (t *themeProvider) Name() string {
return t.name
}

type fsDir struct {
workingDir string
publishDir string
Expand Down
11 changes: 6 additions & 5 deletions internal/domain/config/factory/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/gohugonet/hugoverse/internal/domain/config"
"github.com/gohugonet/hugoverse/internal/domain/config/entity"
"github.com/gohugonet/hugoverse/internal/domain/config/valueobject"
"path"
)

func New() *entity.Config {
Expand All @@ -13,9 +14,9 @@ func New() *entity.Config {
}}
}

func NewConfigFromPath(path string) (config.LanguageProvider, error) {
c := entity.ConfigLoader{
Path: path,
func NewConfigFromPath(projPath string) (config.LanguageProvider, error) {
c := &entity.ConfigLoader{
Path: path.Join(projPath, "config.toml"),
}

m, err := c.LoadConfigFromDisk()
Expand All @@ -25,8 +26,8 @@ func NewConfigFromPath(path string) (config.LanguageProvider, error) {

provider := New()
provider.SetRoot(m)
provider.Set("path", path)
provider.Set("workingDir", path)
provider.Set("path", projPath)
provider.Set("workingDir", projPath)
provider.SetDefault()

provider.SetLanguages([]config.Language{NewDefaultLanguage(provider)})
Expand Down
28 changes: 24 additions & 4 deletions internal/domain/contenthub/entity/contenthub.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
package entity

import (
"fmt"
"github.com/gohugonet/hugoverse/internal/domain/contenthub"
"github.com/gohugonet/hugoverse/internal/domain/module"
)

type ContentHub struct {
ThemeProvider contenthub.ThemeProvider
Modules module.Modules
Fs contenthub.Fs

// ExecTemplate handling.
TemplateProvider contenthub.ResourceProvider
TemplateExecutor contenthub.TemplateExecutor

*ContentSpec

*PageCollections
}

func (ch *ContentHub) Process() error {
if err := ch.readAndProcessContent(); err != nil {
return fmt.Errorf("readAndProcessContent: %w", err)
}
return nil
}

func (ch *ContentHub) readAndProcessContent() error {
proc := newPagesProcessor(ch.PageCollections.PageMap)
c := newPagesCollector(proc, ch.Fs.ContentFs())
if err := c.Collect(); err != nil {
return err
}

return nil
}
Loading

0 comments on commit 42cb449

Please sign in to comment.