tazbug rev 135

Store bug in bug/open and bug/closed (not yet ready for tank still some plugins adjust)
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 21 21:11:27 2017 +0100 (2017-02-21)
parents 7bf28563c0f6
children a7b3022941ad
files mv-open-closed.sh web/bug/0/bug.conf web/bug/0/desc.txt web/bug/open/0/bug.conf web/bug/open/0/desc.txt web/bugs.cgi web/style.css
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mv-open-closed.sh	Tue Feb 21 21:11:27 2017 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# From Tazbug 2.1 bugs are stored into $bugdir/open or $bugdir/closed
     1.7 +# This script will move all bugs to the correct directory
     1.8 +#
     1.9 +. /lib/libtaz.sh
    1.10 +check_root
    1.11 +path="$1"
    1.12 +
    1.13 +if [ ! "${path}" ]; then
    1.14 +	echo "Usage: $0 path/to/bug" && exit 0
    1.15 +fi
    1.16 +
    1.17 +cd ${path}
    1.18 +mkdir -p open closed
    1.19 +
    1.20 +for bug in *
    1.21 +do
    1.22 +	if [ -f "${bug}/bug.conf" ]; then
    1.23 +		. ./${bug}/bug.conf
    1.24 +		echo  -n "Mouving bug: ${bug} $STATUS"
    1.25 +		if [ "$STATUS" == "OPEN" ]; then
    1.26 +			mv ${bug} open/ && status
    1.27 +		else
    1.28 +			mv ${bug} closed/ && status
    1.29 +		fi
    1.30 +		unset DESC BUG STATUS PRIORITY CREATOR DATE PKGS
    1.31 +		
    1.32 +	fi
    1.33 +	chown -R www.www *
    1.34 +done
    1.35 +
    1.36 +exit 0
     2.1 --- a/web/bug/0/bug.conf	Tue Feb 21 19:12:22 2017 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,8 +0,0 @@
     2.4 -# SliTaz Bug configuration
     2.5 -
     2.6 -BUG="Use SliTaz Bug Tracker"
     2.7 -STATUS="OPEN"
     2.8 -PRIORITY="standard"
     2.9 -CREATOR="root"
    2.10 -DATE="2012-03-29"
    2.11 -PKGS="tazbug"
     3.1 --- a/web/bug/0/desc.txt	Tue Feb 21 19:12:22 2017 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,1 +0,0 @@
     3.4 -The bug description with links and useful information
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/web/bug/open/0/bug.conf	Tue Feb 21 21:11:27 2017 +0100
     4.3 @@ -0,0 +1,8 @@
     4.4 +# SliTaz Bug configuration
     4.5 +
     4.6 +BUG="Use SliTaz Bug Tracker"
     4.7 +STATUS="OPEN"
     4.8 +PRIORITY="standard"
     4.9 +CREATOR="root"
    4.10 +DATE="2012-03-29"
    4.11 +PKGS="tazbug"
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/web/bug/open/0/desc.txt	Tue Feb 21 21:11:27 2017 +0100
     5.3 @@ -0,0 +1,1 @@
     5.4 +The bug description with links and useful information
     6.1 --- a/web/bugs.cgi	Tue Feb 21 19:12:22 2017 +0000
     6.2 +++ b/web/bugs.cgi	Tue Feb 21 21:11:27 2017 +0100
     6.3 @@ -216,39 +216,61 @@
     6.4  EOT
     6.5  }
     6.6  
     6.7 +# Set open/closed bug path: set_bugpath ID
     6.8 +set_bugpath() {
     6.9 +	if [ -d "$bugdir/closed/$1" ]; then
    6.10 +		bugpath="$bugdir/closed/$1"
    6.11 +	else
    6.12 +		bugpath="$bugdir/open/$1"
    6.13 +	fi
    6.14 +}
    6.15 +set_bugdir() {
    6.16 +	if [ -d "$bugdir/closed/$1" ]; then
    6.17 +		bugdir="$bugdir/closed"
    6.18 +	else
    6.19 +		bugdir="$bugdir/open"
    6.20 +	fi
    6.21 +}
    6.22 +
    6.23 +# Nice ls output for open and closed bugs
    6.24 +ls_bugs() {
    6.25 +	ls $bugdir/open
    6.26 +	ls $bugdir/closed
    6.27 +}
    6.28 +
    6.29  # Usage: list_bug ID
    6.30  list_bug() {
    6.31  	id="$1"
    6.32 -	. ${bugdir}/${id}/bug.conf
    6.33 +	set_bugpath ${id}
    6.34 +	. ${bugpath}/bug.conf
    6.35  	[ -f "${PEOPLE}/${CREATOR}/account.conf" ] && \
    6.36  	. ${PEOPLE}/${CREATOR}/account.conf
    6.37  	cat << EOT
    6.38  <a href="?user=$USER">$(get_gravatar "$MAIL" 24)</a> \
    6.39 -ID: $id <a href="?id=$id">$BUG</a> <span class="date">- $DATE</span>
    6.40 +ID $id: <a href="?id=$id">$BUG</a> <span class="date">- $DATE</span>
    6.41  EOT
    6.42 -	unset CREATOR USER MAIL
    6.43 +	unset CREATOR USER MAIL bugpath
    6.44  }
    6.45  
    6.46 -# Usage: list_bugs STATUS
    6.47 +# Usage: list_bugs [open|closed]
    6.48  list_bugs() {
    6.49  	status="$1"
    6.50 -	echo "<h3>$(eval_gettext '$status Bugs')</h3>"
    6.51 +	echo "<h3>$(gettext 'Bugs:') $status</h3>"
    6.52  	echo "<pre>"
    6.53  	for pr in critical standard
    6.54  	do
    6.55 -		for bug in $(fgrep -H "$1" $bugdir/*/bug.conf | cut -d ":" -f 1)
    6.56 +		for id in $(ls $bugdir/$status)
    6.57  		do
    6.58 -			. $bug
    6.59 -			id=$(basename $(dirname $bug))
    6.60 +			. $bugdir/$status/$id/bug.conf
    6.61  			if [ "$PRIORITY" == "$pr" ]; then
    6.62  				[ -f "${PEOPLE}/${CREATOR}/account.conf" ] && \
    6.63  					. ${PEOPLE}/${CREATOR}/account.conf
    6.64  				cat << EOT
    6.65  <a href="?user=$USER">$(get_gravatar "$MAIL" 24)</a> \
    6.66 -ID: $id <a href="?id=$id">$BUG</a> <span class="date">- $DATE</span>
    6.67 +ID $id: <a href="?id=$id">$BUG</a> <span class="date">- $DATE</span>
    6.68  EOT
    6.69  			fi
    6.70 -			unset CREATOR USER MAIL
    6.71 +			unset CREATOR USER MAIL BUG
    6.72  		done
    6.73  	done
    6.74  }
    6.75 @@ -279,6 +301,7 @@
    6.76  
    6.77  # Bug page
    6.78  bug_page() {
    6.79 +	. $bugdir/$id/bug.conf
    6.80  	if [ -f "$PEOPLE/$CREATOR/account.conf" ]; then
    6.81  		. $PEOPLE/$CREATOR/account.conf
    6.82  	else
    6.83 @@ -379,8 +402,8 @@
    6.84  
    6.85  # Create a new Bug. ID is set by counting dirs in bug/ + 1
    6.86  new_bug() {
    6.87 -	count=$(ls $bugdir | sort -g | tail -n 1)
    6.88 -	count=$(($count +1))
    6.89 +	count=$(ls_bugs | sort -g | tail -n 1)
    6.90 +	id=$(($count +1))
    6.91  	date=$(date "+%Y-%m-%d %H:%M")
    6.92  	# Sanity check, JS may be disabled.
    6.93  	[ ! "$(GET bug)" ] && echo "Missing bug title" && exit 1
    6.94 @@ -388,9 +411,9 @@
    6.95  	if check_auth; then
    6.96  		USER="$user"
    6.97  	fi
    6.98 -	mkdir -p $bugdir/$count
    6.99 +	mkdir -p $bugdir/open/$id
   6.100  	# bug.conf
   6.101 -	sed "s/$(echo -en '\r') /\n/g" > $bugdir/$count/bug.conf << EOT
   6.102 +	sed "s/$(echo -en '\r') /\n/g" > $bugdir/open/$id/bug.conf << EOT
   6.103  # SliTaz Bug configuration
   6.104  
   6.105  BUG="$(GETfiltered bug)"
   6.106 @@ -401,11 +424,11 @@
   6.107  PKGS="$(GETfiltered pkgs)"
   6.108  EOT
   6.109  	# desc.txt
   6.110 -	sed "s/$(echo -en '\r') /\n/g" > $bugdir/$count/desc.tmp << EOT
   6.111 +	sed "s/$(echo -en '\r') /\n/g" > $bugdir/open/$id/desc.tmp << EOT
   6.112  $(GETfiltered desc)
   6.113  EOT
   6.114 -	fold -s -w 80 $bugdir/$count/desc.tmp > $bugdir/$count/desc.txt
   6.115 -	rm -f $bugdir/$count/*.tmp
   6.116 +	fold -s -w 80 $bugdir/open/$id/desc.tmp > $bugdir/open/$id/desc.txt
   6.117 +	rm -f $bugdir/open/$id/*.tmp
   6.118  }
   6.119  
   6.120  # New bug page for the web interface
   6.121 @@ -504,6 +527,7 @@
   6.122  
   6.123  save_bug() {
   6.124  	id="$(GET id)"
   6.125 +	set_bugdir ${id}
   6.126  	# bug.conf
   6.127  	sed "s/$(echo -en '\r') /\n/g" > $bugdir/$id/bug.conf << EOT
   6.128  # SliTaz Bug configuration
   6.129 @@ -525,12 +549,14 @@
   6.130  
   6.131  # Close a fixed bug
   6.132  close_bug() {
   6.133 -	sed -i s'/OPEN/CLOSED/' $bugdir/$id/bug.conf
   6.134 +	sed -i s'/OPEN/CLOSED/' $bugdir/open/$id/bug.conf
   6.135 +	mv $bugdir/open/$id $bugdir/closed/$id
   6.136  }
   6.137  
   6.138  # Re open an old bug
   6.139  open_bug() {
   6.140 -	sed -i s'/CLOSED/OPEN/' $bugdir/$id/bug.conf
   6.141 +	sed -i s'/CLOSED/OPEN/' $bugdir/closed/$id/bug.conf
   6.142 +	mv $bugdir/closed/$id $bugdir/open/$id
   6.143  }
   6.144  
   6.145  # Get and display Gravatar image: get_gravatar email size
   6.146 @@ -658,7 +684,7 @@
   6.147  		header
   6.148  		html_header
   6.149  		user_box
   6.150 -		list_bugs CLOSED
   6.151 +		list_bugs "closed"
   6.152  		echo "</pre>"
   6.153  		html_footer ;;
   6.154  	*\ login\ *)
   6.155 @@ -706,18 +732,19 @@
   6.156  		fi
   6.157  		html_footer ;;
   6.158  	*\ addbug\ *)
   6.159 -		# Save a new bug from web interface.
   6.160 +		# Save a new bug
   6.161  		header
   6.162  		html_header
   6.163  		if check_auth; then
   6.164  			new_bug
   6.165 -			js_redirection_to "$script?id=$count"
   6.166 +			js_redirection_to "$script?id=$id"
   6.167  		fi ;;
   6.168  	*\ editbug\ *)
   6.169  		# Edit existing bug
   6.170 -		id="$(GET editbug)"
   6.171  		header
   6.172  		html_header
   6.173 +		id="$(GET editbug)"
   6.174 +		set_bugdir ${id}
   6.175  		user_box
   6.176  		edit_bug
   6.177  		html_footer ;;
   6.178 @@ -734,11 +761,11 @@
   6.179  		id="$(GET id)"
   6.180  		[ "$(GET close)" ] && close_bug
   6.181  		[ "$(GET open)" ] && open_bug
   6.182 +		set_bugdir ${id}
   6.183  		[ "$(GET msg)" ] && new_msg
   6.184  		[ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg)
   6.185  		msgs=$(fgrep MSG= $bugdir/$id/msg.* | wc -l)
   6.186  		user_box
   6.187 -		. $bugdir/$id/bug.conf
   6.188  		bug_page
   6.189  		html_footer ;;
   6.190  	*\ signup\ *)
   6.191 @@ -790,10 +817,10 @@
   6.192  		html_footer ;;
   6.193  	*)
   6.194  		# Default page.
   6.195 -		bugs=$(ls -1 $bugdir | wc -l)
   6.196 -		close=$(fgrep "CLOSED" $bugdir/*/bug.conf | wc -l)
   6.197 -		fixme=$(fgrep "OPEN" $bugdir/*/bug.conf | wc -l)
   6.198 -		msgs=$(find $bugdir -name msg.* ! -size 0 | wc -l)
   6.199 +		bugs=$(ls_bugs | wc -l)
   6.200 +		close=$(ls $bugdir/closed | wc -l)
   6.201 +		fixme=$(ls $bugdir/open  | wc -l)
   6.202 +		msgs=$(find $bugdir -name msg.* | wc -l)
   6.203  		pct=0
   6.204  		[ $bugs -gt 0 ] && pct=$(( ($close * 100) / $bugs ))
   6.205  		header
   6.206 @@ -837,20 +864,22 @@
   6.207  EOT
   6.208  		# List last 4 bugs
   6.209  		echo "<pre>"
   6.210 -		for lb in $(ls ${bugdir} | sort -r -n | head -n 4)
   6.211 +		for lb in $(ls_bugs | sort -n -r | head -n 4)
   6.212  		do
   6.213  			list_bug ${lb}
   6.214  		done
   6.215  		echo "</pre>"
   6.216 +		
   6.217  		# List last 4 messages
   6.218  		echo "<h3>$(gettext "Latest Messages")</h3>"
   6.219  		echo "<pre>"
   6.220 -		for msg in $(ls -t ${bugdir}/*/msg.* | head -n 4)
   6.221 +		
   6.222 +		for msg in $(ls -r $bugdir/*/*/msg.* | head -n 4)
   6.223  		do
   6.224  			list_msg ${msg}
   6.225  		done
   6.226  		echo "</pre>"
   6.227 -		list_bugs OPEN
   6.228 +		list_bugs open
   6.229  		echo "</pre>"
   6.230  		html_footer ;;
   6.231  esac
     7.1 --- a/web/style.css	Tue Feb 21 19:12:22 2017 +0000
     7.2 +++ b/web/style.css	Tue Feb 21 21:11:27 2017 +0100
     7.3 @@ -5,8 +5,8 @@
     7.4  h1 { margin: 0; padding: 8px; color: #fff; font-size: 20px; }
     7.5  h1 a { color: #fff; text-decoration: none; }
     7.6  h2 { color: #444; } h3 { color: #666; font-size: 140%; }
     7.7 -a { text-decoration: underline; color: #215090; }
     7.8 -a:hover { text-decoration: none; }
     7.9 +a { text-decoration: none; color: #215090; }
    7.10 +a:hover { text-decoration: underline; }
    7.11  img { border: 0pt none; vertical-align: middle; }
    7.12  pre {
    7.13  	overflow: auto;