tinycm view plugins/dashboard/dashboard.cgi @ rev 81

Improve dashboard plugin (more to come)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 11 14:33:17 2017 +0100 (2017-02-11)
parents 854c4a8f0972
children 4418f0315c8e
line source
1 #!/bin/sh
2 #
3 # TinyCM Plugin - Users and admin Dashboard.
4 #
6 if [ "$(GET dashboard)" ]; then
7 d="Dashboard"
8 header
9 html_header
10 user_box
11 users=$(ls -1 $PEOPLE | wc -l)
12 docs=$(find $wiki -type f | wc -l)
13 wikisize="$(du -sh $wiki | awk '{print $1}')"
14 cachesize="$(du -sh $cache | awk '{print $1}')"
15 [ "$HG" != "yes" ] && hg=$(gettext "disabled")
16 [ "$HG" == "yes" ] && hg=$(gettext "enabled")
17 # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS
18 ADMIN_TOOLS=""
19 DASHBOARD_TOOLS=""
20 for p in $(ls $plugins)
21 do
22 . $plugins/$p/$p.conf
23 done
24 if check_auth && ! admin_user; then
25 ADMIN_TOOLS=""
26 fi
27 if check_auth; then
28 cat << EOT
29 <div id="tools">
30 <a href='$script?log'>Activity log</a>
31 <a href='$script?ls'>Pages list</a>
32 $DASHBOARD_TOOLS
33 $ADMIN_TOOLS
34 </div>
36 <h2>$d</h2>
38 <pre>
39 Wiki docs : $docs ($wikisize)
40 Cache size : $cachesize
41 Mercurial : $hg
42 User accounts : $users
43 Server uptime : $(uptime | cut -d " " -f 4 | sed s"/:/h /" | sed s"/,/min/")
44 </pre>
46 <h3>Admin users</h3>
47 EOT
48 # Get the list of administrators
49 fgrep -l "ADMIN_USER=" $PEOPLE/*/account.conf | while read file;
50 do
51 . ${file}
52 echo "<a href='?user=$USER'>$USER</a>"
53 unset NAME USER
54 done
56 # Only for admins
57 if check_auth && admin_user; then
58 # List all plugins
59 cat << EOT
60 <h3>$(gettext "Plugins")</h3>
61 <table>
62 <thead>
63 <td>$(gettext "Name")</td>
64 <td>$(gettext "Description")</td>
65 <td>$(gettext "Action")</td>
66 </thead>
67 EOT
68 for p in $(ls -1 $plugins)
69 do
70 . $plugins/$p/$p.conf
71 cat << EOT
72 <tr>
73 <td><a href='?$p'>$PLUGIN</a></td>
74 <td>$SHORT_DESC</td>
75 <td>remove</td>
76 </tr>
77 EOT
78 done
79 echo "</table>"
80 fi
81 else
82 gettext "You must be logged in to view the dashboard."
83 fi
84 html_footer && exit 0
85 fi