swx_plan 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # Generate html giving the list of pages in a website
  3. # usage : $0 [directory of site] > website_plan.html
  4. DIR="$1"
  5. parse_dir() {
  6. LIST=$(ls $1)
  7. for i in $LIST; do
  8. if [ -d "$1/$i" ] && [ -f "$1/$i/index.html" ]; then
  9. echo "<li><a href=\"$(echo "$1/$i" |sed -e "s,$DIR,,g")/index.html\">$i</a></li>"
  10. echo "<ul>"
  11. parse_dir "$1/$i"
  12. echo "</ul>"
  13. else
  14. echo "<li><a href=\"$(echo "$1/$i" |sed -e "s,$DIR,,g")\">$i</a></li>"
  15. fi
  16. done
  17. }
  18. if [ ! -d "$1" ]; then
  19. echo "can't find $1"
  20. echo "usage $0 [directory containing website]"
  21. exit 1
  22. fi
  23. # Load config file
  24. if [ ! -f $PWD/swx.conf ]; then
  25. echo "Cannot find swx.conf in current directory"
  26. exit 1
  27. fi
  28. . $PWD/swx.conf
  29. echo "<!doctype html>"
  30. echo "<html>"
  31. echo "<head>"
  32. echo "<title>Plan du site</title>"
  33. echo "<link rel="icon" href="/favicon.png" type="image/png">"
  34. echo "<meta charset="UTF-8">"
  35. echo "<link rel="stylesheet" type="text/css" href="/style.css">"
  36. echo "</head>"
  37. echo "<body>"
  38. echo "<div id=\"main\">"
  39. echo "☺ Utilisez la fonction recherche de votre navigateur (ctrl-f) pour trouver votre bonheur"
  40. echo "<ul>"
  41. parse_dir "$1"
  42. echo "</ul>"
  43. echo "</div>"
  44. echo "</body>"
  45. echo "</html>"