2025-02-11 18:09:37 +00:00
|
|
|
FZF != command -v sk || command -v fzy || command -v fzf || \
|
|
|
|
{ echo install a fuzzy finder && exit 1 ;}
|
|
|
|
|
2025-02-11 11:55:07 +00:00
|
|
|
help: ## Print the help message
|
|
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
|
|
|
|
sort | \
|
|
|
|
column -s ':' -t
|
|
|
|
|
|
|
|
articles != find * -type f -name "*.md"
|
|
|
|
|
2025-02-12 14:46:02 +00:00
|
|
|
categories != ls -d */
|
|
|
|
|
2025-02-11 11:55:07 +00:00
|
|
|
db.rec: $(articles)
|
2025-02-11 18:41:02 +00:00
|
|
|
printf '%s\n' '%rec: guide' > $@
|
2025-02-11 19:38:45 +00:00
|
|
|
printf '%s\n' '%type: wordcount int' >> $@
|
2025-02-11 18:41:02 +00:00
|
|
|
printf '%s\n\n' '%sort: title' >> $@
|
2025-02-11 11:55:07 +00:00
|
|
|
for x in $^ ; do \
|
2025-02-11 17:04:03 +00:00
|
|
|
sed -n '2,/^---$$/ {/^---$$/d; p}' "$$x" |\
|
|
|
|
sed -e 's/\[ //' -e 's/ \]//' |\
|
|
|
|
tr -d '"' ;\
|
|
|
|
printf "file: %s\n\n" "$$x" ;\
|
2025-02-11 18:41:02 +00:00
|
|
|
done >> $@
|
2025-02-11 19:38:45 +00:00
|
|
|
for entry in $^; do \
|
|
|
|
recset $@ -e "file = '$${entry}'" -f wordcount --set-add="$$(wc -w < $${entry})" ;\
|
|
|
|
done
|
2025-02-11 17:04:03 +00:00
|
|
|
recsel $@ -e "requires != ''" -CR title,requires |\
|
|
|
|
while read title requires; do \
|
|
|
|
IFS=', ' && for provider in $$requires; do \
|
|
|
|
recset $@ -e "title = '$${provider}'" -f provides -a "$${title}" ;\
|
|
|
|
done ;\
|
|
|
|
done
|
2025-02-11 18:41:02 +00:00
|
|
|
recfix --sort $@
|
2025-02-11 11:55:07 +00:00
|
|
|
|
|
|
|
default += db.rec
|
|
|
|
|
|
|
|
.git/info/exclude: $(default)
|
|
|
|
echo $^ | tr ' ' '\n' > $@
|
|
|
|
|
|
|
|
default += .git/info/exclude
|
|
|
|
|
|
|
|
.PHONY: database
|
2025-02-11 19:39:24 +00:00
|
|
|
database: $(default) ## Make a recfiles database
|
2025-02-11 11:55:07 +00:00
|
|
|
|
2025-02-11 12:06:37 +00:00
|
|
|
.PHONY: article
|
|
|
|
article: ## Write an article
|
2025-02-12 14:46:02 +00:00
|
|
|
@path=$$(find $(categories) -type d | sort | uniq | $(FZF)) ;\
|
2025-02-12 14:37:05 +00:00
|
|
|
read -p "Title: " title ;\
|
|
|
|
filename="$$(echo "$$title" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')" ;\
|
|
|
|
printf '%s\n' '---' >> $$path/$$filename.md ;\
|
|
|
|
printf 'title: "%s"\n' "$$title" >> $$path/$$filename.md ;\
|
|
|
|
printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$filename.md ;\
|
|
|
|
printf '%s\n\n' '---' >> $$path/$$filename.md ;\
|
|
|
|
$(EDITOR) +5 "$$path/$$filename.md"
|
2025-02-11 12:06:37 +00:00
|
|
|
|
2025-02-11 17:04:03 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean: ## Remove all generated files
|
2025-02-11 11:55:07 +00:00
|
|
|
$(RM) $(default)
|