1 |
#!/bin/bash |
2 |
|
3 |
# cfupdate - convert a crossfire maps hierarchy to html |
4 |
# Copyright (C) 2005 Marc Lehmann <gvpe@schmorp.de> |
5 |
# |
6 |
# CFUPDATE is free software; you can redistribute it and/or modify |
7 |
# it under the terms of the GNU General Public License as published by |
8 |
# the Free Software Foundation; either version 2 of the License, or |
9 |
# (at your option) any later version. |
10 |
# |
11 |
# This program is distributed in the hope that it will be useful, |
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
# GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License |
17 |
# along with gvpe; if not, write to the Free Software |
18 |
# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 |
|
20 |
VERSION=1.08 |
21 |
|
22 |
umask 022 |
23 |
|
24 |
SRC=/root/src/crossfire |
25 |
PATH="$SRC:$PATH" |
26 |
BASE="/var/www/cfmaps.schmorp.de" |
27 |
export CROSSFIRE_LIBDIR="$BASE"/lib |
28 |
|
29 |
cd "$BASE" || exit 69 |
30 |
|
31 |
cvs -Q -z3 update -AdP | grep -v ^\\? |
32 |
|
33 |
rm -f .cfmap2html |
34 |
|
35 |
chmod 644 "$SRC"/*.css |
36 |
cp "$SRC"/*.css . |
37 |
chmod 755 "$SRC"/cfmapidx |
38 |
cp "$SRC"/cfmapidx . |
39 |
|
40 |
find . "(" -name CVS -o -path ./a ")" -prune -o -type d -printf "%P/\n" | while read dir; do |
41 |
( |
42 |
export dir |
43 |
cd "./$dir" || exit 68 |
44 |
{ |
45 |
cat >&7 <<-EOF |
46 |
<?xml version='1.0' encoding='utf-8'?> |
47 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
48 |
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'> |
49 |
<head> |
50 |
<title>Crossfire Maps Directory "$dir"</title> |
51 |
<link rel='stylesheet' type='text/css' media='all' href='/common.css'/> |
52 |
</head> |
53 |
<body> |
54 |
<p>Keyword Search Over All Maps</p> |
55 |
<p><form action='/search'> |
56 |
<input type='text' name='k'/> |
57 |
<input type='submit'/> |
58 |
</form></p> |
59 |
<h1>Crossfire Maps Directory "$dir"</h1><ul> |
60 |
<li><a href='..'><parent></a></li></ul><h2>This Directory</h2><ul> |
61 |
EOF |
62 |
for file in *; do |
63 |
if [ -f "$file" ]; then |
64 |
case "$file" in |
65 |
cfmapidx | *.pst | *.jpg | *.png | *.html | *.html.gz | *.xhtml | *.xhtml.gz | *.css | *~ ) |
66 |
;; |
67 |
* ) |
68 |
if head -5 "$file" | grep -q "^arch map"; then |
69 |
echo >&7 "<li><a href='$file.xhtml'>$file</a> [map]</li>" |
70 |
DIR="${dir#/}" |
71 |
echo "$DIR$file" >>$BASE/.cfmap2html |
72 |
else |
73 |
echo >&7 "<li><a href='$file'>$file</a> [file]</li>" |
74 |
fi |
75 |
;; |
76 |
esac |
77 |
elif [ -d "$file" ]; then |
78 |
case "$file" in |
79 |
CVS ) |
80 |
;; |
81 |
* ) |
82 |
echo >&7 "<li><a href='$file/'>$file/</a> [dir]</li>" |
83 |
;; |
84 |
esac |
85 |
fi |
86 |
done |
87 |
echo >&7 "</ul>" |
88 |
cat >&7 <<-EOF |
89 |
<h2>Bookmarks</h2> |
90 |
<ul> |
91 |
<li><a href="/world/">Worldmap</a></li> |
92 |
<li><a href="/world/world_105_115.xhtml">Scorn</a></li> |
93 |
<li><a href="/world/world_102_108.xhtml">Santo Dominion</a></li> |
94 |
<li><a href="/world/world_107_123.xhtml">Brest</a></li> |
95 |
<li><a href="/world/world_109_126.xhtml">Lake Country</a></li> |
96 |
<li><a href="/world/world_122_117.xhtml">Navar</a></li> |
97 |
<li><a href="/world/world_116_102.xhtml">Darcap</a></li> |
98 |
<li><a href="/world/world_128_109.xhtml">Wolfsburg</a></li> |
99 |
<li><a href="/world/world_128_101.xhtml">Azumauindo</a></li> |
100 |
</ul> |
101 |
<p class="footer">created by <a href='http://software.schmorp.de/#crossfire'>cfupdate</a> version $VERSION</p> |
102 |
EOF |
103 |
echo >&7 "</body></html>" |
104 |
} 7>index.xhtml |
105 |
#gzip -7f index.xhtml |
106 |
) |
107 |
done |
108 |
|
109 |
<.cfmap2html xargs cfmap2html |
110 |
<.cfmap2html xargs cfmapidx -a |
111 |
cfmapidx -c |
112 |
mv .index.dat~ .index.dat |
113 |
|
114 |
#rm -f .cfmap2html |
115 |
|
116 |
cfarch2html |
117 |
cfworldmap |
118 |
|
119 |
chown -R root.root . |
120 |
chmod -R u=rwX,go=rX . |
121 |
|