Compare commits

...

5 Commits

Author SHA1 Message Date
1dfeffeb0f Get the section definition macro working 2023-09-20 21:20:00 -07:00
93c4257149 Update ignore file to revised conventions 2023-09-20 09:28:26 -07:00
08b270990d Tidy message 2023-09-20 09:09:15 -07:00
00fc32829f Add build help message 2023-09-20 09:06:49 -07:00
0316c89570 Abstract tagged index building to separate file
Stub only, not working yet.
2023-09-20 09:05:31 -07:00
6 changed files with 112 additions and 108 deletions

6
.gitignore vendored
View File

@ -1,8 +1,8 @@
# Ignore potential user content
content/*
content
# Workspaces
workspace/*
staging/*
working
staging
# TODO: perhaps consolidate?
tests/*.lnk
tests/posts.idx

View File

@ -149,7 +149,7 @@ ${site_index}: ${site_index_template} ${banner} ${curate_dirs} ${index_dirs}
${curate_dirs}: %: ${WORKING} ${STAGING}
@echo
@echo "Entering $@ section"
@echo "Entering section: $@"
@echo
@mkdir -p ${WORKING}/$@ ${STAGING}/$@
@cd $@ && ${MAKE} -f ${CURATE_MAKE} build
@ -157,7 +157,7 @@ ${curate_dirs}: %: ${WORKING} ${STAGING}
${index_dirs}: %: ${WORKING} ${STAGING}
@echo
@echo "Entering $@ section"
@echo "Entering section: $@"
@echo
@mkdir -p ${WORKING}/$@ ${STAGING}/$@
@#cd ${CONTENT}/$@ && ${MAKE} -f ${index_make} build

View File

@ -34,13 +34,15 @@ ifndef ENV_LOADED
endif
# Compute definitions for the section, working, and staging directories
$(eval $(call SECTION_DIRS))
# Gather file lists
templates ::= $(wildcard *.gmi.m4)
templates_expanded ::= $(addprefix ${STG_SECTION}/, ${templates:.gmi.m4=.gmi})
templates_expanded ::= $(addprefix ${staging_section}/, ${templates:.gmi.m4=.gmi})
gemtext ::= $(wildcard *.gmi)
gemtext_copied ::= $(addprefix ${STG_SECTION}/, ${gemtext})
gemtext_copied ::= $(addprefix ${staging_section}/, ${gemtext})
# Create list of potential dependencies of *.gmi.m4 templates
all ::= $(notdir $(filter-out %.gmi.m4 _% %~, $(wildcard *)))
@ -66,7 +68,8 @@ create: #> Create a new post (default)
fi
build: ${gemtext_copied} ${templates_expanded}
@echo "✓ Completed processing ${SECTION}"
@echo "Makeflags .................... '$${MAKEFLAGS}'"
@echo "✓ Completed processing ${section}"
@echo
@ -75,8 +78,8 @@ show: #> Show enironment variables with values
@echo
@echo "Makefile list: ${MAKEFILE_LIST}"
@echo
@echo "Content section .............................. ${SECTION}"
@echo "Staging space ................................ ${STG_SECTION}"
@echo "Content section .............................. ${section}"
@echo "Staging space ................................ ${staging_section}"
@echo
@echo "Templates found:"
@for x in ${templates}; do echo "\t$$x"; done
@ -86,8 +89,8 @@ show: #> Show enironment variables with values
@echo
clean: #> Delete generated files
@rm -rf ${STG_SECTION}
@echo "✓ Deleted ${STG_SECTION} and everything in it"
@rm -rf ${staging_section}
@echo "✓ Deleted ${staging_section} and everything in it"
help: #> Display this help message
@awk -f ${AWKHELP} ${self}
@ -98,15 +101,15 @@ help: #> Display this help message
#
#-----------------------------------------------------------------------------#
${STG_SECTION}:
${staging_section}:
@mkdir -p $@
@echo "\t✓ Created staging space: $@"
${templates_expanded}: ${STG_SECTION}/%: %.m4 ${STG_SECTION} ${FENCE} ${all}
${templates_expanded}: ${staging_section}/%: %.m4 ${staging_section} ${FENCE} ${all}
@m4 --include=${MAKO_DIR} $< > $@
@echo "\t✓ Generated $@"
${gemtext_copied}: ${STG_SECTION}/%: % ${STG_SECTION}
${gemtext_copied}: ${staging_section}/%: % ${staging_section}
@cat $< > $@
@echo "\t✓ Copied $@"

View File

@ -66,16 +66,20 @@ STAGING ?= ${MAKO_DIR}/staging
STAGING ::= $(strip ${STAGING})
export STAGING
# Place for section-specfic working and staging files as recurive variables
SECTION = $(shell basename ${CURDIR})
export SECTION
# Create shortcuts
STG_SECTION = ${STAGING}/${SECTION}
WRK_SECTION = ${WORKING}/${SECTION}
SECTION_DIRS = ${STG_SECTION} ${WRK_SECTION}
export STG_SECTION
export WRK_SECTION
# Define a macro that creates the section-specific directory variables
#
# NOTE: Make expand variables when they are exported, meaning that will not
# assume the values appropriate for the current section. This approach defines
# a macro that we can call when we recurse into each section
#
# TODO: not call to the shell repeatedly
define SECTION_DIRS
section = $$(shell basename $${CURDIR})
#working_section ::= ${WORKING}/$${section}
#staging_section = ${STAGING}/$$(value section)
working_section = ${WORKING}/$$(shell basename $${CURDIR})
staging_section ::= ${STAGING}/$$(shell basename $${CURDIR})
endef
export SECTION_DIRS
# Makefiles
@ -113,7 +117,7 @@ show: #> Show key variables
@echo "\tBase/root directory of the build system..... ${MAKO_DIR}"
@echo "\tUsef-defined configuration.................. ${SITE_ENV}"
@echo
# future location for templates
@# TODO: future location for templates
@echo "\tLocation of user content.................... ${CONTENT}"
@echo "\tWorking area for intermediate files......... ${WORKING}"
@echo "\tStaging area for site....................... ${STAGING}"

102
index.mk
View File

@ -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 *)))
#-----------------------------------------------------------------------------#
#
@ -106,11 +94,10 @@ create: #> Create a new post (default)
python3 create-post.py --edit; \
fi
build: ${index}
build: ${index} #> Build the site (default)
@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
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: #> Build the site (default)
@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 $@