-
Notifications
You must be signed in to change notification settings - Fork 1
/
tdiary-demogen.sh
86 lines (76 loc) · 2.05 KB
/
tdiary-demogen.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
#!/bin/sh
# $Id: tdiary-demogen.sh,v 1.7 2005/01/25 12:47:11 henoheno Exp $
#
# tDiary demonstration generator: generates many [theme].php
# License: GPL
warn(){ echo "$*" 1>&2; }
err(){ warn "$*"; exit 1; }
usage(){
base="`basename $0`";
warn " $base [-d path/to/theme-directory] list"
warn " $base [-d path/to/theme-directory] interwiki"
warn " $base [-d path/to/theme-directory] touch"
warn " $base [-d path/to/theme-directory] untouch"
warn " Command:"
warn " lis|list - List themes"
warn " int|interwiki - Publish interwiki definition and setting for each theme"
warn " tou|touch - Generate \$theme.php that includes index.php"
warn " unt|untouch - Remove \$theme.php(s) listed in theme directory"
exit 1
}
theme_list(){
cd "$dir" || err "Error: directory '$dir' not found"
ls -1 | while read theme; do
test -f "$theme/$theme.css" && echo "$theme"
done
}
# ---- Argument check ----
dir="skin/theme"
if [ "x-d" = "x$1" ] ; then
dir="$2"
shift 2
fi
cmd="$1"
# ----
case "$cmd" in
''|-h|hel|help ) usage ;;
lis|list ) theme_list ;;
int|inte|inter|interw|interwi|interwik|interwiki)
echo '--------'
echo '- [./$1.php theme] raw tDiary theme selector'
echo '--------'
echo '- (s) = sidebar CSS exists in this theme'
theme_list | while read theme; do
echo -n "+ [[theme:$theme]]"
grep -q div.sidebar "$dir/$theme/$theme.css" && echo -n " (s)"
echo
done
;;
tou|touc|touch )
theme_list | while read theme; do
if [ -f "$theme.php" ]
then echo "Warning: '$theme.php' is already available. Ignoreing..."
else
cat <<EOF > "$theme.php"
<?php
define('TDIARY_THEME', '$theme');
require('./index.php')
?>
EOF
fi
done
;;
unt|unto|untou|untouc|untouch )
echo -n " Remove theme(s).php ? [y/N]: "
read answer
case "$answer" in
[yY] | [yY][eE][sS] )
theme_list | while read theme ; do
test -f "$theme.php" && grep -q "define('TDIARY_THEME', '$theme');" "$theme.php" && rm -f "$theme.php"
done
;;
* )
echo " Stopped."
esac
;;
esac