Browse Source

Add index.html generation to makefile

master
Jens Pitkänen 1 year ago
parent
commit
2681b5abff
7 changed files with 36 additions and 29 deletions
  1. +2
    -3
      .gitignore
  2. +19
    -11
      Makefile
  3. +2
    -1
      public/2019/07/06/make.csv
  4. +2
    -2
      public/default.css
  5. +1
    -9
      templates/index.html
  6. +7
    -0
      templates/post-preview.html
  7. +3
    -3
      templates/post.xml

+ 2
- 3
.gitignore View File

@@ -1,5 +1,4 @@
public/dark.css
public/light.css
public/feed.xml
public/20*/**/*.html
public/20*/**/*.xml
public/**/**/*.html
public/**/**/*.xml

+ 19
- 11
Makefile View File

@@ -1,15 +1,18 @@
.POSIX:

POSTS = public/2019/07/06/make.html
POSTS_XML = $(POSTS:.html=.xml)
RESOURCES = public/dark.css public/light.css public/feed.xml
TEMPLATE_POST_HTML = templates/post.html
TEMPLATE_POST_ATOM = templates/post.xml
TEMPLATE_FEED_ATOM = templates/feed.xml
POSTS = public/2019/07/06/make.html
POSTS_XML = $(POSTS:.html=.xml)
POSTS_PREVIEW = $(POSTS:.html=.preview.html)
RESOURCES = public/dark.css public/light.css public/feed.xml public/index.html
TEMPLATE_POST_HTML = templates/post.html
TEMPLATE_POST_PREVIEW = templates/post-preview.html
TEMPLATE_INDEX = templates/index.html
TEMPLATE_POST_ATOM = templates/post.xml
TEMPLATE_FEED_ATOM = templates/feed.xml

all: $(POSTS) $(POSTS_XML) $(RESOURCES)
all: $(POSTS) $(RESOURCES)
clean:
rm $(POSTS) $(POSTS_XML) $(RESOURCES)
rm $(POSTS) $(POSTS_XML) $(POSTS_PREVIEW) $(RESOURCES)

public/dark.css: public/default.css
sed -e 's/(prefers-color-scheme: light)/not all/g' -e 's/(prefers-color-scheme: dark)/all/g' $? > $@
@@ -22,12 +25,17 @@ public/feed.xml: $(POSTS_XML)
cat $@.tmp | awk "/<updated>/ { print }" | sort | tail -n 1 | awk -f templater.awk -v REPLACE="{{updated}}" - $@.tmp.tmp > $@
rm $@.tmp $@.tmp.tmp

# Touching the .md files to trigger re-rendering if the template file is changed
$(POSTS:.html=.md): $(TEMPLATE_POST_HTML) $(TEMPLATE_POST_ATOM) $(TEMPLATE_FEED_ATOM)
public/index.html: $(POSTS_PREVIEW)
cat $(POSTS_PREVIEW) | awk -f templater.awk - $(TEMPLATE_INDEX) > $@

# Touching the .md files to trigger re-rendering if the template file or the metadata is changed
$(POSTS:.html=.md): $(TEMPLATE_POST_HTML) $(TEMPLATE_POST_ATOM) $(TEMPLATE_FEED_ATOM) $(POSTS:.html=.csv)
touch $@

.SUFFIXES: .html .xml .md
.SUFFIXES: .html .preview.html .xml .md
.md.html:
cmark $< | awk -f templater.awk - $(TEMPLATE_POST_HTML) | awk -f templater.awk -v LOAD_LINES=1 $*.csv - > $@
.md.preview.html:
awk -f templater.awk -v LOAD_LINES=1 $*.csv $(TEMPLATE_POST_PREVIEW) > $@
.md.xml:
cmark $< | awk -f templater.awk - $(TEMPLATE_POST_ATOM) | awk -f templater.awk -v LOAD_LINES=1 $*.csv - > $@

+ 2
- 1
public/2019/07/06/make.csv View File

@@ -1,6 +1,7 @@
/2019/07/06/make.html
My experience learning make
tag:blog.neon.moe,2019-07-06:/2019/07/06/make
2019-07-06
2019-07-06T01:23:38+03:00
2019-07-06T01:23:38+03:00
2019-07-06T23:31:00+03:00
A journal of my journey from a casual cargo fan to a make evangelist. Well, not really, but it's about make and personal development.

+ 2
- 2
public/default.css View File

@@ -89,8 +89,8 @@ footer p { font-size: 0.8rem; }


/* Link styling */
a { text-decoration-style: dashed; }
a:focus { outline-offset: 2px; }
a { text-decoration-skip-ink: auto; }
a:focus { outline: 1px dashed; outline-offset: 1px; }


/* Animations for anchors */


public/index.html → templates/index.html View File

@@ -18,15 +18,7 @@
<br />
<main>
<ul class="blog-list">
<li>
<h3><a href="/2019/07/06/make.html">My experience learning make</a></h3>
<p class="timestamp">2019-07-06</p>
<p>
A journal of my journey from a casual <code>cargo</code> fan to a <code>make</code>
evangelist. Well, not really, but it's about make and personal
development at least.
</p>
</li>
{{insert-here}}
</ul>
</main>
<br />

+ 7
- 0
templates/post-preview.html View File

@@ -0,0 +1,7 @@
<li>
<h3><a href="{{0}}">
{{1}}
</a></h3>
<p class="timestamp">{{3}}</p>
<p>{{6}}</p>
</li>

+ 3
- 3
templates/post.xml View File

@@ -2,13 +2,13 @@
<title>{{1}}</title>
<link href="https://blog.neon.moe{{0}}" />
<id>{{2}}</id>
<published>{{3}}</published>
<updated>{{4}}</updated>
<published>{{4}}</published>
<updated>{{5}}</updated>
<author>
<name>Jens Pitkänen</name>
<email>jens@neon.moe</email>
</author>
<summary>{{5}}</summary>
<summary>{{6}}</summary>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
{{insert-here}}


Loading…
Cancel
Save