Recover lost edits

This commit is contained in:
Andrew Stryker 2023-09-14 11:29:45 -07:00
parent c19ad72ecf
commit 2f0e9afba4

100
index.mk
View File

@ -52,7 +52,7 @@ endif
# Use the current directory as the content section name # Use the current directory as the content section name
content_section ::= $(shell basename ${CURDIR}) content_section ::= $(shell basename ${CURDIR})
working_dir ::= ${WORKING}/${content_section} work_dir ::= ${WORKING}/${content_section}
staging_dir ::= ${STAGING}/${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
@ -63,43 +63,29 @@ index_template ::= index.gmi.m4
index ::= ${staging_dir}/index.gmi index ::= ${staging_dir}/index.gmi
header_template ::= header.gmi.m4 header_template ::= header.gmi.m4
header ::= ${working_dir}/header.gmi header ::= ${work_dir}/header.gmi
footer_template ::= footer.gmi.m4 footer_template ::= footer.gmi.m4
footer ::= ${working_dir}/footer.gmi footer ::= ${work_dir}/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})
tag_list ::= ${work_dir}/tag-list
# Capture potential dependencies # Capture potential dependencies
all ::= $(notdir $(filter-out _%,%~,.%,$(wildcard *))) all ::= $(notdir $(filter-out _%,%~,.%,$(wildcard *)))
# all good above this line #tagged_index_template ?= tagged-index.gmi.m4
#-----------------------------------------------------------------------------#
#
# Configuration
#
#-----------------------------------------------------------------------------#
tagged_index_template ?= tagged-index.gmi.m4
posts ::= $(wildcard *.gmi)
targets ::= $(addprefix ${STAGING}/, ${posts})
# support indexing # support indexing
entries ::= $(addprefix ${WORKSPACE}/, $(patsubst %.gmi, %.lnk, ${posts}))
tag_list ::= ${WORKSPACE}/tag-list
#tags = $(shell cut --delimiter ' ' --fields 3 ${tag_list} | sort) #tags = $(shell cut --delimiter ' ' --fields 3 ${tag_list} | sort)
#tagged_indicies = $(addprefix ${STAGING}/, $(addsuffix .gmi, ${tags})) #tagged_indicies = $(addprefix ${STAGING}/, $(addsuffix .gmi, ${tags}))
# TODO: is there a name for elements header and footer? How can this work with
# templates?
# header and footer
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
# #
# User interface # User interface
@ -149,16 +135,41 @@ help: #> Display this help message
# #
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
${working_dir} ${staging_dir}: %: ${work_dir} ${staging_dir}: %:
@mkdir -p $@ @mkdir -p $@
@echo "\t✓ Created space: $@" @echo "\t✓ Created space: $@"
${header} ${footer}: ${working_dir}/%: % ${working_dir} ${all} ${header} ${footer}: ${work_dir}/%: % ${work_dir} ${all}
@mkdir -p $@ @m4 --include=${MAKO_DIR} $< > $@
@echo "\t✓ Created: $@" @echo "\t✓ Created: $@"
${posts}: ${staging_dir}/%: ${posts_gmi} ${header} ${footer} ${staging_dir}
@m4 --include=${MAKO_DIR} $< > $@
@echo "${build_date_msg}" >> $@
@echo "\t✓ Created $@"
${entries}: ${work_dir}/%.lnk: ${MAKO_DIR}/create-index-entry.awk %.gmi ${work_dir}
@awk -f $(notdir $^) > $@
@echo "\t✓ Created: $@"
# build the tag list
${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}: ${index_template} ${header} ${footer} ${posts}
${index}: ${posts} ${tag_list}
${index}: content-index.gmi.m4 ${STAGING} ${tag_list} ${header} ${footer} ${post_entry}
@m4 --include=.. \
--define=TAGS=${tags_list} \
--define=POSTS=${post_entry} \
--define=HEADER=${header} \
--define=FOOTER=${footer} \
$< > $@
@echo ✓ Created $@
#
# Build posts # Build posts
# #
# 1. Expand header and footer macros # 1. Expand header and footer macros
@ -178,25 +189,15 @@ ${targets}: ${STAGING}/%: % ${header} ${footer}
# #
# 1. Extract indexing data from each post # 1. Extract indexing data from each post
# 2. Combine into one list of tags # 2. Combine into one list of tags
${entries}: ${WORKSPACE}/%.lnk: ${MAKO_DIR}/create-index-entry.awk %.gmi
@awk -f $^ > $@
@echo "\t✓ Created $@"
# build the tag list
${tag_list}: ${entries}
@cat $^ | sort --unique | \
sed -e '/^---/ d; s/^\([a-zA-Z0-09]\+\).*/=> \1.gmi \1/' > $@
@echo "\t✓ Created the tags list"
# #
# Build the index files # Build the index files
# #
# #
${index}: ${index_template} ${tag_list} #${index}: ${index_template} ${tag_list}
# build the index files # # build the index files
# recurse into another Makefile? # # recurse into another Makefile?
@m4 --include=${MAKO_DIR} $< > $@ # @m4 --include=${MAKO_DIR} $< > $@
#${tagged_indicies}: ${STAGING}/%.gmi: tag-index-template.gmi.m4 ${tag_list} #${tagged_indicies}: ${STAGING}/%.gmi: tag-index-template.gmi.m4 ${tag_list}
@ -209,17 +210,8 @@ ${index}: ${index_template} ${tag_list}
# @echo ✓ Created index $@ # @echo ✓ Created index $@
# generate the index entries across all posts # generate the index entries across all posts
${index_entries}: ${tag_list} #${index_entries}: ${tag_list}
@grep "^---" $^ | cut --delimiter=' ' --fields=2 | sort --reverse --key=3 > $@ # @grep "^---" $^ | cut --delimiter=' ' --fields=2 | sort --reverse --key=3 > $@
@echo ✓ Created $@ # @echo ✓ Created $@
${index}: content-index.gmi.m4 ${STAGING} ${tag_list} ${header} ${footer} ${post_entry}
@m4 --include=.. \
--define=TAGS=${tags_list} \
--define=POSTS=${post_entry} \
--define=HEADER=${header} \
--define=FOOTER=${footer} \
$< > $@
@echo ✓ Created $@
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#