Abstract tagged index building to separate file

Stub only, not working yet.
This commit is contained in:
Andrew Stryker 2023-09-20 09:05:31 -07:00
parent f7e94e6a0f
commit 0316c89570
2 changed files with 78 additions and 81 deletions

100
index.mk
View File

@ -50,41 +50,29 @@ ifndef ENV_LOADED
endif endif
# Use the current directory as the content section name
content_section ::= $(shell basename ${CURDIR})
work_dir ::= ${WORKING}/${content_section}
staging_dir ::= ${STAGING}/${content_section}
# Define using the same definition as in the main Makefile # Define using the same definition as in the main Makefile
build_date_msg ?= This page was built on $$(date). build_date_msg ?= This page was built on $$(date).
# Define special files # Define special files
index_template ::= index.gmi.m4 index_template ::= index.gmi.m4
index ::= ${staging_dir}/index.gmi index ::= ${STG_SECTION}/index.gmi
header_template ::= header.gmi.m4 header_template ::= header.gmi.m4
header ::= ${work_dir}/header.gmi header ::= ${WRK_SECTION}/header.gmi
footer_template ::= footer.gmi.m4 footer_template ::= footer.gmi.m4
footer ::= ${work_dir}/footer.gmi footer ::= ${WRK_SECTION}/footer.gmi
# Capture all posts as Gemtext files that begin with an ISO formatted date # Capture all posts as Gemtext files that begin with an ISO formatted date
posts_gmi ::= $(shell ls *.gmi | grep "[[:digit:]]\{4\}\(-[[:digit:]]\{2\}\)\{2\}") posts_gmi ::= $(shell ls *.gmi | grep "[[:digit:]]\{4\}\(-[[:digit:]]\{2\}\)\{2\}")
posts ::= $(addprefix ${staging_dir}/,${posts_gmi}) posts ::= $(addprefix ${STG_SECTION}/, ${posts_gmi})
entries ::= $(addprefix ${work_dir}/,${posts_gmi:.gmi=.lnk}) entries ::= $(addprefix ${WRK_SECTION}/, ${posts_gmi:.gmi=.lnk})
tag_list ::= ${work_dir}/tag-list TAG_LIST ::= ${WRK_SECTION}/tag-list
export TAG_LIST
# Capture potential dependencies # Create list of potential dependencies of *.gmi.m4 templates
all ::= $(notdir $(filter-out _%,%~,.%,$(wildcard *))) template_depends ::= $(notdir $(filter-out %.gmi.m4 _% %~, $(wildcard *)))
#tagged_index_template ?= tagged-index.gmi.m4
# support indexing
#tags = $(shell cut --delimiter ' ' --fields 3 ${tag_list} | sort)
#tagged_indicies = $(addprefix ${STAGING}/, $(addsuffix .gmi, ${tags}))
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# #
@ -110,7 +98,6 @@ build: ${index}
@echo "✓ Completed processing ${content_section}" @echo "✓ Completed processing ${content_section}"
@echo @echo
show: #> Show enironment variables with values show: #> Show enironment variables with values
@echo staging area: ${STAGING} @echo staging area: ${STAGING}
@echo workspace: ${WORKSPACE} @echo workspace: ${WORKSPACE}
@ -119,7 +106,7 @@ show: #> Show enironment variables with values
@echo targets: ${post_targets} @echo targets: ${post_targets}
@echo header: ${header} @echo header: ${header}
@echo footer: ${footer} @echo footer: ${footer}
@echo tag list: ${tag_list} @echo tag list: ${TAG_LIST}
clean: #> Delete generated files clean: #> Delete generated files
@rm -rf ${STAGING} ${WORKSPACE} @rm -rf ${STAGING} ${WORKSPACE}
@ -127,7 +114,7 @@ clean: #> Delete generated files
@echo "\t✓ Deleted all posts in ${STAGING}" @echo "\t✓ Deleted all posts in ${STAGING}"
help: #> Display this help message help: #> Display this help message
@awk -f ../generate-help.awk ${MAKEFILE_LIST} @awk -f ${AWKHELP} ${self}
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# #
@ -135,83 +122,36 @@ help: #> Display this help message
# #
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
${work_dir} ${staging_dir}: %: ${WRK_SECTION} ${STG_SECTION}: %:
@mkdir -p $@ @mkdir -p $@
@echo "\t✓ Created space: $@" @echo "\t✓ Created space: $@"
${header} ${footer}: ${work_dir}/%: % ${work_dir} ${all} ${header} ${footer}: ${WRK_SECTION}/%: % ${WRK_SECTION} ${template_depends}
@m4 --include=${MAKO_DIR} $< > $@ @m4 --include=${MAKO_DIR} $< > $@
@echo "\t✓ Created: $@" @echo "\t✓ Created: $@"
${posts}: ${staging_dir}/%: ${posts_gmi} ${header} ${footer} ${staging_dir} ${posts}: ${STG_SECTION}/%: % ${header} ${footer} ${STG_SECTION}
@m4 --include=${MAKO_DIR} $< > $@ @cat ${header} $< ${footer} > $@
@echo "${build_date_msg}" >> $@ @echo "${build_date_msg}" >> $@
@echo "\t✓ Created $@" @echo "\t✓ Created $@"
${entries}: ${work_dir}/%.lnk: ${MAKO_DIR}/create-index-entry.awk %.gmi ${work_dir} ${entries}: ${WRK_SECTION}/%.lnk: ${MAKO_DIR}/create-index-entry.awk %.gmi ${WRK_SECTION}
@awk -f $(notdir $^) > $@ @awk -f $(notdir $^) > $@
@echo "\t✓ Created: $@" @echo "\t✓ Created: $@"
# build the tag list ${TAG_LIST}: ${entries}
${tag_list}: ${entries}
@cat $^ | sort --unique | \ @cat $^ | sort --unique | \
sed -e '/^---/ d; s/^\([a-zA-Z0-09]\+\).*/=> \1.gmi \1/' > $@ sed -e '/^---/ d; s/^\([a-zA-Z0-09]\+\).*/=> \1.gmi \1/' > $@
@echo "\t✓ Created the tags list" @echo "\t✓ Created the tags list"
${index}: ${index_template} ${header} ${footer} ${posts} ${index}: ${index_template} ${header} ${footer} ${posts} ${TAG_LIST}
@${MAKE} -f ${TAG_MAKE} build
${index}: ${posts} ${tag_list}
${index}: content-index.gmi.m4 ${STAGING} ${tag_list} ${header} ${footer} ${post_entry}
@m4 --include=.. \ @m4 --include=.. \
--define=TAGS=${tags_list} \ --define=TAGS=${tags_list} \
--define=POSTS=${post_entry} \ --define=POSTS=${post_entry} \
--define=HEADER=${header} \ --define=HEADER=${header} \
--define=FOOTER=${footer} \ --define=FOOTER=${footer} \
$< > $@ $< > $@
@echo ✓ Created $@ @echo "✓ Created: $@"
#
# Build posts
#
# 1. Expand header and footer macros
# 2. Concatenate header, post, footer into the staging area
${header} ${footer}: ${WORKSPACE}/%: %.m4
@echo building $@
@m4 --include=${MAKO_DIR}/fence.m4 $< > $@
@echo "\t✓ Created $@"
${targets}: ${STAGING}/%: % ${header} ${footer}
@cat ${header} $< ${footer} > $@
@echo ${build_date_msg} >> $@
@echo "\t✓ Generated $@"
#
# Build the tag list (indexing data)
#
# 1. Extract indexing data from each post
# 2. Combine into one list of tags
#
# Build the index files
#
#
#${index}: ${index_template} ${tag_list}
# # build the index files
# # recurse into another Makefile?
# @m4 --include=${MAKO_DIR} $< > $@
#${tagged_indicies}: ${STAGING}/%.gmi: tag-index-template.gmi.m4 ${tag_list}
# @m4 --include=.. \
# --define=TAG=% \
# --define=ENTRIES=${entries} \
# --define=HEADER=${header} \
# --define=FOOTER=${footer} \
# tag-index-template.gmi.m4 $< > $@
# @echo ✓ Created index $@
# generate the index entries across all posts
#${index_entries}: ${tag_list}
# @grep "^---" $^ | cut --delimiter=' ' --fields=2 | sort --reverse --key=3 > $@
# @echo ✓ Created $@
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#

