tazpanel rev 110
Move to settings.cgi and improve Panel configuration
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Apr 15 10:15:40 2011 +0200 (2011-04-15) |
parents | b898c9887a62 |
children | 11d6b2b61036 |
files | index.cgi lib/libtazpanel settings.cgi styles/default/style.css |
line diff
1.1 --- a/index.cgi Fri Apr 15 09:14:23 2011 +0200 1.2 +++ b/index.cgi Fri Apr 15 10:15:40 2011 +0200 1.3 @@ -143,19 +143,6 @@ 1.4 $(cat $LOG_FILE | tail -n 6) 1.5 </pre> 1.6 1.7 -<h3>`gettext "Panel settings"`</h3> 1.8 -<form method="get" action="$SCRIPT_NAME"> 1.9 - <div> 1.10 - `gettext "Panel password:"` 1.11 - <input type="password" name="panel_pass"/> 1.12 - <input type="submit" value="`gettext "Change"`" /> 1.13 - </div> 1.14 -</form> 1.15 -<p> 1.16 - $(gettext "TazPanel provides a debuging mode and page:") 1.17 - <a href='$SCRIPT_NAME?debug'>debug</a> 1.18 -</p> 1.19 - 1.20 EOT 1.21 ;; 1.22 esac
2.1 --- a/lib/libtazpanel Fri Apr 15 09:14:23 2011 +0200 2.2 +++ b/lib/libtazpanel Fri Apr 15 10:15:40 2011 +0200 2.3 @@ -14,9 +14,9 @@ 2.4 # We need a config file first 2.5 get_config() { 2.6 CONFIG="/etc/slitaz/tazpanel.conf" 2.7 - [ -f $CONFIG ] && . $CONFIG 2.8 - [ -f tazpanel.conf ] && . tazpanel.conf 2.9 - [ ! -f $PANEL/lib/libtazpanel ] && \ 2.10 + [ -f tazpanel.conf ] && CONFIG="tazpanel.conf" 2.11 + [ -f "$CONFIG" ] && . $CONFIG 2.12 + [ ! -f "$PANEL/lib/libtazpanel" ] && \ 2.13 echo "No config file or libtazpanel found: $CONFIG" && \ 2.14 exit 1 2.15 }
3.1 --- a/settings.cgi Fri Apr 15 09:14:23 2011 +0200 3.2 +++ b/settings.cgi Fri Apr 15 10:15:40 2011 +0200 3.3 @@ -23,6 +23,15 @@ 3.4 done 3.5 } 3.6 3.7 +# Get the list of panle styles 3.8 +list_styles() { 3.9 + cd $PANEL/styles 3.10 + for style in * 3.11 + do 3.12 + echo "<option value='$style'>$style</option>" 3.13 + done 3.14 +} 3.15 + 3.16 # 3.17 # Commands executed before page loading. 3.18 # 3.19 @@ -32,9 +41,9 @@ 3.20 # 3.21 # Manage system user accounts 3.22 # 3.23 - for i in $(seq 1 $(GET deluser count)); do 3.24 - deluser $(GET deluser $i) 3.25 - done 3.26 + if [ "$(GET deluser)" ]; then 3.27 + deluser $(GET deluser) 3.28 + fi 3.29 user=$(GET adduser) 3.30 if [ -n "$user" ]; then 3.31 adduser -D $user 3.32 @@ -50,8 +59,11 @@ 3.33 rdate -s tick.greyware.com ;; 3.34 *\ hwclock\ *) 3.35 hwclock -w ;; 3.36 - *) 3.37 - continue ;; 3.38 + *\ panel_pass*) 3.39 + sed -i s@/:root:.*@/:root:$(GET panel_pass)@ $HTTPD_CONF ;; 3.40 + *\ style*) 3.41 + sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG 3.42 + . $CONFIG ;; 3.43 esac 3.44 3.45 # 3.46 @@ -59,61 +71,48 @@ 3.47 # 3.48 xhtml_header 3.49 3.50 -cat << EOT 3.51 -<div id="wrapper"> 3.52 - <h2>`gettext "System settings"`</h2> 3.53 - <p>`gettext "Manage system time, users or language settings"`<p> 3.54 -</div> 3.55 - 3.56 -<pre> 3.57 -`gettext "Time zome :"` `cat /etc/TZ` 3.58 -`gettext "System time :"` `date` 3.59 -`gettext "Hardware clock :"` `hwclock -r` 3.60 -</pre> 3.61 -<a class="button" href="$SCRIPT_NAME?rdate">`gettext "Sync online"`</a> 3.62 -<a class="button" href="$SCRIPT_NAME?hwclock">`gettext "Set hardware clock"`</a> 3.63 +case " $(GET) " in 3.64 + *\ user*) 3.65 + # 3.66 + # Users management 3.67 + # 3.68 + cat <<EOT 3.69 +<h3>`gettext "Manage users"`</h3> 3.70 +<form method="get" action="$SCRIPT_NAME"> 3.71 +$(table_start) 3.72 +<thead> 3.73 + <tr> 3.74 + <td>`gettext "Login"`</td> 3.75 + <td>`gettext "User ID"`</td> 3.76 + <td>`gettext "Name"`</td> 3.77 + <td>`gettext "Home"`</td> 3.78 + <td>`gettext "SHell"`</td> 3.79 + </tr> 3.80 +</thead> 3.81 EOT 3.82 -# 3.83 -# Users management 3.84 -# 3.85 - 3.86 -cat <<EOT 3.87 -<h3>`gettext "Users"`</h3> 3.88 -<form method="get" action="$SCRIPT_NAME"> 3.89 -EOT 3.90 -table_start 3.91 -cat << EOT 3.92 -<tr class="thead"> 3.93 - <td>`gettext "Login"`</td> 3.94 - <td>`gettext "User ID"`</td> 3.95 - <td>`gettext "Name"`</td> 3.96 - <td>`gettext "Home"`</td> 3.97 - <td>`gettext "SHell"`</td> 3.98 -</tr> 3.99 -EOT 3.100 -for i in `cat /etc/passwd | cut -d ":" -f 1` 3.101 -do 3.102 - if [ -d /home/$i ]; then 3.103 - login=$i 3.104 - uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3` 3.105 - gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4` 3.106 - name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | \ 3.107 - sed s/,,,//` 3.108 - home=`cat /etc/passwd | grep $i | cut -d ":" -f 6` 3.109 - shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7` 3.110 - echo '<tr>' 3.111 - echo "<td><input type='hidden' name='user' /> 3.112 - <input type='checkbox' name='deluser' value='$login' /> 3.113 - <img src='$IMAGES/user.png' />$login</td>" 3.114 - echo "<td>$uid:$gid</td>" 3.115 - echo "<td>$name</td>" 3.116 - echo "<td>$home</td>" 3.117 - echo "<td>$shell</td>" 3.118 - echo '</tr>' 3.119 - fi 3.120 -done 3.121 -table_end 3.122 -cat << EOT 3.123 + for i in `cat /etc/passwd | cut -d ":" -f 1` 3.124 + do 3.125 + if [ -d /home/$i ]; then 3.126 + login=$i 3.127 + uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3` 3.128 + gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4` 3.129 + name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | \ 3.130 + sed s/,,,//` 3.131 + home=`cat /etc/passwd | grep $i | cut -d ":" -f 6` 3.132 + shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7` 3.133 + echo '<tr>' 3.134 + echo "<td><input type='hidden' name='user' /> 3.135 + <input type='checkbox' name='deluser' value='$login' /> 3.136 + <img src='$IMAGES/user.png' />$login</td>" 3.137 + echo "<td>$uid:$gid</td>" 3.138 + echo "<td>$name</td>" 3.139 + echo "<td>$home</td>" 3.140 + echo "<td>$shell</td>" 3.141 + echo '</tr>' 3.142 + fi 3.143 + done 3.144 + table_end 3.145 + cat << EOT 3.146 <div> 3.147 <input type="submit" value="`gettext "Delete selected user"`" /> 3.148 </div> 3.149 @@ -129,11 +128,34 @@ 3.150 <input type="submit" value="`gettext "Create user"`" /> 3.151 </form> 3.152 EOT 3.153 + ;; 3.154 + *) 3.155 + # 3.156 + # Defaut system settings page 3.157 + # 3.158 + cat << EOT 3.159 +<div id="wrapper"> 3.160 + <h2>$(gettext "System settings")</h2> 3.161 + <p>$(gettext "Manage system time, users or language settings")<p> 3.162 +</div> 3.163 +<div id="actions"> 3.164 + <a class="button" href="$SCRIPT_NAME?users"> 3.165 + <img src="$IMAGES/users.png" />$(gettext "Manage users")</a> 3.166 +</div> 3.167 3.168 -# 3.169 -# Locale settings 3.170 -# 3.171 -cat << EOT 3.172 +<h3>`gettext "System time"`</h3> 3.173 +<pre> 3.174 +`gettext "Time zome :"` `cat /etc/TZ` 3.175 +`gettext "System time :"` `date` 3.176 +`gettext "Hardware clock :"` `hwclock -r` 3.177 +</pre> 3.178 +<a class="button" href="$SCRIPT_NAME?rdate">`gettext "Sync online"`</a> 3.179 +<a class="button" href="$SCRIPT_NAME?hwclock">`gettext "Set hardware clock"`</a> 3.180 +EOT 3.181 + # 3.182 + # Locale settings 3.183 + # 3.184 + cat << EOT 3.185 <a name="locale"></a> 3.186 <h3>`gettext "System language"`</h3> 3.187 <p> 3.188 @@ -149,20 +171,51 @@ 3.189 eval_gettext "You must logout and login again to your current 3.190 session to use \$new_locale locale." 3.191 else 3.192 - eval_gettext "Current system locales: " 3.193 + gettext "Current system locales: " 3.194 locale -a 3.195 fi 3.196 cat << EOT 3.197 </p> 3.198 <form method="get" action="$SCRIPT_NAME"> 3.199 - `gettext "Available locales:"` 3.200 + $(gettext "Available locales:") 3.201 <select name="gen_locale"> 3.202 <option value="en_US">en_US</options> 3.203 - `list_locales` 3.204 + $(list_locales) 3.205 </select> 3.206 - <input type="submit" value="`gettext "Select"`" /> 3.207 + <input type="submit" value="$(gettext "Activate")" /> 3.208 </form> 3.209 + 3.210 +<h3>$(gettext "Panel configuration")</h3> 3.211 +<form method="get" action="$SCRIPT_NAME"> 3.212 + <p> 3.213 + $(gettext "Style:") 3.214 + <select name="style"> 3.215 + $(list_styles) 3.216 + </select> 3.217 + <input type="submit" value="$(gettext "Activate")" /> 3.218 + </p> 3.219 +</form> 3.220 +<form method="get" action="$SCRIPT_NAME"> 3.221 + <p> 3.222 + $(gettext "Panel password:") 3.223 + <input type="password" name="panel_pass"/> 3.224 + <input type="submit" value="$(gettext "Change")" /> 3.225 + </p> 3.226 +</form> 3.227 +<p> 3.228 + $(gettext "Configuration files: ") 3.229 + <a class="button" href="index.cgi?file=$CONFIG"> 3.230 + <img src="$IMAGES/edit.png" />$(gettext "Panel")</a> 3.231 + <a class="button" href="index.cgi?file=$HTTPD_CONF"> 3.232 + <img src="$IMAGES/edit.png" />$(gettext "Server")</a> 3.233 +</p> 3.234 +<p> 3.235 + $(gettext "TazPanel provides a debuging mode and page:") 3.236 + <a href='/index.cgi?debug'>debug</a> 3.237 +</p> 3.238 EOT 3.239 + ;; 3.240 +esac 3.241 3.242 xhtml_footer 3.243 exit 0
4.1 --- a/styles/default/style.css Fri Apr 15 09:14:23 2011 +0200 4.2 +++ b/styles/default/style.css Fri Apr 15 10:15:40 2011 +0200 4.3 @@ -19,7 +19,7 @@ 4.4 h3 { color: #666; font-size: 140%; } 4.5 h4 { color: #888; font-size: 120%; margin: 10px 0 5px; } 4.6 img { border: 0pt none; vertical-align: middle; padding: 0px 6px 2px 0;} 4.7 -p { margin: 6px 0; } 4.8 +p { margin: 10px 0; } 4.9 ul { list-style-type: square; } 4.10 li { padding: 4px 0; } 4.11 a { text-decoration: none; color: #666; }