Abstract tagged index building to separate file
Stub only, not working yet.
This commit is contained in:
parent
f7e94e6a0f
commit
0316c89570
102
index.mk
102
index.mk
@ -7,7 +7,7 @@
|
||||
#>
|
||||
#
|
||||
# Allowing posts to be m4 files introduces complexity without clear benefit.
|
||||
# Thus we are
|
||||
# Thus we are
|
||||
#
|
||||
# Strategy:
|
||||
# 1. Mark all *.gmi files as posts.
|
||||
@ -50,41 +50,29 @@ ifndef ENV_LOADED
|
||||
|
||||
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
|
||||
build_date_msg ?= This page was built on $$(date).
|
||||
|
||||
# Define special files
|
||||
index_template ::= index.gmi.m4
|
||||
index ::= ${staging_dir}/index.gmi
|
||||
index ::= ${STG_SECTION}/index.gmi
|
||||
|
||||
header_template ::= header.gmi.m4
|
||||
header ::= ${work_dir}/header.gmi
|
||||
header ::= ${WRK_SECTION}/header.gmi
|
||||
|
||||
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
|
||||
posts_gmi ::= $(shell ls *.gmi | grep "[[:digit:]]\{4\}\(-[[:digit:]]\{2\}\)\{2\}")
|
||||
posts ::= $(addprefix ${staging_dir}/,${posts_gmi})
|
||||
entries ::= $(addprefix ${work_dir}/,${posts_gmi:.gmi=.lnk})
|
||||
posts ::= $(addprefix ${STG_SECTION}/, ${posts_gmi})
|
||||
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
|
||||
all ::= $(notdir $(filter-out _%,%~,.%,$(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}))
|
||||
# Create list of potential dependencies of *.gmi.m4 templates
|
||||
template_depends ::= $(notdir $(filter-out %.gmi.m4 _% %~, $(wildcard *)))
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
#
|
||||
@ -110,7 +98,6 @@ build: ${index}
|
||||
@echo "✓ Completed processing ${content_section}"
|
||||
@echo
|
||||
|
||||
|
||||
show: #> Show enironment variables with values
|
||||
@echo staging area: ${STAGING}
|
||||
@echo workspace: ${WORKSPACE}
|
||||
@ -119,7 +106,7 @@ show: #> Show enironment variables with values
|
||||
@echo targets: ${post_targets}
|
||||
@echo header: ${header}
|
||||
@echo footer: ${footer}
|
||||
@echo tag list: ${tag_list}
|
||||
@echo tag list: ${TAG_LIST}
|
||||
|
||||
clean: #> Delete generated files
|
||||
@rm -rf ${STAGING} ${WORKSPACE}
|
||||
@ -127,7 +114,7 @@ clean: #> Delete generated files
|
||||
@echo "\t✓ Deleted all posts in ${STAGING}"
|
||||
|
||||
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 $@
|
||||
@echo "\t✓ Created space: $@"
|
||||
|
||||
${header} ${footer}: ${work_dir}/%: % ${work_dir} ${all}
|
||||
${header} ${footer}: ${WRK_SECTION}/%: % ${WRK_SECTION} ${template_depends}
|
||||
@m4 --include=${MAKO_DIR} $< > $@
|
||||
@echo "\t✓ Created: $@"
|
||||
|
||||
${posts}: ${staging_dir}/%: ${posts_gmi} ${header} ${footer} ${staging_dir}
|
||||
@m4 --include=${MAKO_DIR} $< > $@
|
||||
${posts}: ${STG_SECTION}/%: % ${header} ${footer} ${STG_SECTION}
|
||||
@cat ${header} $< ${footer} > $@
|
||||
@echo "${build_date_msg}" >> $@
|
||||
@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 $^) > $@
|
||||
@echo "\t✓ Created: $@"
|
||||
|
||||
# build the tag list
|
||||
${tag_list}: ${entries}
|
||||
${TAG_LIST}: ${entries}
|
||||
@cat $^ | sort --unique | \
|
||||
sed -e '/^---/ d; s/^\([a-zA-Z0-09]\+\).*/=> \1.gmi \1/' > $@
|
||||
@echo "\t✓ Created the tags list"
|
||||
|
||||
${index}: ${index_template} ${header} ${footer} ${posts}
|
||||
|
||||
${index}: ${posts} ${tag_list}
|
||||
${index}: content-index.gmi.m4 ${STAGING} ${tag_list} ${header} ${footer} ${post_entry}
|
||||
${index}: ${index_template} ${header} ${footer} ${posts} ${TAG_LIST}
|
||||
@${MAKE} -f ${TAG_MAKE} build
|
||||
@m4 --include=.. \
|
||||
--define=TAGS=${tags_list} \
|
||||
--define=POSTS=${post_entry} \
|
||||
--define=HEADER=${header} \
|
||||
--define=FOOTER=${footer} \
|
||||
$< > $@
|
||||
@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 $@
|
||||
@echo "✓ Created: $@"
|
||||
|
||||
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|
||||
|
57
tagged-index.mk
Normal file
57
tagged-index.mk
Normal 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 $@
|
Loading…
x
Reference in New Issue
Block a user