Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
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
59 changes: 59 additions & 0 deletions .github/workflows/web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy to GitHub Pages

on:
push:
branches: [ frontend ] # NOTE: Switch to 'main' when confirmed it's working.

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: 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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
# 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
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=
55 changes: 55 additions & 0 deletions tqweb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 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

build: clean
$(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

serve:
python3 -m http.server 8000
14 changes: 14 additions & 0 deletions tqweb/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* 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.
*/
const onCopyClick = async (query, input) => {
var output = `<<EOF tq -q '${query}'\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.

117 changes: 117 additions & 0 deletions tqweb/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<base href="/" />
<script src="https://cdn.tailwindcss.com"></script>
<script src="htmx.min.js"></script>
<script src="copy.js"></script>
<script>
navigator.serviceWorker.register("worker.js");
</script>
</head>
<body class="bg-[#000000] text-[#9cd0f4] min-h-screen font-mono">
<div class="flex flex-col min-h-screen">
<nav class="flex items-center justify-between px-4 py-3 bg-gray-700">
<div class="flex items-center space-x-2">
<a href="https://github.com/mdm-code/tq">
<img class="w-6" src="tq.svg" alt="TQ">
</a>
<span class="text-base font-bold">
<h1>
playground
</h1>
</span>
</div>
<div class="flex fill-[#9cd0f4] items-center space-x-4 me-4 text-xl">
<div class="flex relative group">
<button
onclick="onCopyClick(document.querySelector('#query').value, document.querySelector('#input').value)"
class="hover:fill-gray-900"
>
<svg class="w-6" viewBox="0 0 24 24">
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"/>
</svg>
</button>
<div class="absolute mt-9 text-xs left-1/2 -translate-x-1/2 hidden group-hover:block bg-gray-800 text-sm px-2 py-1 rounded">copy</div>
</div>
<div class="flex relative group">
<button class="hover:fill-gray-900">
<a href="https://github.com/mdm-code/tq">
<svg class="w-6" viewBox="0 0 24 24">
<path d="M12 1.27a11 11 0 00-3.48 21.46c.55.09.73-.28.73-.55v-1.84c-3.03.64-3.67-1.46-3.67-1.46-.55-1.29-1.28-1.65-1.28-1.65-.92-.65.1-.65.1-.65 1.1 0 1.73 1.1 1.73 1.1.92 1.65 2.57 1.2 3.21.92a2 2 0 01.64-1.47c-2.47-.27-5.04-1.19-5.04-5.5 0-1.1.46-2.1 1.2-2.84a3.76 3.76 0 010-2.93s.91-.28 3.11 1.1c1.8-.49 3.7-.49 5.5 0 2.1-1.38 3.02-1.1 3.02-1.1a3.76 3.76 0 010 2.93c.83.74 1.2 1.74 1.2 2.94 0 4.21-2.57 5.13-5.04 5.4.45.37.82.92.82 2.02v3.03c0 .27.1.64.73.55A11 11 0 0012 1.27"/>
</svg>
</a>
</button>
<div class="absolute mt-9 text-xs left-1/2 -translate-x-1/2 hidden group-hover:block bg-gray-800 text-sm px-2 py-1 rounded">source</div>
</div>
</div>
</nav>
<main class="flex flex-1 overflow-hidden">
<form class="flex w-full" id="tq-form">
<section class="w-1/2 border-r border-gray-700 flex flex-col gap-4 p-4">
<div class="border border border-gray-700 bg-[#171717] rounded" id="tq-form-field-query">
<header class="border-b border-gray-700 px-4 py-2">
<h2 class="text-sm font-bold tracking-widest">
QUERY
</h2>
</header>
<div class="h-32">
<textarea
spellcheck="false"
class="w-full h-full bg-transparent text-sm px-4 py-2 resize-none focus:outline-none"
name="query"
id="query"
hx-post="api/process"
hx-trigger="input changed delay:1000ms"
hx-sync="this:replace"
hx-swap="outerHTML"
hx-target="#output"
></textarea>
</div>
</div>
<div class="flex-1 border border-gray-700 bg-[#171717] rouded flex flex-col" id="tq-form-field-input">
<header class="border-b border-gray-700 px-4 py-2">
<h2 class="text-sm font-bold tracking-widest">
TOML
</h2>
</header>
<div class="flex-1">
<textarea
spellcheck="false"
class="w-full h-full bg-transparent text-sm px-4 py-2 resize-none focus:outline-none"
name="input"
id="input"
hx-post="api/process"
hx-trigger="input changed delay:1000ms"
hx-sync="this:replace"
hx-swap="outerHTML"
hx-target="#output"
></textarea>
</div>
</div>
</section>
<section class="w-1/2 flex flex-col p-4">
<div class="flex-1 border border-gray-700 bg-[#171717] rounded flex flex-col" id="tq-form-field-output">
<header class="border-b border-gray-700 px-4 py-2">
<h2 class="text-sm font-bold tracking-widest">
OUTPUT
</h2>
</header>
<div class="flex-1">
<textarea
spellcheck="false"
class="w-full h-full bg-transparent text-sm px-4 py-2 resize-none focus:outline-none"
name="output"
id="output"
readonly
></textarea>
</div>
</div>
</section>
</form>
</main>
</div>
</body>
</html>
Loading
Loading