From bfc0b7f598c8e9b7e94d798656fa3aa0366f1d26 Mon Sep 17 00:00:00 2001
From: Wen Kokke <wenkokke@users.noreply.github.com>
Date: Wed, 15 Jul 2020 16:02:57 +0100
Subject: [PATCH 1/5] Fixed Makefile; fixed historical Source links.

---
 Makefile | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 52f39544..de412363 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,12 @@ else
 AGDA_STDLIB_URL := https://agda.github.io/agda-stdlib/v$(AGDA_STDLIB_VERSION)/
 endif
 
+ifeq ($(shell sed --version >/dev/null 2>&1; echo $$?),1)
+SEDI := sed -i ""
+else
+SEDI := sed -i
+endif
+
 
 # Build PLFA web version and test links
 default: test
@@ -52,11 +58,15 @@ build-incremental: $(MARKDOWN_FILES)
 # Download PLFA web releases
 build-history: latest/ $(RELEASES)
 
-latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION))) | .versions/
-	cd $< && $(JEKYLL) clean && $(JEKYLL) build --destination '../../latest' --baseurl '/latest'
+latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION)))
+	$(SEDI) "s/branch: dev/branch: dev-$(LATEST_VERSION)/" $(addsuffix _config.yml,$<)
+	cd $< \
+		&& $(JEKYLL) clean \
+		&& $(JEKYLL) build --destination '../../latest' --baseurl '/latest'
 
 # Download PLFA web release and build it under the relevant folder
 define build_release
+version := $(1)
 out := $(addsuffix /,$(1))
 url := $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
 tmp_zip := $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
@@ -66,18 +76,21 @@ baseurl := $(addprefix /,$(1))
 $$(tmp_zip): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
 $$(tmp_zip): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
 $$(tmp_zip):
+	@mkdir -p .versions/
 	wget -c $$(url) -O $$(tmp_zip)
 
 $$(tmp_dir): tmp_dir = $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(1)))
 $$(tmp_dir): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
-$$(tmp_dir): $$(tmp_zip) | .versions/
-	unzip -qq $$(tmp_zip) -d .versions/
+$$(tmp_dir): $$(tmp_zip)
+	yes | unzip -qq $$(tmp_zip) -d .versions/
 
+$$(out): version = $(1)
 $$(out): out = $(addsuffix /,$(1))
 $$(out): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
 $$(out): tmp_dir = $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(1)))
 $$(out): baseurl = $(addprefix /,$(1))
 $$(out): $$(tmp_dir)
+	$(SEDI) "s/branch: dev/branch: dev-$$(version)/" $$(addsuffix _config.yml,$$(tmp_dir))
 	cd $$(tmp_dir) \
 		&& rm -rf _posts \
 		&& $(JEKYLL) clean \
@@ -87,10 +100,6 @@ endef
 # Incorporate previous releases of PLFA web version
 $(foreach release_version,$(RELEASE_VERSIONS),$(eval $(call build_release,$(release_version))))
 
-.versions/:
-	mkdir -p .versions/
-
-
 # Convert literal Agda to Markdown using highlight.sh
 define AGDA_template
 in := $(1)
@@ -99,6 +108,7 @@ $$(out) : in  = $(1)
 $$(out) : out = $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
 $$(out) : $$(in) | out/
 	@echo "Processing $$(subst ./,,$$(in))"
+	@mkdir -p out/
 ifeq (,$$(findstring courses/,$$(in)))
 	./highlight.sh $$(subst ./,,$$(in)) --include-path=src/
 else
@@ -126,9 +136,6 @@ test-stable-offline: $(MARKDOWN_FILES)
 	$(JEKYLL) build --destination '_site/stable' --baseurl '/stable'
 	$(HTMLPROOFER) '_site' --disable-external
 
-out/:
-	mkdir -p out/
-
 .phony: test test-offline test-stable-offline
 
 
@@ -140,6 +147,7 @@ epubcheck: out/epub/plfa.epub
 	$(EPUBCHECK) out/epub/plfa.epub
 
 out/epub/plfa.epub: out/epub/ | $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epub/acknowledgements.md
+	@mkdir -p out/epub/
 	$(PANDOC) --strip-comments \
 		--css=epub/main.css \
 		--epub-embed-font='assets/fonts/mononoki.woff' \
@@ -157,19 +165,16 @@ out/epub/plfa.epub: out/epub/ | $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epu
 		epub/index.md
 
 out/epub/acknowledgements.md: src/plfa/acknowledgements.md _config.yml
+	@mkdir -p out/epub/
 	 $(BUNDLE) exec ruby epub/render-liquid-template.rb _config.yml $< $@
 
-out/epub/:
-	mkdir -p out/epub/
-
 .phony: epub epubcheck
 
 
 # Clean auxiliary files
 clean:
 	rm -f .agda-stdlib.sed .links-*.sed out/epub/acknowledgements.md
-	rm -f plfa.github.io-web-*.zip
-	rm -rf plfa.github.io-web-*/
+	rm -rf .versions
 ifneq ($(strip $(AGDAI_FILES)),)
 	rm $(AGDAI_FILES)
 endif
@@ -178,6 +183,7 @@ endif
 clobber: clean
 	$(JEKYLL) clean
 	rm -rf out/
+	rm -rf latest/ $(RELEASES)
 
 .phony: clean clobber
 

From 56613e9d5e299786bc677674988500f3097fd51e Mon Sep 17 00:00:00 2001
From: Wen Kokke <wenkokke@users.noreply.github.com>
Date: Wed, 15 Jul 2020 16:19:23 +0100
Subject: [PATCH 2/5] Fix Makefile.

