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.
 
 
 
 

89 lines
3.3 KiB

#!/bin/bash
set -euf -o pipefail #exit on fail, unset variables, file-globs/expansion and piping problems
function finish {
read -n 1 -s -r -p "Press any key to continue"
}
trap finish EXIT
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
mkdir -p "out/images" || 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 vico fluajho argodejo) #The order here is the order on the page. Each of these gets its own entry.
#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
#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"
cat "modules/10head" "temp/$PROJECT/module_menu" "modules/20aftermenu" "temp/$PROJECT/module_page" "modules/90foot" > "out/$PROJECT.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
cat "modules/10head" "temp/index_menu" "modules/20aftermenu" "directcontent/index" "modules/90foot" > "out/index.html"