diff --git a/main.go b/main.go index edf9f78..12a56d7 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "io/ioutil" "log" "os" "path/filepath" @@ -13,12 +14,13 @@ import ( var ( resources = flag.String("resources", "./resources", "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") ) func main() { flag.Parse() - if *resources == "" || *content == "" || *public == "" { + if *resources == "" || *content == "" || *public == "" || *statics == "" { log.Fatal("missing parameter") } @@ -28,6 +30,17 @@ func main() { log.Fatal(err) } + // add statics + staticNames, err := ioutil.ReadDir(*statics) + if err != nil { + log.Fatal(err) + } + for _, sn := range staticNames { + if sn.IsDir() { + s.AddStaticPage(filepath.Join(*statics, sn.Name())) + } + } + // add content for _, cp := range strings.Split(*content, ",") { log.Printf("checking %s for content\n", cp) diff --git a/resources/about/rss.png b/resources/about/rss.png deleted file mode 100644 index e047c86..0000000 Binary files a/resources/about/rss.png and /dev/null differ diff --git a/resources/other/beginnenmetroken.jpg b/resources/other/beginnenmetroken.jpg deleted file mode 100644 index 017ae53..0000000 Binary files a/resources/other/beginnenmetroken.jpg and /dev/null differ diff --git a/resources/other/christel 39.mp3 b/resources/other/christel 39.mp3 deleted file mode 100644 index 4df0d26..0000000 Binary files a/resources/other/christel 39.mp3 and /dev/null differ diff --git a/resources/other/crunchy.jpeg b/resources/other/crunchy.jpeg deleted file mode 100644 index 96f5080..0000000 Binary files a/resources/other/crunchy.jpeg and /dev/null differ diff --git a/resources/other/lowlandswedstrijd.jpg b/resources/other/lowlandswedstrijd.jpg deleted file mode 100644 index d631b1f..0000000 Binary files a/resources/other/lowlandswedstrijd.jpg and /dev/null differ diff --git a/resources/other/volca testje.mp3 b/resources/other/volca testje.mp3 deleted file mode 100644 index 3aa1be6..0000000 Binary files a/resources/other/volca testje.mp3 and /dev/null differ diff --git a/resources/other/volca.png b/resources/other/volca.png deleted file mode 100644 index 0f233d0..0000000 Binary files a/resources/other/volca.png and /dev/null differ diff --git a/resources/other/werkeloos.mp3 b/resources/other/werkeloos.mp3 deleted file mode 100644 index e300bd3..0000000 Binary files a/resources/other/werkeloos.mp3 and /dev/null differ diff --git a/resources/template/about.gohtml b/resources/template/about.gohtml deleted file mode 100644 index 7e7073a..0000000 --- a/resources/template/about.gohtml +++ /dev/null @@ -1,19 +0,0 @@ - - -{{- template "head" . -}} - -{{- template "menu" -}} -
-
-

Hi,

-

As you may have guessed from the contents of this site, I am a Dutch software developer who also likes literature and music and a bunch of other things.

-

I am old enough to remember what the internet was like before platforms like Facebook, Twitter, Github, etc. came around. Everything was decentralized, everybody had their own website and it actually felt more personal and real than the “social” media of today.

-

Since I like to create things, I thought I’d make myself an old school personal website again. For my own pleasure. And for others like me. I know you are out there!

-

RSS Feeds

-

To stay updated, there is an RSS link: RSS IconRecent

-

Contact

-

I'm @ewintr@fosstodon.org on Mastodon.

-

Otherwise, you can contact me by sending me an email.

-
-
- diff --git a/resources/template/other.gohtml b/resources/template/other.gohtml deleted file mode 100644 index 29ba63f..0000000 --- a/resources/template/other.gohtml +++ /dev/null @@ -1,37 +0,0 @@ - - -{{- template "head" . -}} - -{{- template "menu" -}} -
-
-
-

Crunchy Granola logo

-

A site 🇳🇱 full of recipes for crunchy, tasty granolas that are nothing like the mundane stuff you buy at the store. Everything made from scratch, healthy ingredients, with options for all kinds of diets like gluten-free and keto. All recipes, photos, texts and design created by my wonderful girlfriend. I -eh- also did things.

-
-
-

Volca Keys

-

Some sounds I made. Some time ago.

- - - -
-
-

Story illustration

-

In 2015, one of my stories won the Lowlands Short Story contest. Because of that, it was featured in NRC, a Dutch national newspaper. You can read it here 🇳🇱 on their site.

-
-
-

Logo Beginnenmetroken.nl

-

A long time ago, somewhere at the start of this century, I created www.BeginnenMetRoken.nl, a satirical site that “helped” people to kickstart their smoking habit. Right in the middle of large campaings urging people to quit, it struck a nerve and went viral. Millions of pageviews, featured in several magazines. People still bring it up, twenty years later.

-

The site is gone, but it you can still view it here 🇳🇱 on Archive.org.

-
-
-
- - diff --git a/resources/template/static.gohtml b/resources/template/static.gohtml new file mode 100644 index 0000000..59ebf9c --- /dev/null +++ b/resources/template/static.gohtml @@ -0,0 +1,9 @@ + + +{{- template "head" . -}} + +{{- template "menu" -}} +
+{{- .MainHTML -}} +
+ diff --git a/site/render.go b/site/render.go index b159dec..f1e5fff 100644 --- a/site/render.go +++ b/site/render.go @@ -33,7 +33,7 @@ func moveResources(targetPath, resourcesPath string) error { return nil } -func renderStaticPages(targetPath string, statics []*StaticPage) error { +func renderStaticPages(targetPath string, tpl *template.Template, statics []*StaticPage) error { for _, static := range statics { destPath := filepath.Join(targetPath, static.Name) if err := os.MkdirAll(destPath, dirMode); err != nil { @@ -45,16 +45,23 @@ func renderStaticPages(targetPath string, statics []*StaticPage) error { } defer pageFile.Close() - data := struct { - Title string - }{ - Title: strings.Title(static.Name), - } - if err := static.Template.Execute(pageFile, data); err != nil { + mainHTML, err := ioutil.ReadFile(filepath.Join(static.Path, "main.html")) + if err != nil { return err } - if err := copyFiles(filepath.Join(static.SourcePath, "*"), destPath); err != nil { + data := struct { + Title string + Main string + }{ + Title: strings.Title(static.Name), + Main: string(mainHTML), + } + if err := tpl.Execute(pageFile, data); err != nil { + return err + } + + if err := copyFiles(filepath.Join(static.Path, "resources", "*"), destPath); err != nil { return err } } diff --git a/site/site.go b/site/site.go index 1e0536e..760a66d 100644 --- a/site/site.go +++ b/site/site.go @@ -8,9 +8,8 @@ import ( ) type StaticPage struct { - Name string - Template *template.Template - SourcePath string + Name string + Path string } type Site struct { @@ -26,23 +25,21 @@ func New(resourcesPath string) (*Site, error) { return &Site{}, err } - staticPages := []*StaticPage{} - for _, stName := range []string{"other", "about"} { - staticPages = append(staticPages, &StaticPage{ - Name: stName, - Template: templates[stName], - SourcePath: filepath.Join(resourcesPath, stName), - }) - } - return &Site{ resourcesPath: resourcesPath, templates: templates, posts: []Post{}, - staticPages: staticPages, + staticPages: []*StaticPage{}, }, nil } +func (s *Site) AddStaticPage(staticPath string) { + s.staticPages = append(s.staticPages, &StaticPage{ + Name: filepath.Base(staticPath), + Path: staticPath, + }) +} + func (s *Site) AddFilePost(fPath string) error { content, err := ioutil.ReadFile(fPath) if err != nil { @@ -67,7 +64,7 @@ func (s *Site) RenderHTML(targetPath string) error { if err := moveResources(targetPath, s.resourcesPath); err != nil { return err } - if err := renderStaticPages(targetPath, s.staticPages); err != nil { + if err := renderStaticPages(targetPath, s.templates["static"], s.staticPages); err != nil { return err } @@ -96,7 +93,7 @@ func (s *Site) RenderHTML(targetPath string) error { func parseTemplates(resourcesPath string) (map[string]*template.Template, error) { templates := map[string]*template.Template{} tPath := filepath.Join(resourcesPath, "template") - for _, tName := range []string{"post", "list", "archive", "other", "about"} { + for _, tName := range []string{"post", "list", "archive", "static"} { var tFiles []string for _, tf := range []string{tName, "head", "menu"} { tFiles = append(tFiles, filepath.Join(tPath, fmt.Sprintf("%s.gohtml", tf)))