An assortment of scripts and programs that pulls in info from our repositories and puts out a website.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

112 rindas
4.0 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 tembro agordejo patroneo) #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"
cp -r "temp/$PROJECT/documentation/screenshot.png" "out/screenshots/$PROJECT.png" #there is now png and apng
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
#Update Atom Release Feeds. We already need the project dirs in /out for this step.
for PROJECT in ${PROJECTS[*]}
do
./atomfeedgen.py "$PROJECT" "temp/$PROJECT/CHANGELOG" "out/$PROJECT/feed.atom"
done
cd "$ROOTPATH" #reset for next step
#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