2 # $Id: tdiary-demogen.sh,v 1.7 2005/01/25 12:47:11 henoheno Exp $
4 # tDiary demonstration generator: generates many [theme].php
7 warn(){ echo "$*" 1>&2; }
8 err(){ warn "$*"; exit 1; }
12 warn " $base [-d path/to/theme-directory] list"
13 warn " $base [-d path/to/theme-directory] interwiki"
14 warn " $base [-d path/to/theme-directory] touch"
15 warn " $base [-d path/to/theme-directory] untouch"
17 warn " lis|list - List themes"
18 warn " int|interwiki - Publish interwiki definition and setting for each theme"
19 warn " tou|touch - Generate \$theme.php that includes index.php"
20 warn " unt|untouch - Remove \$theme.php(s) listed in theme directory"
25 cd "$dir" || err "Error: directory '$dir' not found"
26 ls -1 | while read theme; do
27 test -f "$theme/$theme.css" && echo "$theme"
31 # ---- Argument check ----
33 if [ "x-d" = "x$1" ] ; then
42 ''|-h|hel|help ) usage ;;
43 lis|list ) theme_list ;;
45 int|inte|inter|interw|interwi|interwik|interwiki)
47 echo '- [./$1.php theme] raw tDiary theme selector'
49 echo '- (s) = sidebar CSS exists in this theme'
50 theme_list | while read theme; do
51 echo -n "+ [[theme:$theme]]"
52 grep -q div.sidebar "$dir/$theme/$theme.css" && echo -n " (s)"
58 theme_list | while read theme; do
59 if [ -f "$theme.php" ]
60 then echo "Warning: '$theme.php' is already available. Ignoreing..."
62 cat <<EOF > "$theme.php"
64 define('TDIARY_THEME', '$theme');
65 require('./index.php')
72 unt|unto|untou|untouc|untouch )
73 echo -n " Remove theme(s).php ? [y/N]: "
77 theme_list | while read theme ; do
78 test -f "$theme.php" && grep -q "define('TDIARY_THEME', '$theme');" "$theme.php" && rm -f "$theme.php"