Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fc3f2e6
Commit go.work to the repository
mdm-code Nov 30, 2025
3c30b78
Vendored dependencies in the workspace
mdm-code Nov 30, 2025
0843e8e
Added tqweb as a separate module
mdm-code Nov 30, 2025
d8cc0e0
Added vendored dependencies for tqweb
mdm-code Nov 30, 2025
1def14c
Created tqweb Makefile
mdm-code Nov 30, 2025
fee1967
Added js asserts and placeholders
mdm-code Nov 30, 2025
f210c98
WIP
mdm-code Dec 9, 2025
0ec5f16
Added dummy form for query
mdm-code Jan 27, 2026
8fde633
Wrote dummy wasm http handler
mdm-code Jan 27, 2026
995f72a
Imported tq from the workspace
mdm-code Jan 29, 2026
8efdb75
Plop a css stylesheet placeholder
mdm-code Feb 3, 2026
10e0c65
Add basic tq processing with input and output
mdm-code Feb 3, 2026
8560efa
Simplified the wasm web server
mdm-code Feb 6, 2026
a1c493d
Cleaned dependencies
mdm-code Feb 6, 2026
ccdd928
Wrapped up the playground frontend
mdm-code Feb 16, 2026
a0cfe1a
Update web server for static files
mdm-code Apr 16, 2026
6b57bb9
Updated tqweb environment to Go 1,26
mdm-code May 5, 2026
50314d6
Added base to the index.html
mdm-code May 5, 2026
3335d53
Created static web deployment
mdm-code May 5, 2026
c8748a4
Updated the catalog for gh pages deployment
mdm-code May 5, 2026
e871bf7
Updated base href for sed to work
mdm-code May 5, 2026
2d30860
Updated the sed command, again
mdm-code May 5, 2026
ad7dbea
Temporary deployment check
mdm-code May 5, 2026
2f5d40f
Switch to github actions for static site deploy
mdm-code Jul 30, 2026
0e394d2
Resolve issue with missing sw.js on assets download
mdm-code Aug 4, 2026
656a2ad
Version the wasm binary not to hit cache
mdm-code Aug 4, 2026
8471dd9
Open source code links in the new tab
mdm-code Aug 4, 2026
884bd73
Stop using dev version of tailwind
mdm-code Aug 6, 2026
7111afd
Added tq flag options to the frontend
mdm-code Aug 10, 2026
81e2ae8
Added ripple effects on buttons
mdm-code Aug 10, 2026
d606930
Renamed view from index to output
mdm-code Aug 11, 2026
d59fc03
Switch github pages deploy to main branch
mdm-code Aug 11, 2026
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
69 changes: 69 additions & 0 deletions .github/workflows/web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy to GitHub Pages

