diff --git a/bin/sake b/bin/sake index f1d82ae..74ecc20 100755 --- a/bin/sake +++ b/bin/sake @@ -4,6 +4,9 @@ # Wraps make # +# Environment +declare -ri NCORES=${NCORES:-2} + # Options set -o errexit -o noglob -o nounset -o pipefail shopt -s expand_aliases @@ -15,9 +18,8 @@ declare -r SELF=${0##*/} declare -xr JQTLIB='/usr/local/share/jqt' # GMake call -declare -ri CORES=2 declare -ra makeflags=( - --jobs=$(( CORES * 150 / 100 )) # CORES * 1.5 + --jobs=$(( NCORES * 150 / 100 )) # NCORES * 1.5 --makefile=Sakefile --output-sync=target ) @@ -61,6 +63,10 @@ case $1 in shift _sake build "$@" ;; + config) + shift + _sake configure "$@" + ;; clober) shift _sake clobber "$@" diff --git a/docs/Sakefile b/docs/Sakefile index befbb6e..2935dbb 100644 --- a/docs/Sakefile +++ b/docs/Sakefile @@ -43,21 +43,9 @@ JQTFLAGS += -5 --toc-depth=4 # TODO: new, help, man page, SITE section on web, taxonomies (flags, series...) -# Remove? -#$(PagesHTML): $(Root)/%.html : $(Meta)/pages/%.json -#$(PagesHTML): $(Root)/blog/%.html : $(Meta)/pages/blog/%.json - - # TODO: show content pending to render? #newer: $(Meta)/lastbuild - -# TODO: move to phase3 -depend: - grep -r '<%include\s\+[^>]\+>' blocks/ layouts/\ - | sed -e 's/:.*<%include\s\+/\t/;s/>.*$$//' \ - | jq -nrR -f ./phase3_layout.jq --arg Layouts $(Layouts) - endif # __build # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/docs/phase3_layout.jq b/docs/phase3_layout.jq deleted file mode 100644 index be7ed44..0000000 --- a/docs/phase3_layout.jq +++ /dev/null @@ -1,29 +0,0 @@ -######################################################################## -# phase3_layout.jq -- Define contents for `$(Meta)/phase3_layout.json`. -# -# jq -nRr -f phase3_layout.jq -# < ... -# > $(Meta)/phase3_layout.json - -def makedepend: - def branch($root; $tree): - def _branch: - if in($tree) - then . , ($tree[.][] | _branch) - else . - end - ; - [$root | _branch][1:] | sort - ; - reduce inputs as $line ({}; ($line/"\t") as [$key,$value] | .[$key]+=[$value]) - | . as $tree - | reduce keys_unsorted[] as $r ({}; .[$r]=branch($r; $tree)) - | . as $dependents - | $tree | keys[] - | select(startswith($Layouts+"/")) - | "\(.): \($dependents[.] | join(" "))" -; - -makedepend - -# vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq diff --git a/share/sake.d/configuration.make b/share/sake.d/configuration.make index ed63d3c..4a293b9 100644 --- a/share/sake.d/configuration.make +++ b/share/sake.d/configuration.make @@ -26,8 +26,8 @@ MAKECMDGOALS ?= build # Make configuration. ######################################################################## -# Use renamed makefile -MAKE += --makefile=Sakefile +#!# Use renamed makefile +#!MAKE += --makefile=Sakefile # Disable builtins. MAKEFLAGS += --no-builtin-rules diff --git a/share/sake.d/main.make b/share/sake.d/main.make index abfef02..de480aa 100644 --- a/share/sake.d/main.make +++ b/share/sake.d/main.make @@ -2,27 +2,44 @@ # main.make -- Main makefile. # # Imported variables: -# JQTDIR +# JQTLIB # # Variables: # Meta # Rules: -# $(Meta) directory target and clobber target +# $(Meta) directory `mkdir`, `clobber' and ' clean' targets +# $(Root) directory `mkdir`, `clobber' and ' clean' targets +# Targets: +# build +# clean +# clobber +# nuke +# configure # ######################################################################## -# Where all *.make files resides... -MDIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) - ######################################################################## # Load _Make_ configuration. ######################################################################## +# Where all *.make files resides... +MDIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) + include $(MDIR)/configuration.make # Do not try to rebuilt static makefiles. $(CURDIR)/Sakefile $(MDIR)/main.make $(MDIR)/configuration.make: ; +######################################################################## +# Print debug info. +######################################################################## + +ifneq (,$(TRACE)) +ifdef MAKE_RESTARTS +$(info Makefile phase restarted: $(MAKE_RESTARTS)) +endif +endif + ######################################################################## # Metadata directory for all generated make and metadata files. ######################################################################## @@ -36,16 +53,6 @@ $(Meta): # Delete all generated metadata clobber:: ; @rm -rf $(Meta) -######################################################################## -# Print debug info. -######################################################################## - -ifneq (,$(TRACE)) -ifdef MAKE_RESTARTS -$(info Makefile phase restarted: $(MAKE_RESTARTS)) -endif -endif - ######################################################################## # Check command line sanity. ######################################################################## @@ -55,7 +62,7 @@ ifneq (1,$(words $(MAKECMDGOALS))) $(error Only one target accepted) endif -# Do not build to clobber immediately. +# Do not remake $(Meta)/phase[123].make to clobber immediately. ifeq (clobber,$(MAKECMDGOALS)) ifeq (,$(wildcard $(Meta))) $(error Nothing to clobber) @@ -66,11 +73,15 @@ endif # Include all makefile phases. ######################################################################## -# Recursive variable used in all included makefiles. This works because the -# included files do not include other makefiles. +# Recursive variables used in all included makefiles. +# Current makefile. +# $(THIS) works because the included files do not include other makefiles. THIS = $(lastword $(MAKEFILE_LIST)) +# JQ script generating target +SCRIPT = $(MDIR)/$$(basename $$(notdir $$@)).jq + ######################################################################## # Derive metadata from `config.yaml` or `config.json`. @@ -80,11 +91,12 @@ THIS = $(lastword $(MAKEFILE_LIST)) # Do not try to rebuilt static makefiles. $(MDIR)/phase1.make: ; -# If `__phase_1` is not defined because `phase1.make` does not exists, after -# this point the rest of the file is ignored, but `phase1.make` is built -# because a rule exists in the file `config.make`. Then this `Makefile` is -# restarted, `MAKE_RESTARTS` is be equal to 1, `phase1.make` is now loaded and -# `__phase_1` is defined. Equivalent situation happens in all phases. +# If `__phase_1` is not defined because `$(Meta)/phase1.make` does not +# exists, after this point the rest of the file is ignored, but +# `$(Meta)/phase1.make` is built because a rule exists in the file +# `$(MDIR)/phase1.make`. Then this `Makefile` is restarted, +# `MAKE_RESTARTS` is be equal to 1, `$(Meta)/phase1.make` is now loaded +# and `__phase_1` is defined. Equivalent situation happens in all phases. ifdef __phase_1 @@ -103,6 +115,7 @@ ifdef __phase_2 # Define standard rules and rules for HTML pages and nodes. -include $(Meta)/phase3.make +-include $(Meta)/phase3d.make include $(MDIR)/phase3.make # Do not try to rebuilt static makefiles. @@ -111,8 +124,47 @@ $(MDIR)/phase3.make: ; ifdef __phase_3 __build := 1 +######################################################################## +# Standard targets. +######################################################################## + +sake_builtin := new help touch list +.PHONY: build clean clobber nuke configure $(sake_builtin) + +# Filter builtin tools defined in `sake`script. +$(sake_builtin): ; @echo 'sake: Target `$@` not implemented.' + +# Copy Assets after create HTML pages. +build:: $(PagesHTML) + @cp --verbose --recursive --update $(Assets)/* $(Root) \ + | sed "s/^.*-> ./==> /;s/.$$//" + date -Iseconds > $(Meta)/lastbuild + +# Delete secondary files. +clobber:: ; @rm -rf *~ *.bak *.log + +# Delete metadata. Usage: `sake nuke && sake configure`. +nuke: ; @rm -rf $(Meta) + +# Build all metadata and data files. +configure: $(DataFiles) # $(PagesJSON) are built for phase2.make + +######################################################################## +# Site destination directory. + +$(Root): + $(info ==> $@) + mkdir --parents $@ >/dev/null 2>&1 || true + +# Delete generated files. Usage: `sake clean && sake`. +clean: ; @rm -rf $(Root)/* + +# Delete destination directory. +clobber:: ; @rm -rf $(Root) + ######################################################################## # Several complementary makefiles. +######################################################################## include $(MDIR)/sitemap.make include $(MDIR)/styles.make @@ -123,12 +175,6 @@ $(MDIR)/sitemap.make: ; $(MDIR)/styles.make: ; $(MDIR)/tools.make: ; -# Filter builtin tools defined in `sake`script. -sake_builtin := new help touch list -.PHONY: $(sake_builtin) -$(sake_builtin): - echo 'sake: Target `$@` not implemented.' - endif # __phase_3 endif # __phase_2 endif # __phase_1 diff --git a/share/sake.d/phase1.jq b/share/sake.d/phase1.jq index 745efed..0125642 100644 --- a/share/sake.d/phase1.jq +++ b/share/sake.d/phase1.jq @@ -2,7 +2,7 @@ # phase1.jq -- Define contents for `$(Meta)/phase2.make`. # # jq -r -f phase1.jq -# < $(Meta)/site.json +# < $(Meta)/phase1_site.json # > $(Meta)/phase1.make # diff --git a/share/sake.d/phase1.make b/share/sake.d/phase1.make index c2e251e..f5da368 100644 --- a/share/sake.d/phase1.make +++ b/share/sake.d/phase1.make @@ -13,9 +13,8 @@ # # Rules defined in $(MDIR)/phase1.make: # $(Meta)/config.json -# $(Meta)/site.json +# $(Meta)/phase1_site.json # $(Meta)/phase1.make -# $(Root) directory rule and clobber and clean targets SUPER := $(MDIR)/main.make @@ -24,33 +23,21 @@ SUPER := $(MDIR)/main.make ######################################################################## # -# Create `$(Meta)/config.json` from `config.yaml` or `config.json`. +# Create `$(Meta)/phase1.make` from `$(Meta)/phase1_site.json` using +# `$(MDIR)/phase1.jq`. # -ifeq (config.yaml,$(wildcard config.yaml)) - -# Convert `config.yaml` to `$(Meta)/config.json`. -$(Meta)/config.json: $(CURDIR)/config.yaml $(SUPER) $(THIS) \ -| $(Meta) - $(info ==> $@) - yaml2json < $< > $@ - -else ifeq (config.json,$(wildcard config.json)) - -# Convert `config.json` to `$(Meta)/config.json`. -$(Meta)/config.json: $(CURDIR)/onfig.json $(SUPER) $(THIS) \ -| $(Meta) +$(Meta)/phase1.make: $(SUPER) $(THIS) $(CURDIR)/Sakefile +$(Meta)/phase1.make: $(Meta)/phase1_site.json $(SCRIPT) $(info ==> $@) - jqt -Pjson < $< > $@ - -else -$(error Configuration file not found) -endif + jq --raw-output \ + --from-file $(MDIR)/phase1.jq \ + < $< > $@ # -# Create `$(Meta)/site.json` from `$(Meta)/config.json` using +# Create `$(Meta)/phase1_site.json` from `$(Meta)/config.json` using # `$(MDIR)/phase1_site.jq`. # -$(Meta)/site.json: $(Meta)/config.json $(MDIR)/phase1_site.jq +$(Meta)/phase1_site.json: $(Meta)/config.json $(SCRIPT) $(THIS) $(info ==> $@) jq --sort-keys \ --from-file $(MDIR)/phase1_site.jq \ @@ -58,31 +45,26 @@ $(Meta)/site.json: $(Meta)/config.json $(MDIR)/phase1_site.jq < $< > $@ # -# Create `$(Meta)/phase1.make` from `$(Meta)/site.json` using -# `$(MDIR)/phase1.jq`. +# Create `$(Meta)/config.json` from `config.yaml` or `config.json`. # -$(Meta)/phase1.make: $(Meta)/site.json $(MDIR)/phase1.jq - $(info ==> $@) - jq --raw-output \ - --from-file $(MDIR)/phase1.jq \ - < $< > $@ - -ifdef __phase_1 - -######################################################################## -# Site destination directory. -######################################################################## +ifeq (config.yaml,$(wildcard config.yaml)) -$(Root): +# Convert `config.yaml` to `$(Meta)/config.json`. +$(Meta)/config.json: $(CURDIR)/config.yaml $(THIS) \ +| $(Meta) $(info ==> $@) - mkdir --parents $@ >/dev/null 2>&1 || true + yaml2json < $< > $@ -# Delete generated files. -clean: ; @rm -rf $(Root)/* +else ifeq (config.json,$(wildcard config.json)) -# Delete destination directory. -clobber:: ; @rm -rf $(Root) +# Convert `config.json` to `$(Meta)/config.json`. +$(Meta)/config.json: $(CURDIR)/config.json $(THIS) \ +| $(Meta) + $(info ==> $@) + jqt -Pjson < $< > $@ -endif # __phase_1 +else +$(error Configuration file not found) +endif # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/share/sake.d/phase1_site.jq b/share/sake.d/phase1_site.jq index 3805261..5c8fd92 100644 --- a/share/sake.d/phase1_site.jq +++ b/share/sake.d/phase1_site.jq @@ -3,7 +3,7 @@ # # jq -S -f phase1_site.jq --arg Meta $(Meta) # < $(Meta)/config.json -# > $(Meta)/site.json +# > $(Meta)/phase1_site.json # Delete `.defaults` and add some new members with default value if not defined # in the configuration file. diff --git a/share/sake.d/phase2.make b/share/sake.d/phase2.make index ee588ad..6262cb8 100644 --- a/share/sake.d/phase2.make +++ b/share/sake.d/phase2.make @@ -37,25 +37,11 @@ SUPER := $(Meta)/phase1.make # generate JSON metadata files for each page. ######################################################################## -phase2_files := $(Meta)/content.text $(Meta)/data.text - -# Do not preserve! -.INTERMEDIATE: $(phase2_files) - -$(Meta)/content.text: $(THIS) - find $(Content) -type f -a \ - -name '[!_]*.md' -o \ - -name '[!_]*.mkd' -o \ - -name '[!_]*.markdown' \ - > $@ - -$(Meta)/data.text: $(THIS) - find $(Data) -name '*.*' > $@ - # # Create `$(Meta)/phase2.make` from `find` output using `$(MDIR)/phase2.jq`. # -$(Meta)/phase2.make: $(MDIR)/phase2.jq $(phase2_files) $(SUPER) $(THIS) +$(Meta)/phase2.make: $(SUPER) $(THIS) +$(Meta)/phase2.make: $(Meta)/content.text $(Meta)/data.text $(SCRIPT) $(info ==> $@) jq --raw-input \ --raw-output \ @@ -66,7 +52,22 @@ $(Meta)/phase2.make: $(MDIR)/phase2.jq $(phase2_files) $(SUPER) $(THIS) --arg Data $(Data) \ --arg Root $(Root) \ --arg Meta $(Meta) \ - < $(Meta)/content.text > $@ + < $< > $@ + +# Do not preserve! +.INTERMEDIATE: $(Meta)/content.text $(Meta)/data.text + +$(Meta)/content.text: $(THIS) + $(info ==> $@) + find $(Content) -type f -a \ + -name '[!_]*.md' -o \ + -name '[!_]*.mkd' -o \ + -name '[!_]*.markdown' \ + > $@ + +$(Meta)/data.text: $(THIS) + $(info ==> $@) + find $(Data) -name '*.*' > $@ ifdef __phase_2 @@ -147,11 +148,6 @@ $(Meta)/pages-by-id.json: $(PagesJSON) | jq -n 'reduce inputs as $$p ({}; . + {($$p.Id):$$p})' \ > $@ -# Alternative: -#$(Meta)/pages-by-id.json: $(PagesJSON) -# $(info ==> $@) -# @jq --slurp 'reduce .[] as $$p ({}; . + {($$p.Id): $$p})' $^ > $@ - ######################################################################## # Files derived from `$(Data)/*`. ######################################################################## diff --git a/share/sake.d/phase2_page.jq b/share/sake.d/phase2_page.jq index 47d8bc6..4814c8c 100644 --- a/share/sake.d/phase2_page.jq +++ b/share/sake.d/phase2_page.jq @@ -25,6 +25,7 @@ def notdir: ; # `$(Meta)/pages/path/to/page.json` => `(../)+` +# BUG! No usar Meta en input!!! def page_base: # . as $target ("../" * (((. / "/") | length) - 3)) // "" diff --git a/share/sake.d/phase3.jq b/share/sake.d/phase3.jq index cc9fc60..b41dd7f 100644 --- a/share/sake.d/phase3.jq +++ b/share/sake.d/phase3.jq @@ -18,13 +18,13 @@ def dependencies: else "" end + if .Datasets - then " " + ([.Datasets[] | basename | "$(Meta)/\(.).json"] | join(" ")) + then " " + ([.Datasets[] | basename | "\($Meta)/\(.).json"] | join(" ")) else "" end ; def dataset: if .Datasets - then " " + ([.Datasets[] | basename | "-m\(.):$(Meta)/\(.).json"] | join(" ")) + then " " + ([.Datasets[] | basename | "-m\(.):\($Meta)/\(.).json"] | join(" ")) else "" end ; @@ -35,7 +35,15 @@ def flags: ; def page: - " -mpage:$(Meta)/pages/\(.Id).json" + " -mpage:\($Meta)/pages/\(.Id).json" +; + +# %.html: _site/%.html ; +# blog/%.html: _site/blog/%.html ; +def page_target: + map(.Path) + | unique[] + | "\(.)%.html: \($Root)/\(.)%.html ;" ; def layout: @@ -51,26 +59,20 @@ def layout: # @$(JQT) -d $< -mpage:.meta/pages/blog/2017-04-13-hello.json layouts/page.html | $(DETAILS) > $@ def page_rule: .[] | - $Root+"/"+.URL+": " + .Source + layout + dependencies, + "\($Root)/"+.URL+": " + .Source + dependencies, "\t$(info ==> $@)", "\t@$(JQT) -d $<" + dataset + flags + page + layout + " | $(DETAILS) > $@" ; -# %.html: _site/%.html ; -# blog/%.html: _site/blog/%.html ; -def page_target: - map(.Path) - | unique[] - | "\(.)%.html: $(Root)/\(.)%.html ;" -; - # # Output makefile # "__phase_3 := 1\n", page_target, # for each path +"", page_rule, # for each page -"\n# \u0076im:syntax=make" +"", +"# \u0076im:syntax=make" # vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq diff --git a/share/sake.d/phase3.make b/share/sake.d/phase3.make index 7922028..e66be97 100644 --- a/share/sake.d/phase3.make +++ b/share/sake.d/phase3.make @@ -6,12 +6,8 @@ # # Rules defined in $(MDIR)/phase3.make: # $(Meta)/phase3.make -# -# Targets defined in $(MDIR)/phase3.make: -# build -# clean -# clobber -# configure +# $(Meta)/phase3_json.json +# $(Meta)/phase3d.make SUPER := $(Meta)/phase2.make @@ -20,13 +16,35 @@ SUPER := $(Meta)/phase2.make ######################################################################## # Build rules for each page. -$(Meta)/phase3.make: $(Meta)/pages-by-id.json $(MDIR)/phase3.jq $(SUPER) $(THIS) +$(Meta)/phase3.make: $(SUPER) $(THIS) +$(Meta)/phase3.make: $(Meta)/pages-by-id.json $(SCRIPT) + $(info ==> $@) + jq --raw-output \ + --arg Meta $(Meta) \ + --arg Layouts $(Layouts) \ + --arg Root $(Root) \ + --from-file $(MDIR)/phase3.jq \ + < $< > $@ + +# Do not preserve! +.INTERMEDIATE: $(Meta)/phase3_json.json + +$(Meta)/phase3_json.json: $(SCRIPT) $(THIS) + $(info ==> $@) + grep -r '<%include\s\+[^>]\+>' blocks/ layouts/\ + | sed -e 's/:.*<%include\s\+/\t/;s/>.*$$//' \ + | jq -nrR \ + --arg Layouts $(Layouts) \ + --from-file $(MDIR)/phase3_json.jq \ + > $@ + +$(Meta)/phase3d.make: $(Meta)/pages-by-id.json $(Meta)/phase3_json.json $(SCRIPT) $(THIS) $(info ==> $@) - jq --raw-output \ - --arg Meta $(Meta) \ - --arg Layouts $(Layouts) \ - --arg Root $(Root) \ - --from-file $(MDIR)/phase3.jq \ + jq --raw-output \ + --arg Layouts $(Layouts) \ + --arg Root $(Root) \ + --slurpfile ldep $(Meta)/phase3_json.json \ + --from-file $(MDIR)/phase3d.jq \ < $< > $@ ifdef __phase_3 @@ -36,10 +54,10 @@ ifdef __phase_3 # define JQTFLAGS := - -msite:$(Meta)/site.json \ - -I./ \ - -L$(Meta) \ - -L$(Blocks) \ + -msite:$(Meta)/phase1_site.json \ + -I./ \ + -L$(Meta) \ + -L$(Blocks) \ -ifilters endef @@ -62,40 +80,17 @@ $(PagesHTML): $(Meta)/phase3.make \ # Content example for `$(Meta)/phase3.make`: # __phase_3 := 1 -# _site/jqt/index.html: content/index.md layouts/page.html content/macros.m content/LINKS.txt content/EXAMPLE.txt .meta/snippets.json +# _site/jqt/index.html: content/index.md content/macros.m content/LINKS.txt content/EXAMPLE.txt .meta/snippets.json # $(info ==> $@) # @$(JQT) -d $< -mpage:.meta/pages/index.json layouts/page.html | $(DETAILS) > $@ # ... -# _site/jqt/blog/2017-04-13-hello.html: content/blog/2017-04-13-hello.md layouts/page.html .meta/snippets.json +# _site/jqt/blog/2017-04-13-hello.html: content/blog/2017-04-13-hello.md .meta/snippets.json # $(info ==> $@) # @$(JQT) -d $< -mpage:.meta/pages/blog/2017-04-13-hello.json layouts/page.html | $(DETAILS) > $@ -# _site/jqt/blog/index.html: content/blog/index.md layouts/blog.html .meta/snippets.json +# _site/jqt/blog/index.html: content/blog/index.md .meta/snippets.json # $(info ==> $@) # @$(JQT) -d $< -mpage:.meta/pages/blog/index.json layouts/blog.html | $(DETAILS) > $@ -######################################################################## -# Standard targets. -######################################################################## - -.PHONY: clean clobber - -# Copy Assets after create HTML pages. -build:: $(PagesHTML) - @cp --verbose --recursive --update $(Assets)/* $(Root) \ - | sed "s/^.*-> ./==> /;s/.$$//" - date -Iseconds > $(Meta)/lastbuild - -# Delete secondary files. -clobber:: ; @rm -rf *~ *.bak *.log - -######################################################################## -# Variations on the `build` target. - -.PHONY: configure - -# Build all metadata and data files. -configure: $(DataFiles) # $(PagesJSON) are built for phase2.make - endif # __phase_3 # vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make diff --git a/share/sake.d/phase3_json.jq b/share/sake.d/phase3_json.jq new file mode 100644 index 0000000..881000c --- /dev/null +++ b/share/sake.d/phase3_json.jq @@ -0,0 +1,27 @@ +######################################################################## +# phase3_json.jq -- Define contents for `$(Meta)/phase3_json.json`. +# +# output from grep/sed includes | +# jq -nR +# -f ./phase3_json.jq +# --arg Layouts $(Layouts) +# > $(Meta)/phase3_json.json + +def branch($root; $tree): + def _branch: + if in($tree) + then . , ($tree[.][] | _branch) + else . + end + ; + [$root | _branch] | sort +; + +reduce inputs as $line + ({}; ($line/"\t") as [$key,$value] | .[$key]+=[$value]) +| . as $tree +| reduce (keys_unsorted[]|select(startswith($Layouts+"/"))) as $r + ({}; .[$r]=branch($r; $tree)) + + +# vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq diff --git a/share/sake.d/phase3d.jq b/share/sake.d/phase3d.jq new file mode 100644 index 0000000..e87fc2c --- /dev/null +++ b/share/sake.d/phase3d.jq @@ -0,0 +1,26 @@ +######################################################################## +# phase3d.jq -- Define contents for `$(Meta)/phase3d.make`. +# +#?# jq -r -f phase3.jq +#?# --arg Layouts $(Layouts) +#?# --arg Root $(Root) +#?# --slurpfile ldep $(Meta)/phase3_json.json +#?# < $(Meta)/pages-by-id.json +#?# > $(Meta)/phase3d.make + +#_site/content.html: blocks/body/_toc/markup.html blocks/content/markup.html blocks/footer/markup.html blocks/header/markup.html blocks/license/markup.html blocks/logo/markup.html blocks/menu-bar/markup.html blocks/repository/markup.html blocks/toc/markup.html layouts/default.html layouts/page-toc.html +#_site/data.html: blocks/body/_toc/markup.html blocks/content/markup.html blocks/footer/markup.html blocks/header/markup.html blocks/license/markup.html blocks/logo/markup.html blocks/menu-bar/markup.html blocks/repository/markup.html blocks/toc/markup.html layouts/default.html layouts/page-toc.html +def page_layouts: + .[] + | "\($Layouts)/\(.Layout).html" as $l + | $Root+"/"+.URL+": " + ($ldep[0][$l] | join(" ")) +; + +# +# Output makefile +# + +page_layouts, +"\n# \u0076im:syntax=make" + +# vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq diff --git a/share/sake.d/sitemap.jq b/share/sake.d/sitemap.jq index d39df95..3e38815 100644 --- a/share/sake.d/sitemap.jq +++ b/share/sake.d/sitemap.jq @@ -2,7 +2,7 @@ # sitemap.jq -- Generate site map XML file. # # jq -r -f sitemap.jq -# --slurpfile site $(Meta)/site.json +# --slurpfile site $(Meta)/phase1_site.json # < $(Meta)/pages-by-id.json # > $(Root)/sitemap.xml diff --git a/share/sake.d/sitemap.make b/share/sake.d/sitemap.make index 1ec2cb3..e36f9ad 100644 --- a/share/sake.d/sitemap.make +++ b/share/sake.d/sitemap.make @@ -5,12 +5,13 @@ # $(Root)/sitemap.xml # $(Root)/sitemap.xml.gz -$(Root)/sitemap.xml: $(Meta)/pages-by-id.json $(Meta)/site.json $(MDIR)/sitemap.jq $(THIS) \ +$(Root)/sitemap.xml: $(SCRIPT) $(THIS) +$(Root)/sitemap.xml: $(Meta)/pages-by-id.json $(Meta)/phase1_site.json \ | $(Root) $(info ==> $@) - jq --raw-output \ - --slurpfile site $(Meta)/site.json \ - --from-file $(MDIR)/sitemap.jq \ + jq --raw-output \ + --slurpfile site $(Meta)/phase1_site.json \ + --from-file $(MDIR)/sitemap.jq \ < $< > $@ $(Root)/sitemap.xml.gz: $(Root)/sitemap.xml