summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2021-04-21 22:57:39 -0400
committerAdam T. Carpenter <atc@53hor.net>2021-04-21 22:57:39 -0400
commit890b34bcc1a6b4073d1e512b1386634f7bc5ea52 (patch)
tree17efbec82a5bc118c2ae0b3ec56acbf159e4edda /Makefile
parente87bdb082057c4eddd1af159374b667c7fe234d4 (diff)
download53hor-890b34bcc1a6b4073d1e512b1386634f7bc5ea52.tar.xz
53hor-890b34bcc1a6b4073d1e512b1386634f7bc5ea52.zip
unified posts dir, until I can figure out makefile sub-subdirs. makefile auto-generates index
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile19
1 files changed, 13 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index c20643c..afa9a7e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,16 @@
# Written for FreeBSD make(1), or pmake. Not tested with GNU make.
-TEMPLATE = templates/template.html
+POST_T = templates/template.html
+INDEX_HEAD_T = templates/index_foot.html
+INDEX_FOOT_T = templates/index_head.html
-.PHONY: serve post
+.PHONY: serve post clean
+
+all: index.html
serve:
python3.7 -m http.server 3000
-profile/adamcarpenter.pdf: profile/adamcarpenter.html
- touch profile/adamcarpenter.pdf
-
post:
@read -p "Title: " TITLE; \
read -p "Category: " CATEGORY; \
@@ -17,8 +18,14 @@ post:
LONG_DATE=`date +"%a, %d %b %Y"`; \
mkdir -p posts/$$CATEGORY; \
FILENAME=posts/$$CATEGORY/$$SHORT_DATE-`printf "$$TITLE" | tr -Cs "[:alnum:]" '-' | tr "[:upper:]" "[:lower:]"`.html; \
- cp $(TEMPLATE) $$FILENAME; \
+ cp $(POST_T) $$FILENAME; \
sed -i '' "s/{{ title }}/$$TITLE/g" $$FILENAME; \
$$EDITOR $$FILENAME; \
sed -i '' "s#</channel>#<item> <title>$$TITLE</title> <pubDate>$$LONG_DATE</pubDate> <link>https://www.53hor.net/$$FILENAME</link> <guid>https://www.53hor.net/$$FILENAME</guid> </item>\n</channel>#" rss.xml; \
sed -i '' "s#<ul id=\"index\">#<ul id=\"index\">\n<li> <a href=\"/$$FILENAME\">$$TITLE <code>$$LONG_DATE</code> </a> </li>#" index.html
+
+index.html: posts/*.html
+ @grep h1 $> | sort -r | sed 's#^\(posts/\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\)[^:]*\):[ \t]*<h1>\(.*\)</h1>#<li><a href="/\1">\3 <code>\2</code></a></li>#' | cat $(INDEX_FOOT_T) - $(INDEX_HEAD_T) > index.html
+
+clean:
+ rm index.html