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 # Ignore potential user content
content/* content
# Workspaces # Workspaces
workspace/* working
staging/* staging
# TODO: perhaps consolidate? # TODO: perhaps consolidate?
tests/*.lnk tests/*.lnk
tests/posts.idx tests/posts.idx

View File

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

View File

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

View File

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

104
index.mk
View File

@ -7,7 +7,7 @@
#> #>
# #
# Allowing posts to be m4 files introduces complexity without clear benefit. # Allowing posts to be m4 files introduces complexity without clear benefit.
# Thus we are # Thus we are
# #
# Strategy: # Strategy:
# 1. Mark all *.gmi files as posts. # 1. Mark all *.gmi files as posts.
@ -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}))
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# #
@ -106,11 +94,10 @@ create: #> Create a new post (default)
python3 create-post.py --edit; \ python3 create-post.py --edit; \
fi fi
build: ${index} build: ${index} #> Build the site (default)
@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: #> 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 $@