diff options
-rw-r--r-- | _config.yml | 1 | ||||
-rw-r--r-- | _pastebins/2016-04-05-rpn-macro-setup.md (renamed from _pastebins/rpn-macro-setup.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-11-nix-pinning.md (renamed from _pastebins/nix-pinning.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-13-gnu-guix-systemd-daemon-for-nixos.md (renamed from _pastebins/gnu-guix-systemd-daemon-for-nixos.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-13-guix-builder-user-creation-commands.md (renamed from _pastebins/guix-builder-user-creation-commands.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-13-guix-users-in-nixos-system-configuration.md (renamed from _pastebins/guix-users-in-nixos-system-configuration.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-13-nix-string-padding.md (renamed from _pastebins/nix-string-padding.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-25-nix-exps.md (renamed from _pastebins/nix-exps.md) | 0 | ||||
-rw-r--r-- | _pastebins/2018-07-25-nix-show-derivation.md (renamed from _pastebins/nix-show-derivation.md) | 0 | ||||
-rw-r--r-- | _pastebins/2019-06-08-inconsistent-hash-of-buildgomodule.md (renamed from _pastebins/inconsistent-hash-of-buildgomodule.md) | 0 | ||||
-rw-r--r-- | _pastebins/2019-12-29-raku-tuple-type-annotation.md (renamed from _pastebins/raku-tuple-type-annotation.md) | 0 | ||||
-rw-r--r-- | _pastebins/2020-01-04-failure-on-guix-tex-live-importer.md (renamed from _pastebins/failure-on-guix-tex-live-importer.md) | 0 | ||||
-rw-r--r-- | _pastebins/2020-02-14-guix-shebang.md (renamed from _pastebins/guix-shebang.md) | 0 | ||||
-rwxr-xr-x | scripts/assert-content.sh | 92 |
14 files changed, 34 insertions, 59 deletions
diff --git a/_config.yml b/_config.yml index 134e719..4508ade 100644 --- a/_config.yml +++ b/_config.yml @@ -31,6 +31,7 @@ exclude: - templates/ - drafts/ - description + - result collections: articles: diff --git a/_pastebins/rpn-macro-setup.md b/_pastebins/2016-04-05-rpn-macro-setup.md index 5ebe3ab..5ebe3ab 100644 --- a/_pastebins/rpn-macro-setup.md +++ b/_pastebins/2016-04-05-rpn-macro-setup.md diff --git a/_pastebins/nix-pinning.md b/_pastebins/2018-07-11-nix-pinning.md index 4239511..4239511 100644 --- a/_pastebins/nix-pinning.md +++ b/_pastebins/2018-07-11-nix-pinning.md diff --git a/_pastebins/gnu-guix-systemd-daemon-for-nixos.md b/_pastebins/2018-07-13-gnu-guix-systemd-daemon-for-nixos.md index 0580993..0580993 100644 --- a/_pastebins/gnu-guix-systemd-daemon-for-nixos.md +++ b/_pastebins/2018-07-13-gnu-guix-systemd-daemon-for-nixos.md diff --git a/_pastebins/guix-builder-user-creation-commands.md b/_pastebins/2018-07-13-guix-builder-user-creation-commands.md index 356fe4b..356fe4b 100644 --- a/_pastebins/guix-builder-user-creation-commands.md +++ b/_pastebins/2018-07-13-guix-builder-user-creation-commands.md diff --git a/_pastebins/guix-users-in-nixos-system-configuration.md b/_pastebins/2018-07-13-guix-users-in-nixos-system-configuration.md index f7c8440..f7c8440 100644 --- a/_pastebins/guix-users-in-nixos-system-configuration.md +++ b/_pastebins/2018-07-13-guix-users-in-nixos-system-configuration.md diff --git a/_pastebins/nix-string-padding.md b/_pastebins/2018-07-13-nix-string-padding.md index 8de9048..8de9048 100644 --- a/_pastebins/nix-string-padding.md +++ b/_pastebins/2018-07-13-nix-string-padding.md diff --git a/_pastebins/nix-exps.md b/_pastebins/2018-07-25-nix-exps.md index d0ee26b..d0ee26b 100644 --- a/_pastebins/nix-exps.md +++ b/_pastebins/2018-07-25-nix-exps.md diff --git a/_pastebins/nix-show-derivation.md b/_pastebins/2018-07-25-nix-show-derivation.md index 90ec80e..90ec80e 100644 --- a/_pastebins/nix-show-derivation.md +++ b/_pastebins/2018-07-25-nix-show-derivation.md diff --git a/_pastebins/inconsistent-hash-of-buildgomodule.md b/_pastebins/2019-06-08-inconsistent-hash-of-buildgomodule.md index 8b1ebaa..8b1ebaa 100644 --- a/_pastebins/inconsistent-hash-of-buildgomodule.md +++ b/_pastebins/2019-06-08-inconsistent-hash-of-buildgomodule.md diff --git a/_pastebins/raku-tuple-type-annotation.md b/_pastebins/2019-12-29-raku-tuple-type-annotation.md index 21dbdf2..21dbdf2 100644 --- a/_pastebins/raku-tuple-type-annotation.md +++ b/_pastebins/2019-12-29-raku-tuple-type-annotation.md diff --git a/_pastebins/failure-on-guix-tex-live-importer.md b/_pastebins/2020-01-04-failure-on-guix-tex-live-importer.md index 5b74724..5b74724 100644 --- a/_pastebins/failure-on-guix-tex-live-importer.md +++ b/_pastebins/2020-01-04-failure-on-guix-tex-live-importer.md diff --git a/_pastebins/guix-shebang.md b/_pastebins/2020-02-14-guix-shebang.md index 626aea8..626aea8 100644 --- a/_pastebins/guix-shebang.md +++ b/_pastebins/2020-02-14-guix-shebang.md diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh index 8e30aca..a0d661f 100755 --- a/scripts/assert-content.sh +++ b/scripts/assert-content.sh @@ -75,12 +75,17 @@ get-layout() { ## Assertions assert-frontmatter() { - F="${1}" + F="$1" + DESIRED_LAYOUT="$2" + PREFIX="${3:-}" LANG="$(get-lang "$F")" REF="$(get-ref "$F")" URL="$(get-url "$F")" + LAYOUT="$(get-layout "$F")" + [[ -z "${LANG}" ]] && fail-attr 'lang' "${URL}" [[ -z "${REF}" ]] && fail-attr 'ref' "${URL}" + if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then TITLE="$(get-title "$F")" [[ -z "${TITLE}" ]] && fail-attr 'title' "${URL}" @@ -90,58 +95,47 @@ assert-frontmatter() { red "Invalid lang '${LANG}' in ${URL}." >&2 exit 1 fi -} -echo Linting posts... >&2 -for post in $(jq -r '.posts[] | @base64' "${JSON}"); do - assert-frontmatter "$post" - DATE="$(get-date "$post" | awk '{print $1}')" - URL="$(basename "$(get-url "$post")")" - FILE="_posts/${DATE}-${URL%.html}.md" - - [[ -f "${FILE}" ]] || { - red "date/filename mismatch: '${FILE}' does not exist." + if [[ "${DESIRED_LAYOUT}" != "${LAYOUT}" ]]; then + red "Layout mismatch: expected '${DESIRED_LAYOUT}', got '${LAYOUT}'." + red "Page: ${URL}." exit 1 - } + fi + + if [[ -n "${PREFIX}" ]]; then + DATE="$(get-date "$F" | awk '{print $1}')" + URL_BASENAME="$(basename "$(get-url "$F")")" + FILE="${PREFIX}/${DATE}-${URL_BASENAME%.html}.md" + + [[ -f "${FILE}" ]] || { + red "date/filename mismatch: '${FILE}' does not exist. To fix, run:" + echo " mv '${PREFIX}/${URL_BASENAME%.html}.md' '${FILE}'" + exit 1 + } + fi +} + +echo Linting articles... >&2 +for article in $(jq -r '.articles[] | @base64' "${JSON}"); do + assert-frontmatter "$article" 'post' '_articles' done echo Linting pages... >&2 for page in $(jq -r '.pages[] | @base64' "${JSON}"); do URL="$(get-url "$page")" if ! contains-element "${URL}" "${IGNORED_PAGES[@]}"; then - assert-frontmatter "${page}" + assert-frontmatter "${page}" 'page' fi done echo Linting pastebins... >&2 for pastebin in $(jq -r '.pastebins[] | @base64' "${JSON}"); do - assert-frontmatter "$pastebin" + assert-frontmatter "$pastebin" 'pastebin' '_pastebins' done echo Linting tils... >&2 for til in $(jq -r '.tils[] | @base64' "${JSON}"); do - assert-frontmatter "$til" - DATE="$(get-date "$til" | awk '{print $1}')" - URL="$(basename "$(get-url "$til")")" - FILE="_tils/${DATE}-${URL%.html}.md" - - [[ -f "${FILE}" ]] || { - red "date/filename mismatch: '${FILE}' does not exist." - exit 1 - } -done - -echo Lintins slides... >&2 -for slide in $(jq -r '.slides[] | @base64' "${JSON}"); do - assert-frontmatter "$slide" - DATE="$(get-date "$slide" | awk '{print $1}')" - URL="$(basename "$(get-url "$slide")")" - FILE="_slides/${DATE}-${URL%.html}.html" - - [[ -f "${FILE}" ]] || { - red "date/filename mismatch: '${FILE}' does not exist." - exit 1 - } + assert-frontmatter "$til" 'post' '_tils' done echo Asserting unique refs... >&2 @@ -166,28 +160,8 @@ assert-unique-ref() { done } -assert-unique-ref "$(jq -r '.pages[] | @base64' "${JSON}")" -assert-unique-ref "$(jq -r '.pastebins[] | @base64' "${JSON}")" -assert-unique-ref "$(jq -r '.posts[] | @base64' "${JSON}")" -assert-unique-ref "$(jq -r '.tils[] | @base64' "${JSON}")" - -echo Asserting layouts... >&2 -assert-layout() { - DESIRED=$2 - for p in $1; do - LAYOUT="$(get-layout "$p")" - URL="$(get-url "$p")" - if [[ "${DESIRED}" != "${LAYOUT}" ]]; then - red "Layout mismatch: expected '${DESIRED}', got '${LAYOUT}'." - red "Page: ${URL}." - exit 1 - fi - done -} - -assert-layout "$(jq -r '.posts[] | @base64' "${JSON}")" "post" -assert-layout "$(jq -r '.pastebins[] | @base64' "${JSON}")" "pastebin" -assert-layout "$(jq -r '.tils[] | @base64' "${JSON}")" "til" -assert-layout "$(jq -r '.slides[] | @base64' "${JSON}")" "slide" +assert-unique-ref "$(jq -r '.pages[] | @base64' "${JSON}")" +assert-unique-ref "$(jq -r '.articles[] | @base64' "${JSON}")" +assert-unique-ref "$(jq -r '.tils[] | @base64' "${JSON}")" echo Done. >&2 |