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.
 
 
 
 

102 lines
3.6 KiB

#!/bin/bash
set -euf -o pipefail #exit on fail, unset variables, file-globs/expansion and piping problems
ROOTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd "$ROOTPATH"
echo Running from "$ROOTPATH"
#Create initial structure and data-set
mkdir temp || true #in .gitignore . Make dir, ignore fail if exists for set -e
rm -rf out/
cp -r static out
cd temp
#We loop over all projects several times, each stage of the generation.
#Instead of doing one project fully at a time, creating one giant nested loop.
#Administration first, the processing!
PROJECTS=(laborejo patroneo agordejo fluajho vico) #The order here is the order on the page. Each of these gets its own entry.
PROJECTS_AS_STRING=$( IFS=$' '; echo "${PROJECTS[*]}" )
#Gather and update data
for PROJECT in ${PROJECTS[*]} template
do
GIT="https://git.laborejo.org/lss/$PROJECT.git"
echo "$GIT"
if [ -d "$PROJECT" ]; then
cd "$PROJECT"
git pull
cd ..
else
git clone "$GIT"
fi
done
cd "$ROOTPATH" #reset for next step
#Documentation, just a copy
for PROJECT in ${PROJECTS[*]}
do
cp -r "temp/$PROJECT/documentation/out" "out/documentation/$PROJECT"
cp "static/images/$PROJECT.png" "out/documentation/$PROJECT/logo.png"
done
#Generate Menu. n^2 loop. For each project all projects
for PROJECT in ${PROJECTS[*]}
do
echo "" > "temp/$PROJECT/module_menu" #empty file
#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.
echo "<li class='pure-menu-item'><a class='pure-menu-link' href='/'>Home</a></li>" >> "temp/$PROJECT/module_menu" #automatic newline
for EACH in ${PROJECTS[*]}
do
TITLE=$(echo "$EACH" | sed 's/[^ ]\+/\L\u&/g')
if [ "$PROJECT" = "$EACH" ]; then
#Special line for ourselves
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
else
echo "<li class='pure-menu-item'><a class='pure-menu-link' href='/$EACH/'>$TITLE</a></li>" >> "temp/$PROJECT/module_menu" #automatic newline
fi
done
done
for PROJECT in ${PROJECTS[*]}
do
echo "" > "temp/$PROJECT/module_page" #empty file
done
cd "$ROOTPATH" #reset for next step
#Combine Modules to real html in out/
for PROJECT in ${PROJECTS[*]}
do
./projectinfo2modulepage.py "$PROJECT" > "temp/$PROJECT/module_page"
mkdir -p "out/$PROJECT"
cat "modules/10head" "temp/$PROJECT/module_menu" "modules/20aftermenu" "temp/$PROJECT/module_page" "modules/90foot" > "out/$PROJECT/index.html"
done
#Create Home/Welcome page
#A bit of redundancy first. Generate a menu.
echo "" > "temp/index_menu" #empty file
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
for EACH in ${PROJECTS[*]}
do
TITLE=$(echo "$EACH" | sed 's/[^ ]\+/\L\u&/g')
echo "<li class='pure-menu-item'><a class='pure-menu-link' href='/$EACH/'>$TITLE</a></li>" >> "temp/index_menu" #automatic newline
done
#Home-Content
./index2dataindex.py $PROJECTS_AS_STRING > temp/index
cat "modules/10head" "temp/index_menu" "modules/20aftermenu" "temp/index" "modules/90foot" > "out/index.html"
#Check if we have an HTML dir, then deploy
cd "$ROOTPATH" #reset for next step
if [ -d "../html" ]; then
echo "It looks like we are on a host. Deploying website"
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
fi