From bc2be9d337d523caa48d5bd23b709df5fa547e6e Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Mon, 5 Apr 2021 11:37:57 +0200 Subject: [PATCH] removed vkvnl --- cmd/ssg/main.go | 18 +--- cmd/ssg/resources/vkvnl/template/post.gohtml | 29 ------- cmd/ssg/resources/vkvnl/template/rss.goxml | 20 ----- cmd/ssg/site/config.go | 5 +- cmd/ssg/site/rendervkvnl.go | 88 -------------------- cmd/ssg/site/sites.go | 23 ----- 6 files changed, 4 insertions(+), 179 deletions(-) delete mode 100644 cmd/ssg/resources/vkvnl/template/post.gohtml delete mode 100644 cmd/ssg/resources/vkvnl/template/rss.goxml delete mode 100644 cmd/ssg/site/rendervkvnl.go diff --git a/cmd/ssg/main.go b/cmd/ssg/main.go index ea850ab..4ac526e 100644 --- a/cmd/ssg/main.go +++ b/cmd/ssg/main.go @@ -1,7 +1,6 @@ package main import ( - "errors" "flag" "io/ioutil" "log" @@ -13,8 +12,7 @@ import ( ) var ( - siteName = flag.String("site", "ewnl", "site id, either 'ewnl' or 'vkvnl'") - resources = flag.String("resources", "./resources", "folder with templates and other resources") + resources = flag.String("resources", "./resources/ewnl", "folder with templates and other resources") content = flag.String("content", "./content,/projectx", "comma separated list of folders search for content") statics = flag.String("statics", "./statics", "folder with static content") public = flag.String("public", "./public", "target folder for generated site") @@ -22,22 +20,12 @@ var ( func main() { flag.Parse() - if *siteName == "" || *resources == "" || *content == "" || *public == "" || *statics == "" { + if *resources == "" || *content == "" || *public == "" || *statics == "" { log.Fatal("missing parameter") } - var siteId site.SiteID - switch *siteName { - case "ewnl": - siteId = site.SITE_EWNL - case "vkvnl": - siteId = site.SITE_VKVNL - default: - log.Fatal(errors.New("unknown site")) - } - // initialize site - config, err := site.NewSiteConfig(siteId) + config, err := site.NewSiteConfig(site.SITE_EWNL) if err != nil { log.Fatal(err) } diff --git a/cmd/ssg/resources/vkvnl/template/post.gohtml b/cmd/ssg/resources/vkvnl/template/post.gohtml deleted file mode 100644 index d735ca3..0000000 --- a/cmd/ssg/resources/vkvnl/template/post.gohtml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - {{ .Title }} - - - - -
-

{{ .Title }}

- - - . - {{ .Content }} - -
- - diff --git a/cmd/ssg/resources/vkvnl/template/rss.goxml b/cmd/ssg/resources/vkvnl/template/rss.goxml deleted file mode 100644 index c8fc7be..0000000 --- a/cmd/ssg/resources/vkvnl/template/rss.goxml +++ /dev/null @@ -1,20 +0,0 @@ - - - - VrijKorteVerhalen.nl - https://vrijkorteverhalen.nl/ - VKV's op VrijKorteVerhalen.nl - nl-nl - {{ .DateFormal }} - - {{- range .Posts -}} - - {{ .Title }} - {{ .Link }} - {{ .DateFormal }} - {{ .Link }} - {{ .Content }} - - {{- end -}} - - diff --git a/cmd/ssg/site/config.go b/cmd/ssg/site/config.go index 7f52c4f..96bac38 100644 --- a/cmd/ssg/site/config.go +++ b/cmd/ssg/site/config.go @@ -16,8 +16,7 @@ var ( type SiteID string const ( - SITE_EWNL = SiteID("ewnl") - SITE_VKVNL = SiteID("vkvnl") + SITE_EWNL = SiteID("ewnl") ) type TemplateConfig struct { @@ -43,8 +42,6 @@ func NewSiteConfig(id SiteID) (*SiteConfig, error) { switch id { case SITE_EWNL: config = SITE_CONFIG_EWNL - case SITE_VKVNL: - config = SITE_CONFIG_VKVNL default: return &SiteConfig{}, ErrUnknownSiteID } diff --git a/cmd/ssg/site/rendervkvnl.go b/cmd/ssg/site/rendervkvnl.go deleted file mode 100644 index 9b658b9..0000000 --- a/cmd/ssg/site/rendervkvnl.go +++ /dev/null @@ -1,88 +0,0 @@ -package site - -import ( - "os" - "path/filepath" - "text/template" - "time" -) - -func renderVKVNLPosts(targetPath string, tpl *template.Template, posts Posts, _ []*StaticPage) error { - last, first := 0, len(posts)-1 // posts are sorted in reverse order - for i, post := range posts { - pData := post.HTMLPost() - if pData.Slug == "" { - return ErrInvalidPost - } - - data := struct { - Slug string - Title string - DateLong string - DateShort string - Content string - PreviousLink string - NextLink string - }{ - Slug: pData.Slug, - Title: pData.Title, - DateLong: pData.DateLong, - DateShort: pData.DateShort, - Content: pData.Content, - } - - path := targetPath - if i != first { - data.PreviousLink = posts[i+1].Link() - } - if i != last { - data.NextLink = posts[i-1].Link() - if i == last+1 { - data.NextLink = "/" - } - path = filepath.Join(targetPath, post.Year(), data.Slug) - } - if i == last-1 { - } - - if err := os.MkdirAll(path, dirMode); err != nil { - return err - } - - nPath := filepath.Join(path, "index.html") - f, err := os.Create(nPath) - if err != nil { - return err - } - defer f.Close() - - if err := tpl.Execute(f, data); err != nil { - return err - } - } - - return nil -} - -func renderVKVNLRSS(targetPath string, tpl *template.Template, posts Posts, _ []*StaticPage) error { - rssPath := filepath.Join(targetPath, "index.xml") - rssFile, err := os.Create(rssPath) - if err != nil { - return err - } - defer rssFile.Close() - - var xmlPosts []*XMLPost - for _, p := range posts.RemoveKind(KIND_NOTE).Limit(10) { - xmlPosts = append(xmlPosts, p.XMLPost()) - } - - data := struct { - DateFormal string - Posts []*XMLPost - }{ - DateFormal: time.Now().Format(time.RFC1123Z), - Posts: xmlPosts, - } - return tpl.Execute(rssFile, data) -} diff --git a/cmd/ssg/site/sites.go b/cmd/ssg/site/sites.go index f4941b7..98a17bc 100644 --- a/cmd/ssg/site/sites.go +++ b/cmd/ssg/site/sites.go @@ -53,27 +53,4 @@ var ( adoc.KIND_ARTICLE: KIND_ARTICLE, }, } - - SITE_CONFIG_VKVNL = &SiteConfig{ - ID: SITE_VKVNL, - BaseURL: "https://vrijkorteverhalen.nl", - PathsWithKind: false, - TemplateConfigs: []*TemplateConfig{ - { - Name: "post", - TemplateNames: []string{"post"}, - TemplateExt: "gohtml", - Render: renderVKVNLPosts, - }, - { - Name: "rss", - TemplateNames: []string{"rss"}, - TemplateExt: "goxml", - Render: renderVKVNLRSS, - }, - }, - KindMap: map[adoc.Kind]Kind{ - adoc.KIND_VKV: KIND_STORY, - }, - } )