This commit is contained in:
mjsmagalhaes 2023-03-23 03:17:13 -03:00 committed by GitHub
commit b81d0a6b18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 148 additions and 1 deletions

38
.github/workflows/go-linux.yml vendored Normal file
View file

@ -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
.github/workflows/go-mac.yml vendored Normal file
View file

@ -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
.github/workflows/go.yml vendored Normal file
View file

@ -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.

View file

@ -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",

View file

@ -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"
)
@ -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())
@ -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