Create a jq Plugin

A brainstorm and some notes about motivation. jq can be compiled to wasm. What would a jq wiki plugin look like? link github

This page is a Project within a Topicmap. dmx

Type a jq filter into the jq wiki console below then click out of the <textarea>. jq will run this page json through the filter and emit the results into a little object inspector.

The simplest jq program is "." which just emits the whole page. You could also try ".story[].type". See the jq documentation and get as creative as you like.

./jq docs

https://dobbs.github.io/wiki-jq/ HEIGHT 400

Motivation

Wiki is made of trees. (true for most web apps, for that matter). The HTML DOM, the json pages, the sitemap and site-index.

I'm imagining a jq item where the editor lets me specify three things: a source, a program to transform the source, and a target for the output. We would include a button so the reader is in control of when the transformation takes place.

A json source could be the wiki page itself, an item in the page, or maybe actions in the journal, or a URL to some other json source. We could also ask for something like a radar-source or similar wiki data source.

The filter is a text field for editing the jq language.

The target could emit the resulting json into a <details> item, or open a ghost page. That latter trick is the one I imagine being most generally useful for hacking wiki-based data.

Example jq programs

Here is a link to examples that use jq to transform a minimal json configuration into the shape needed for wiki's config.json and the related owner.json for friends security plugin. See dobbs/droplet-wiki-wiki

Tasks

GitHub repo of the wasm library: owenthereal/jq-wasm

Very small amount of code for this frame experiment. See dobbs/wiki-jq .

- [x] FAILED build the jqlang playground from source - [x] FAILED build the jq-wasm from source

- [x] does jq-web work? yes, but it's slow - [x] learn the minimum possible for browserify - [x] try jq-wasm again with browserify SUCCESS!

- [x] create a custom build to get the wasm and javascript wrapper into a shape that could live in a wiki assets folder - [x] experiment a little in the browser console to run json through a jq filter - [ ] move experiments into libraries

- [x] sketch the editor in HTML - [x] try using frame plugin to host an editor

- [ ] decide: is the framed jq editor sufficient to satisfy the needs for jq experimentation? or would a wiki plugin offer enough advantage? Question: what would the plugin docs look like? (pursuing an answer to this question may help reveal if there's enough to gain from a full plugin)