From 21ac2bdd8805eb72e11acc6d16a228edf7a446fc Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 15 Jul 2021 15:44:17 +0300 Subject: feat: add (un)localize make targets --- Makefile | 12 +++++++++++- compile_emoji_sedstring.sh | 2 +- header.html | 2 +- index.md | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 9025e5e..4f61ae7 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ PANDOC_ARGS=-s --from=$(MARKDOWN) --to=html -c $(STYLESHEET) -B $(HEADER) -H $(I LINK_SEDSTRING=s/.md)/.html)/g; EMOJI_SEDSTRING=$(shell ./compile_emoji_sedstring.sh) +LOCALIZE_SEDSTRING=s|\"/|\"$(PWD)/|; +UNLOCALIZE_SEDSTRING=s|$(PWD)||; + SOURCES=$(wildcard *.md blog/*.md) HTML=$(patsubst %.md, %.html, $(SOURCES)) @@ -27,14 +30,21 @@ index.html: index.md blog/preview.md blog/preview.md: blog/index.md @echo $@ - @sed -n "s/^-/ -/; /^ -/p" $< | head -n 4 > $@ + @sed -n "s/^-/ -/; s|(|(blog/| ; /^ -/p" $< | head -n 4 > $@ open: $(HTML) $(BROWSER) index.html deploy: $(HTML) + $(MAKE) unlocalize rsync -zarv --exclude=".git" --exclude="*.md" . $(RSYNC_DESTINATION) +localize: $(HTML) + @for file in $^; do sed -i "$(UNLOCALIZE_SEDSTRING) $(LOCALIZE_SEDSTRING)" $$file; done + +unlocalize: $(HTML) + @for file in $^; do sed -i "$(UNLOCALIZE_SEDSTRING)" $$file; done + clean: rm -f $(HTML) blog/preview.md diff --git a/compile_emoji_sedstring.sh b/compile_emoji_sedstring.sh index 2fb2f6d..3337e59 100755 --- a/compile_emoji_sedstring.sh +++ b/compile_emoji_sedstring.sh @@ -6,5 +6,5 @@ cd public/emoji; for EMOJI in *; do BASENAME=${EMOJI%.*} - echo "s|:${BASENAME}:|\\\"${BASENAME}-icon\\\"|g; " + echo "s|:${BASENAME}:|\\\"${BASENAME}-icon\\\"|g; " done diff --git a/header.html b/header.html index 5ad7977..55b5c27 100755 --- a/header.html +++ b/header.html @@ -1,5 +1,5 @@
- + eug-vs

Eugene's Space

diff --git a/index.md b/index.md index 85c3371..fd98b35 100755 --- a/index.md +++ b/index.md @@ -9,7 +9,7 @@ This website runs on my local *Raspberry Pi* and features secure **HTTPS** conne No bullshit, ads, trackers or client-side JavaScript here. -# Recent blog posts +# Recent blog posts :newspaper: - [See all...](./blog/index.md) # Articles :page_with_curl: -- cgit v1.2.3