tazbug rev 49
Add a small dashboard plugin and misc fixes
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jan 05 00:01:34 2014 +0100 (2014-01-05) |
parents | a8652095c93f |
children | 02a11d8d636e |
files | web/bugs.cgi web/plugins/dashboard/dashboard.cgi web/plugins/dashboard/dashboard.conf web/plugins/skel/skel.conf |
line diff
1.1 --- a/web/bugs.cgi Sat Jan 04 21:46:07 2014 +0100 1.2 +++ b/web/bugs.cgi Sun Jan 05 00:01:34 2014 +0100 1.3 @@ -116,14 +116,18 @@ 1.4 fi 1.5 } 1.6 1.7 +# Check if user is admin 1.8 +admin_user() { 1.9 + fgrep -q 'ADMIN_USER="yes"' ${PEOPLE}/${user}/account.conf 1.10 +} 1.11 1.12 # Authentified or not 1.13 user_box() { 1.14 - 1.15 -IDLOC="" 1.16 -if [[ "$(GET id)" ]] ;then 1.17 - IDLOC="&id=$(GET id)" 1.18 -fi 1.19 + 1.20 + IDLOC="" 1.21 + if [[ "$(GET id)" ]] ;then 1.22 + IDLOC="&id=$(GET id)" 1.23 + fi 1.24 1.25 if check_auth; then 1.26 . $PEOPLE/$user/account.conf 1.27 @@ -188,11 +192,11 @@ 1.28 1.29 # Login page 1.30 login_page() { 1.31 -IDLOC="" 1.32 -if [[ "$(GET id)" ]] ;then 1.33 - IDLOC="?id=$(GET id)" 1.34 -fi 1.35 - 1.36 + 1.37 + IDLOC="" 1.38 + if [[ "$(GET id)" ]] ;then 1.39 + IDLOC="?id=$(GET id)" 1.40 + fi 1.41 cat << EOT 1.42 <h2>$(gettext 'Login')</h2> 1.43 1.44 @@ -205,7 +209,7 @@ 1.45 </div> 1.46 1.47 <div id="login"> 1.48 - <form method="post" action="$SCRIPT_NAME"> 1.49 + <form method="post" action="$script"> 1.50 <input type="text" name="auth" placeholder="$(gettext 'User name')" /> 1.51 <input type="password" name="pass" placeholder="$(gettext 'Password')" /> 1.52 <div> 1.53 @@ -262,7 +266,6 @@ 1.54 done 1.55 } 1.56 1.57 - 1.58 # Stripped down Wiki parser for bug desc and messages which are simply 1.59 # displayed in <pre> 1.60 wiki_parser() { 1.61 @@ -272,7 +275,6 @@ 1.62 -e 's#\\\\n#\n#g;s#%22#"#g;s#%21#!#g' 1.63 } 1.64 1.65 - 1.66 # Bug page 1.67 bug_page() { 1.68 if [ -f "$PEOPLE/$CREATOR/account.conf" ]; then 1.69 @@ -348,7 +350,6 @@ 1.70 fi 1.71 } 1.72 1.73 - 1.74 # Write a new message 1.75 new_msg() { 1.76 date=$(date "+%Y-%m-%d %H:%M") 1.77 @@ -365,7 +366,6 @@ 1.78 EOT 1.79 } 1.80 1.81 - 1.82 # Create a new Bug 1.83 new_bug() { 1.84 count=$(ls -1 $bugdir | wc -l) 1.85 @@ -391,7 +391,6 @@ 1.86 EOT 1.87 } 1.88 1.89 - 1.90 # New bug page for the web interface 1.91 new_bug_page() { 1.92 cat << EOT 1.93 @@ -486,7 +485,6 @@ 1.94 echo "<img src=\"$url/$md5?d=identicon&s=$size\" alt=\"\" />" 1.95 } 1.96 1.97 - 1.98 # Create a new user in AUTH_FILE and PEOPLE 1.99 new_user_config() { 1.100 if [ ! "$online" ]; then 1.101 @@ -572,11 +570,19 @@ 1.102 header 1.103 html_header 1.104 user_box 1.105 - echo "<h2>gettext "User already exists: $user"</h2>" 1.106 + echo "<h2>$(gettext "User already exists:") $user</h2>" 1.107 html_footer && exit 0 1.108 fi ;; 1.109 esac 1.110 1.111 +# 1.112 +# Plugins Now! 1.113 +# 1.114 +for p in $(ls -1 $plugins) 1.115 +do 1.116 + [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf 1.117 + [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi 1.118 +done 1.119 1.120 ######################################################################## 1.121 # GET actions # 1.122 @@ -788,8 +794,8 @@ 1.123 <div class="pct" style="width: ${pct}%;">${pct}%</div> 1.124 </div> 1.125 1.126 -<p>$(gettext "Please read the <a href=\"?README\">README</a> for help and more \ 1.127 -information. You may also be interested by the SliTaz \ 1.128 +<p>$(gettext "Please read the <a href=\"?README\">README</a> for help and \ 1.129 +more information. You may also be interested by the SliTaz \ 1.130 <a href=\"http://roadmap.slitaz.org/\">Roadmap</a> and the packages \ 1.131 <a href=\"http://cook.slitaz.org/\">Cooker</a>. To perform a search \ 1.132 enter your term and press ENTER.") 1.133 @@ -800,6 +806,7 @@ 1.134 EOT 1.135 if check_auth; then 1.136 echo "<a href='?newbug'>$(gettext 'Create a new bug')</a>" 1.137 + echo "$PLUGINS_TOOLS" 1.138 fi 1.139 cat << EOT 1.140 </div> 1.141 @@ -808,16 +815,4 @@ 1.142 html_footer ;; 1.143 esac 1.144 1.145 - 1.146 -######################################################################## 1.147 -# Plugins # 1.148 -######################################################################## 1.149 - 1.150 -for p in $(ls -1 $plugins) 1.151 -do 1.152 - [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf 1.153 - [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi 1.154 -done 1.155 - 1.156 - 1.157 exit 0
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/web/plugins/dashboard/dashboard.cgi Sun Jan 05 00:01:34 2014 +0100 2.3 @@ -0,0 +1,80 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# TinyCM/TazBug Plugin - Dashboard 2.7 +# 2.8 +. /usr/lib/slitaz/httphelper 2.9 + 2.10 +case " $(GET) " in 2.11 + *\ users\ *) 2.12 + d="Dashboard" 2.13 + header 2.14 + html_header 2.15 + user_box 2.16 + if ! admin_user; then 2.17 + gettext "You must be admin in to manage users." 2.18 + exit 0 2.19 + fi 2.20 + users=$(ls -1 $PEOPLE | wc -l) 2.21 + cat << EOT 2.22 +<h2>Users: $users</h2> 2.23 +<pre> 2.24 +EOT 2.25 + for u in $(ls $PEOPLE) 2.26 + do 2.27 + #. ${PEOPLE}/${u}/account.conf 2.28 + . "${PEOPLE}/${u}/account.conf" 2.29 + cat << EOT 2.30 +<img src="images/avatar.png" /> <a href="?user=$USER">$USER</a> | $NAME 2.31 +EOT 2.32 +# deluser link 2.33 +#: <a href="?users&deluser=$USER">$(gettext "delete")</a> 2.34 + unset NAME USER 2.35 + done 2.36 + echo "</pre>" && exit 0 ;; 2.37 + 2.38 + *\ dashboard\ *) 2.39 + d="Dashboard" 2.40 + header 2.41 + html_header 2.42 + user_box 2.43 + if ! check_auth; then 2.44 + gettext "You must be logged in to view the dashboard." 2.45 + exit 0 2.46 + fi 2.47 + if admin_user; then 2.48 + admintools="<a href='?users'>Users</a>" 2.49 + fi 2.50 + users=$(ls -1 $PEOPLE | wc -l) 2.51 + bugsize=$(du -sh $bugdir | awk '{print $1}') 2.52 + cat << EOT 2.53 +<h2>Dashboard</h2> 2.54 +<pre> 2.55 +Users : $users 2.56 +Bugsize : $bugsize 2.57 +</pre> 2.58 +<div id="tools"> 2.59 +$admintools 2.60 +</div> 2.61 +<h3>Admin users</h3> 2.62 +EOT 2.63 + # Get the list of administrators 2.64 + for u in $(ls $PEOPLE) 2.65 + do 2.66 + user=${u} 2.67 + if admin_user; then 2.68 + echo "<a href='?user=$u'>$u</a>" 2.69 + fi 2.70 + done 2.71 + cat << EOT 2.72 +<h3>$(gettext "Plugins")</h3> 2.73 +<pre> 2.74 +EOT 2.75 + for p in $(ls -1 $plugins) 2.76 + do 2.77 + . $plugins/$p/$p.conf 2.78 + echo "<a href='?$p'>$PLUGIN</a> - $SHORT_DESC" 2.79 + done 2.80 + echo '</pre>' 2.81 + html_footer 2.82 + exit 0 ;; 2.83 +esac
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/web/plugins/dashboard/dashboard.conf Sun Jan 05 00:01:34 2014 +0100 3.3 @@ -0,0 +1,8 @@ 3.4 +# TinycM/TazBug Plugin configuration 3.5 + 3.6 +PLUGIN="TazBug Dashboard" 3.7 +SHORT_DESC="Light TazBug Dashboard" 3.8 +MAINTAINER="devel@slitaz.org" 3.9 +PLUGINS_TOOLS="<a href='?dashboard'>Dashboard</a> ${PLUGINS_TOOLS}" 3.10 + 3.11 +# Configurable variables used in plugin.cgi
4.1 --- a/web/plugins/skel/skel.conf Sat Jan 04 21:46:07 2014 +0100 4.2 +++ b/web/plugins/skel/skel.conf Sun Jan 05 00:01:34 2014 +0100 4.3 @@ -1,7 +1,8 @@ 4.4 -# TinyCM Plugin configuration 4.5 +# TinyCM/TazBug Plugin configuration 4.6 4.7 PLUGIN="Plugin Skeleton" 4.8 -SHORT_DESC="An example plugin for TinyCM" 4.9 +SHORT_DESC="An example plugin for TinyCM/TazBug" 4.10 MAINTAINER="devel@slitaz.org" 4.11 +PLUGINS_TOOLS="${PLUGINS_TOOLS}" 4.12 4.13 # Configurable variables used in plugin.cgi