tazbug view web/plugins/textmode/textmode.cgi @ rev 126

Add textmode plugin, rewrite tazbug cmdline tool
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 21 03:44:35 2017 +0100 (2017-02-21)
parents
children 7bf28563c0f6
line source
1 #!/bin/sh
2 #
3 # TazBug Plugin - Textmode will output plain data to be used by remote client
4 #
6 if [ "$(GET textmode)" ]; then
7 header "Content-type: text/plain; charset=UTF-8"
9 separator() {
10 echo "-------------------------------------------------------------------------------"
11 }
13 case " $(GET) " in
15 *\ stats\ *)
16 echo "Bugs count : $(ls $bugdir | wc -l)"
17 echo "Database size : $(du -sh $bugdir | awk '{print $1}')" ;;
19 *\ search\ *)
20 for bug in $(ls $bugdir)
21 do
22 result=$(fgrep -i -h "$(GET search)" $bugdir/$bug/*)
23 if [ "$result" ]; then
24 found=$(($found + 1))
25 . ${bugdir}/${bug}/bug.conf
26 echo "Bug: $bug - $BUG"
27 fi
28 done
29 if [ "$found" == "" ]; then
30 echo "No result found for: $(GET search)"
31 else
32 separator && echo "$found result(s) found"
33 fi ;;
35 *\ id\ *)
36 # Show bug information and description
37 id=$(GET id)
38 if [ -f "$bugdir/$id/bug.conf" ]; then
39 . ${bugdir}/${id}/bug.conf
40 cat << EOT
41 Bug : $id - $STATUS - $PRIORITY
42 Title : $BUG
43 Info : $DATE - Creator: $CREATOR
44 $(separator)
45 $(cat $bugdir/$id/desc.txt)
46 EOT
47 else
48 echo "Can't found bug ID: $id" && exit 0
49 fi ;;
51 *)
52 cat << EOT
53 Tazbug Textmode plugin
54 $(separator)
55 $(date)
57 Functions:
58 &stats Display bug tracker stats
59 &search= Search for bugs by pattern
60 &id= Show bug info and description
61 EOT
62 ;;
63 esac
64 exit 0
65 fi