about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-28 23:13:42 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-28 23:18:06 +0700
commit89bb239365bdfdef8827251748e6a36d741fdf63 (patch)
tree713c95eaa3beccd0616a1f25753e7dd6b022bf42
parentc111dacfdef7624bef023341b6f3a0b88b830ab3 (diff)
downloadsite-89bb239365bdfdef8827251748e6a36d741fdf63.tar.gz
Fix all HTML and RSS compliance issues (hopefully!)
-rw-r--r--.builds/auto.yml (renamed from .build.yml)5
-rw-r--r--.builds/franklin.jl (renamed from .build.jl)2
-rw-r--r--.builds/shell.nix (renamed from shell.nix)4
-rw-r--r--.gitignore2
-rw-r--r--README.md5
-rwxr-xr-x_libs/minify39
-rw-r--r--blog/2020/gsoc/article/5.md2
-rw-r--r--blog/2020/gsoc/article/7.md4
-rw-r--r--blog/2020/gsoc/index.md1
-rw-r--r--config.md4
-rw-r--r--utils.jl2
11 files changed, 56 insertions, 14 deletions
diff --git a/.build.yml b/.builds/auto.yml
index 80bd57b..c5b9a7b 100644
--- a/.build.yml
+++ b/.builds/auto.yml
@@ -3,6 +3,7 @@ oauth: lists.sr.ht/EMAILS:RO pages.sr.ht/PAGES:RW
 packages:
   - nixos.jq
   - nixos.openring
+  - nixos.python3
 sources:
   - https://git.sr.ht/~cnx/site
 environment:
@@ -17,8 +18,8 @@ tasks:
       acurl https://lists.sr.ht/query/list/5261.mbox -o site/_libs/formbox/mbox
   - build: |
       cd site
-      nix-shell --run 'julia --project=@. .build.jl'
-      rm -r __site/libs
+      nix-shell .builds/shell.nix --run 'julia --project=@. .builds/franklin.jl'
+      nix-shell -p python3Packages.css-html-js-minify --run _libs/minify
   - deploy: |
       tar -cvzf site.tar.gz -C site/__site .
       acurl -f https://pages.sr.ht/publish/cnx.srht.site -F content=@site.tar.gz
diff --git a/.build.jl b/.builds/franklin.jl
index 52bbec3..c090540 100644
--- a/.build.jl
+++ b/.builds/franklin.jl
@@ -2,5 +2,5 @@ import Pkg
 Pkg.instantiate()
 
 using Franklin
