An assortment of scripts and programs that pulls in info from our repositories and puts out a website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.0KB

  1. #!/bin/bash
  2. set -euf -o pipefail #exit on fail, unset variables, file-globs/expansion and piping problems
  3. ROOTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
  4. cd "$ROOTPATH"
  5. echo Running from "$ROOTPATH"
  6. #Create initial structure and data-set
  7. mkdir temp || true #in .gitignore . Make dir, ignore fail if exists for set -e
  8. rm -rf out/
  9. cp -r static out
  10. cd temp
  11. #We loop over all projects several times, each stage of the generation.
  12. #Instead of doing one project fully at a time, creating one giant nested loop.
  13. #Administration first, the processing!
  14. PROJECTS=(laborejo patroneo agordejo fluajho) #The order here is the order on the page. Each of these gets its own entry.
  15. PROJECTS_AS_STRING=$( IFS=$' '; echo "${PROJECTS[*]}" )
  16. #Gather and update data
  17. for PROJECT in ${PROJECTS[*]} template
  18. do
  19. GIT="https://git.laborejo.org/lss/$PROJECT.git"
  20. echo "$GIT"
  21. if [ -d "$PROJECT" ]; then
  22. cd "$PROJECT"
  23. git pull
  24. cd ..
  25. else
  26. git clone "$GIT"
  27. fi
  28. done
  29. cd "$ROOTPATH" #reset for next step
  30. #Documentation, just a copy
  31. for PROJECT in ${PROJECTS[*]}
  32. do
  33. cp -r "temp/$PROJECT/documentation/out" "out/documentation/$PROJECT"
  34. cp "static/images/$PROJECT.png" "out/documentation/$PROJECT/logo.png"
  35. cp -r "temp/$PROJECT/documentation/screenshot.png" "out/screenshots/$PROJECT.png" #there is now png and apng
  36. done
  37. #Generate Menu. n^2 loop. For each project all projects
  38. for PROJECT in ${PROJECTS[*]}
  39. do
  40. echo "" > "temp/$PROJECT/module_menu" #empty file
  41. #Index/Home is the same for all sub-pages. index is not included in the list so we do not care about the "this is the current page" highlight here.
  42. echo "<li class='pure-menu-item'><a class='pure-menu-link' href='/'>Home</a></li>" >> "temp/$PROJECT/module_menu" #automatic newline
  43. for EACH in ${PROJECTS[*]}
  44. do
  45. TITLE=$(echo "$EACH" | sed 's/[^ ]\+/\L\u&/g')
  46. if [ "$PROJECT" = "$EACH" ]; then
  47. #Special line for ourselves
  48. echo "<li class='pure-menu-item menu-item-divided pure-menu-selected'><a class='pure-menu-link' href='/$PROJECT/'>$TITLE</a></li>" >> "temp/$PROJECT/module_menu" #automatic newline
  49. else
  50. echo "<li class='pure-menu-item'><a class='pure-menu-link' href='/$EACH/'>$TITLE</a></li>" >> "temp/$PROJECT/module_menu" #automatic newline
  51. fi
  52. done
  53. done
  54. for PROJECT in ${PROJECTS[*]}
  55. do
  56. echo "" > "temp/$PROJECT/module_page" #empty file
  57. done
  58. cd "$ROOTPATH" #reset for next step
  59. #Combine Modules to real html in out/
  60. for PROJECT in ${PROJECTS[*]}
  61. do
  62. ./projectinfo2modulepage.py "$PROJECT" > "temp/$PROJECT/module_page"
  63. mkdir -p "out/$PROJECT"
  64. cat "modules/10head" "temp/$PROJECT/module_menu" "modules/20aftermenu" "temp/$PROJECT/module_page" "modules/90foot" > "out/$PROJECT/index.html"
  65. done
  66. #Update Atom Release Feeds. We already need the project dirs in /out for this step.
  67. for PROJECT in ${PROJECTS[*]}
  68. do
  69. ./atomfeedgen.py "$PROJECT" "temp/$PROJECT/CHANGELOG" "out/$PROJECT/feed.atom"
  70. done
  71. cd "$ROOTPATH" #reset for next step
  72. #Create Home/Welcome page
  73. #A bit of redundancy first. Generate a menu.
  74. echo "" > "temp/index_menu" #empty file
  75. echo "<li class='pure-menu-item menu-item-divided pure-menu-selected'><a class='pure-menu-link' href='/'>Home</a></li>" >> "temp/index_menu" #automatic newline
  76. for EACH in ${PROJECTS[*]}
  77. do
  78. TITLE=$(echo "$EACH" | sed 's/[^ ]\+/\L\u&/g')
  79. echo "<li class='pure-menu-item'><a class='pure-menu-link' href='/$EACH/'>$TITLE</a></li>" >> "temp/index_menu" #automatic newline
  80. done
  81. #Home-Content
  82. ./index2dataindex.py $PROJECTS_AS_STRING > temp/index
  83. cat "modules/10head" "temp/index_menu" "modules/20aftermenu" "temp/index" "modules/90foot" > "out/index.html"
  84. #Check if we have an HTML dir, then deploy
  85. cd "$ROOTPATH" #reset for next step
  86. if [ -d "../html" ]; then
  87. echo "It looks like we are on a host. Deploying website"
  88. cp -r out/. ../html #copy all, including hidden. This will not replace the html symlink . Do NOT use cp -a, this will screw up file permissions
  89. fi