---
 Makefile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index de412363..30337403 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 SHELL := /usr/bin/env bash
-AGDA_FILES := $(shell find . -type f -and \( -path '*/src/*' -or -path '*/courses/*' \) -and -name '*.lagda.md')
-AGDAI_FILES := $(shell find . -type f -and \( -path '*/src/*' -or -path '*/courses/*' \) -and -name '*.agdai')
+AGDA_FILES := $(shell find . -type f -and \( -path './src/*' -or -path './courses/*' \) -and -name '*.lagda.md')
+AGDAI_FILES := $(shell find . -type f -and \( -path './src/*' -or -path './courses/*' \) -and -name '*.agdai')
 MARKDOWN_FILES := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(AGDA_FILES))))
 PLFA_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
 PANDOC := pandoc
@@ -27,6 +27,9 @@ else
 SEDI := sed -i
 endif
 
+bla:
+	@echo $(AGDA_FILES)
+
 
 # Build PLFA web version and test links
 default: test

From 26ad191b9ba4958a78d8e28d5e50af6a67892047 Mon Sep 17 00:00:00 2001
From: Wen Kokke <wenkokke@users.noreply.github.com>
Date: Wed, 15 Jul 2020 16:26:21 +0100
Subject: [PATCH 3/5] Fix Makefile

---
 Makefile | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 30337403..ff5c8c86 100644
--- a/Makefile
+++ b/Makefile
@@ -27,9 +27,6 @@ else
 SEDI := sed -i
 endif
 
-bla:
-	@echo $(AGDA_FILES)
-
 
 # Build PLFA web version and test links
 default: test
@@ -109,7 +106,7 @@ in := $(1)
 out := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
 $$(out) : in  = $(1)
 $$(out) : out = $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
-$$(out) : $$(in) | out/
+$$(out) : $$(in)
 	@echo "Processing $$(subst ./,,$$(in))"
 	@mkdir -p out/
 ifeq (,$$(findstring courses/,$$(in)))
@@ -149,7 +146,7 @@ epub: out/epub/plfa.epub
 epubcheck: out/epub/plfa.epub
 	$(EPUBCHECK) out/epub/plfa.epub
 
-out/epub/plfa.epub: out/epub/ | $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epub/acknowledgements.md
+out/epub/plfa.epub: $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epub/acknowledgements.md
 	@mkdir -p out/epub/
 	$(PANDOC) --strip-comments \
 		--css=epub/main.css \

From 7dd0479994f8ccb1e1db7a9fe6d461d8f87c4468 Mon Sep 17 00:00:00 2001
From: Wen Kokke <wenkokke@users.noreply.github.com>
Date: Wed, 15 Jul 2020 16:30:49 +0100
Subject: [PATCH 4/5] Update _config.yml

---
 _config.yml | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/_config.yml b/_config.yml
index 18394e64..c7e10420 100644
--- a/_config.yml
+++ b/_config.yml
@@ -55,16 +55,15 @@ markdown: kramdown
 theme: minima
 excerpt_separator: <!--more-->
 exclude:
-  - "hs/"
-  - "extra/"
-  - "depr/"
-  - "papers/"
-  - "slides/"
-  - "vendor/"
-  - ".versions/"
+  - "*.lagda.md"
   - "*.agdai"
   - "*.agda-lib"
-  - "*.lagda.md"
+  - "extra/"
+  - "papers/"
+  - "vendor/"
+  - "epub/"
+  - ".versions/"
+  - "_build/"
   - "Guardfile"
   - "Gemfile"
   - "Gemfile.lock"

From 3ba6a0508da77173e55712ecfa9a9ffb3b498473 Mon Sep 17 00:00:00 2001
From: Wen Kokke <wenkokke@users.noreply.github.com>
Date: Wed, 15 Jul 2020 17:12:42 +0100
Subject: [PATCH 5/5] Fix Makefile.

---
 Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index ff5c8c86..3d60511b 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,6 @@ build-incremental: $(MARKDOWN_FILES)
 build-history: latest/ $(RELEASES)
 
 latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION)))
-	$(SEDI) "s/branch: dev/branch: dev-$(LATEST_VERSION)/" $(addsuffix _config.yml,$<)
 	cd $< \
 		&& $(JEKYLL) clean \
 		&& $(JEKYLL) build --destination '../../latest' --baseurl '/latest'
@@ -79,18 +78,18 @@ $$(tmp_zip):
 	@mkdir -p .versions/
 	wget -c $$(url) -O $$(tmp_zip)
 
+$$(tmp_dir): version = $(1)
 $$(tmp_dir): tmp_dir = $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(1)))
 $$(tmp_dir): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
 $$(tmp_dir): $$(tmp_zip)
 	yes | unzip -qq $$(tmp_zip) -d .versions/
+	$(SEDI) "s/branch: dev/branch: dev-$$(version)/" $$(addsuffix _config.yml,$$(tmp_dir))
 
-$$(out): version = $(1)
 $$(out): out = $(addsuffix /,$(1))
 $$(out): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
 $$(out): tmp_dir = $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(1)))
 $$(out): baseurl = $(addprefix /,$(1))
 $$(out): $$(tmp_dir)
-	$(SEDI) "s/branch: dev/branch: dev-$$(version)/" $$(addsuffix _config.yml,$$(tmp_dir))
 	cd $$(tmp_dir) \
 		&& rm -rf _posts \
 		&& $(JEKYLL) clean \