-optimize(clear=true, no_fail_prerender=false,
+optimize(clear=true, minify=false, no_fail_prerender=false,
          suppress_errors=false, fail_on_warning=true)
diff --git a/shell.nix b/.builds/shell.nix
index 50d4e3e..3f21d40 100644
--- a/shell.nix
+++ b/.builds/shell.nix
@@ -1,8 +1,8 @@
 with import <nixpkgs> {};
 mkShell {
   nativeBuildInputs = [
-    julia-bin nodejs nodePackages.katex python3
-  ] ++ (with python3Packages; [ bleach css-html-js-minify markdown ]);
+    julia-bin nodejs nodePackages.katex
+  ] ++ (with python3Packages; [ bleach markdown ]);
 
   shellHook = ''
     npm install highlight.js # https://github.com/NixOS/nixpkgs/issues/152201
diff --git a/.gitignore b/.gitignore
index 0a3ca5a..5c6f140 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,7 @@ _css/katex.min.css
 _libs/fediring
 _libs/formbox/mbox
 _libs/highlight/
-_libs/katex/
+_libs/katex
 _libs/openring/out.html
 node_modules/
 package-lock.json
diff --git a/README.md b/README.md
index f780ddf..7030b3d 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,8 @@ This is my Franklin-generated static site, *without* client-side scripts.
 
 ## Building
 
-    julia --project=@. .build.jl
+    julia --project=@. .builds/franklin.jl
+    _libs/minify
 
 ### Explicit dependencies
 
@@ -17,7 +18,7 @@ The following are needed to run the command above:
 * [css-html-js-minify](https://pypi.org/p/css-html-js-minify)
 
 KaTex has to installed to `_css` and `_libs` similar
-to what done in `.build.yml`.  Furthermore, adjacent sites
+to what done in `.builds/auto.yml`.  Furthermore, adjacent sites
 in the [Fediring](https://fediring.net) needs to present
 in `_libs/fediring` and `_libs/openring/out.html` needs to be
 generated using [openring](https://sr.ht/~sircmpwn/openring).  Live-rendering
diff --git a/_libs/minify b/_libs/minify
new file mode 100755
index 0000000..67634a3
--- /dev/null
+++ b/_libs/minify
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# Minify HTML and CSS, patch HTML and remove JS
+# Copyright (C) 2021  Nguyễn Gia Phong
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+import re
+from contextlib import suppress
+from pathlib import Path
+from shutil import rmtree
+
+from css_html_js_minify import html_minify, process_single_css_file
+
+FOOTNOTES_START = re.compile('(<p>)?\s*<table')
+FOOTNOTES_END = re.compile('</table>\s*(</p>)?')
+
+
+def fix_footnotes(html):
+    """Work around https://github.com/tlienart/Franklin.jl/issues/936"""
+    return FOOTNOTES_START.sub('<table', FOOTNOTES_END.sub('</table>', html))
+
+
+site = Path(__file__).parent.parent / '__site'
+process_single_css_file(site/'css'/'style.css', overwrite=True)
+for html in site.rglob('*.html'):
+    print('Minifying and fixing up', html)
+    html.write_text(fix_footnotes(html_minify(html.read_text())))
+with suppress(FileNotFoundError): rmtree(site/'libs')
diff --git a/blog/2020/gsoc/article/5.md b/blog/2020/gsoc/article/5.md
index cdcc509..bd9d7e6 100644
--- a/blog/2020/gsoc/article/5.md
+++ b/blog/2020/gsoc/article/5.md
@@ -4,7 +4,7 @@ date = Date(2020, 8, 3)
 tags = ["gsoc", "pip", "python"]
 +++
 
-Sorting Things Out
+# Sorting Things Out
 
 Hi!  I really hope that everyone reading this is still doing okay,
 and if that isn't the case, I wish you a good day!
diff --git a/blog/2020/gsoc/article/7.md b/blog/2020/gsoc/article/7.md
index 4e2073b..6deebb9 100644
--- a/blog/2020/gsoc/article/7.md
+++ b/blog/2020/gsoc/article/7.md
@@ -4,13 +4,13 @@ date = Date(2020, 8, 31)
 tags = ["gsoc", "pip", "python"]
 +++
 
+# Outro
+
 > Steamed fish was amazing, matter of fact\
 > Let me get some jerk chicken to go\
 > Grabbed me one of them lemon pie theories\
 > And let me get some of them benchmarks you theories too
 
-# Outro
-
 \toc
 
 ## The Look
diff --git a/blog/2020/gsoc/index.md b/blog/2020/gsoc/index.md
index b05c908..0606c13 100644
--- a/blog/2020/gsoc/index.md
+++ b/blog/2020/gsoc/index.md
@@ -2,6 +2,7 @@
 rss = "GSoC 2020 final report"
 date = Date(2020, 8, 31)
 rss_pubdate = date # work around Franklin issue GH-797
+fd_full_url = "https://cnx.srht.site/blog/2020/gsoc/index.html"
 tags = ["fun", "gsoc", "packaging", "pip"]
 internship = "https://summerofcode.withgoogle.com/archive/2020/projects/6238594655584256"
 benchmark = "/blog/2020/gsoc/article/7/#the_benchmark"
diff --git a/config.md b/config.md
index 077fcfb..a77b1f7 100644
--- a/config.md
+++ b/config.md
@@ -7,8 +7,8 @@ website_url = "https://cnx.srht.site"
 date_format = "yyyy-mm-dd"
 mintoclevel = 2
 generate_rss = true
-ignore = [".build.jl", ".build.yml", "Manifest.toml", "Project.toml",
-          "node_modules/", "package-lock.json", "shell.nix"]
+ignore = [".builds/", "Manifest.toml", "Project.toml",
+          "node_modules/", "package-lock.json"]
 +++
 
 \newcommand{\R}{\mathbb R}
diff --git a/utils.jl b/utils.jl
index 62dce1d..a056c30 100644
--- a/utils.jl
+++ b/utils.jl
@@ -20,7 +20,7 @@ function render_comments(template)
   format = joinpath(prefix, "format")
   mbox = joinpath(prefix, "mbox")
   template_path = joinpath(prefix, template)
-  readchomp(`python3 $format $mbox $(message_id()) $template_path`)
+  readchomp(`$format $mbox $(message_id()) $template_path`)
 end
 
 hfun_comments_rendered() = render_comments("comment.html")