on:
push:
branches: [ main ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
defaults:
run: # NOTE: This only applies to 'run' steps like make, sed, cp; not to actions.
working-directory: './tqweb'
steps:
- name: Checkout
uses: actions/checkout@v4.2.0
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5.4.0
with:
go-version: '1.26' # must match go.work

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm
cache-dependency-path: tqweb/package-lock.json

- name: Install npm dependencies
run: npm ci

- name: Build assets
run: make assets

- name: Build WASM
run: make build

- name: Change base tag in index.html from / to tq
run: sed -i 's|<base href="/" />|<base href="/tq/" />|g' index.html

- name: Copy index.html to 404.html
run: cp index.html 404.html

- name: Add .nojekyll
run: touch .nojekyll

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: tqweb

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@
# vendor/

# Go workspace file
go.work
# go.work

# Project specific files that should not be committed to the repository
# Built WASM binaries (unversioned and content-hashed)
api.wasm
api.*.wasm
# Worker file generated from worker.js.in
worker.js

# Files related to tailwind
node_modules/
styles.css
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ require (
github.com/mdm-code/scanner v1.2.1
github.com/pelletier/go-toml/v2 v2.1.0
)

require github.com/stretchr/testify v1.10.0 // indirect
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
6 changes: 6 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.26.0

use (
.
./tqweb
)
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/mdm-code/tq/v2 v2.5.1/go.mod h1:InmaslI3cLnYkGSxckoxdo+oGf58sT8cBz++ET5CylY=
61 changes: 61 additions & 0 deletions tqweb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
GO=go
GOFLAGS=-mod=vendor -trimpath
HTMX_VERSION?=2.0.8
# NOTE
# ====
# #1 The master version of the Javascript code fom the go-wasm-http-server has
# been updated since the version v2.2.1. If for any reason it might be necessary
# to revert to the version used in Go code, here is a quick shell script to
# pull the version from the go.mod file.
#
# GO_WASM_HTTP_SERVER_VERSION?=master
#
# #2 The master version seems not to work right with Go 1.26.
#
GO_WASM_HTTP_SERVER_VERSION?=$(shell\
grep go-wasm-http-server go.mod |\
cut -d' ' -f2\
)
# ====

export CGO_ENABLED=0
export GOOS=js
export GOARCH=wasm

ifndef VERBOSE
.SILENT:
endif

.PHONY: assets npm css build serve clean

.PHONY: .ONESHELL
.ONESHELL:

assets:
cp $$(go env GOROOT)/lib/wasm/wasm_exec.js wasm_exec.js
curl https://cdn.jsdelivr.net/npm/htmx.org@$(HTMX_VERSION)/dist/htmx.min.js > htmx.min.js
curl https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@$(GO_WASM_HTTP_SERVER_VERSION)/sw.js > sw.js

npm:
npm ci

css: npm
npx @tailwindcss/cli -i ./input.css -o ./styles.css --minify

build: clean css
$(GO) build $(GOFLAGS) -ldflags '-s -w' -o api.wasm .
if command -v sha256sum >/dev/null 2>&1; then \
VERSION=$$(sha256sum api.wasm | cut -c1-8); \
else \
VERSION=$$(shasum -a 256 api.wasm | cut -c1-8); \
fi; \
mv api.wasm api.$${VERSION}.wasm; \
sed -e "s|__WASM__|api.$${VERSION}.wasm|g" \
-e "s|__CACHE__|api-$${VERSION}|g" \
worker.js.in > worker.js

clean:
rm -f api.wasm api.*.wasm worker.js styles.css

serve:
python3 -m http.server 8000
30 changes: 30 additions & 0 deletions tqweb/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copy the tq terminal command to the clipboard.
*
* @param {string} query - The query provided by the user.
* @param {string} input - The input provided by the user.
* @param {HTMLFormElement} form - The playground form with option checkboxes.
*/
const onCopyClick = async (query, input, form) => {
const flags = [];
if (form.querySelector('[name="tables-inline"]')?.checked) {
flags.push('-t');
}
if (form.querySelector('[name="arrays-multiline"]')?.checked) {
flags.push('-m');
}
if (form.querySelector('[name="indent-tables"]')?.checked) {
flags.push('-i');
}
const indentSymbol = form.querySelector('[name="indent-symbol"]')?.value ?? '';
if (indentSymbol !== '' && indentSymbol !== ' ') {
flags.push(`-s '${indentSymbol.replace(/'/g, `'\\''`)}'`);
}
const flagStr = flags.length ? ` ${flags.join(' ')}` : '';
var output = `<<EOF tq -q '${query}'${flagStr}\n${input}\nEOF`;
try {
navigator.clipboard.writeText(output);
} catch (err) {
console.log('Unable to copy the query.');
};
};
4 changes: 4 additions & 0 deletions tqweb/copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tqweb/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions tqweb/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/mdm-code/tqweb

go 1.26.0

require (
github.com/mdm-code/tq/v2 v2.5.1
github.com/nlepage/go-wasm-http-server/v2 v2.2.1
)

require (
github.com/hack-pad/safejs v0.1.1 // indirect
github.com/mdm-code/scanner v1.2.1 // indirect
github.com/nlepage/go-js-promise v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/stretchr/testify v1.10.0 // indirect
)
29 changes: 29 additions & 0 deletions tqweb/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hack-pad/safejs v0.1.1 h1:d5qPO0iQ7h2oVtpzGnLExE+Wn9AtytxIfltcS2b9KD8=
github.com/hack-pad/safejs v0.1.1/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
github.com/mdm-code/scanner v1.2.1 h1:GZ1DYAkhTXK+M4AG65L5fnl5eUt7M6XDAYBVZNH+cBc=
github.com/mdm-code/scanner v1.2.1/go.mod h1:ut94FGYZVrQk7uBkf0vJ0ngKuJbdkTEDnmY07ZI8yb0=
github.com/mdm-code/tq/v2 v2.5.1 h1:G6rSTYYByx+/jRodFkrLnsWNK617nMMx34jWZWxX470=
github.com/mdm-code/tq/v2 v2.5.1/go.mod h1:InmaslI3cLnYkGSxckoxdo+oGf58sT8cBz++ET5CylY=
github.com/nlepage/go-js-promise v1.0.0 h1:K7OmJ3+0BgWJ2LfXchg2sI6RDr7AW/KWR8182epFwGQ=
github.com/nlepage/go-js-promise v1.0.0/go.mod h1:bdOP0wObXu34euibyK39K1hoBCtlgTKXGc56AGflaRo=
github.com/nlepage/go-wasm-http-server/v2 v2.2.1 h1:4tzhSb3HKQ3Ykt2TPfqEnmcPfw8n1E8agv4OzAyckr8=
github.com/nlepage/go-wasm-http-server/v2 v2.2.1/go.mod h1:r8j7cEOeUqNp+c+C52sNuWaFTvvT/cNqIwBuEtA36HA=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1 change: 1 addition & 0 deletions tqweb/htmx.min.js

Large diffs are not rendered by default.

Loading
Loading