57
tagged-index.mk Normal file
View File

@ -0,0 +1,57 @@
#tagged_index_template ?= tagged-index.gmi.m4
# support indexing
#tags = $(shell cut --delimiter ' ' --fields 3 ${tag_list} | sort)
#tagged_indicies = $(addprefix ${STAGING}/, $(addsuffix .gmi, ${tags}))
#-----------------------------------------------------------------------------#
#
# User interface
#
#> This makefile supports the following targets:
#>
#-----------------------------------------------------------------------------#
.PHONY: default build clean show help
# define the default target explicitly
default: build
build:
@echo "✗ Building tagged index files not yet supported."
@echo
show: #> Show enironment variables with values
@echo "✗ Showing variables not yet supported."
@echo
clean: #> Delete generated files
@echo "✗ Cleaning tagged index files not yet supports."
@echo
help: #> Display this help message
@awk -f ${AWKHELP} ${self}
#-----------------------------------------------------------------------------#
#
# File system interface
#
#-----------------------------------------------------------------------------#
#${tagged_indicies}: ${STAGING}/%.gmi: tag-index-template.gmi.m4 ${tag_list}
# @m4 --include=.. \
# --define=TAG=% \
# --define=ENTRIES=${entries} \
# --define=HEADER=${header} \
# --define=FOOTER=${footer} \
# tag-index-template.gmi.m4 $< > $@
# @echo ✓ Created index $@
# generate the index entries across all posts
#${index_entries}: ${tag_list}
# @grep "^---" $^ | cut --delimiter=' ' --fields=2 | sort --reverse --key=3 > $@
# @echo ✓ Created $@