/
make_presentation.sh
executable file
·101 lines (84 loc) · 3.51 KB
/
make_presentation.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Copyright (c) 2009 The Open Source Geospatial Foundation.
# Licensed under the GNU LGPL version >= 2.1.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 2.1 of the License,
# or any later version. This library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY, without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details, either
# in the "LICENSE.LGPL.txt" file distributed with this software or at
# web page "http://www.fsf.org/licenses/lgpl.html".
#
# About:
# =====
# Preprocess the OSGeoLive presentation and copy into the target directory.
# * Change URL of images files
# * Copy contributor and translator names into a HTML table on Credits slide,
#
# Usage:
# ======
# make_presentation <source dir> <target dir>
# script assumes it is being run in the main directory
tmp=/tmp/make_presentation.tmp
cols=8 # Number of table columns
source="en/presentation" # source presentation file
target="_build/html/en/presentation" # target presentation file
if [ -d "$1" ] ; then
source="$1";
if [ "$2" ] ; then
target="$2";
else
echo "You have to pass to variables, a source and a target directories"
exit
fi
fi
mkdir -p "$target"
# copy the abstract.txt to the target
if [ ! -d "$target"/abstract.txt ] ; then
cp --preserve=mode,timestamps -r "$source"/abstract.txt "$target"
fi
# copy the reveal.js libary to the target
if [ ! -d "$target"/../../reveal.js ] ; then
cp --preserve=mode,timestamps -r "$source"/../../reveal.js "$target"/../..
fi
# Extract a list of names from contributors.csv and translators.csv
insertLine=`grep -n "Contributors and translators table is inserted here" "$source/index.html" | cut -d":" -f1`
# Replace space with @ so the name string is treated as one token in the for
# loop
cut -d"," -f1 contributors.csv | sed -e "s/ /@/g ; s/Name//" > "$tmp"
cut -d"," -f3 translators.csv | sed -e "s/ /@/g ; s/Name//" >> "$tmp"
# print top of the presentation file
head -n "$insertLine" "$source/index.html" > "$target/index.html"
j=0
echo "<table>" >> "$target/index.html"
for name in `cat "$tmp" | sort -u` ; do
if [ $((j % cols )) -eq 0 ]; then
echo "<tr>" >> "$target/index.html"
fi
# insert space back into name string
echo "<td>$name</td>" | sed -e "s/@/ /g" >> "$target/index.html"
j=$((j + 1 ))
if [ $((j % cols )) -eq 0 ]; then
echo "</tr>" >> "$target/index.html"
fi
done
echo "</table>" >> "$target/index.html"
# print bottom of the presentation file
tail -n +"$insertLine" "$source/index.html" >> "$target/index.html"
mv "$target/index.html" "$tmp"
# copy the presentation images to the target
mkdir -p "$target/../../_images/"
cp -p images/banner.png "$target/../../_images/"
cp -p images/presentation/* "$target/../../_images/"
# copy the others images linked in the presentation
cp -pr images/projects/1024x768/* "$target/../../_images/"
cp -p images/projects/800x600/* "$target/../../_images/"
cp -p images/project_logos/* "$target/../../_images/"
cp -p images/logos/* "$target/../../_images/"
# change all image URL references to be placed into _images/ dir
#<img src="../../images/projects/1024x768/mapwindow-screenshot.jpg"
# becomes <img src="_images/mapwindow-screenshot.jpg"
sed -e 's#\(<img.*\)\(src="../../images[^\.]*/\)\([^\.]*\.[^\/]*"\)#\1 src="../../_images/\3#' "$tmp" > "$target/index.html"