OSDN Git Service

tDiary demonstration generator: generates many [theme].php
[pukiwiki/pukiwiki_devel.git] / tdiary-demogen.sh
1 #!/bin/sh
2 # $Id: tdiary-demogen.sh,v 1.1 2005/01/09 04:07:04 henoheno Exp $
3 #
4 # tDiary demonstrator generator
5 # License: GPL
6
7 usage(){
8   base="`basename $0`";
9   echo "  $base [-d path/to/theme-directory] list"
10   echo "  $base [-d path/to/theme-directory] interwiki [URI]"
11   echo "  $base [-d path/to/theme-directory] touch"
12   echo "    Command:"
13   echo "      lis|listt     - List theme"
14   echo "      int|interwiki - Publish interwiki definition and setting for each theme"
15   echo "      tou|touch     - Generate \$theme.php that includes index.php"
16 }
17
18 theme_list(){
19   cd "$dir" || echo "Error: directory '$dir' not found";
20   ls -1 | while read theme; do
21     test -f "$theme/$theme.css" && echo "$theme"
22   done
23 }
24
25 # ---- Argument check ----
26 dir="skin/theme"
27 if [ "x-d" = "x$1" ] ; then
28   dir="$2"
29   shift 2
30 fi
31 cmd="$1"
32
33 # ----
34
35 case "$cmd" in
36 ''|-h|hel|help ) usage ;;
37 lis|list       ) theme_list ;;
38
39 int|inte|inter|interw|interwi|interwik|interwiki)
40   echo '--------'
41   echo '- [./$1.php theme] raw tDiary theme selector'
42   echo '--------'
43   theme_list | while read theme; do
44     echo "[[theme:$theme]]"
45   done
46   ;;
47
48 tou|touc|touch )
49   theme_list | while read theme; do
50     if [ -f "$theme.php" ]
51     then echo "Warning: '$theme.php' is already available. Ignoreing..."
52     else
53       cat <<EOF  > "$theme.php"
54 <?php
55         define('TDIARY_THEME', '$theme');
56         require('./index.php')
57 ?>
58 EOF
59     fi
60   done
61   ;;
62 esac
63