summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-04-21 17:43:44 +0300
committereug-vs <eugene@eug-vs.xyz>2022-04-21 17:44:45 +0300
commit02d6ea3076ba578f3e1bb4859a1089c01b03c185 (patch)
tree698d9f4bde3165cec82169e3a349f8f5f3b4d181
parent73376d049e64f335b7c40c94c4d7f6fa9e06d77b (diff)
downloadbenzin-02d6ea3076ba578f3e1bb4859a1089c01b03c185.tar.gz
feat: add custom emoji support
-rw-r--r--Makefile34
1 files changed, 26 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index a049daf..d47b458 100644
--- a/Makefile
+++ b/Makefile
@@ -3,15 +3,16 @@
WEBSITE_URL=https://example.com
WEBSITE_TITLE="Example Website"
-
CONVERT=pandoc --from=gfm+emoji --to=html --section-divs --shift-heading-level-by=1
PAGE_TEMPLATE=templates/page.html
OPENRING_TEMPLATE=templates/openring.html
RSS_TEMPLATE=templates/rss.xml
RSS_ITEM_TEMPLATE=templates/rss_item.xml
+EMOJI_SIZE=20
+EMOJI_STYLE=margin-bottom: -4px;
+
RSS=out/blog/index.xml
-PUBLIC=out/public
OPENRING_FOOTER=tmp/openring.html
OPENRING_ARGS=-s https://eug-vs.xyz/blog/index.xml -s https://drewdevault.com/blog/index.xml
@@ -24,6 +25,11 @@ HTML=$(patsubst src/%.md, out/%.html, $(SOURCES))
BLOG_XML=$(patsubst src/%.md, tmp/%.xml, $(BLOG_SOURCES))
+PUBLIC_SOURCES=$(shell find src/public -type f)
+PUBLIC=$(patsubst src/%, out/%, $(PUBLIC_SOURCES))
+
+EMOJI_SOURCES=$(wildcard src/public/emoji/*)
+
.PHONY: clean all serve
.SECONDARY: $(TMP_HTML) $(BLOG_XML)
@@ -37,14 +43,14 @@ out/%.html: tmp/%.content.html tmp/%.meta.title $(PAGE_TEMPLATE) $(OPENRING_FOOT
-e 'a <title>' -e "r tmp/$*.meta.title" -e 'a <\/title>' \
-e '}' $@
-tmp/%.content.html: src/%.md
+tmp/%.content.html: src/%.md tmp/emoji.sed
@mkdir -p $(@D)
- sed "s/.md)/.html)/g" $< | $(CONVERT) > $@
+ sed -e "s/.md)/.html)/g" -f tmp/emoji.sed $< | $(CONVERT) > $@
tmp/%.meta.title: src/%.md
@mkdir -p $(@D)
sed '/^#/q' $< | sed 's/#* //' > $@
- echo "| $(WEBSITE_TITLE)" >> $@
+ @echo "| $(WEBSITE_TITLE)" >> $@
tmp/index.meta.title:
@mkdir -p $(@D)
@@ -67,9 +73,21 @@ $(OPENRING_FOOTER): $(OPENRING_TEMPLATE)
@mkdir -p $(@D)
openring $(OPENRING_ARGS) < $< > $@
-# TODO: this is dumb
-$(PUBLIC): src/public
- cp -r $< $@
+out/public/%: src/public/%
+ @mkdir -p $(@D)
+ cp $^ $@
+
+out/public/emoji/%.png: src/public/emoji/%.png
+ @mkdir -p $(@D)
+ convert $< -resize $(EMOJI_SIZE)x$(EMOJI_SIZE) $@
+
+tmp/emoji.sed: $(EMOJI_SOURCES)
+ @mkdir -p $(@D)
+ for emoji in $^; do\
+ basename=$$(basename $$emoji); \
+ name=$${basename%.*}; \
+ echo "s|:$${name}:|<img src=\"/public/emoji/$${basename}\" alt=\"$${basename}-emoji\" height=\"$(EMOJI_SIZE)\" width=\"$(EMOJI_SIZE)\" style=\"$(EMOJI_STYLE)\">|g;" >> $@; \
+ done
serve: $(HTML)
quark -h 127.0.0.1 -p 8000 -d out -l