more translation
This commit is contained in:
parent
8ee055bfa8
commit
2ce9ca50b5
459 changed files with 21001 additions and 9395 deletions
165
scripts/test_site.sh
Executable file
165
scripts/test_site.sh
Executable file
|
|
@ -0,0 +1,165 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${YELLOW}Starting Zola site testing...${NC}"
|
||||
|
||||
# Function to clean up background processes
|
||||
cleanup() {
|
||||
echo -e "\n${YELLOW}Cleaning up...${NC}"
|
||||
# Kill any running zola processes
|
||||
pkill -f "zola serve" 2>/dev/null
|
||||
exit
|
||||
}
|
||||
|
||||
# Set up trap for cleanup
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Check if zola is installed
|
||||
if ! command -v zola &> /dev/null; then
|
||||
echo -e "${RED}Error: Zola is not installed. Please install it first.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 1: Check zola build
|
||||
echo -e "\n${YELLOW}Test 1: Checking if site builds successfully...${NC}"
|
||||
if zola build; then
|
||||
echo -e "${GREEN}✓ Site builds successfully${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Site build failed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test 2: Check for broken links
|
||||
echo -e "\n${YELLOW}Test 2: Starting server and checking for broken links...${NC}"
|
||||
zola serve &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Wait for server to start
|
||||
sleep 2
|
||||
|
||||
# Use curl to check if server is running
|
||||
if ! curl -s http://127.0.0.1:1111 > /dev/null; then
|
||||
echo -e "${RED}✗ Server is not responding${NC}"
|
||||
kill $SERVER_PID
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ Server is responding${NC}"
|
||||
|
||||
# Extract and check all links using curl
|
||||
echo -e "${YELLOW}Checking for broken links...${NC}"
|
||||
|
||||
# Create temp files for storing links
|
||||
INTERNAL_LINKS=$(mktemp)
|
||||
EXTERNAL_LINKS=$(mktemp)
|
||||
|
||||
# Get the site content and extract all links
|
||||
curl -s http://127.0.0.1:1111 | grep -o 'href="[^"]*"' | sed 's/href="\([^"]*\)"/\1/g' > "$INTERNAL_LINKS"
|
||||
|
||||
# Add other important pages to check
|
||||
echo "/de" >> "$INTERNAL_LINKS"
|
||||
echo "/atom.xml" >> "$INTERNAL_LINKS"
|
||||
echo "/tags" >> "$INTERNAL_LINKS"
|
||||
echo "/project" >> "$INTERNAL_LINKS"
|
||||
|
||||
# Also check project pages and other content
|
||||
for page in $(curl -s http://127.0.0.1:1111/project/ | grep -o 'href="[^"]*"' | sed 's/href="\([^"]*\)"/\1/g'); do
|
||||
echo "$page" >> "$INTERNAL_LINKS"
|
||||
done
|
||||
|
||||
# Function to check a URL with proper user agent and timeout
|
||||
check_url() {
|
||||
local url="$1"
|
||||
local timeout=10
|
||||
curl -s -f -o /dev/null \
|
||||
--max-time "$timeout" \
|
||||
-H "User-Agent: Mozilla/5.0 (compatible; LinkChecker/1.0)" \
|
||||
"$url"
|
||||
return $?
|
||||
}
|
||||
|
||||
echo -e "${YELLOW}Checking internal links...${NC}"
|
||||
BROKEN_INTERNAL=0
|
||||
while read -r link; do
|
||||
# Skip empty lines and external links
|
||||
[[ -z "$link" ]] && continue
|
||||
if [[ "$link" =~ ^(http|https|mailto|tel): ]]; then
|
||||
echo "$link" >> "$EXTERNAL_LINKS"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Construct full URL for relative links
|
||||
url="http://127.0.0.1:1111${link}"
|
||||
|
||||
# Check the link
|
||||
if check_url "$url"; then
|
||||
echo -e "${GREEN}✓ Valid internal link: $link${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Broken internal link: $link${NC}"
|
||||
BROKEN_INTERNAL=$((BROKEN_INTERNAL + 1))
|
||||
fi
|
||||
done < "$INTERNAL_LINKS"
|
||||
|
||||
echo -e "\n${YELLOW}Checking external links...${NC}"
|
||||
BROKEN_EXTERNAL=0
|
||||
while read -r url; do
|
||||
# Skip empty lines and non-http(s) links
|
||||
[[ -z "$url" || ! "$url" =~ ^https?:// ]] && continue
|
||||
|
||||
# Check the external link
|
||||
if check_url "$url"; then
|
||||
echo -e "${GREEN}✓ Valid external link: $url${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Broken external link: $url${NC}"
|
||||
BROKEN_EXTERNAL=$((BROKEN_EXTERNAL + 1))
|
||||
fi
|
||||
done < "$EXTERNAL_LINKS"
|
||||
|
||||
# Clean up
|
||||
rm "$INTERNAL_LINKS" "$EXTERNAL_LINKS"
|
||||
|
||||
# Report summary
|
||||
echo -e "\n${YELLOW}Link Check Summary:${NC}"
|
||||
if [ $BROKEN_INTERNAL -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ All internal links are valid${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Found $BROKEN_INTERNAL broken internal links${NC}"
|
||||
fi
|
||||
|
||||
if [ $BROKEN_EXTERNAL -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ All external links are valid${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Found $BROKEN_EXTERNAL broken external links${NC}"
|
||||
fi
|
||||
|
||||
# Test 3: Check multilingual content
|
||||
echo -e "\n${YELLOW}Test 3: Checking multilingual content...${NC}"
|
||||
if curl -s http://127.0.0.1:1111/de > /dev/null; then
|
||||
echo -e "${GREEN}✓ German version is accessible${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ German version is not accessible${NC}"
|
||||
fi
|
||||
|
||||
if curl -s http://127.0.0.1:1111/en > /dev/null; then
|
||||
echo -e "${GREEN}✓ English version is accessible${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ English version is not accessible${NC}"
|
||||
fi
|
||||
|
||||
# Test 4: Check RSS feeds
|
||||
echo -e "\n${YELLOW}Test 4: Checking RSS feeds...${NC}"
|
||||
if curl -s http://127.0.0.1:1111/atom.xml > /dev/null; then
|
||||
echo -e "${GREEN}✓ RSS feed is accessible${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ RSS feed is not accessible${NC}"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
kill $SERVER_PID
|
||||
|
||||
echo -e "\n${GREEN}All tests completed!${NC}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue