summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorymber <mtaylor1252dev@gmail.com>2021-05-18 08:29:37 +0100
committerFrançois-Xavier Carton <fx.carton91@gmail.com>2021-05-20 00:35:02 +0200
commite4d2d7da3690aa7cfeb639457e8a11e560130c55 (patch)
treeaad5604dc88f5626d6369d22c1740f33a03aef5e
parentdf6f20462635c1bb27e523bd58afc2f4cdf7992b (diff)
Make blog source directory variable
-rwxr-xr-xblogit19
1 files changed, 10 insertions, 9 deletions
diff --git a/blogit b/blogit
index dec09d7..cbbc787 100755
--- a/blogit
+++ b/blogit
@@ -13,18 +13,19 @@ BLOG_DESCRIPTION ?= blog
BLOG_URL_ROOT ?= http://localhost/blog
BLOG_FEED_MAX ?= 20
BLOG_FEEDS ?= rss atom
+BLOG_SRC ?= articles
.PHONY: help init build deploy clean
-ARTICLES = $(shell git ls-tree HEAD --name-only -- articles/ 2>/dev/null)
-TAGFILES = $(patsubst articles/%.md,tags/%,$(ARTICLES))
+ARTICLES = $(shell git ls-tree HEAD --name-only -- $(BLOG_SRC)/ 2>/dev/null)
+TAGFILES = $(patsubst $(BLOG_SRC)/%.md,tags/%,$(ARTICLES))
help:
$(info blogit init|build|deploy|clean)
init:
- mkdir -p articles data templates
+ mkdir -p $(BLOG_SRC) data templates
printf '<!DOCTYPE html><html><head><title>$$TITLE</title></head><body>' > templates/header.html
printf '</body></html>' > templates/footer.html
printf '' > templates/index_header.html
@@ -43,7 +44,7 @@ init:
printf '' > templates/article_footer.html
printf 'blog\n' > .git/info/exclude
-build: blog/index.html tagpages $(patsubst articles/%.md,blog/%.html,$(ARTICLES)) $(patsubst %,blog/%.xml,$(BLOG_FEEDS))
+build: blog/index.html tagpages $(patsubst $(BLOG_SRC)/%.md,blog/%.html,$(ARTICLES)) $(patsubst %,blog/%.xml,$(BLOG_FEEDS))
deploy: build
rsync -rLtvz $(BLOG_RSYNC_OPTS) blog/ data/ $(BLOG_REMOTE)
@@ -56,7 +57,7 @@ config:
'$(shell printf "Blog remote (eg: host:/var/www/html): ">/dev/tty; head -n1)' \
> $@
-tags/%: articles/%.md
+tags/%: $(BLOG_SRC)/%.md
mkdir -p tags
grep -i '^; *tags:' "$<" | cut -d: -f2- | sed 's/ */\n/g' | sed '/^$$/d' | sort -u > $@
@@ -83,7 +84,7 @@ blog/index.html: $(ARTICLES) $(TAGFILES) $(addprefix templates/,$(addsuffix .htm
git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \
done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \
"$$first" || envsubst < templates/article_separator.html; \
- URL="`printf '%s' "\$$FILE" | sed 's,^articles/\(.*\).md,\1,'`.html" \
+ URL="`printf '%s' "\$$FILE" | sed 's,^$(BLOG_SRC)/\(.*\).md,\1,'`.html" \
DATE="$$DATE" \
TITLE="`head -n1 "\$$FILE" | sed -e 's/^# //g'`" \
envsubst < templates/article_entry.html; \
@@ -110,12 +111,12 @@ blog/@%.html: $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header tag_in
envsubst < templates/tag_index_header.html >> $@; \
envsubst < templates/article_list_header.html >> $@; \
first=true; \
- for f in $(shell grep -FH '$*' $(TAGFILES) | sed 's,^tags/\([^:]*\):.*,articles/\1.md,'); do \
+ for f in $(shell grep -FH '$*' $(TAGFILES) | sed 's,^tags/\([^:]*\):.*,$(BLOG_SRC)/\1.md,'); do \
printf '%s ' "$$f"; \
git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \
done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \
"$$first" || envsubst < templates/article_separator.html; \
- URL="`printf '%s' "\$$FILE" | sed 's,^articles/\(.*\).md,\1,'`.html" \
+ URL="`printf '%s' "\$$FILE" | sed 's,^$(BLOG_SRC)/\(.*\).md,\1,'`.html" \
DATE="$$DATE" \
TITLE="`head -n1 "\$$FILE" | sed -e 's/^# //g'`" \
envsubst < templates/article_entry.html; \
@@ -126,7 +127,7 @@ blog/@%.html: $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header tag_in
envsubst < templates/footer.html >> $@; \
-blog/%.html: articles/%.md $(addprefix templates/,$(addsuffix .html,header article_header article_footer footer))
+blog/%.html: $(BLOG_SRC)/%.md $(addprefix templates/,$(addsuffix .html,header article_header article_footer footer))
mkdir -p blog
TITLE="$(shell head -n1 $<)"; \
export TITLE; \