From: Lady Date: Thu, 31 Jul 2025 01:11:55 +0000 (-0400) Subject: Improve development setup X-Git-Url: https://git.ladys.computer/Vocab/commitdiff_plain/8ea5a16a134fe52695c84822c97edb0fc6a3fe30?ds=sidebyside Improve development setup - A leading '%' can now be used to ignore files. - `make serve` can be used to spin up a simple webserver. --- diff --git a/.gitignore b/.gitignore index e75c358..f34112d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /build /public .grass +%* diff --git a/GNUmakefile b/GNUmakefile index 72bf292..9be1646 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -34,7 +34,9 @@ SHUSHEOPTS := $(MAKEOPTS) SRCDIR='$(SRCDIR)' DATADIR='$(DATADIR)' BUILDDIR='$(BU YSEME := .πŸ‘₯πŸ“€ YSEMEOPTS := $(MAKEOPTS) BUILDTARGET='$(BUILDTARGET)' DESTDIR='$(DESTDIR)' SERVERPATH='lady/vocab' -xmls := $(wildcard $(DATADIR)/*/*) +PORT := 3000 + +xmls := $(wildcard $(DATADIR)/*/[0-9A-Za-z_]*) $(wildcard $(DATADIR)/*/Β¦*) # ━ Β§ Call out to β›©πŸ“° δΉ¦η€Ύ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -81,10 +83,14 @@ $(foreach xml,$(xmls),lint][$(xml)) : lint][% : .libxml2/xmllint .IGNORE : $(foreach xml,$(xmls),lint][$(xml)) ; -.PHONY : FORCE build clean dry-sync gone lint $(foreach xml,$(xmls),lint][$(xml)) list prebuild sync uninstall ; +.PHONY : FORCE build clean dry-sync gone lint $(foreach xml,$(xmls),lint][$(xml)) list prebuild serve sync uninstall ; gone : clean uninstall ; +serve : + @printf '%b\n' '\0033[1m\n\0033[7m NOTE: \0033[27m Visit to view the site.\n\0033[7m \0033[27m \n\0033[7m \0033[27m Press control + C to exit.\n\0033[22m' >&2 + @ruby ./scripts/serve.rb $(PORT) >&2 + uninstall : @for publicfile in $(patsubst %,"%",$(wildcard $(DESTDIR)/*)); do if $(GIT) check-ignore -q "$$publicfile"; then $(RM) -rf "$$publicfile"; fi; done diff --git a/scripts/serve.rb b/scripts/serve.rb new file mode 100755 index 0000000..cf3b14a --- /dev/null +++ b/scripts/serve.rb @@ -0,0 +1,18 @@ +#!/usr/bin/ruby +# SPDX-FileCopyrightText: 2025 Lady +# SPDX-License-Identifier: CC0-1.0 + +require "webrick" + +server = WEBrick::HTTPServer.new(Port: ARGV[0] || 3000, DocumentRoot: "public", DirectoryIndex: ["index.xhtml"]) +trap 'INT' do server.shutdown end + +class XHTMLHandler < WEBrick::HTTPServlet::DefaultFileHandler + def do_GET request, response + super + response['Content-Type'] = 'application/xhtml+xml' + end +end +WEBrick::HTTPServlet::FileHandler.add_handler("xhtml", XHTMLHandler) + +server.start