tazbug annotate web/plugins/textmode/textmode.cgi @ rev 137
Update all plugins to use new storage paths
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 22 14:59:49 2017 +0100 (2017-02-22) |
parents | 7bf28563c0f6 |
children | 2a172aca8228 |
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@126 | 30 done |
pankso@126 | 31 if [ "$found" == "" ]; then |
pankso@126 | 32 echo "No result found for: $(GET search)" |
pankso@126 | 33 else |
pankso@126 | 34 separator && echo "$found result(s) found" |
pankso@126 | 35 fi ;; |
pankso@126 | 36 |
pankso@126 | 37 *\ id\ *) |
pankso@126 | 38 # Show bug information and description |
pankso@126 | 39 id=$(GET id) |
pankso@137 | 40 set_bugdir "$id" |
pankso@126 | 41 if [ -f "$bugdir/$id/bug.conf" ]; then |
pankso@126 | 42 . ${bugdir}/${id}/bug.conf |
pankso@126 | 43 cat << EOT |
pankso@126 | 44 Bug : $id - $STATUS - $PRIORITY |
pankso@126 | 45 Title : $BUG |
pankso@126 | 46 Info : $DATE - Creator: $CREATOR |
pankso@126 | 47 $(separator) |
pankso@126 | 48 $(cat $bugdir/$id/desc.txt) |
pankso@126 | 49 EOT |
pankso@126 | 50 else |
paul@134 | 51 echo "Can't find bug ID: $id" && exit 0 |
pankso@126 | 52 fi ;; |
pankso@126 | 53 |
pankso@126 | 54 *) |
pankso@126 | 55 cat << EOT |
pankso@126 | 56 Tazbug Textmode plugin |
pankso@126 | 57 $(separator) |
pankso@126 | 58 $(date) |
pankso@126 | 59 |
pankso@126 | 60 Functions: |
pankso@126 | 61 &stats Display bug tracker stats |
pankso@126 | 62 &search= Search for bugs by pattern |
pankso@126 | 63 &id= Show bug info and description |
pankso@126 | 64 EOT |
pankso@126 | 65 ;; |
pankso@126 | 66 esac |
pankso@126 | 67 exit 0 |
pankso@126 | 68 fi |