tazbug annotate web/bugs.cgi @ rev 31
check i18n: make {pot,msgfmt,clean}; fix Makefile; change i18n; add ru.po
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sun Jul 01 22:26:53 2012 +0000 (2012-07-01) |
parents | ea58d117d71a |
children | db97998089d6 |
rev | line source |
---|---|
pankso@9 | 1 #!/bin/sh |
pankso@9 | 2 # |
pankso@9 | 3 # TazBug Web interface |
pankso@9 | 4 # |
pankso@9 | 5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License |
pankso@9 | 6 # |
pankso@9 | 7 . /usr/lib/slitaz/httphelper |
pankso@9 | 8 [ -f "/etc/slitaz/tazbug.conf" ] && . /etc/slitaz/tazbug.conf |
pankso@9 | 9 [ -f "../tazbug.conf" ] && . ../tazbug.conf |
pankso@9 | 10 |
pankso@9 | 11 # Internal variable |
pankso@9 | 12 bugdir="bug" |
pankso@29 | 13 plugins="plugins" |
pankso@9 | 14 sessions="/tmp/tazbug/sessions" |
pankso@30 | 15 po="" |
pankso@9 | 16 |
pankso@9 | 17 # Content negotiation for Gettext |
pankso@9 | 18 IFS="," |
pankso@9 | 19 for lang in $HTTP_ACCEPT_LANGUAGE |
pankso@9 | 20 do |
pankso@9 | 21 lang=${lang%;*} lang=${lang# } lang=${lang%-*} |
pankso@9 | 22 case "$lang" in |
pankso@30 | 23 en) LANG="C" ;; |
pankso@30 | 24 de) LANG="de_DE" ;; |
pankso@30 | 25 es) LANG="es_ES" ;; |
pankso@30 | 26 fr) LANG="fr_FR" ;; |
pankso@30 | 27 it) LANG="it_IT" ;; |
pankso@30 | 28 pt) LANG="pt_BR" ;; |
pankso@30 | 29 ru) LANG="ru_RU" ;; |
pankso@30 | 30 zh) LANG="zh_TW" ;; |
pankso@9 | 31 esac |
pankso@30 | 32 if echo "$po" | fgrep -q "$lang"; then |
pankso@30 | 33 break |
pankso@30 | 34 fi |
pankso@9 | 35 done |
pankso@9 | 36 unset IFS |
pankso@30 | 37 export LANG LC_ALL=$LANG |
pankso@9 | 38 |
pankso@9 | 39 # Internationalization: $(gettext "") |
pankso@9 | 40 . /usr/bin/gettext.sh |
pankso@9 | 41 TEXTDOMAIN='tazbug' |
pankso@9 | 42 export TEXTDOMAIN |
pankso@9 | 43 |
pankso@9 | 44 # |
pankso@9 | 45 # Functions |
pankso@9 | 46 # |
pankso@9 | 47 |
pankso@9 | 48 # HTML 5 header. |
pankso@9 | 49 html_header() { |
pankso@9 | 50 cat lib/header.html |
pankso@9 | 51 } |
pankso@9 | 52 |
pankso@9 | 53 # HTML 5 footer. |
pankso@9 | 54 html_footer() { |
pankso@9 | 55 cat << EOT |
pankso@9 | 56 </div> |
pankso@9 | 57 |
pankso@9 | 58 <div id="footer"> |
pankso@9 | 59 <a href="./">SliTaz Bugs</a> - |
pankso@9 | 60 <a href="./?README">README</a> |
pankso@9 | 61 </div> |
pankso@9 | 62 |
pankso@9 | 63 </body> |
pankso@9 | 64 </html> |
pankso@9 | 65 EOT |
pankso@9 | 66 } |
pankso@9 | 67 |
pankso@9 | 68 # Check if user is auth |
pankso@9 | 69 check_auth() { |
pankso@9 | 70 auth="$(COOKIE auth)" |
pankso@9 | 71 user="$(echo $auth | cut -d ":" -f 1)" |
pankso@9 | 72 md5cookie="$(echo $auth | cut -d ":" -f 2)" |
pankso@9 | 73 [ -f "$sessions/$user" ] && md5session="$(cat $sessions/$user)" |
pankso@9 | 74 if [ "$md5cookie" == "$md5session" ] && [ "$auth" ]; then |
pankso@9 | 75 return 0 |
pankso@9 | 76 else |
pankso@9 | 77 return 1 |
pankso@9 | 78 fi |
pankso@9 | 79 } |
pankso@9 | 80 |
pankso@9 | 81 # Authentified or not |
pankso@9 | 82 user_box() { |
pankso@9 | 83 if check_auth; then |
pankso@26 | 84 . $PEOPLE/$user/account.conf |
pankso@9 | 85 cat << EOT |
pankso@9 | 86 <div id="user"> |
pankso@24 | 87 <a href="?user=$user">$(get_gravatar $MAIL 20)</a> |
al@31 | 88 <a href="?logout">$(gettext 'Log out')</a> |
pankso@9 | 89 </div> |
pankso@9 | 90 EOT |
pankso@9 | 91 else |
pankso@9 | 92 cat << EOT |
pankso@9 | 93 <div id="user"> |
pankso@26 | 94 <a href="?login"><img src="images/avatar.png" alt="[ User ]" /></a> |
al@31 | 95 <a href="?login">$(gettext 'Log in')</a> |
pankso@9 | 96 </div> |
pankso@9 | 97 EOT |
pankso@9 | 98 fi |
pankso@9 | 99 cat << EOT |
pankso@9 | 100 |
pankso@24 | 101 <div id="search"> |
pankso@24 | 102 <form method="get" action="./"> |
al@31 | 103 <input type="text" name="search" placeholder="$(gettext 'Search')" /> |
al@31 | 104 <!-- <input type="submit" value="$(gettext 'Search')" /> --> |
pankso@24 | 105 </form> |
pankso@24 | 106 </div> |
pankso@24 | 107 |
pankso@9 | 108 <!-- Content --> |
pankso@9 | 109 <div id="content"> |
pankso@9 | 110 |
pankso@9 | 111 EOT |
pankso@9 | 112 } |
pankso@9 | 113 |
pankso@9 | 114 # Login page |
pankso@9 | 115 login_page() { |
pankso@9 | 116 cat << EOT |
al@31 | 117 <h2>$(gettext 'Login')</h2> |
pankso@9 | 118 |
pankso@9 | 119 <div id="account-info"> |
al@31 | 120 <p>$(gettext "No account yet? Please signup using the SliTaz Bugs reporter \ |
al@31 | 121 on your SliTaz system.")</p> |
al@31 | 122 <p>$(gettext "Tip: to attach big files or images, you can use SliTaz Paste \ |
al@31 | 123 services:") <a href="http://paste.slitaz.org/">paste.slitaz.org</a></p> |
pankso@9 | 124 </div> |
pankso@9 | 125 |
pankso@9 | 126 <div id="login"> |
pankso@9 | 127 <form method="post" action="$SCRIPT_NAME"> |
al@31 | 128 <input type="text" name="auth" placeholder="$(gettext 'User name')" /> |
al@31 | 129 <input type="password" name="pass" placeholder="$(gettext 'Password')" /> |
pankso@21 | 130 <div> |
al@31 | 131 <input type="submit" value="$(gettext 'Log in')" /> |
pankso@21 | 132 $error |
pankso@21 | 133 </div> |
pankso@9 | 134 </form> |
pankso@9 | 135 </div> |
pankso@9 | 136 |
pankso@9 | 137 <div style="clear: both;"></div> |
pankso@9 | 138 EOT |
pankso@9 | 139 } |
pankso@9 | 140 |
pankso@9 | 141 # Display user public profile. |
pankso@9 | 142 public_people() { |
pankso@9 | 143 cat << EOT |
pankso@9 | 144 <pre> |
al@31 | 145 $(eval_gettext 'Real name : $NAME') |
pankso@9 | 146 </pre> |
pankso@9 | 147 EOT |
pankso@9 | 148 } |
pankso@9 | 149 |
pankso@9 | 150 # Display authentified user profile. TODO: change password |
pankso@9 | 151 auth_people() { |
pankso@9 | 152 cat << EOT |
pankso@9 | 153 <pre> |
al@31 | 154 $(eval_gettext 'Real name : $NAME') |
al@31 | 155 $(eval_gettext 'Email : $MAIL') |
al@31 | 156 $(eval_gettext 'Secure key : $KEY') |
pankso@9 | 157 </pre> |
pankso@9 | 158 EOT |
pankso@9 | 159 } |
pankso@9 | 160 |
pankso@9 | 161 # Usage: list_bugs STATUS |
pankso@9 | 162 list_bugs() { |
al@31 | 163 bug="$1" |
al@31 | 164 echo "<h3>$(eval_gettext '$bug Bug')</h3>" |
pankso@9 | 165 for pr in critical standard |
pankso@9 | 166 do |
pankso@9 | 167 for bug in $(fgrep -H "$1" $bugdir/*/bug.conf | cut -d ":" -f 1) |
pankso@9 | 168 do |
pankso@9 | 169 . $bug |
pankso@9 | 170 id=$(dirname $bug | cut -d "/" -f 2) |
pankso@9 | 171 if [ "$PRIORITY" == "$pr" ]; then |
pankso@9 | 172 cat << EOT |
pankso@9 | 173 <pre> |
al@31 | 174 $(gettext 'Bug title :') <strong>$BUG</strong> <a href="?id=$id">$(gettext 'Show')</a> |
al@31 | 175 $(gettext 'ID - Date :') $id - $DATE |
al@31 | 176 $(gettext 'Creator :') <a href="?user=$CREATOR">$CREATOR</a> |
pankso@9 | 177 </pre> |
pankso@9 | 178 EOT |
pankso@9 | 179 fi |
pankso@9 | 180 done |
pankso@9 | 181 done |
pankso@9 | 182 } |
pankso@9 | 183 |
paul@17 | 184 # Stripped down Wiki parser for bug desc and messages which are simply |
paul@17 | 185 # displayed in <pre> |
pankso@9 | 186 wiki_parser() { |
pankso@9 | 187 sed \ |
pankso@9 | 188 -e s"#http://\([^']*\).png#<img src='\0' alt='[ Image ]' />#"g \ |
pankso@9 | 189 -e s"#http://\([^']*\).*# <a href='\0'>\1</a>#"g |
pankso@9 | 190 } |
pankso@9 | 191 |
pankso@9 | 192 # Bug page |
pankso@9 | 193 bug_page() { |
pankso@26 | 194 if [ -f "$PEOPLE/$CREATOR/account.conf" ]; then |
pankso@26 | 195 . $PEOPLE/$CREATOR/account.conf |
pankso@9 | 196 else |
pankso@15 | 197 MAIL="default" |
pankso@9 | 198 fi |
pankso@9 | 199 cat << EOT |
al@31 | 200 <h2>$(eval_gettext 'Bug $id')</h2> |
pankso@9 | 201 <form method="get" action="./"> |
pankso@9 | 202 |
pankso@9 | 203 <p> |
al@31 | 204 $(get_gravatar $MAIL 32) |
al@31 | 205 <strong>$STATUS</strong> |
al@31 | 206 $BUG - $DATE - |
al@31 | 207 $(eval_gettext 'Priority $PRIORITY') - |
al@31 | 208 $(eval_ngettext '$msgs message' '$msgs messages' $msgs) |
pankso@9 | 209 </p> |
pankso@9 | 210 |
pankso@9 | 211 <pre> |
pankso@9 | 212 $(echo "$DESC" | wiki_parser) |
pankso@9 | 213 </pre> |
pankso@9 | 214 |
pankso@9 | 215 <div id="tools"> |
pankso@9 | 216 EOT |
pankso@9 | 217 if check_auth; then |
pankso@9 | 218 if [ "$STATUS" == "OPEN" ]; then |
pankso@30 | 219 cat << EOT |
pankso@9 | 220 <a href="?id=$id&close">$(gettext "Close bug")</a> |
pankso@9 | 221 <a href="?edit=$id">$(gettext "Edit bug")</a> |
pankso@9 | 222 EOT |
pankso@9 | 223 else |
pankso@9 | 224 cat << EOT |
pankso@9 | 225 <a href="?id=$id&open">$(gettext "Re open bug")</a> |
pankso@9 | 226 EOT |
pankso@9 | 227 fi |
pankso@9 | 228 fi |
pankso@9 | 229 cat << EOT |
pankso@9 | 230 </div> |
pankso@9 | 231 |
pankso@9 | 232 <h3>$(gettext "Messages")</h3> |
pankso@9 | 233 EOT |
pankso@9 | 234 [ "$msgs" == "0" ] && gettext "No messages" |
pankso@9 | 235 for msg in $(ls -1tr $bugdir/$id/msg.*) |
pankso@9 | 236 do |
pankso@9 | 237 . $msg |
pankso@9 | 238 if [ "$MSG" ]; then |
pankso@9 | 239 msgid=$(echo $msg | cut -d "." -f 2) |
pankso@9 | 240 del="" |
pankso@9 | 241 # User can delete his post. |
pankso@9 | 242 [ "$user" == "$USER" ] && \ |
pankso@9 | 243 del="<a href=\"?id=$id&delmsg=$msgid\">delete</a>" |
pankso@9 | 244 cat << EOT |
pankso@9 | 245 <p><strong>$USER</strong> $DATE $del</p> |
pankso@9 | 246 <pre> |
pankso@9 | 247 $(echo "$MSG" | wiki_parser) |
pankso@9 | 248 </pre> |
pankso@9 | 249 EOT |
pankso@9 | 250 fi |
pankso@9 | 251 unset NAME DATE MSG |
pankso@9 | 252 done |
pankso@9 | 253 if check_auth; then |
pankso@9 | 254 cat << EOT |
pankso@9 | 255 <div> |
pankso@9 | 256 <h3>$(gettext "New message")</h3> |
pankso@30 | 257 |
pankso@9 | 258 <input type="hidden" name="id" value="$id" /> |
pankso@9 | 259 <textarea name="msg" rows="8"></textarea> |
al@31 | 260 <p><input type="submit" value="$(gettext 'Send message')" /></p> |
pankso@9 | 261 </form> |
pankso@9 | 262 </div> |
pankso@9 | 263 EOT |
pankso@9 | 264 fi |
pankso@9 | 265 } |
pankso@9 | 266 |
pankso@9 | 267 # Write a new message |
pankso@9 | 268 new_msg() { |
pankso@9 | 269 date=$(date "+%Y-%m-%d %H:%M") |
pankso@9 | 270 msgs=$(ls -1 $bugdir/$id/msg.* | wc -l) |
pankso@9 | 271 count=$(($msgs + 1)) |
pankso@9 | 272 if check_auth; then |
pankso@9 | 273 USER="$user" |
pankso@9 | 274 fi |
pankso@9 | 275 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$id/msg.$count << EOT |
pankso@9 | 276 USER="$USER" |
pankso@9 | 277 DATE="$date" |
pankso@9 | 278 MSG="$(GET msg)" |
pankso@9 | 279 EOT |
pankso@9 | 280 } |
pankso@9 | 281 |
pankso@9 | 282 # Create a new Bug |
pankso@9 | 283 new_bug() { |
pankso@9 | 284 count=$(ls -1 $bugdir | wc -l) |
pankso@9 | 285 date=$(date "+%Y-%m-%d %H:%M") |
pankso@9 | 286 # Sanity check, JS may be disabled. |
pankso@9 | 287 [ ! "$(GET bug)" ] && echo "Missing bug title" && exit 1 |
pankso@9 | 288 [ ! "$(GET desc)" ] && echo "Missing bug description" && exit 1 |
pankso@9 | 289 if check_auth; then |
pankso@9 | 290 USER="$user" |
pankso@9 | 291 fi |
pankso@9 | 292 mkdir -p $bugdir/$count |
pankso@9 | 293 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$count/bug.conf << EOT |
pankso@9 | 294 # SliTaz Bug configuration |
pankso@9 | 295 |
pankso@9 | 296 BUG="$(GET bug)" |
pankso@9 | 297 STATUS="OPEN" |
pankso@9 | 298 PRIORITY="$(GET priority)" |
pankso@9 | 299 CREATOR="$USER" |
pankso@9 | 300 DATE="$date" |
pankso@9 | 301 PKGS="$(GET pkgs)" |
pankso@9 | 302 |
pankso@9 | 303 DESC="$(GET desc)" |
pankso@9 | 304 EOT |
pankso@9 | 305 } |
pankso@9 | 306 |
pankso@9 | 307 # New bug page for the web interface |
pankso@9 | 308 new_bug_page() { |
pankso@9 | 309 cat << EOT |
pankso@9 | 310 <h2>$(gettext "New Bug")</h2> |
pankso@9 | 311 <div id="newbug"> |
pankso@9 | 312 |
pankso@9 | 313 <form method="get" action="./" onsubmit="return checkNewBug();"> |
pankso@9 | 314 <input type="hidden" name="addbug" /> |
pankso@9 | 315 <table> |
pankso@9 | 316 <tbody> |
pankso@9 | 317 <tr> |
pankso@9 | 318 <td>$(gettext "Bug title")*</td> |
pankso@9 | 319 <td><input type="text" name="bug" /></td> |
pankso@9 | 320 </tr> |
pankso@9 | 321 <tr> |
pankso@9 | 322 <td>$(gettext "Description")*</td> |
pankso@9 | 323 <td><textarea name="desc"></textarea></td> |
pankso@9 | 324 </tr> |
pankso@9 | 325 <tr> |
pankso@9 | 326 <td>$(gettext "Packages")</td> |
pankso@9 | 327 <td><input type="text" name="pkgs" /></td> |
pankso@9 | 328 </tr> |
pankso@9 | 329 <tr> |
pankso@9 | 330 <td>$(gettext "Priority")</td> |
pankso@9 | 331 <td> |
pankso@9 | 332 <select name="priority"> |
pankso@9 | 333 <option value="standard">$(gettext "Standard")</option> |
pankso@9 | 334 <option value="critical">$(gettext "Critical")</option> |
pankso@9 | 335 </select> |
pankso@9 | 336 <input type="submit" value="$(gettext "Create Bug")" /> |
pankso@9 | 337 </td> |
pankso@9 | 338 </tr> |
pankso@9 | 339 </tbody> |
pankso@9 | 340 </table> |
pankso@9 | 341 </form> |
pankso@9 | 342 |
pankso@9 | 343 <p> |
al@19 | 344 $(gettext "* field is obligatory. You can also specify affected packages.") |
pankso@9 | 345 </p> |
pankso@9 | 346 |
pankso@9 | 347 </div> |
pankso@9 | 348 EOT |
pankso@9 | 349 } |
pankso@9 | 350 |
pankso@9 | 351 # Edit/Save a bug configuration file |
pankso@9 | 352 edit_bug() { |
pankso@9 | 353 cat << EOT |
al@31 | 354 <h2>$(eval_gettext 'Edit Bug $bug')</h2> |
pankso@9 | 355 <div id="edit"> |
pankso@9 | 356 |
pankso@9 | 357 <form method="get" action="./"> |
pankso@9 | 358 <textarea name="bugconf">$(cat $bugdir/$bug/bug.conf)</textarea> |
pankso@9 | 359 <input type="hidden" name="bug" value="$bug" /> |
al@31 | 360 <input type="submit" value="$(gettext 'Save configuration')" /> |
pankso@9 | 361 </form> |
pankso@9 | 362 |
pankso@9 | 363 </div> |
pankso@9 | 364 EOT |
pankso@9 | 365 } |
pankso@9 | 366 |
pankso@9 | 367 save_bug() { |
pankso@9 | 368 bug="$(GET bug)" |
pankso@9 | 369 content="$(GET bugconf)" |
al@31 | 370 sed "s|\"|'|" | sed "s/$(echo -en '\r') /\n/g" > $bugdir/$bug/bug.conf << EOT |
pankso@9 | 371 $content |
pankso@9 | 372 EOT |
pankso@9 | 373 } |
pankso@9 | 374 |
pankso@9 | 375 # Close a fixed bug |
pankso@9 | 376 close_bug() { |
pankso@9 | 377 sed -i s'/OPEN/CLOSED/' $bugdir/$id/bug.conf |
pankso@9 | 378 } |
pankso@9 | 379 |
pankso@9 | 380 # Re open an old bug |
pankso@9 | 381 open_bug() { |
pankso@9 | 382 sed -i s'/CLOSED/OPEN/' $bugdir/$id/bug.conf |
pankso@9 | 383 } |
pankso@9 | 384 |
pankso@9 | 385 # Get and display Gravatar image: get_gravatar email size |
pankso@9 | 386 # Link to profile: <a href="http://www.gravatar.com/$md5">...</a> |
pankso@9 | 387 get_gravatar() { |
pankso@9 | 388 email=$1 |
pankso@9 | 389 size=$2 |
pankso@9 | 390 [ "$size" ] || size=48 |
pankso@9 | 391 url="http://www.gravatar.com/avatar" |
pankso@29 | 392 md5=$(md5crypt $email) |
al@31 | 393 echo "<img src=\"$url/$md5?d=identicon&s=$size\" alt=\"\" />" |
pankso@9 | 394 } |
pankso@9 | 395 |
pankso@21 | 396 # Create a new user in AUTH_FILE and PEOPLE |
pankso@9 | 397 new_user_config() { |
pankso@9 | 398 mail="$(GET mail)" |
pankso@9 | 399 pass="$(GET pass)" |
pankso@9 | 400 key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}') |
pankso@9 | 401 echo "$user:$pass" >> $AUTH_FILE |
pankso@9 | 402 mkdir -p $PEOPLE/$user/ |
pankso@26 | 403 cat > $PEOPLE/$user/account.conf << EOT |
pankso@9 | 404 # SliTaz user configuration |
pankso@9 | 405 # |
pankso@9 | 406 |
pankso@9 | 407 NAME="$(GET name)" |
pankso@9 | 408 USER="$user" |
pankso@9 | 409 MAIL="$mail" |
pankso@9 | 410 KEY="$key" |
pankso@9 | 411 |
pankso@9 | 412 COMMUNITY="$(GET scn)" |
pankso@9 | 413 LOCATION="$(GET location)" |
pankso@9 | 414 RELEASES="$(GET releases)" |
pankso@9 | 415 PACKAGES="$(GET packages)" |
pankso@9 | 416 EOT |
pankso@26 | 417 chmod 0600 $PEOPLE/$user/account.conf |
pankso@9 | 418 } |
pankso@9 | 419 |
pankso@9 | 420 # |
pankso@9 | 421 # POST actions |
pankso@9 | 422 # |
pankso@9 | 423 |
pankso@9 | 424 case " $(POST) " in |
pankso@9 | 425 *\ auth\ *) |
pankso@9 | 426 # Authenticate user. Create a session file in $sessions to be used |
pankso@9 | 427 # by check_auth. We have the user login name and a peer session |
pankso@9 | 428 # md5 string in the COOKIE. |
pankso@9 | 429 user="$(POST auth)" |
pankso@29 | 430 pass="$(md5crypt "$(POST pass)")" |
pankso@9 | 431 valid=$(fgrep "${user}:" $AUTH_FILE | cut -d ":" -f 2) |
pankso@9 | 432 if [ "$pass" == "$valid" ] && [ "$pass" != "" ]; then |
pankso@9 | 433 md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}') |
pankso@9 | 434 mkdir -p $sessions |
pankso@9 | 435 echo "$md5session" > $sessions/$user |
pankso@9 | 436 header "Location: $WEB_URL" \ |
pankso@9 | 437 "Set-Cookie: auth=$user:$md5session; HttpOnly" |
pankso@9 | 438 else |
pankso@9 | 439 header "Location: $WEB_URL?login&error" |
pankso@9 | 440 fi ;; |
pankso@9 | 441 esac |
pankso@9 | 442 |
pankso@9 | 443 # |
pankso@29 | 444 # Plugins |
pankso@29 | 445 # |
pankso@29 | 446 for p in $(ls -1 $plugins) |
pankso@29 | 447 do |
pankso@29 | 448 [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf |
pankso@29 | 449 [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi |
pankso@29 | 450 done |
pankso@29 | 451 |
pankso@29 | 452 # |
pankso@9 | 453 # GET actions |
pankso@9 | 454 # |
pankso@9 | 455 |
pankso@9 | 456 case " $(GET) " in |
pankso@9 | 457 *\ README\ *) |
pankso@9 | 458 header |
pankso@9 | 459 html_header |
pankso@9 | 460 user_box |
pankso@9 | 461 echo '<h2>README</h2>' |
pankso@9 | 462 echo '<pre>' |
pankso@9 | 463 cat /usr/share/doc/tazbug/README |
pankso@30 | 464 echo '</pre>' |
pankso@9 | 465 html_footer ;; |
pankso@9 | 466 *\ closed\ *) |
pankso@9 | 467 # Show all closed bugs. |
pankso@9 | 468 header |
pankso@9 | 469 html_header |
pankso@9 | 470 user_box |
pankso@9 | 471 list_bugs CLOSED |
pankso@9 | 472 html_footer ;; |
pankso@9 | 473 *\ login\ *) |
pankso@9 | 474 # The login page |
pankso@9 | 475 [ "$(GET error)" ] && \ |
al@31 | 476 error="<span class='error'>$(gettext 'Bad login or pass')</span>" |
pankso@30 | 477 header |
pankso@9 | 478 html_header |
pankso@21 | 479 user_box |
pankso@30 | 480 login_page |
pankso@9 | 481 html_footer ;; |
pankso@9 | 482 *\ logout\ *) |
pankso@9 | 483 # Set a Cookie in the past to logout. |
pankso@9 | 484 expires="Expires=Wed, 01-Jan-1980 00:00:00 GMT" |
pankso@9 | 485 if check_auth; then |
pankso@9 | 486 rm -f "$sessions/$user" |
pankso@9 | 487 header "Location: $WEB_URL" "Set-Cookie: auth=none; $expires; HttpOnly" |
pankso@9 | 488 fi ;; |
pankso@9 | 489 *\ user\ *) |
pankso@9 | 490 # User profile |
pankso@9 | 491 header |
pankso@9 | 492 html_header |
pankso@9 | 493 user_box |
pankso@26 | 494 . $PEOPLE/"$(GET user)"/account.conf |
pankso@9 | 495 echo "<h2>$(get_gravatar $MAIL) $(GET user)</h2>" |
pankso@9 | 496 if check_auth && [ "$(GET user)" == "$user" ]; then |
pankso@9 | 497 auth_people |
pankso@9 | 498 else |
pankso@9 | 499 public_people |
pankso@9 | 500 fi |
pankso@9 | 501 html_footer ;; |
pankso@9 | 502 *\ newbug\ *) |
pankso@9 | 503 # Add a bug from web interface. |
pankso@9 | 504 header |
pankso@9 | 505 html_header |
pankso@9 | 506 user_box |
pankso@9 | 507 if check_auth; then |
pankso@9 | 508 new_bug_page |
pankso@9 | 509 else |
al@31 | 510 echo "<p>$(gettext 'You must be logged in to post a new bug')</p>" |
pankso@9 | 511 fi |
pankso@9 | 512 html_footer ;; |
pankso@9 | 513 *\ addbug\ *) |
pankso@9 | 514 # Add a bug from web interface. |
pankso@9 | 515 if check_auth; then |
pankso@9 | 516 new_bug |
pankso@9 | 517 header "Location: $WEB_URL?id=$count" |
pankso@9 | 518 fi ;; |
pankso@9 | 519 *\ edit\ *) |
pankso@9 | 520 bug="$(GET edit)" |
pankso@9 | 521 header |
pankso@9 | 522 html_header |
pankso@9 | 523 user_box |
pankso@9 | 524 edit_bug |
pankso@9 | 525 html_footer ;; |
pankso@9 | 526 *\ bugconf\ *) |
pankso@9 | 527 if check_auth; then |
pankso@9 | 528 save_bug |
pankso@9 | 529 header "Location: $WEB_URL?id=$bug" |
pankso@9 | 530 fi ;; |
pankso@9 | 531 *\ id\ *) |
pankso@9 | 532 # Empty deleted messages to keep msg count working. |
pankso@9 | 533 id="$(GET id)" |
pankso@9 | 534 [ "$(GET close)" ] && close_bug |
pankso@9 | 535 [ "$(GET open)" ] && open_bug |
pankso@9 | 536 [ "$(GET msg)" ] && new_msg |
pankso@9 | 537 [ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg) && \ |
pankso@9 | 538 touch $bugdir/$id/msg.$(GET delmsg) |
pankso@9 | 539 msgs=$(fgrep MSG= $bugdir/$id/msg.* | wc -l) |
pankso@30 | 540 header |
pankso@9 | 541 html_header |
pankso@30 | 542 user_box |
pankso@9 | 543 . $bugdir/$id/bug.conf |
pankso@9 | 544 bug_page |
pankso@9 | 545 html_footer ;; |
pankso@9 | 546 *\ signup\ *) |
pankso@9 | 547 # Signup |
pankso@9 | 548 header "Content-type: text/plain;" |
pankso@9 | 549 user="$(GET signup)" |
pankso@9 | 550 echo "Requested user login : $user" |
pankso@9 | 551 if fgrep -q "$user:" $AUTH_FILE; then |
paul@17 | 552 echo "ERROR: User already exists" && exit 1 |
pankso@9 | 553 else |
pankso@9 | 554 echo "Creating account for : $(GET name)" |
pankso@30 | 555 new_user_config |
pankso@9 | 556 fi ;; |
pankso@9 | 557 *\ key\ *) |
pankso@9 | 558 # Let user post new bug or message with crypted key (no gettext) |
pankso@9 | 559 # |
pankso@9 | 560 # Testing only and is security acceptable ? |
pankso@9 | 561 # |
pankso@9 | 562 key="$(GET key)" |
pankso@9 | 563 id="$(GET bug)" |
pankso@9 | 564 header "Content-type: text/plain;" |
pankso@30 | 565 echo "Checking secure key..." |
pankso@26 | 566 if fgrep -qH $key $PEOPLE/*/account.conf; then |
pankso@26 | 567 conf=$(fgrep -H $key $PEOPLE/*/account.conf | cut -d ":" -f 1) |
pankso@9 | 568 . $conf |
pankso@9 | 569 echo "Authentified: $NAME ($USER)" |
pankso@9 | 570 case " $(GET) " in |
pankso@9 | 571 *\ msg\ *) |
pankso@9 | 572 [ ! "$id" ] && echo "Missing bug ID" && exit 0 |
pankso@9 | 573 echo "Posting new message to bug: $id" |
pankso@9 | 574 echo "Message: $(GET msg)" |
pankso@9 | 575 new_msg ;; |
pankso@9 | 576 *\ bug\ *) |
pankso@30 | 577 echo "Adding new bug: $(GET bug)" |
pankso@30 | 578 echo "Description: $(GET desc)" |
pankso@9 | 579 new_bug ;; |
pankso@30 | 580 esac |
pankso@9 | 581 else |
pankso@9 | 582 echo "Not a valid SliTaz user key" |
pankso@9 | 583 exit 0 |
pankso@9 | 584 fi ;; |
pankso@9 | 585 *\ search\ *) |
pankso@9 | 586 header |
pankso@9 | 587 html_header |
pankso@9 | 588 user_box |
pankso@9 | 589 cat << EOT |
pankso@9 | 590 <h2>$(gettext "Search")</h2> |
pankso@9 | 591 <form method="get" action="./"> |
pankso@9 | 592 <input type="text" name="search" /> |
al@31 | 593 <input type="submit" value="$(gettext 'Search')" /> |
pankso@9 | 594 </form> |
pankso@21 | 595 <div> |
pankso@9 | 596 EOT |
pankso@30 | 597 |
pankso@21 | 598 #found=0 JS to notify or write results nb under the search box. |
pankso@21 | 599 for bug in $bugdir/* |
pankso@9 | 600 do |
pankso@21 | 601 result=$(fgrep -i "$(GET search)" $bug/*) |
pankso@21 | 602 if [ "$result" ]; then |
pankso@21 | 603 #found=$(($found + 1)) |
pankso@21 | 604 id=${bug#bug/} |
al@31 | 605 echo "<p><strong>Bug $id</strong> <a href=\"?id=$id\">"$(gettext 'Show')"</a></p>" |
pankso@21 | 606 echo '<pre>' |
pankso@21 | 607 fgrep -i "$(GET search)" $bugdir/$id/* | \ |
pankso@21 | 608 sed s"/$(GET search)/<span class='ok'>$(GET search)<\/span>/"g |
pankso@21 | 609 echo '</pre>' |
pankso@21 | 610 else |
al@31 | 611 get_search=$(GET search) |
al@31 | 612 echo "<p>$(eval_gettext 'No result found for: $get_search')</p>" |
pankso@21 | 613 fi |
pankso@9 | 614 done |
pankso@21 | 615 echo '</div>' |
pankso@9 | 616 html_footer ;; |
pankso@9 | 617 *) |
pankso@9 | 618 # Default page. |
pankso@9 | 619 bugs=$(ls -1 $bugdir | wc -l) |
pankso@9 | 620 close=$(fgrep "CLOSED" $bugdir/*/bug.conf | wc -l) |
pankso@9 | 621 fixme=$(fgrep "OPEN" $bugdir/*/bug.conf | wc -l) |
pankso@9 | 622 msgs=$(find $bugdir -name msg.* ! -size 0 | wc -l) |
pankso@9 | 623 pct=0 |
pankso@9 | 624 [ $bugs -gt 0 ] && pct=$(( ($close * 100) / $bugs )) |
pankso@9 | 625 header |
pankso@9 | 626 html_header |
pankso@9 | 627 user_box |
pankso@9 | 628 cat << EOT |
pankso@9 | 629 |
pankso@9 | 630 <h2>$(gettext "Summary")</h2> |
pankso@9 | 631 |
pankso@9 | 632 <p> |
al@31 | 633 $(eval_ngettext 'Bug: $bugs in total -' 'Bugs: $bugs in total -' $bugs) |
al@31 | 634 $(eval_ngettext '$close fixed -' '$close fixed -' $close) |
al@31 | 635 $(eval_ngettext '$fixme to fix -' '$fixme to fix -' $fixme) |
al@31 | 636 $(eval_ngettext '$msgs message' '$msgs messages' $msgs) |
pankso@9 | 637 </p> |
pankso@9 | 638 |
pankso@9 | 639 <div class="pctbar"> |
pankso@9 | 640 <div class="pct" style="width: ${pct}%;">${pct}%</div> |
pankso@9 | 641 </div> |
pankso@9 | 642 |
al@31 | 643 <p>$(gettext "Please read the <a href=\"?README\">README</a> for help and more \ |
al@31 | 644 information. You may also be interested by the SliTaz \ |
al@31 | 645 <a href=\"http://roadmap.slitaz.org/\">Roadmap</a> and the packages \ |
al@31 | 646 <a href=\"http://cook.slitaz.org/\">Cooker</a>. To perform a search \ |
al@31 | 647 enter your term and press ENTER.") |
pankso@9 | 648 </p> |
pankso@9 | 649 |
pankso@9 | 650 <div id="tools"> |
al@31 | 651 <a href="?closed">$(gettext 'View closed bugs')</a> |
pankso@9 | 652 EOT |
pankso@9 | 653 if check_auth; then |
al@31 | 654 echo "<a href='?newbug'>$(gettext 'Create a new bug')</a>" |
pankso@9 | 655 fi |
pankso@9 | 656 cat << EOT |
pankso@9 | 657 </div> |
pankso@9 | 658 EOT |
pankso@9 | 659 list_bugs OPEN |
pankso@9 | 660 html_footer ;; |
pankso@9 | 661 esac |
pankso@9 | 662 |
pankso@9 | 663 exit 0 |