Adding new blog post
This commit is contained in:
parent
f6283b1142
commit
6c959a9f96
3 changed files with 110 additions and 98 deletions
|
|
@ -21,114 +21,71 @@ BLUE='\033[0;34m'
|
|||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}Removing existing files...${NC}"
|
||||
# Clean up public folder and create redirect files
|
||||
echo -e "${BLUE}Cleaning public folder...${NC}"
|
||||
rm -rf public/
|
||||
mkdir -p public/log
|
||||
|
||||
# Build the Hugo site
|
||||
echo -e "${BLUE}Building Hugo site...${NC}"
|
||||
hugo
|
||||
# Create index.html with redirect to https://ritual.sh
|
||||
cat > public/index.html << 'EOF'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; url=https://ritual.sh">
|
||||
<title>Redirecting...</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="https://ritual.sh">ritual.sh</a>...</p>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Hugo build failed!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ Hugo build successful!${NC}"
|
||||
|
||||
# Remove folders that shouldn't be uploaded to Neocities
|
||||
FOLDERS_TO_REMOVE=(
|
||||
"about"
|
||||
"archives"
|
||||
"audio"
|
||||
"blog"
|
||||
"buttons"
|
||||
"gear"
|
||||
"guestbook"
|
||||
"media"
|
||||
"now"
|
||||
"resources"
|
||||
"tags"
|
||||
"test"
|
||||
"updates"
|
||||
"uses"
|
||||
"fonts"
|
||||
"images"
|
||||
"js"
|
||||
"games"
|
||||
)
|
||||
|
||||
echo -e "${BLUE}Removing excluded folders from public...${NC}"
|
||||
for folder in "${FOLDERS_TO_REMOVE[@]}"; do
|
||||
if [ -d "public/$folder" ]; then
|
||||
rm -rf "public/$folder"
|
||||
echo -e " ${GREEN}✓${NC} Removed $folder/"
|
||||
fi
|
||||
done
|
||||
echo -e "${GREEN}✓ Folder cleanup complete!${NC}"
|
||||
|
||||
# Remove specific files that shouldn't be uploaded
|
||||
FILES_TO_REMOVE=(
|
||||
"index.html"
|
||||
"404.html"
|
||||
)
|
||||
|
||||
echo -e "${BLUE}Removing excluded files from public...${NC}"
|
||||
for file in "${FILES_TO_REMOVE[@]}"; do
|
||||
if [ -f "public/$file" ]; then
|
||||
rm -f "public/$file"
|
||||
echo -e " ${GREEN}✓${NC} Removed $file"
|
||||
fi
|
||||
done
|
||||
echo -e "${GREEN}✓ File cleanup complete!${NC}"
|
||||
# Create log/index.html with redirect to https://ritual.sh/logs/
|
||||
cat > public/log/index.html << 'EOF'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; url=https://ritual.sh/log/">
|
||||
<title>Redirecting...</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="https://ritual.sh/log/">ritual.sh/log/</a>...</p>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✓ Redirect files created!${NC}"
|
||||
echo ""
|
||||
|
||||
# Count total files
|
||||
# Upload the redirect files
|
||||
cd public
|
||||
total_files=$(find . -type f | wc -l)
|
||||
current=0
|
||||
|
||||
echo -e "${BLUE}Uploading $total_files files to Neocities...${NC}"
|
||||
echo -e "${BLUE}Uploading files to Neocities...${NC}"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Upload files using the API
|
||||
find . -type f | while read file; do
|
||||
cleanfile="${file#./}"
|
||||
((current++))
|
||||
|
||||
# Calculate progress percentage
|
||||
percentage=$((current * 100 / total_files))
|
||||
|
||||
# Create progress bar with simple characters
|
||||
filled=$((percentage / 2))
|
||||
empty=$((50 - filled))
|
||||
bar=$(printf "%${filled}s" | tr ' ' '=')
|
||||
space=$(printf "%${empty}s" | tr ' ' '-')
|
||||
|
||||
# Upload and capture response
|
||||
response=$(curl -s -H "Authorization: Bearer $NEOCITIES_API_KEY" \
|
||||
-F "$cleanfile=@$file" \
|
||||
"https://neocities.org/api/upload")
|
||||
|
||||
# Parse result from JSON - check if response contains "success"
|
||||
if echo "$response" | grep -q '"result"[[:space:]]*:[[:space:]]*"success"'; then
|
||||
result="success"
|
||||
else
|
||||
result="error"
|
||||
fi
|
||||
|
||||
# Display progress with color
|
||||
printf "[${YELLOW}%s${NC}%s] %3d%% (%d/%d) " "$bar" "$space" "$percentage" "$current" "$total_files"
|
||||
|
||||
# Show file status
|
||||
if [ "$result" = "success" ]; then
|
||||
echo -e "${GREEN}✓${NC} $cleanfile"
|
||||
else
|
||||
echo -e "${RED}✗${NC} $cleanfile - ERROR"
|
||||
echo " Response: $response"
|
||||
fi
|
||||
done
|
||||
# Upload index.html
|
||||
response=$(curl -s -H "Authorization: Bearer $NEOCITIES_API_KEY" \
|
||||
-F "index.html=@index.html" \
|
||||
"https://neocities.org/api/upload")
|
||||
|
||||
if echo "$response" | grep -q '"result"[[:space:]]*:[[:space:]]*"success"'; then
|
||||
echo -e "${GREEN}✓${NC} index.html"
|
||||
else
|
||||
echo -e "${RED}✗${NC} index.html - ERROR"
|
||||
echo " Response: $response"
|
||||
fi
|
||||
|
||||
# Upload log/index.html
|
||||
response=$(curl -s -H "Authorization: Bearer $NEOCITIES_API_KEY" \
|
||||
-F "log/index.html=@log/index.html" \
|
||||
"https://neocities.org/api/upload")
|
||||
|
||||
if echo "$response" | grep -q '"result"[[:space:]]*:[[:space:]]*"success"'; then
|
||||
echo -e "${GREEN}✓${NC} log/index.html"
|
||||
else
|
||||
echo -e "${RED}✗${NC} log/index.html - ERROR"
|
||||
echo " Response: $response"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue