OSDN Git Service

Show sidebar-enabled or not
[pukiwiki/pukiwiki_devel.git] / tdiary-demogen.sh
1 #!/bin/sh
2 # $Id: tdiary-demogen.sh,v 1.5 2005/01/15 14:54:46 henoheno Exp $
3 #
4 # tDiary demonstration generator: generates many [theme].php
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"
11   echo "  $base [-d path/to/theme-directory] touch"
12   echo "    Command:"
13   echo "      lis|list      - List themes"
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 -n "+ [[theme:$theme]]"
45     grep -q div.sidebar "$dir/$theme/$theme.css" && echo -n " (sidebar)"
46     echo
47   done
48   ;;
49
50 tou|touc|touch )
51   theme_list | while read theme; do
52     if [ -f "$theme.php" ]
53     then echo "Warning: '$theme.php' is already available. Ignoreing..."
54     else
55       cat <<EOF  > "$theme.php"
56 <?php
57         define('TDIARY_THEME', '$theme');
58         require('./index.php')
59 ?>
60 EOF
61     fi
62   done
63   ;;
64 esac
65