tinycm view index.cgi @ rev 40
Added tag 1.0 for changeset eea2e04b7436
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Jan 08 00:02:16 2014 +0100 (2014-01-08) |
parents | 41bca604bd31 |
children | 30e39dd19525 |
line source
1 #!/bin/sh
2 #
3 # TinyCM - Small, fast and elegent CGI/SHell Content Manager
4 #
5 # Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
6 #
7 . /usr/lib/slitaz/httphelper
9 # Let's have a peer site config file with a .cgi extension so content
10 # is secure even if left in a web server directory.
11 . config.cgi
13 tiny="$PWD"
14 content="content"
15 wiki="$content/wiki"
16 index="index"
17 cache="cache"
18 plugins="plugins"
19 tmp="/tmp/tinycm"
20 sessions="$tmp/sessions"
21 script="$SCRIPT_NAME"
22 activity="$cache/log/activity.log"
24 # Content negotiation for Gettext
25 IFS=","
26 for lang in $HTTP_ACCEPT_LANGUAGE
27 do
28 lang=${lang%;*} lang=${lang# } lang=${lang%-*}
29 if echo "$po" | fgrep -q "$lang"; then
30 break
31 fi
32 case "$lang" in
33 en) lang="C" ;;
34 fr) lang="fr_FR" ;;
35 pt) lang="pt_BR" ;;
36 ru) lang="ru_RU" ;;
37 esac
38 done
39 unset IFS
40 export LANG=$lang LC_ALL=$lang
42 #
43 # Functions
44 #
46 # Used by edit to display language name and the language box. This is
47 # for CM content not gettext support.
48 get_lang() {
49 lang=$(echo $d | cut -d "/" -f 1)
50 doc=${d#$lang/}
51 echo '<div id="lang">'
52 for l in $LANGUAGES
53 do
54 case $lang in
55 en) i18n="English" ;;
56 fr) i18n="Français" ;;
57 pt) i18n="Português" ;;
58 ru) i18n="Русский" ;;
59 *) i18n="*" ;;
60 esac
61 echo "<a href='?d=$l/$doc'>$l</a>"
62 done
63 echo '</div>'
64 }
66 # HTML 5 header.
67 html_header() {
68 if [ -f "$tiny/lib/header.html" ]; then
69 cat $tiny/lib/header.html | sed -e s!'%TITLE%'!"$TITLE - $d"!g
70 else
71 cat << EOT
72 <!DOCTYPE html>
73 <html xmlns="http://www.w3.org/1999/xhtml">
74 <head>
75 <title>$TITLE</title>
76 <meta charset="utf-8" />
77 <style type="text/css">body { margin: 40px 120px; }</style>
78 </head>
79 <body>
80 <!-- Content -->
81 <div id="content">
82 EOT
83 fi
84 }
86 # HTML 5 footer.
87 html_footer() {
88 if [ -f "$tiny/lib/footer.html" ]; then
89 cat $tiny/lib/footer.html
90 else
91 cat << EOT
93 <!-- End content -->
94 </div>
96 <div id="footer">♥</div>
98 </body>
99 </html>
100 EOT
101 fi
102 }
104 # Default index if missing
105 default_index() {
106 mkdir -p "$wiki"
107 cat > $wiki/$index.txt << EOT
108 ==== Welcome ====
110 <p>
111 This is the default index page of your TinyCM, you can login then start to
112 edit and adding some content. You can read the help about text formating
113 and functions: <a href='?d=en/help'>Help page</a>
114 </p>
116 EOT
117 }
119 # Log main activity.
120 log_activity() {
121 [ -d "$cache/log" ] || mkdir -p ${cache}/log
122 #gravatar="$(get_gravatar $MAIL 24)"
123 grep ^[A-Z] | \
124 sed s"#^[A-Z]\([^']*\)#$user|$(date '+%Y-%m-%d')|\0#" \
125 >> $cache/log/activity.log
126 }
128 # Log documents activity.
129 log() {
130 grep ^[A-Z] | \
131 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" \
132 >> $cache/$d/activity.log
133 }
135 # Check if user is auth
136 check_auth() {
137 auth="$(COOKIE auth)"
138 user="$(echo $auth | cut -d ":" -f 1)"
139 md5cookie="$(echo $auth | cut -d ":" -f 2)"
140 [ -f "$sessions/$user" ] && md5session="$(cat $sessions/$user)"
141 if [ "$md5cookie" == "$md5session" ] && [ "$auth" ]; then
142 . $PEOPLE/$user/account.conf
143 return 0
144 else
145 return 1
146 fi
147 }
149 # Check if user is admin
150 admin_user() {
151 fgrep -q 'ADMIN_USER="yes"' ${PEOPLE}/${user}/account.conf
152 }
154 # Authentified or not
155 user_box() {
156 if check_auth; then
157 cat << EOT
159 <div id="user">
160 <a href="$script?user=$user">$(get_gravatar $MAIL 20)</a>
161 <a href="$script?logout">Logout</a>
162 </div>
164 EOT
165 else
166 cat << EOT
168 <div id="user">
169 <a href="$script?login"><img src="images/avatar.png" alt="[ User ]" /></a>
170 <a href="$script?login">Login</a>
171 </div>
173 EOT
174 fi
175 cat << EOT
176 <!--
177 <div id="search">
178 <form method="get" action="$script">
179 <input type="text" name="search" placeholder="$(gettext "Search")" />
180 </form>
181 </div>
182 -->
183 EOT
184 }
186 # Link for online signup if enabled.
187 online_signup() {
188 if [ "$ONLINE_SIGNUP" == "yes" ]; then
189 echo -n "<p><a href='$script?signup'>"
190 gettext "Create a new account"
191 echo '</a></p>'
192 fi
193 }
195 # Login page
196 login_page() {
197 cat << EOT
198 <h2>$(gettext "Login")</h2>
200 <div id="account-info">
201 $(gettext "No account yet or trouble with you account? Please send
202 a request to $ADMIN_MAIL with your real name, user name, mail and password.")
203 $(online_signup)
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="Login" /> $error
212 </div>
213 </form>
214 </div>
216 <div style="clear: both;"></div>
217 EOT
218 }
220 # Signup page
221 signup_page() {
222 cat << EOT
224 <div id="signup">
225 <form method="post" name="signup" action="$script" onsubmit="return checkSignup();">
226 <input type="hidden" name="signup" value="new" />
227 <input type="text" name="name" placeholder="$(gettext "Real name")" />
228 <input type="text" name="user" placeholder="$(gettext "User name")" />
229 <input type="text" name="mail" placeholder="$(gettext "Email")" />
230 <input type="password" name="pass" placeholder="$(gettext "Password")" />
231 <div>
232 <input type="submit" value="$(gettext "Create new account")" />
233 </div>
234 </form>
235 </div>
237 EOT
238 }
240 # Create a new user in AUTH_FILE and PEOPLE
241 new_user_config() {
242 if [ ! -f "$AUTH_FILE" ];then
243 touch $(DESTDIR)$(LOGIN)/auth/people
244 chmod 0600 $(DESTDIR)$(LOGIN)/auth/people
245 fi
246 key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}')
247 echo "$user:$pass" >> $AUTH_FILE
248 mkdir -p $PEOPLE/$user/
249 cat > $PEOPLE/$user/account.conf << EOT
250 # SliTaz user configuration
251 #
253 NAME="$name"
254 USER="$user"
255 MAIL="$mail"
256 KEY="$key"
258 EOT
259 chmod 0600 $PEOPLE/$user/account.conf
260 # First created user is admin
261 if [ $(ls ${PEOPLE} | wc -l) == "1" ]; then
262 echo 'ADMIN_USER="yes"' >> $PEOPLE/$user/account.conf
263 fi
264 }
266 # Display user public profile.
267 public_people() {
268 echo "</pre>"
269 # Display personnal user profile
270 if [ -f "$PEOPLE/$USER/profile.txt" ]; then
271 cat $PEOPLE/$USER/profile.txt | wiki_parser
272 fi
273 }
275 # Display authentified user profile. TODO: change password
276 auth_people() {
277 cat << EOT
278 Email : $MAIL
279 Secure key : $KEY
280 </pre>
281 EOT
282 # Each user can have personal profile page
283 if [ -f "$PEOPLE/$USER/profile.txt" ]; then
284 cat $PEOPLE/$USER/profile.txt | wiki_parser
285 cat << EOT
286 <div id="tools">
287 <a href="$script?edit=profile">$(gettext "Edit profile")</a>
288 </div>
289 EOT
290 else
291 cat << EOT
292 <div id="tools">
293 <a href="$script?edit=profile">$(gettext "Create a profile page")</a>
294 </div>
295 EOT
296 fi
297 }
299 # The CM style parser. Just a title, simple text formating and internal
300 # links, as well as images and use HTML for other stuff. Keep it fast!
301 # To make TinyCM as easy as possible we have a small HTML editor/helper
302 # written in Javascript
303 wiki_parser() {
304 doc="[0-9a-zA-Z\.\#/~\_%=\?\&,\+\:@;!\(\)\*\$'\-]*"
305 sed \
306 -e s"#====\([^']*\)====#<h2>\1</h2>#"g \
307 -e s"#===\([^']*\)===#<h3>\1</h3>#"g \
308 -e s"#==\([^']*\)==#<h4>\1</h4>#"g \
309 -e s"#\*\*\([^']*\)\*\*#<b>\1</b>#"g \
310 -e s"#''\([^']*\)''#<em>\1</em>#"g \
311 -e s"#__\([^']*\)__#<u>\1</u>#"g \
312 -e s"#\[\([^]]*\)|\($doc\)\]#<a href='$script?d=\2'>\1</a>#"g \
313 -e s"#\[\([^]]*\)!\($doc\)\]#<a href='\2'>\1</a>#"g \
314 -e s"#\[\(http://*[^]]*.png\)\]#<img src='\1' />#"g \
315 -e s"#\[\([^]]*.png\)\]#<img src='content/cloud/\1' />#"g
316 }
318 link_user() {
319 echo "<a href='$(basename $script)?user=$user'>$user</a>"
320 }
322 # Save a document. Do we need more than 1 backup and diff ?
323 save_document() {
324 mkdir -p $cache/$d $(dirname $wiki/$d)
325 # May be a new page.
326 if [ ! -f "$wiki/$d.txt" ]; then
327 new=0
328 touch $wiki/$d.txt
329 fi
330 cp $wiki/$d.txt $cache/$d/last.bak
331 sed "s/$(echo -en '\r') /\n/g" > $wiki/$d.txt << EOT
332 $(GET content)
333 EOT
334 diff $cache/$d/last.bak $wiki/$d.txt > $cache/$d/last.diff
335 # Log
336 if [ "$new" ]; then
337 echo "Page created by: $(link_user)" | log
338 echo "New document: <a href='$script?d=$d'>$d</a>" | log_activity
339 if [ "$HG" == "yes" ]; then
340 cd $content && hg -q add
341 hg commit -q -u "$NAME <$MAIL>" -m "Created new document: $d"
342 cd $tiny
343 fi
344 else
345 # Here we may clean log: cat && tail -n 40
346 echo "Page edited by: $(link_user)" | log
347 if [ "$HG" == "yes" ]; then
348 cd $content && hg commit -q -u "$NAME <$MAIL>" \
349 -m "Edited document: $d"
350 cd $tiny
351 fi
352 fi
353 }
355 # Save a user profile.
356 save_profile() {
357 path="$PEOPLE/$user"
358 cp -f ${path}/${d}.txt ${path}/${d}.bak
359 sed "s/$(echo -en '\r') /\n/g" > ${path}/${d}.txt << EOT
360 $(GET content)
361 EOT
362 }
364 # CM tools (edit, diff, etc).
365 wiki_tools() {
366 cat << EOT
367 <div id="tools">
368 <a href="$script?edit=$d">$(gettext "Edit document")</a>
369 <a href="$script?diff=$d">$(gettext "Last diff")</a>
370 <a href="$script?log=$d">$(gettext "File log")</a>
371 <a href="$script?dashboard">$(gettext "Dashboard")</a>
372 $([ "$HG" == "yes" ] && echo "<a href='$script?hg'>Hg Log</a>")
373 </div>
374 EOT
375 }
377 # Get and display Gravatar image: get_gravatar email size
378 # Link to profile: <a href="http://www.gravatar.com/$md5">...</a>
379 get_gravatar() {
380 email=$1
381 size=$2
382 [ "$size" ] || size=48
383 url="http://www.gravatar.com/avatar"
384 md5=$(md5crypt $email)
385 echo "<img src='$url/$md5?d=identicon&s=$size' alt='∗' />"
386 }
388 # List hg logs
389 hg_log() {
390 cd $content
391 cat << EOT
392 <table>
393 <thead>
394 <td>$(gettext "User")</td>
395 <td>$(gettext "Description")</td>
396 <td>$(gettext "Revision")</td>
397 </thead>
398 EOT
399 hg log --template "<tr><td>{author}</td><td>{desc}</td><td>{rev}</td></tr>\n"
400 echo '</table>'
401 }
403 #
404 # POST actions
405 #
407 case " $(POST) " in
408 *\ auth\ *)
409 # Authenticate user. Create a session file in $sessions to be used
410 # by check_auth. We have the user login name and a peer session
411 # md5 string in the COOKIE.
412 user="$(POST auth)"
413 pass="$(md5crypt "$(POST pass)")"
414 valid=$(fgrep "${user}:" $AUTH_FILE | cut -d ":" -f 2)
415 if [ "$pass" == "$valid" ] && [ "$pass" != "" ]; then
416 md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}')
417 [ -d $sessions ] || mkdir -p $sessions
418 date '+%Y-%m-%d' > ${PEOPLE}/${user}/last
419 echo "$md5session" > $sessions/$user
420 header "Location: $script" \
421 "Set-Cookie: auth=$user:$md5session; HttpOnly"
422 else
423 header "Location: $script?login&error"
424 fi ;;
425 *\ signup\ *)
426 # POST action for signup
427 name="$(POST name)"
428 user="$(POST user)"
429 mail="$(POST mail)"
430 pass="$(md5crypt "$(POST pass)")"
431 if ! grep "^${user}:" $AUTH_FILE; then
432 new_user_config
433 header "Location: $script?login"
434 else
435 header
436 html_header
437 user_box
438 echo "<h2>gettext "User already exists: $user"</h2>"
439 html_footer
440 fi ;;
441 esac
443 #
444 # Plugins
445 #
446 for p in $(ls -1 $plugins)
447 do
448 [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf
449 [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi
450 done
452 #
453 # GET actions
454 #
456 case " $(GET) " in
457 *\ edit\ *)
458 d="$(GET edit)"
459 header
460 html_header
461 user_box
462 get_lang
463 if check_auth; then
464 if [ "$doc" == "profile" ]; then
465 wiki="$PEOPLE/$user"
466 fi
467 cat << EOT
468 <h2>$(gettext "Edit $doc [ $i18n ]")</h2>
470 <div id="edit">
472 <form method="get" action="$script" name="editor">
473 <input type="hidden" name="save" value="$d" />
474 <textarea name="content">$(cat "$wiki/$d.txt")</textarea>
475 <input type="submit" value="$(gettext "Save document")" />
476 $(gettext "Code Helper:")
477 $(cat lib/jseditor.html)
478 </form>
480 </div>
481 EOT
482 else
483 gettext "You must be logged in to edit pages"
484 fi
485 html_footer ;;
487 *\ save\ *)
488 d="$(GET save)"
489 if check_auth; then
490 # User profile
491 if [ "$d" == "profile" ]; then
492 save_profile
493 header "Location: $script?user=$user"
494 else
495 save_document
496 fi
497 fi
498 header "Location: $script?d=$d" ;;
500 *\ log\ *)
501 d="$(GET log)"
502 header
503 html_header
504 user_box
505 # Main activity
506 if [ "$d" == "log" ]; then
507 echo "<h2>$(gettext "Activity")</h2>"
508 if check_auth; then
509 echo "<div id='tools'>"
510 echo "<a href='$script?dashboard'>Dashboard</a>"
511 echo "</div>"
512 fi
513 echo '<pre>'
514 if [ -f "$cache/log/activity.log" ]; then
515 IFS="|"
516 tac $cache/log/activity.log | while read USER DATE LOG
517 do
518 . ${PEOPLE}/${USER}/account.conf
519 cat << EOT
520 <a href='$script?user=$USER'>$(get_gravatar $MAIL 24)</a>\
521 <span class='date'>$DATE -</span> $LOG
522 EOT
523 done
524 unset IFS
525 else
526 gettext "No activity log yet"; echo
527 fi
528 echo '</pre>'
529 html_footer && exit 0
530 fi
531 get_lang
532 echo "<h2>$(gettext "Activity for:") <a href='$script?d=$d'>$d</a></h2>"
533 echo '<pre>'
534 if [ -f "$cache/$d/activity.log" ]; then
535 tac $cache/$d/activity.log
536 else
537 gettext "No log for: $d"; echo
538 fi
539 echo '</pre>'
540 if check_auth; then
541 wiki_tools
542 fi
543 html_footer ;;
545 *\ ls\ *)
546 d="Document list"
547 header
548 html_header
549 user_box
550 echo "<h2>$(gettext "Document list")</h2>"
551 if check_auth; then
552 echo "<div id='tools'>"
553 echo "<a href='$script?dashboard'>Dashboard</a>"
554 echo "</div>"
555 fi
556 echo '<pre>'
557 cd ${wiki}
558 for d in $(find . -type f | sed s'/.\///')
559 do
560 echo "<a href='$script?d=${d%.txt}'>${d%.txt}</a>"
561 done
562 echo '</pre>'
563 html_footer ;;
565 *\ diff\ *)
566 d="$(GET diff)"
567 date="last"
568 header
569 html_header
570 user_box
571 get_lang
572 echo "<h2>$(gettext "Diff for:") <a href='$script?d=$d'>$d</a></h2>"
573 echo '<pre>'
574 if [ -f "$cache/$d/$date.diff" ]; then
575 cat $cache/$d/$date.diff | sed \
576 -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' \
577 -e s"#^-\([^']*\).#<span style='color: red;'>\0</span>#"g \
578 -e s"#^+\([^']*\).#<span style='color: green;'>\0</span>#"g \
579 -e s"#@@\([^']*\)@@#<span style='color: blue;'>@@\1@@</span>#"g
580 else
581 gettext "No diff for: $d"; echo
582 fi
583 echo '</pre>'
584 if check_auth; then
585 wiki_tools
586 fi
587 html_footer ;;
589 *\ login\ *)
590 # The login page
591 d="Login"
592 [ "$(GET error)" ] && \
593 error="<p class="error">$(gettext "Bad login or pass")</p>"
594 header
595 html_header
596 user_box
597 login_page
598 html_footer ;;
600 *\ signup\ *)
601 # The login page
602 d="$(gettext "Sign Up")"
603 header
604 html_header
605 user_box
606 echo "<h2>$d</h2>"
607 if [ "$ONLINE_SIGNUP" == "yes" ]; then
608 signup_page
609 else
610 gettext "Online registration is disabled"
611 fi
612 html_footer ;;
614 *\ logout\ *)
615 # Set a Cookie in the past to logout.
616 expires="Expires=Wed, 01-Jan-1980 00:00:00 GMT"
617 if check_auth; then
618 rm -f "$sessions/$user"
619 header "Location: $script" "Set-Cookie: auth=none; $expires; HttpOnly"
620 fi ;;
622 *\ user\ *)
623 # User profile
624 d="$(GET user)"
625 last="$(cat $PEOPLE/"$(GET user)"/last)"
626 header
627 html_header
628 user_box
629 . $PEOPLE/"$(GET user)"/account.conf
630 cat << EOT
631 <h2>$(get_gravatar $MAIL) $NAME</h2>
633 <pre>
634 $(gettext "User name :") $USER
635 $(gettext "Last login :") $last
636 EOT
637 if check_auth && [ "$(GET user)" == "$user" ]; then
638 auth_people
639 else
640 # check_auth will set VARS to current logged user: re-source
641 . $PEOPLE/"$(GET user)"/account.conf
642 public_people
643 fi
644 html_footer ;;
646 *\ dashboard\ *)
647 # For now simply list plugins and users info. We could have a
648 # dashbord only for ADMINS found in the config file. The dashboard
649 # should also be a plugin.
650 d="Dashboard"
651 header
652 html_header
653 user_box
654 users=$(ls -1 $PEOPLE | wc -l)
655 docs=$(find $wiki -type f | wc -l)
656 wikisize="$(du -sh $wiki | awk '{print $1}')"
657 cachesize="$(du -sh $cache | awk '{print $1}')"
658 [ "$HG" != "yes" ] && hg=$(gettext "disabled")
659 [ "$HG" == "yes" ] && hg=$(gettext "enabled")
660 # Source all plugins.conf to get DASHBOARD_TOOLS and ADMIN_TOOLS
661 ADMIN_TOOLS=""
662 DASHBOARD_TOOLS=""
663 for p in $(ls $plugins)
664 do
665 . $plugins/$p/$p.conf
666 done
667 if check_auth && ! admin_user; then
668 ADMIN_TOOLS=""
669 fi
670 echo "<h2>$d</h2>"
671 if check_auth; then
672 cat << EOT
673 <div id="tools">
674 <a href='$script?log'>Activity log</a>
675 <a href='$script?ls'>List files</a>
676 $DASHBOARD_TOOLS
677 $ADMIN_TOOLS
678 </div>
680 <pre>
681 Users : $users
682 Wiki : $docs ($wikisize)
683 Cache : $cachesize
684 Mercurial : $hg
685 </pre>
686 <h3>Admin users</h3>
687 EOT
688 # Get the list of administrators
689 for u in $(ls $PEOPLE)
690 do
691 user=${u}
692 if admin_user; then
693 echo "<a href='?user=$u'>$u</a>"
694 fi
695 done
696 cat << EOT
697 <h3>$(gettext "Plugins")</h3>
698 <pre>
699 EOT
700 for p in $(ls -1 $plugins)
701 do
702 . $plugins/$p/$p.conf
703 echo "<a href='?$p'>$PLUGIN</a> - $SHORT_DESC"
704 done
705 echo '</pre>'
706 else
707 gettext "You must be logged in to view the dashboard."
708 fi
709 html_footer ;;
711 *\ hg\ *)
712 header
713 [ "$HG" != "yes" ] && gettext "Hg is disabled" && exit 0
714 [ ! -x /usr/bin/hg ] && gettext "Hg is not installed" && exit 0
715 d="Hg Log"
716 html_header
717 user_box
718 echo "<h2>$d</h2>"
719 case " $(GET hg) " in
720 *\ init\ *)
721 if check_auth; then
722 [ -d "$content/.hg" ] && exit 0
723 echo '<pre>'
724 gettext "Executing: hg init"; echo
725 cd $content/ && hg init
726 echo '[hooks]' > .hg/hgrc
727 echo 'incoming = hg update' >> .hg/hgrc
728 gettext "Adding current content and committing"; echo
729 [ ! -f "$wiki/index.txt" ] && touch $wiki/$index.txt
730 hg add && hg commit -u "$NAME <$MAIL>" \
731 -m "Initial commit with current content"
732 echo '</pre>' && cd ..
733 fi ;;
734 esac
735 hg_log
736 html_footer ;;
738 *)
739 # Display requested page
740 d="$(GET d)"
741 [ "$d" ] || d=$index
742 header
743 html_header
744 user_box
745 get_lang
746 # Generate a default index on first run
747 if [ ! -f "$wiki/$index.txt" ]; then
748 if ! default_index; then
749 echo "<pre class='error'>Directory : content/ is not writable</pre>"
750 html_footer && exit 0
751 fi
752 fi
753 # Check cache dir
754 if [ ! -w "$cache" ]; then
755 echo "<pre class='error'>Directory : cache/ is not writable"
756 echo "Command : install -m 0777 -d $tiny/cache</pre>"
757 html_footer && exit 0
758 fi
759 # Wiki document
760 if [ ! -f "$wiki/$d.txt" ]; then
761 echo "<h2>$d</h2>"
762 gettext "The document does not exist. You can create it or read the"
763 echo " <a href='?d=en/help'>help</a>"
764 else
765 if fgrep -q [NOWIKI] $wiki/$d.txt; then
766 cat $wiki/$d.txt | sed '/\[NOWIKI\]/'d
767 else
768 cat $wiki/$d.txt | wiki_parser
769 fi
770 fi
771 if check_auth; then
772 wiki_tools
773 if [ "$HG" == "yes" ] && [ ! -d "$content/.hg" ]; then
774 echo '<p class="error box">'
775 gettext "Mercurial is enabled but no repository found"
776 echo ": <a href='?hg=init'>Hg init</a>"
777 echo '</p>'
778 fi
779 fi
780 html_footer ;;
781 esac
783 exit 0