#!/bin/bash

OUTPUT="index.html"

echo "<!DOCTYPE html>
<html>
<head>
    <meta charset=\"UTF-8\">
    <title>Directory listing</title>
    <style>
        body { font-family: Arial, sans-serif; }
        h1 { color: #333; }
        ul { list-style-type: none; padding: 0; }
        li { margin: 5px 0; }
        a { text-decoration: none; color: #0066cc; }
        a:hover { text-decoration: underline; }
    </style>
</head>
<body>
    <h1>Directory listing</h1>
    <ul>" > "$OUTPUT"

# Loop through files
for file in *; do
    # Skip the output file itself
    if [ "$file" = "$OUTPUT" ]; then
        continue
    fi

    if [ -d "$file" ]; then
        echo "        <li>[D] <a href=\"$file/\">$file/</a></li>" >> "$OUTPUT"
    else
        echo "        <li><a href=\"$file\">$file</a></li>" >> "$OUTPUT"
    fi
done

echo "    </ul>
</body>
</html>" >> "$OUTPUT"

echo "index.html generated."
