Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/go-linux.yml
Original file line number Diff line number Diff line change
@@ -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.
38 changes: 38 additions & 0 deletions .github/workflows/go-mac.yml
Original file line number Diff line number Diff line change
@@ -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.
38 changes: 38 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -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 Windows

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:

jobs:
build:
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-windows
path: ./tweego.exe
# The desired behavior if no files are found using the provided path.
1 change: 1 addition & 0 deletions filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 33 additions & 1 deletion storyload.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ package main
import (
// standard packages
"bytes"
"compress/zlib"
b64 "encoding/base64"
"fmt"
"log"
"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"
)
Expand Down Expand Up @@ -50,6 +54,18 @@ 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", "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())
}
case "otf", "ttf", "woff", "woff2":
if err := s.loadFont(filename); err != nil {
log.Fatalf("error: load %s: %s", filename, err.Error())
Expand Down Expand Up @@ -379,10 +395,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
Expand Down