From 6a91103a6d7e60375dcad05879eb1427229ad6d8 Mon Sep 17 00:00:00 2001 From: MJSM Date: Fri, 17 Feb 2023 05:38:31 -0300 Subject: [PATCH 1/9] [UPDATE] Add support to YAML and NJK files --- storyload.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storyload.go b/storyload.go index 7f8a378..ba1df9b 100644 --- a/storyload.go +++ b/storyload.go @@ -14,9 +14,11 @@ import ( "path/filepath" "strconv" "strings" + // internal packages twee2 "github.com/tmedwards/tweego/internal/twee2compat" twlex "github.com/tmedwards/tweego/internal/tweelexer" + // external packages "golang.org/x/net/html" ) @@ -50,6 +52,14 @@ func (s *story) load(filenames []string, c *config) { if err := s.loadTagged("script", filename, c.encoding); err != nil { log.Fatalf("error: load %s: %s", filename, err.Error()) } + case "yaml": + if err := s.loadTagged("data", filename, c.encoding); err != nil { + log.Fatalf("error: load %s: %s", filename, err.Error()) + } + case "njk": + if err := s.loadTagged("template", filename, c.encoding); err != nil { + log.Fatalf("error: load %s: %s", filename, err.Error()) + } case "otf", "ttf", "woff", "woff2": if err := s.loadFont(filename); err != nil { log.Fatalf("error: load %s: %s", filename, err.Error()) From f6e633fc0f026955cf8b04fa5ff948bc0a2231d8 Mon Sep 17 00:00:00 2001 From: MJSM Date: Fri, 17 Feb 2023 11:10:08 -0300 Subject: [PATCH 2/9] [UPDATE] Add compression to data and template tags --- storyload.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/storyload.go b/storyload.go index ba1df9b..410c0fa 100644 --- a/storyload.go +++ b/storyload.go @@ -9,6 +9,8 @@ package main import ( // standard packages "bytes" + "compress/zlib" + b64 "encoding/base64" "fmt" "log" "path/filepath" @@ -389,10 +391,26 @@ func (s *story) loadTagged(tag, filename, encoding string) error { return err } + var str string + + if tag == "data" || tag == "template" { + // Add Compression + var b bytes.Buffer + w := zlib.NewWriter(&b) + w.Write(source) + w.Close() + + // str = b64.StdEncoding.EncodeToString(source) + str = b64.StdEncoding.EncodeToString(b.Bytes()) + // fmt.Println(filename, len(b.Bytes()), len(str)) + } else { + str = string(source) + } + s.add(newPassage( filepath.Base(filename), []string{tag}, - string(source), + str, )) return nil From 9a71ecab7d1b789945b95e705c5746fa90390706 Mon Sep 17 00:00:00 2001 From: MJSM Date: Sun, 19 Feb 2023 07:36:00 -0300 Subject: [PATCH 3/9] [UPDATE]: Add support to JSON --- filesystem.go | 1 + storyload.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/filesystem.go b/filesystem.go index 1535e26..949df5e 100644 --- a/filesystem.go +++ b/filesystem.go @@ -203,6 +203,7 @@ func knownFileType(filename string) bool { "htm", "html", "css", "js", + "yaml", "njk", "json", "otf", "ttf", "woff", "woff2", "gif", "jpeg", "jpg", "png", "svg", "tif", "tiff", "webp", "aac", "flac", "m4a", "mp3", "oga", "ogg", "opus", "wav", "wave", "weba", diff --git a/storyload.go b/storyload.go index 410c0fa..f133931 100644 --- a/storyload.go +++ b/storyload.go @@ -54,10 +54,14 @@ func (s *story) load(filenames []string, c *config) { if err := s.loadTagged("script", filename, c.encoding); err != nil { log.Fatalf("error: load %s: %s", filename, err.Error()) } - case "yaml": + case "yaml", "json": if err := s.loadTagged("data", filename, c.encoding); err != nil { log.Fatalf("error: load %s: %s", filename, err.Error()) } + // case "json": + // if err := s.loadJson("data", filename, c.encoding); err != nil { + // log.Fatalf("error: load %s: %s", filename, err.Error()) + // } case "njk": if err := s.loadTagged("template", filename, c.encoding); err != nil { log.Fatalf("error: load %s: %s", filename, err.Error()) From 841615cb9bc0d8e73812fe6810febd12f876bee8 Mon Sep 17 00:00:00 2001 From: mjsmagalhaes Date: Wed, 22 Feb 2023 10:56:22 -0300 Subject: [PATCH 4/9] [UPDATE]: Setup action to build linux release --- .github/workflows/go.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..bea9bd6 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,35 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Build + run: go build -v + + - name: Test + run: go test -v + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: Tweego + path: ./tweego + # The desired behavior if no files are found using the provided path. From e59ac7dd4089c0d0c462a46a96423229068ad5f4 Mon Sep 17 00:00:00 2001 From: mjsmagalhaes Date: Wed, 22 Feb 2023 10:59:06 -0300 Subject: [PATCH 5/9] [UPDATE]: Update workflow --- .github/workflows/go.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index bea9bd6..e909d4c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,13 +1,14 @@ # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go -name: Go +name: Go Ubuntu on: push: branches: [ "master" ] pull_request: branches: [ "master" ] + workflow_dispatch: jobs: From aa7aab34eceac66cc211862a9790ae080a167d5a Mon Sep 17 00:00:00 2001 From: mjsmagalhaes Date: Wed, 22 Feb 2023 11:06:15 -0300 Subject: [PATCH 6/9] Update go.yml --- .github/workflows/go.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e909d4c..e32c29d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,6 +21,10 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19 + cache: true + + - name: Install dependencies + run: go get . - name: Build run: go build -v From 8e530797a102f9c2d9eaded23a590da2d8cd84c1 Mon Sep 17 00:00:00 2001 From: mjsmagalhaes Date: Wed, 22 Feb 2023 11:07:54 -0300 Subject: [PATCH 7/9] Update go.yml --- .github/workflows/go.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e32c29d..a001184 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,6 +22,7 @@ jobs: with: go-version: 1.19 cache: true + cache-dependency-path: go.sum - name: Install dependencies run: go get . From 3682adbdc5071246c403da29bdb2d77cfceacf93 Mon Sep 17 00:00:00 2001 From: mjsmagalhaes Date: Wed, 22 Feb 2023 11:09:04 -0300 Subject: [PATCH 8/9] Update go.yml --- .github/workflows/go.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a001184..fd5ebc2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,8 +21,6 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19 - cache: true - cache-dependency-path: go.sum - name: Install dependencies run: go get . From e82a5db8266387167b92258ffe88bd8f2d32cd73 Mon Sep 17 00:00:00 2001 From: MJSM Date: Wed, 22 Feb 2023 11:21:47 -0300 Subject: [PATCH 9/9] update(workflows): add win, linux and macos artifacts --- .github/workflows/go-linux.yml | 38 ++++++++++++++++++++++++ .github/workflows/go-mac.yml | 38 ++++++++++++++++++++++++ .github/workflows/go.yml | 53 +++++++++++++++++----------------- 3 files changed, 102 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/go-linux.yml create mode 100644 .github/workflows/go-mac.yml diff --git a/.github/workflows/go-linux.yml b/.github/workflows/go-linux.yml new file mode 100644 index 0000000..1ea3356 --- /dev/null +++ b/.github/workflows/go-linux.yml @@ -0,0 +1,38 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go Linux + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Install dependencies + run: go get . + + - name: Build + run: go build -v + + - name: Test + run: go test -v + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: tweego-linux + path: ./tweego + # The desired behavior if no files are found using the provided path. diff --git a/.github/workflows/go-mac.yml b/.github/workflows/go-mac.yml new file mode 100644 index 0000000..c29daa4 --- /dev/null +++ b/.github/workflows/go-mac.yml @@ -0,0 +1,38 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go Linux + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + workflow_dispatch: + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Install dependencies + run: go get . + + - name: Build + run: go build -v + + - name: Test + run: go test -v + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: tweego-macos + path: ./tweego + # The desired behavior if no files are found using the provided path. diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fd5ebc2..46fae1f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,39 +1,38 @@ # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go -name: Go Ubuntu +name: Go Windows on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - - name: Install dependencies - run: go get . - - - name: Build - run: go build -v - - - name: Test - run: go test -v - - - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.1.2 - with: - name: Tweego - path: ./tweego - # The desired behavior if no files are found using the provided path. + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Install dependencies + run: go get . + + - name: Build + run: go build -v + + - name: Test + run: go test -v + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.2 + with: + name: tweego-windows + path: ./tweego.exe + # The desired behavior if no files are found using the provided path.