tazbug view web/bugs.cgi @ rev 55

List 3 latest bug after summary
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jan 07 18:59:47 2014 +0100 (2014-01-07)
parents 1995b2fd9270
children a8b2767870a7
line source
1 #!/bin/sh
2 #
3 # TazBug Web interface
4 #
5 # Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
6 #
7 . /usr/lib/slitaz/httphelper
9 # Source config file
10 [ -f "/etc/slitaz/tazbug.conf" ] && . /etc/slitaz/tazbug.conf
11 # Web interface can have different setting than cmdline tools
12 [ -f "/etc/slitaz/bugs.conf" ] && . /etc/slitaz/bugs.conf
14 # Internal variable
15 bugdir="$PWD/bug"
16 plugins="plugins"
17 sessions="/tmp/bugs/sessions"
18 script="$SCRIPT_NAME"
20 # Content negotiation for Gettext
21 IFS=","
22 for lang in $HTTP_ACCEPT_LANGUAGE
23 do
24 lang=${lang%;*} lang=${lang# } lang=${lang%-*}
25 case "$lang" in
26 en) LANG="C" ;;
27 de) LANG="de_DE" ;;
28 es) LANG="es_ES" ;;
29 fr) LANG="fr_FR" ;;
30 it) LANG="it_IT" ;;
31 pt) LANG="pt_BR" ;;
32 ru) LANG="ru_RU" ;;
33 zh) LANG="zh_TW" ;;
34 esac
35 if echo "$po" | fgrep -q "$lang"; then
36 break
37 fi
38 done
39 unset IFS
40 export LANG LC_ALL=$LANG
42 # Internationalization: $(gettext "")
43 . /usr/bin/gettext.sh
44 TEXTDOMAIN='tazbug'
45 export TEXTDOMAIN
47 #
48 # Functions
49 #
51 # HTML 5 header.
52 html_header() {
53 cat lib/header.html
54 }
56 # HTML 5 footer.
57 html_footer() {
58 cat << EOT
59 </div>
61 <div id="footer">
62 <a href="$script">SliTaz Bugs</a> -
63 <a href="$script?README">README</a>
64 </div>
66 </body>
67 </html>
68 EOT
69 }
71 GETfiltered() {
72 GET $1 | sed -e "s/'/\&#39;/g; s|\n|<br/>|g; s/\t/\&#09;/g;s/\%22/\"/g"
73 }
75 js_redirection_to() {
76 js_log "Redirecting to $1"
77 echo "<script type=\"text/javascript\"> document.location = \"$1\"; </script>"
78 }
80 js_log() {
81 echo "<script type=\"text/javascript\">console.log('$1')</script>";
82 }
84 js_set_cookie() {
85 name=$1
86 value=$2
87 js_log 'Setting cookie.'
88 echo "<script type=\"text/javascript\">"
89 echo "document.cookie = \"$name=$value; expires=0; path=/\"";
90 echo "</script>"
91 }
93 js_unset_cookie() {
94 name=$1
95 js_log 'Unsetting cookie.'
96 echo "<script type=\"text/javascript\">"
97 echo "document.cookie = \"$1=\"\"; expires=-1; path=/";
98 echo "</script>"
99 }
101 # Check if user is auth
102 check_auth() {
103 auth="$(COOKIE auth)"
104 user="$(echo $auth | cut -d ":" -f 1)"
105 md5cookie="$(echo $auth | cut -d ":" -f 2)"
106 [ -f "$sessions/$user" ] && md5session="$(cat $sessions/$user)"
107 if [ "$md5cookie" == "$md5session" ] && [ "$auth" ]; then
108 return 0
109 else
110 return 1
111 fi
112 }
114 # Check if user is admin
115 admin_user() {
116 fgrep -q 'ADMIN_USER="yes"' ${PEOPLE}/${user}/account.conf
117 }
119 # Authentified or not
120 user_box() {
122 IDLOC=""
123 if [[ "$(GET id)" ]] ;then
124 IDLOC="&id=$(GET id)"
125 fi
127 if check_auth; then
128 . $PEOPLE/$user/account.conf
129 cat << EOT
130 <div id="user">
131 <a href="?user=$user">$(get_gravatar $MAIL 20)</a>
132 <a href="?logout">$(gettext 'Logout')</a>
133 </div>
134 EOT
135 else
136 cat << EOT
137 <div id="user">
138 <a href="?login$IDLOC"><img src="images/avatar.png" alt="[ User ]" /></a>
139 <a href="?login$IDLOC">$(gettext 'Log in')</a>
140 </div>
141 EOT
142 fi
143 cat << EOT
145 <div id="search">
146 <form method="get" action="$script">
147 <input type="text" name="search" placeholder="$(gettext 'Search')" />
148 <!-- <input type="submit" value="$(gettext 'Search')" /> -->
149 </form>
150 </div>
152 <!-- Content -->
153 <div id="content">
155 EOT
156 }
158 # Signup page
159 signup_page() {
160 cat << EOT
162 <div id="signup">
163 <form method="post" name="signup" action="$SCRIPT_NAME" onsubmit="return checkSignup();">
164 <input type="hidden" name="signup" value="new" />
165 <input type="text" name="name" placeholder="$(gettext "Real name")" />
166 <input type="text" name="user" placeholder="$(gettext "User name")" />
167 <input type="text" name="mail" placeholder="$(gettext "Email")" />
168 <input type="password" name="pass" placeholder="$(gettext "Password")" />
169 <div>
170 <input type="submit" value="$(gettext "Create new account")" />
171 </div>
172 </form>
173 </div>
175 EOT
176 }
178 # Link for online signup if enabled.
179 online_signup() {
180 if [ "$ONLINE_SIGNUP" == "yes" ]; then
181 echo -n "<p>" && gettext "Or:"; echo -n " "
182 echo -n "<a href='$script?signup&amp;online'>"
183 gettext "Sign Up Online"
184 echo '</a></p>'
185 fi
186 }
188 # Login page
189 login_page() {
191 IDLOC=""
192 if [[ "$(GET id)" ]] ;then
193 IDLOC="?id=$(GET id)"
194 fi
195 cat << EOT
196 <h2>$(gettext 'Login')</h2>
198 <div id="account-info">
199 <p>$(gettext "No account yet? You can signup using the SliTaz Bugs reporter \
200 on your SliTaz system.")</p>
201 $(online_signup)
202 <p>$(gettext "Tip: to attach big files or images, you can use SliTaz Paste \
203 services:") <a href="http://paste.slitaz.org/">paste.slitaz.org</a></p>
204 </div>
206 <div id="login">
207 <form method="post" action="$script">
208 <input type="text" name="auth" placeholder="$(gettext 'User name')" />
209 <input type="password" name="pass" placeholder="$(gettext 'Password')" />
210 <div>
211 <input type="submit" value="$(gettext 'Log in')" />
212 $error
213 </div>
214 </form>
215 </div>
217 <div style="clear: both;"></div>
218 EOT
219 }
221 # Display user public profile.
222 public_people() {
223 cat << EOT
224 <pre>
225 $(eval_gettext 'Real name : $NAME')
226 </pre>
227 EOT
228 }
230 # Display authentified user profile. TODO: change password
231 auth_people() {
232 cat << EOT
233 <pre>
234 $(eval_gettext 'Real name : $NAME')
235 $(eval_gettext 'Email : $MAIL')
236 $(eval_gettext 'Secure key : $KEY')
237 </pre>
238 EOT
239 }
241 # Usage: list_bug ID
242 list_bug() {
243 id="$1"
244 . ${bugdir}/${id}/bug.conf
245 [ -f "${PEOPLE}/${CREATOR}/account.conf" ] && \
246 . ${PEOPLE}/${CREATOR}/account.conf
247 cat << EOT
248 <a href="?user=$USER">$(get_gravatar "$MAIL" 24)</a> \
249 ID: $id <strong><a href="?id=$id">$BUG</a></strong> \
250 <span class="date">$DATE</span>
251 EOT
252 unset CREATOR USER MAIL
254 }
256 # Usage: list_bugs STATUS
257 list_bugs() {
258 status="$1"
259 echo "<h3>$(eval_gettext '$status Bugs')</h3>"
260 echo "<pre>"
261 for pr in critical standard
262 do
263 for bug in $(fgrep -H "$1" $bugdir/*/bug.conf | cut -d ":" -f 1)
264 do
265 . $bug
266 id=$(basename $(dirname $bug))
267 if [ "$PRIORITY" == "$pr" ]; then
268 [ -f "${PEOPLE}/${CREATOR}/account.conf" ] && \
269 . ${PEOPLE}/${CREATOR}/account.conf
270 cat << EOT
271 <a href="?user=$USER">$(get_gravatar "$MAIL" 24)</a> \
272 ID: $id <strong><a href="?id=$id">$BUG</a></strong> \
273 <span class="date">$DATE</span>
274 EOT
275 fi
276 unset CREATOR USER MAIL
277 done
278 done
279 }
281 # Stripped down Wiki parser for bug desc and messages which are simply
282 # displayed in <pre>
283 wiki_parser() {
284 sed \
285 -e s"#http://\([^']*\).png#<img src='\0' alt='[ Image ]' />#"g \
286 -e s"#http://\([^']*\).*# <a href='\0'>\1</a>#"g \
287 -e 's#\\\\n#\n#g;s#%22#"#g;s#%21#!#g'
288 }
290 # Bug page
291 bug_page() {
292 if [ -f "$PEOPLE/$CREATOR/account.conf" ]; then
293 . $PEOPLE/$CREATOR/account.conf
294 else
295 MAIL="default"
296 fi
297 cat << EOT
298 <h2>$(eval_gettext 'Bug $id: $STATUS')</h2>
299 <form method="get" action="$script">
301 <p>
302 $(get_gravatar $MAIL 32) <strong>$BUG</strong>
303 </p>
304 <p>
305 $(gettext "Date:") $DATE -
306 $(eval_gettext 'Priority $PRIORITY') -
307 $(eval_ngettext '$msgs message' '$msgs messages' $msgs)
308 </p>
310 <pre>
311 $(echo "$DESC" | wiki_parser)
312 </pre>
314 <div id="tools">
315 EOT
316 if check_auth; then
317 if [ "$STATUS" == "OPEN" ]; then
318 cat << EOT
319 <a href="?id=$id&amp;close">$(gettext "Close bug")</a>
320 <a href="?edit=$id">$(gettext "Edit bug")</a>
321 EOT
322 else
323 cat << EOT
324 <a href="?id=$id&amp;open">$(gettext "Re open bug")</a>
325 EOT
326 fi
327 fi
328 cat << EOT
329 </div>
331 <h3>$(gettext "Messages")</h3>
332 EOT
333 [ "$msgs" == "0" ] && gettext "No messages"
334 for msg in $(ls -1tr $bugdir/$id/msg.*)
335 do
336 . $msg
337 if [ "$MSG" ]; then
338 msgid=$(echo $msg | cut -d "." -f 2)
339 del=""
340 # User can delete his post.
341 [ "$user" == "$USER" ] && \
342 del="<a href=\"?id=$id&amp;delmsg=$msgid\">delete</a>"
343 cat << EOT
344 <p><strong>$USER</strong> $DATE $del</p>
345 <pre>
346 $(echo "$MSG" | wiki_parser)
347 </pre>
348 EOT
349 fi
350 unset NAME DATE MSG
351 done
352 if check_auth; then
353 cat << EOT
354 <div>
355 <h3>$(gettext "New message")</h3>
357 <input type="hidden" name="id" value="$id" />
358 <textarea name="msg" rows="8"></textarea>
359 <p><input type="submit" value="$(gettext 'Send message')" /></p>
360 </form>
361 </div>
362 EOT
363 fi
364 }
366 # Write a new message
367 new_msg() {
368 date=$(date "+%Y-%m-%d %H:%M")
369 msgs=$(ls -1 $bugdir/$id/msg.* | wc -l)
370 count=$(($msgs + 1))
371 if check_auth; then
372 USER="$user"
373 fi
374 js_log "Will write message in $bugdir/$id/msg.$count "
375 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$id/msg.$count << EOT
376 USER="$USER"
377 DATE="$date"
378 MSG="$(GETfiltered msg)"
379 EOT
380 }
382 # Create a new Bug
383 new_bug() {
384 count=$(ls -1 $bugdir | wc -l)
385 date=$(date "+%Y-%m-%d %H:%M")
386 # Sanity check, JS may be disabled.
387 [ ! "$(GET bug)" ] && echo "Missing bug title" && exit 1
388 [ ! "$(GET desc)" ] && echo "Missing bug description" && exit 1
389 if check_auth; then
390 USER="$user"
391 fi
392 mkdir -p $bugdir/$count
393 sed "s/$(echo -en '\r') /\n/g" > $bugdir/$count/bug.conf << EOT
394 # SliTaz Bug configuration
396 BUG="$(GETfiltered bug)"
397 STATUS="OPEN"
398 PRIORITY="$(GET priority)"
399 CREATOR="$USER"
400 DATE="$date"
401 PKGS="$(GETfiltered pkgs)"
403 DESC="$(GETfiltered desc)"
404 EOT
405 }
407 # New bug page for the web interface
408 new_bug_page() {
409 cat << EOT
410 <h2>$(gettext "New Bug")</h2>
411 <div id="newbug">
413 <form method="get" action="$script" onsubmit="return checkNewBug();">
414 <input type="hidden" name="addbug" />
415 <table>
416 <tbody>
417 <tr>
418 <td>$(gettext "Bug title")*</td>
419 <td><input type="text" name="bug" /></td>
420 </tr>
421 <tr>
422 <td>$(gettext "Description")*</td>
423 <td><textarea name="desc"></textarea></td>
424 </tr>
425 <tr>
426 <td>$(gettext "Packages")</td>
427 <td><input type="text" name="pkgs" /></td>
428 </tr>
429 <tr>
430 <td>$(gettext "Priority")</td>
431 <td>
432 <select name="priority">
433 <option value="standard">$(gettext "Standard")</option>
434 <option value="critical">$(gettext "Critical")</option>
435 </select>
436 <input type="submit" value="$(gettext "Create Bug")" />
437 </td>
438 </tr>
439 </tbody>
440 </table>
441 </form>
443 <p>
444 $(gettext "* field is obligatory. You can also specify affected packages.")
445 </p>
447 </div>
448 EOT
449 }
452 # Edit/Save a bug configuration file
453 edit_bug() {
454 cat << EOT
455 <h2>$(eval_gettext 'Edit Bug $bug')</h2>
456 <div id="edit">
458 <form method="get" action="$script">
459 <textarea name="bugconf">$(cat $bugdir/$bug/bug.conf)</textarea>
460 <input type="hidden" name="bug" value="$bug" />
461 <input type="submit" value="$(gettext 'Save configuration')" />
462 </form>
464 </div>
465 EOT
466 }
469 save_bug() {
470 bug="$(GET bug)"
471 content="$(GET bugconf)"
472 sed "s|\"|'|" | sed "s/$(echo -en '\r') /\n/g" > $bugdir/$bug/bug.conf << EOT
473 $content
474 EOT
475 }
478 # Close a fixed bug
479 close_bug() {
480 sed -i s'/OPEN/CLOSED/' $bugdir/$id/bug.conf
481 }
484 # Re open an old bug
485 open_bug() {
486 sed -i s'/CLOSED/OPEN/' $bugdir/$id/bug.conf
487 }
490 # Get and display Gravatar image: get_gravatar email size
491 # Link to profile: <a href="http://www.gravatar.com/$md5">...</a>
492 get_gravatar() {
493 email=$1
494 size=$2
495 [ "$size" ] || size=48
496 url="http://www.gravatar.com/avatar"
497 md5=$(md5crypt $email)
498 echo "<img src=\"$url/$md5?d=identicon&amp;s=$size\" alt=\"\" />"
499 }
501 # Create a new user in AUTH_FILE and PEOPLE
502 new_user_config() {
503 if [ ! "$online" ]; then
504 name="$(GET name)"
505 mail="$(GET mail)"
506 pass="$(GET pass)"
507 echo "Creating Server Key..."
508 fi
509 key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}')
510 echo "$user:$pass" >> $AUTH_FILE
511 mkdir -pm0700 $PEOPLE/$user/
512 cat > $PEOPLE/$user/account.conf << EOT
513 # SliTaz user configuration
514 #
516 NAME="$name"
517 USER="$user"
518 MAIL="$mail"
519 KEY="$key"
521 COMMUNITY="$(GET scn)"
522 LOCATION="$(GET location)"
523 RELEASES="$(GET releases)"
524 PACKAGES="$(GET packages)"
525 EOT
526 chmod 0600 $PEOPLE/$user/account.conf
527 if [ ! -f $PEOPLE/$user/account.conf ]; then
528 echo "ERROR: User creation failed!"
529 fi
530 }
532 ########################################################################
533 # POST actions #
534 ########################################################################
536 case " $(POST) " in
537 *\ auth\ *)
538 header
539 html_header
540 # Authenticate user. Create a session file in $sessions to be used
541 # by check_auth. We have the user login name and a peer session
542 # md5 string in the COOKIE.
543 user="$(POST auth)"
544 pass="$(echo -n "$(POST pass)" | md5sum | awk '{print $1}')"
546 IDLOC=""
547 if [[ "$(GET id)" ]] ;then
548 IDLOC="&id=$(GET id)"
549 fi
551 if [ ! -f $AUTH_FILE ] ; then
552 js_log "$AUTH_FILE (defined in \$AUTH_FILE) has not been found."
553 js_redirection_to "$script?login$IDLOC"
554 fi;
556 valid=$(fgrep "${user}:" $AUTH_FILE | cut -d ":" -f 2)
557 if [ "$pass" == "$valid" ] && [ "$pass" != "" ]; then
558 if [[ "$(GET id)" ]] ;then
559 IDLOC="?id=$(GET id)"
560 fi
561 md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}')
562 mkdir -p $sessions
563 echo "$md5session" > $sessions/$user
564 js_set_cookie 'auth' "$user:$md5session"
565 js_log "Login authentification has been executed & accepted :)"
566 js_redirection_to "$script$IDLOC"
567 else
568 js_log "Login authentification has been executed & refused"
569 js_redirection_to "$script?login&error$IDLOC"
570 fi
571 html_footer ;;
572 *\ signup\ *)
573 # POST action for online signup
574 name="$(POST name)"
575 user="$(POST user)"
576 mail="$(POST mail)"
577 pass="$(md5crypt "$(POST pass)")"
578 if ! grep "^${user}:" $AUTH_FILE; then
579 online="yes"
580 new_user_config
581 header "Location: $SCRIPT_NAME?login"
582 else
583 header
584 html_header
585 user_box
586 echo "<h2>$(gettext "User already exists:") $user</h2>"
587 html_footer && exit 0
588 fi ;;
589 esac
591 #
592 # Plugins Now!
593 #
594 for p in $(ls -1 $plugins)
595 do
596 [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf
597 [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi
598 done
600 ########################################################################
601 # GET actions #
602 ########################################################################
604 case " $(GET) " in
605 *\ README\ *)
606 header
607 html_header
608 user_box
609 echo '<h2>README</h2>'
610 echo '<pre>'
611 if [ -f "README" ]; then
612 cat README
613 else
614 cat /usr/share/doc/tazbug/README
615 fi
616 echo '</pre>'
617 html_footer ;;
618 *\ closed\ *)
619 # Show all closed bugs.
620 header
621 html_header
622 user_box
623 list_bugs CLOSED
624 echo "</pre>"
625 html_footer ;;
626 *\ login\ *)
627 # The login page
628 [ "$(GET error)" ] && \
629 error="<span class='error'>$(gettext 'Bad login or pass')</span>"
630 header
631 html_header
632 user_box
633 login_page
634 html_footer ;;
635 *\ logout\ *)
636 header
637 html_header
638 if check_auth; then
639 rm -f "$sessions/$user"
640 js_unset_cookie 'auth'
641 js_redirection_to "$script"
642 fi ;;
643 *\ user\ *)
644 # User profile
645 header
646 html_header
647 user_box
648 . $PEOPLE/"$(GET user)"/account.conf
649 echo "<h2>$(get_gravatar $MAIL) $(GET user)</h2>"
650 if check_auth && [ "$(GET user)" == "$user" ]; then
651 auth_people
652 else
653 public_people
654 fi
655 html_footer ;;
656 *\ newbug\ *)
657 # Add a bug from web interface.
658 header
659 html_header
660 user_box
661 if check_auth; then
662 new_bug_page
663 else
664 echo "<p>$(gettext 'You must be logged in to post a new bug')</p>"
665 fi
666 html_footer ;;
667 *\ addbug\ *)
668 # Add a bug from web interface.
669 header
670 html_header
671 if check_auth; then
672 new_bug
673 js_redirection_to "$script?id=$count"
674 fi ;;
675 *\ edit\ *)
676 bug="$(GET edit)"
677 header
678 html_header
679 user_box
680 edit_bug
681 html_footer ;;
682 *\ bugconf\ *)
683 header
684 html_header
685 if check_auth; then
686 save_bug
687 js_redirection_to "$script?id=$bug"
688 fi ;;
689 *\ id\ *)
690 # Empty deleted messages to keep msg count working.
691 header
692 html_header
693 id="$(GET id)"
694 [ "$(GET close)" ] && close_bug
695 [ "$(GET open)" ] && open_bug
696 [ "$(GET msg)" ] && new_msg
697 [ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg) && \
698 touch $bugdir/$id/msg.$(GET delmsg)
699 msgs=$(fgrep MSG= $bugdir/$id/msg.* | wc -l)
700 user_box
701 . $bugdir/$id/bug.conf
702 bug_page
703 html_footer ;;
704 *\ signup\ *)
705 # Signup
706 if [ "$(GET online)" ];then
707 header
708 html_header
709 user_box
710 echo "<h2>$(gettext "Sign Up")</h2>"
711 if [ "$ONLINE_SIGNUP" == "yes" ]; then
712 signup_page
713 else
714 gettext "Online registration is disabled"
715 fi
716 html_footer && exit 0
717 else
718 header "Content-type: text/plain;"
719 user="$(GET signup)"
720 echo "Requested user login : $user"
721 if fgrep -q "$user:" $AUTH_FILE; then
722 echo "ERROR: User already exists" && exit 1
723 else
724 echo "Creating account for : $(GET name)"
725 new_user_config
726 fi
727 fi ;;
728 *\ key\ *)
729 # Let user post new bug or message with crypted key (no gettext)
730 #
731 # Testing only and is security acceptable ?
732 #
733 key="$(GET key)"
734 id="$(GET bug)"
735 header "Content-type: text/plain;"
736 echo "Checking secure key..."
737 if fgrep -qH $key $PEOPLE/*/account.conf; then
738 conf=$(fgrep -H $key $PEOPLE/*/account.conf | cut -d ":" -f 1)
739 . $conf
740 echo "Authentified: $NAME ($USER)"
741 case " $(GET) " in
742 *\ msg\ *)
743 [ ! "$id" ] && echo "Missing bug ID" && exit 0
744 echo "Posting new message to bug: $id"
745 echo "Message: $(GET msg)"
746 new_msg ;;
747 *\ bug\ *)
748 echo "Adding new bug: $(GET bug)"
749 echo "Description: $(GET desc)"
750 new_bug ;;
751 esac
752 else
753 echo "Not a valid SliTaz user key"
754 exit 0
755 fi ;;
756 *\ search\ *)
757 header
758 html_header
759 user_box
760 cat << EOT
761 <h2>$(gettext "Search")</h2>
762 <form method="get" action="$script">
763 <input type="text" name="search" />
764 <input type="submit" value="$(gettext 'Search')" />
765 </form>
766 <div>
767 EOT
769 #found=0 JS to notify or write results nb under the search box.
770 for bug in $bugdir/*
771 do
772 result=$(fgrep -i "$(GET search)" $bug/*)
773 if [ "$result" ]; then
774 #found=$(($found + 1))
775 id=${bug#bug/}
776 echo "<p><strong>Bug $id</strong> <a href=\"?id=$id\">"$(gettext 'Show')"</a></p>"
777 echo '<pre>'
778 fgrep -i "$(GET search)" $bugdir/$id/* | \
779 sed s"/$(GET search)/<span class='ok'>$(GET search)<\/span>/"g
780 echo '</pre>'
781 else
782 get_search=$(GET search)
783 echo "<p>$(eval_gettext 'No result found for: $get_search')</p>"
784 fi
785 done
786 echo '</div>'
787 html_footer ;;
788 *)
789 # Default page.
790 bugs=$(ls -1 $bugdir | wc -l)
791 close=$(fgrep "CLOSED" $bugdir/*/bug.conf | wc -l)
792 fixme=$(fgrep "OPEN" $bugdir/*/bug.conf | wc -l)
793 msgs=$(find $bugdir -name msg.* ! -size 0 | wc -l)
794 pct=0
795 [ $bugs -gt 0 ] && pct=$(( ($close * 100) / $bugs ))
796 header
797 html_header
798 user_box
799 cat << EOT
801 <h2>$(gettext "Summary")</h2>
803 <p>
804 $(eval_ngettext 'Bug: $bugs in total -' 'Bugs: $bugs in total -' $bugs)
805 $(eval_ngettext '$close fixed -' '$close fixed -' $close)
806 $(eval_ngettext '$fixme to fix -' '$fixme to fix -' $fixme)
807 $(eval_ngettext '$msgs message' '$msgs messages' $msgs)
808 </p>
810 <div class="pctbar">
811 <div class="pct" style="width: ${pct}%;">${pct}%</div>
812 </div>
814 <p>$(gettext "Please read the <a href=\"?README\">README</a> for help and \
815 more information. You may also be interested by the SliTaz \
816 <a href=\"http://roadmap.slitaz.org/\">Roadmap</a> and the packages \
817 <a href=\"http://cook.slitaz.org/\">Cooker</a>. To perform a search \
818 enter your term and press ENTER.")
819 </p>
821 <div id="tools">
822 <a href="?closed">$(gettext 'View closed bugs')</a>
823 EOT
824 if check_auth; then
825 echo "<a href='?newbug'>$(gettext 'Create a new bug')</a>"
826 echo "$PLUGINS_TOOLS"
827 fi
828 cat << EOT
829 </div>
831 <h3>$(gettext "Latest Bugs")</h3>
832 EOT
833 # List last 3 bugs
834 echo "<pre>"
835 for lb in $(ls -r ${bugdir} | head -n 3)
836 do
837 list_bug ${lb}
838 done
839 echo "</pre>"
840 list_bugs OPEN
841 echo "</pre>"
842 html_footer ;;
843 esac
845 exit 0