blog
Deploy to Development and Production / deploy (push) Successful in 8s

This commit is contained in:
Mark Poljanšek committed 2025-11-19 00:47:50 +01:00
1 parent de47c2ce8f
commit 718e29a9d8
74 files changed
+22865 -2852

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
BLOG_INDEX="blog/index.html"
SAMPLE_ARTICLE="blog/clanki/2025-11-17-sample-article.html"
echo "Checking links in $BLOG_INDEX..."
# Extract all href attributes and check if they return 200 OK
grep -Eio 'href="([^"]+)"' "$BLOG_INDEX" | sed -E 's/href="([^"]+)"/\1/' | while read -r link; do
if [[ "$link" == /* ]]; then # Internal link
# For internal links, check if the file exists
if [ -f ".${link}" ]; then
echo " [OK] Internal link: $link"
else
echo " [ERROR] Internal link not found: $link"
exit 1
fi
elif [[ "$link" == http* ]]; then # External link
# For external links, use curl to check status
status_code=$(curl -s -o /dev/null -w "%{http_code}" "$link")
if [ "$status_code" -eq 200 ]; then
echo " [OK] External link: $link"
else
echo " [ERROR] External link failed ($status_code): $link"
exit 1
fi
fi
done
echo "Checking links in $SAMPLE_ARTICLE..."
grep -Eio 'href="([^"]+)"' "$SAMPLE_ARTICLE" | sed -E 's/href="([^"]+)"/\1/' | while read -r link; do
if [[ "$link" == /* ]]; then # Internal link
# For internal links, check if the file exists
if [ -f ".${link}" ]; then
echo " [OK] Internal link: $link"
else
echo " [ERROR] Internal link not found: $link"
exit 1
fi
elif [[ "$link" == http* ]]; then # External link
status_code=$(curl -s -o /dev/null -w "%{http_code}" "$link")
if [ "$status_code" -eq 200 ]; then
echo " [OK] External link: $link"
else
echo " [ERROR] External link failed ($status_code): $link"
exit 1
fi
fi
done
echo "Link checking completed."
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bats
load '../posodobi_blog.sh' # Load the script to be tested
@test "check_jq_dependency exits with error if jq is not installed" {
# Mock command -v jq to simulate jq not being installed
PATH_ORIGINAL="$PATH"
export PATH="/tmp/nonexistent_path:$PATH" # Temporarily modify PATH
run check_jq_dependency
[ "$status" -eq 1 ]
[[ "$output" == *"Error: 'jq' is not installed. Please install it to run this script."* ]]
export PATH="$PATH_ORIGINAL" # Restore original PATH
}
@test "check_jq_dependency does not exit if jq is installed" {
# Mock command -v jq to simulate jq being installed
# Assuming jq is installed in the test environment
run check_jq_dependency
[ "$status" -eq 0 ]
[ "$output" == "" ] # Should not print anything on success
}
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
BLOG_INDEX="blog/index.html"
echo "Validating $BLOG_INDEX with tidy..."
# Run tidy with HTML5 doctype, quiet output, and show warnings
tidy -q -e -utf8 --doctype html5 "$BLOG_INDEX"
echo "HTML validation for $BLOG_INDEX completed."