diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..3bab95e --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,28 @@ +name: Pages +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/configure-pages@v3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: prototypes/basic/package-lock.json + - name: Setup hq + run: | + curl https://github.com/ludovicianul/hq/releases/download/hq-1.3.2/hq_linux_amd64_1.3.2.tar.gz --output - | tar -xv + - name: Build site + working-directory: ./prototypes/basic + run: | + npm install + coproc npm run dev & + while ! (echo >/dev/tcp/localhost/3000); do sleep 1; done + export PATH:../../:$PATH + make -C ../../doc -j all + make -C ../../doc -j all + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..795bc88 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,49 @@ +HQ ?= $(shell which hq) + +SOURCES := $(wildcard ../lib/importer/assets/docs/*.html) +OBJECTS := $(subst ../lib/importer/assets/docs/,./,${SOURCES}) + +# Create a list of all of the assets the pages need, by looking at the scripts +# and stylesheets they intended to download. +assets.txt: ${SOURCES} + (echo $^ | xargs -n1 -IINPUT ${HQ} -r '[data-plugin-only]' -f INPUT -a src 'script[src]'; \ + echo $^ | xargs -n1 -IINPUT ${HQ} -r '[data-plugin-only]' -f INPUT -a href 'link[rel=stylesheet]') | \ + sort -u | grep . > $@ + +# Now build a Makefile dependency include, specifying the correct download +# location for each asset and that we require it for a complete package. +assets.mk: assets.txt + for ASSET in $$(cat assets.txt); do \ + export SRC=$$(echo $$ASSET | sed 's:^[^\/]:/plugin-assets/%40register-dynamics%2Fimporter/assets/docs/.:'); \ + printf "all: $$(basename $$ASSET)\n"; \ + printf "%s: SRC=%s\n\n" $$(basename $$ASSET) $$SRC; \ + done > $@ + +.PHONY: all +all: ${OBJECTS} | assets.txt # Rewrite all of the asset paths to be local now. + for ASSET in $$(cat assets.txt); do \ + sed -i '' -e "s:$$ASSET:$$(basename $$ASSET):" ${OBJECTS}; \ + done +include assets.mk + +# We can generate the .gitignore from all of the things we know we are going to +# end up with in the root dir. +.gitignore: assets.txt + (cat $^; printf '%s\n' ${OBJECTS}; echo assets.mk) | xargs basename > $@ +all: .gitignore + +# Download the page and remove any elements marked only for plugin use. +%.html: ../lib/importer/assets/docs/%.html + curl --fail -sL http://localhost:3000/$(subst ../lib/importer/,/plugin-assets/%40register-dynamics%2Fimporter/,$^) | \ + ${HQ} -r '[data-plugin-only]' -o $@ html + +# Download the asset. This is the easiest way to get the real thing, as some of +# them (e.g. application.css) are generated by the Prototype Kit and can't just +# be copied from the disk. +%.css %.js: + curl --fail -sL "http://localhost:3000/${SRC}" > $@ + +.PHONY: clean +clean: + -cat .gitignore | xargs $(RM) + -$(RM) assets.mk assets.txt