Newer
Older

Fabian Nuraddin Alexander Gabel
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# generate namelist of collaborators from topic file
original="topic-template.md"
filename="topic-output.md"
baseurl='https://www.mat.tuhh.de'
#make output copy
cp $original $filename
#replace working group
for wg in {aa,cm,dm,nm,st}
do
fullname=`wget -qO- $baseurl/forschung/$wg | grep h1 | sed -e "s/<h1>\s*\(.*\)<\/h1>.*$/\1/g" | sed -e 's/^[ \t]*//'`
sed -i "s;### Working Groups:\(.*\)$wg\(.*\);### Working Groups:\1\[$fullname\]($baseurl/forschung/$wg)\2;g" $filename
done
namelist=`grep -h -i -m 1 -r "###\s*Collaborators (MAT):" $filename | sed -e 's/^###\s*Collaborators (MAT):\s*//I' -e 's/\s*,\s*/\n/g' | sort -u`
for name in $namelist
do
# pipeline to get full name of staff-member from mat-homepage
# -> wget the staff homepage of $name
# -> grep the line with the <h1>-tag, something like <h1>Fabian Gabel, M. Sc.</h1><div class='staffIntro'><p><img src='/home/fgabel/images/portrait.png' title='Foto von Fabian Gabel, M. Sc.' class='staffPicture'></p><div class='staffContact'>
# -> strip the string such that only the portion between <h1></h1> remains
# -> remove leading spaces
fullname=`wget -qO- $baseurl/home/$name/?homepage_id=$name | grep h1 | sed -e "s/<h1>\s*\(.*\)<\/h1>.*$/\1/g" | sed -e 's/^[ \t]*//'`
# dirty replacement to avoid dealing with
errstr='Binary file (standard input) matches'
if [ "$fullname" = "$errstr" ];
then
fullname=`echo "$name $fullname" | \
sed -e "s;jgrossmann $errstr;Dr. Julian Großmann;g" \
-e "s;fbuenger $errstr;Dr. Florian Bünger;g" \
-e "s;hvoss $errstr;Prof. Dr. Heinrich Voß;g" \
-e "s;fboesch $errstr;Dipl. Ing. Frank Bösch;g" \
-e "s;sgoetschel $errst;Dr. Sebastian Götschel;g"`
fi
# replace name in .md file
sed -i "s;$name;\[$fullname\]($baseurl/home/$name);g" $filename
done