tazbug annotate web/plugins/textmode/textmode.cgi @ rev 138
Last fixes and improvemnt before using new tazbug storage on Tank
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 22 15:43:58 2017 +0100 (2017-02-22) |
parents | f07cd117feed |
children | 8fcbcf75a882 |
rev | line source |
---|---|
pankso@126 | 1 #!/bin/sh |
pankso@126 | 2 # |
pankso@126 | 3 # TazBug Plugin - Textmode will output plain data to be used by remote client |
pankso@126 | 4 # |
pankso@126 | 5 |
pankso@126 | 6 if [ "$(GET textmode)" ]; then |
pankso@126 | 7 header "Content-type: text/plain; charset=UTF-8" |
pankso@126 | 8 |
pankso@126 | 9 separator() { |
pankso@126 | 10 echo "-------------------------------------------------------------------------------" |
pankso@126 | 11 } |
pankso@126 | 12 |
pankso@126 | 13 case " $(GET) " in |
pankso@126 | 14 |
pankso@126 | 15 *\ stats\ *) |
pankso@137 | 16 echo "Bugs count : $(ls_bugs | wc -l)" |
pankso@137 | 17 echo "Messages count : $(find $bugdir -name msg.* | wc -l)" |
pankso@126 | 18 echo "Database size : $(du -sh $bugdir | awk '{print $1}')" ;; |
pankso@126 | 19 |
pankso@126 | 20 *\ search\ *) |
pankso@137 | 21 for bug in $(ls_bugs) |
pankso@126 | 22 do |
pankso@137 | 23 set_bugdir "$bug" |
pankso@126 | 24 result=$(fgrep -i -h "$(GET search)" $bugdir/$bug/*) |
pankso@126 | 25 if [ "$result" ]; then |
pankso@126 | 26 found=$(($found + 1)) |
pankso@126 | 27 . ${bugdir}/${bug}/bug.conf |
pankso@126 | 28 echo "Bug: $bug - $BUG" |
pankso@126 | 29 fi |
pankso@138 | 30 bugdir=$(dirname $bugdir) |
pankso@126 | 31 done |
pankso@126 | 32 if [ "$found" == "" ]; then |
pankso@126 | 33 echo "No result found for: $(GET search)" |
pankso@126 | 34 else |
pankso@126 | 35 separator && echo "$found result(s) found" |
pankso@126 | 36 fi ;; |
pankso@126 | 37 |
pankso@126 | 38 *\ id\ *) |
pankso@126 | 39 # Show bug information and description |
pankso@126 | 40 id=$(GET id) |
pankso@137 | 41 set_bugdir "$id" |
pankso@126 | 42 if [ -f "$bugdir/$id/bug.conf" ]; then |
pankso@126 | 43 . ${bugdir}/${id}/bug.conf |
pankso@126 | 44 cat << EOT |
pankso@126 | 45 Bug : $id - $STATUS - $PRIORITY |
pankso@126 | 46 Title : $BUG |
pankso@126 | 47 Info : $DATE - Creator: $CREATOR |
pankso@126 | 48 $(separator) |
pankso@126 | 49 $(cat $bugdir/$id/desc.txt) |
pankso@126 | 50 EOT |
pankso@126 | 51 else |
paul@134 | 52 echo "Can't find bug ID: $id" && exit 0 |
pankso@126 | 53 fi ;; |
pankso@126 | 54 |
pankso@126 | 55 *) |
pankso@126 | 56 cat << EOT |
pankso@126 | 57 Tazbug Textmode plugin |
pankso@126 | 58 $(separator) |
pankso@126 | 59 $(date) |
pankso@126 | 60 |
pankso@126 | 61 Functions: |
pankso@126 | 62 &stats Display bug tracker stats |
pankso@126 | 63 &search= Search for bugs by pattern |
pankso@126 | 64 &id= Show bug info and description |
pankso@126 | 65 EOT |
pankso@126 | 66 ;; |
pankso@126 | 67 esac |
pankso@126 | 68 exit 0 |
pankso@126 | 69 fi |