summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile21
1 files changed, 12 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index afa9a7e..8df6ceb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,15 @@
# Written for FreeBSD make(1), or pmake. Not tested with GNU make.
+EDITOR = $$EDITOR
POST_T = templates/template.html
-INDEX_HEAD_T = templates/index_foot.html
-INDEX_FOOT_T = templates/index_head.html
+INDEX_HEAD_T = templates/index_head.html
+INDEX_FOOT_T = templates/index_foot.html
+RSS_HEAD_T = templates/rss_head.xml
+RSS_FOOT_T = templates/rss_foot.xml
.PHONY: serve post clean
-all: index.html
+all: index.html rss.xml
serve:
python3.7 -m http.server 3000
@@ -15,17 +18,17 @@ post:
@read -p "Title: " TITLE; \
read -p "Category: " CATEGORY; \
SHORT_DATE=`date +"%Y-%m-%d"`; \
- 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 $(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
+ $EDITOR $$FILENAME
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
+ @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_HEAD_T) - $(INDEX_FOOT_T) > index.html
+
+rss.xml: posts/*.html
+ @grep h1 $> | sort -r | sed 's#^\(posts/[^:]*\):[ \t]*<h1>\(.*\)</h1>#<item><title>\2</title><link>https://www.53hor.net/posts/\1</link></item>#' | cat $(RSS_HEAD_T) - $(RSS_FOOT_T) > rss.xml
clean:
- rm index.html
+ rm -f index.html rss.xml