From 25c14c56abc73c6f553247dc6daed6bcf8ff7043 Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 18 Sep 2021 09:32:14 +1000 Subject: [PATCH] Forked project --- README.md | 19 ++----- zs_build_test.go => build_test.go | 0 go.mod | 4 +- go.sum | 4 -- zs.go => main.go | 82 ++----------------------------- zs_test.go => main_test.go | 0 6 files changed, 7 insertions(+), 102 deletions(-) rename zs_build_test.go => build_test.go (100%) rename zs.go => main.go (82%) rename zs_test.go => main_test.go (100%) diff --git a/README.md b/README.md index 18055d8..dda5588 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ -zs -== - -[![Build Status](https://travis-ci.org/zserge/zs.svg?branch=master)](https://travis-ci.org/zserge/zs) +# zs zs is an extremely minimal static site generator written in Go. @@ -22,11 +19,11 @@ The name stands for 'zen static' as well as it's my initials. Download the binaries from Github or build it manually: - $ go get github.com/zserge/zs + $ go get git.mills.io/prologic/zs ## Ideology -Keep your texts in markdown, [amber] or HTML format right in the main directory +Keep your texts in markdown, or HTML format right in the main directory of your blog/site. Keep all service files (extensions, layout pages, deployment scripts etc) @@ -92,12 +89,6 @@ content generation, or additional commands, like LESS to CSS conversion: lessc < $ZS_OUTDIR/styles.less > $ZS_OUTDIR/styles.css rm -f $ZS_OUTDIR/styles.css -## Syntax sugar - -By default, `zs` converts each `.amber` file into `.html`, so you can use lightweight Jade-like syntax instead of bloated HTML. - -Also, `zs` converts `.gcss` into `.css`, so you don't really need LESS or SASS. More about GCSS can be found [here][gcss]. - ## Command line usage `zs build` re-builds your site. @@ -113,7 +104,3 @@ it's an empty string). ## License The software is distributed under the MIT license. - -[amber]: https://github.com/eknkc/amber/ -[YAML]: https://github.com/go-yaml/yaml -[gcss]: https://github.com/yosssi/gcss diff --git a/zs_build_test.go b/build_test.go similarity index 100% rename from zs_build_test.go rename to build_test.go diff --git a/go.mod b/go.mod index 7e0495b..636544d 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,8 @@ -module github.com/zserge/zs +module git.mills.io/prologic/zs go 1.17 require ( - github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 github.com/russross/blackfriday/v2 v2.1.0 - github.com/yosssi/gcss v0.1.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index f31dbb0..6fc9007 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,5 @@ -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/yosssi/gcss v0.1.0 h1:jRuino7qq7kqntBIhT+0xSUI5/sBgCA/zCQ1Tuzd6Gg= -github.com/yosssi/gcss v0.1.0/go.mod h1:M3mTPOWZWjVROkXKZ2AiDzOBOXu2MqQeDXF/nKO44sI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/zs.go b/main.go similarity index 82% rename from zs.go rename to main.go index 49629cb..fcea445 100644 --- a/zs.go +++ b/main.go @@ -13,9 +13,7 @@ import ( "text/template" "time" - "github.com/eknkc/amber" "github.com/russross/blackfriday/v2" - "github.com/yosssi/gcss" "gopkg.in/yaml.v2" ) @@ -58,10 +56,7 @@ func globals() Vars { // prepended. Additional variable $ZS contains path to the zs binary. Command // stderr is printed to zs stderr, command output is returned as a string. func run(vars Vars, cmd string, args ...string) (string, error) { - // First check if partial exists (.amber or .html) - if b, err := ioutil.ReadFile(filepath.Join(ZSDIR, cmd+".amber")); err == nil { - return string(b), nil - } + // First check if partial exists (.html) if b, err := ioutil.ReadFile(filepath.Join(ZSDIR, cmd+".html")); err == nil { return string(b), nil } @@ -115,11 +110,7 @@ func getVars(path string, globals Vars) (Vars, string, error) { // Add layout if none is specified if _, ok := v["layout"]; !ok { - if _, err := os.Stat(filepath.Join(ZSDIR, "layout.amber")); err == nil { - v["layout"] = "layout.amber" - } else { - v["layout"] = "layout.html" - } + v["layout"] = "layout.html" } delim := "\n---\n" @@ -200,11 +191,7 @@ func buildMarkdown(path string, w io.Writer, vars Vars) error { defer out.Close() w = out } - if strings.HasSuffix(v["layout"], ".amber") { - return buildAmber(filepath.Join(ZSDIR, v["layout"]), w, v) - } else { - return buildHTML(filepath.Join(ZSDIR, v["layout"]), w, v) - } + return buildHTML(filepath.Join(ZSDIR, v["layout"]), w, v) } // Renders text file expanding all variable macros inside it @@ -231,65 +218,6 @@ func buildHTML(path string, w io.Writer, vars Vars) error { return tmpl.Execute(w, vars) } -// Renders .amber file into .html -func buildAmber(path string, w io.Writer, vars Vars) error { - v, body, err := getVars(path, vars) - if err != nil { - return err - } - a := amber.New() - if err := a.Parse(body); err != nil { - fmt.Println(body) - return err - } - - t, err := a.Compile() - if err != nil { - return err - } - - htmlBuf := &bytes.Buffer{} - if err := t.Execute(htmlBuf, v); err != nil { - return err - } - - if body, err = render(string(htmlBuf.Bytes()), v); err != nil { - return err - } - - if w == nil { - f, err := os.Create(filepath.Join(PUBDIR, renameExt(path, ".amber", ".html"))) - if err != nil { - return err - } - defer f.Close() - w = f - } - _, err = io.WriteString(w, body) - return err -} - -// Compiles .gcss into .css -func buildGCSS(path string, w io.Writer) error { - f, err := os.Open(path) - if err != nil { - return err - } - defer f.Close() - - if w == nil { - s := strings.TrimSuffix(path, ".gcss") + ".css" - css, err := os.Create(filepath.Join(PUBDIR, s)) - if err != nil { - return err - } - defer css.Close() - w = css - } - _, err = gcss.Compile(w, f) - return err -} - // Copies file as is from path to writer func buildRaw(path string, w io.Writer) error { in, err := os.Open(path) @@ -315,10 +243,6 @@ func build(path string, w io.Writer, vars Vars) error { return buildMarkdown(path, w, vars) } else if ext == ".html" || ext == ".xml" { return buildHTML(path, w, vars) - } else if ext == ".amber" { - return buildAmber(path, w, vars) - } else if ext == ".gcss" { - return buildGCSS(path, w) } else { return buildRaw(path, w) } diff --git a/zs_test.go b/main_test.go similarity index 100% rename from zs_test.go rename to main_test.go