tinycm rev 5
Add tinycm CGI script
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Apr 11 15:59:21 2012 +0200 (2012-04-11) |
parents | 7914154807bb |
children | 1b62b3339583 |
files | config.cgi index.cgi |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config.cgi Wed Apr 11 15:59:21 2012 +0200 1.3 @@ -0,0 +1,23 @@ 1.4 +# CM configuration 1.5 +# 1.6 + 1.7 +# CM URL for redirection and RSS 1.8 +WEB_URL="http://localhost/~pankso/cgi-bin/tinycm/" 1.9 + 1.10 +# Administrator email. 1.11 +ADMIN_MAIL="root@$SERVER_NAME" 1.12 + 1.13 +# Auth file for user 1.14 +AUTH_FILE="/var/lib/slitaz/auth/people" 1.15 + 1.16 +# People config files 1.17 +PEOPLE="/var/lib/slitaz/people" 1.18 + 1.19 +# CM documents languages. 1.20 +LANGUAGES="en fr pt" 1.21 + 1.22 +# Online registration for user 1.23 +ONLINE_SIGNUP="yes" 1.24 + 1.25 +# Use Mercurial repo for content and configure user name 1.26 +HG="yes"
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/index.cgi Wed Apr 11 15:59:21 2012 +0200 2.3 @@ -0,0 +1,612 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# TinyCM - Small, fast and elegent CGI/SHell Content Manager 2.7 +# 2.8 +# Copyright (C) 2012 SliTaz GNU/Linux - BSD License 2.9 +# 2.10 +. /usr/lib/slitaz/httphelper 2.11 + 2.12 +# Let have a peer site config file with a .cgi extension so content 2.13 +# is secure even if left in a web server directory. 2.14 +. config.cgi 2.15 + 2.16 +tiny="$PWD" 2.17 +po="en fr" 2.18 +content="content" 2.19 +wiki="$content/wiki" 2.20 +index="index" 2.21 +cache="cache" 2.22 +plugins="plugins" 2.23 +tmp="/tmp/tinycm" 2.24 +sessions="$tmp/sessions" 2.25 +script=$SCRIPT_NAME 2.26 + 2.27 +# Content negotiation for Gettext 2.28 +IFS="," 2.29 +for lang in $HTTP_ACCEPT_LANGUAGE 2.30 +do 2.31 + lang=${lang%;*} lang=${lang# } lang=${lang%-*} 2.32 + if echo "$po" | fgrep -q "$lang"; then 2.33 + break 2.34 + fi 2.35 + case "$lang" in 2.36 + en) lang="C" ;; 2.37 + fr) lang="fr_FR" ;; 2.38 + pt) lang="pt_BR" ;; 2.39 + ru) lang="ru_RU" ;; 2.40 + esac 2.41 +done 2.42 +unset IFS 2.43 +export LANG=$lang LC_ALL=$lang 2.44 + 2.45 +# 2.46 +# Functions 2.47 +# 2.48 + 2.49 +# Used by edit to display language name and the language box. this is 2.50 +# for CM content not gettext support. 2.51 +get_lang() { 2.52 + lang=$(echo $d | cut -d "/" -f 1) 2.53 + doc=${d#$lang/} 2.54 + echo '<div id="lang">' 2.55 + for l in $LANGUAGES 2.56 + do 2.57 + case $lang in 2.58 + en) i18n="English" ;; 2.59 + fr) i18n="Français" ;; 2.60 + pt) i18n="Português" ;; 2.61 + ru) i18n="Русский" ;; 2.62 + *) i18n="*" ;; 2.63 + esac 2.64 + echo "<a href='?d=$l/$doc'>$l</a>" 2.65 + done 2.66 + echo '</div>' 2.67 +} 2.68 + 2.69 +# HTML 5 header. 2.70 +html_header() { 2.71 + if [ -f "$tiny/lib/header.html" ]; then 2.72 + cat $tiny/lib/header.html | sed -e s!'%TITLE%'!"$TITLE - $d"!g 2.73 + else 2.74 + cat << EOT 2.75 +<!DOCTYPE html> 2.76 +<html xmlns="http://www.w3.org/1999/xhtml"> 2.77 +<head> 2.78 + <title>$TITLE</title> 2.79 + <meta charset="utf-8" /> 2.80 + <style type="text/css">body { margin: 40px 120px; }</style> 2.81 +</head> 2.82 +<body> 2.83 +<!-- Content --> 2.84 +<div id="content"> 2.85 +EOT 2.86 + fi 2.87 +} 2.88 + 2.89 +# HTML 5 footer. 2.90 +html_footer() { 2.91 + if [ -f "$tiny/lib/footer.html" ]; then 2.92 + cat $tiny/lib/footer.html 2.93 + else 2.94 + cat << EOT 2.95 + 2.96 +<!-- End content --> 2.97 +</div> 2.98 + 2.99 +<div id="footer">♥</div> 2.100 + 2.101 +</body> 2.102 +</html> 2.103 +EOT 2.104 + fi 2.105 +} 2.106 + 2.107 +# Default index if missing 2.108 +default_index() { 2.109 + mkdir -p $(dirname $index) 2.110 + cat > $wiki/$index.txt << EOT 2.111 +==== Welcome ==== 2.112 + 2.113 +This is the default index page of your CM, you can edit to start adding 2.114 +some content to your TinyCM. 2.115 + 2.116 +EOT 2.117 +} 2.118 + 2.119 +# Log documents activity. 2.120 +log() { 2.121 + grep ^[A-Z] | \ 2.122 + sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" \ 2.123 + >> $cache/$d/activity.log 2.124 +} 2.125 + 2.126 +# Check if user is auth 2.127 +check_auth() { 2.128 + auth="$(COOKIE auth)" 2.129 + user="$(echo $auth | cut -d ":" -f 1)" 2.130 + md5cookie="$(echo $auth | cut -d ":" -f 2)" 2.131 + [ -f "$sessions/$user" ] && md5session="$(cat $sessions/$user)" 2.132 + if [ "$md5cookie" == "$md5session" ] && [ "$auth" ]; then 2.133 + . $PEOPLE/$user/account.conf 2.134 + return 0 2.135 + else 2.136 + return 1 2.137 + fi 2.138 +} 2.139 + 2.140 +# Authentified or not 2.141 +user_box() { 2.142 + if check_auth; then 2.143 + cat << EOT 2.144 + 2.145 +<div id="user"> 2.146 + <a href="$script?user=$user">$(get_gravatar $MAIL 20)</a> 2.147 + <a href="$script?logout">Logout</a> 2.148 +</div> 2.149 + 2.150 +EOT 2.151 + else 2.152 + cat << EOT 2.153 + 2.154 +<div id="user"> 2.155 + <a href="$script?login"><img src="images/avatar.png" alt="[ User ]" /></a> 2.156 + <a href="$script?login">Login</a> 2.157 +</div> 2.158 + 2.159 +EOT 2.160 + fi 2.161 + cat << EOT 2.162 +<!-- 2.163 +<div id="search"> 2.164 + <form method="get" action="$script"> 2.165 + <input type="text" name="search" placeholder="$(gettext "Search")" /> 2.166 + </form> 2.167 +</div> 2.168 +--> 2.169 +EOT 2.170 +} 2.171 + 2.172 +# Link for online signup if enabled. 2.173 +online_signup() { 2.174 + if [ "$ONLINE_SIGNUP" == "yes" ]; then 2.175 + echo -n "<p><a href='$script?signup'>" 2.176 + gettext "Create a new account" 2.177 + echo '</a></p>' 2.178 + fi 2.179 +} 2.180 + 2.181 +# Login page 2.182 +login_page() { 2.183 + cat << EOT 2.184 +<h2>$(gettext "Login")</h2> 2.185 + 2.186 +<div id="account-info"> 2.187 +$(gettext "Not yet and account or trouble with you account? Please send 2.188 +a request to $ADMIN_MAIL with your real name, user name, mail and password.") 2.189 +$(online_signup) 2.190 +</div> 2.191 + 2.192 +<div id="login"> 2.193 + <form method="post" action="$script"> 2.194 + <input type="text" name="auth" placeholder="$(gettext "User name")" /> 2.195 + <input type="password" name="pass" placeholder="$(gettext "Password")" /> 2.196 + <div> 2.197 + <input type="submit" value="Login" /> $error 2.198 + </div> 2.199 + </form> 2.200 +</div> 2.201 + 2.202 +<div style="clear: both;"></div> 2.203 +EOT 2.204 +} 2.205 + 2.206 +# Signup page 2.207 +signup_page() { 2.208 + cat << EOT 2.209 + 2.210 +<div id="signup"> 2.211 + <form method="post" name="signup" action="$script" onsubmit="return checkSignup();"> 2.212 + <input type="hidden" name="signup" value="new" /> 2.213 + <input type="text" name="name" placeholder="$(gettext "Real name")" /> 2.214 + <input type="text" name="user" placeholder="$(gettext "User name")" /> 2.215 + <input type="text" name="mail" placeholder="$(gettext "Email")" /> 2.216 + <input type="password" name="pass" placeholder="$(gettext "Password")" /> 2.217 + <div> 2.218 + <input type="submit" value="$(gettext "Create new account")" /> 2.219 + </div> 2.220 + </form> 2.221 +</div> 2.222 + 2.223 +EOT 2.224 +} 2.225 + 2.226 +# Create a new user in AUTH_FILE and PEOPLE 2.227 +new_user_config() { 2.228 + key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}') 2.229 + echo "$user:$pass" >> $AUTH_FILE 2.230 + mkdir -p $PEOPLE/$user/ 2.231 + cat > $PEOPLE/$user/account.conf << EOT 2.232 +# SliTaz user configuration 2.233 +# 2.234 + 2.235 +NAME="$name" 2.236 +USER="$user" 2.237 +MAIL="$mail" 2.238 +KEY="$key" 2.239 + 2.240 +EOT 2.241 + chmod 0600 $PEOPLE/$user/account.conf 2.242 +} 2.243 + 2.244 +# Display user public profile. 2.245 +public_people() { 2.246 + cat << EOT 2.247 +<pre> 2.248 +Real name : $NAME 2.249 +</pre> 2.250 +EOT 2.251 +} 2.252 + 2.253 +# Display authentified user profile. TODO: change password 2.254 +auth_people() { 2.255 + cat << EOT 2.256 +<pre> 2.257 +Real name : $NAME 2.258 +Email : $MAIL 2.259 +Secure key : $KEY 2.260 +</pre> 2.261 +EOT 2.262 +} 2.263 + 2.264 +# The CM style parser. Just title, simple text formating and internal 2.265 +# link, as well as images and use HTML for other stuff. Keep it fast! 2.266 +# To make TinyCM as easy as possible we have a small HTML editor/helper 2.267 +# written in Javascript 2.268 +wiki_parser() { 2.269 + doc="[0-9a-zA-Z\.\#/~\_%=\?\&,\+\:@;!\(\)\*\$'\-]*" 2.270 + sed \ 2.271 + -e s"#====\([^']*\)====#<h2>\1</h2>#"g \ 2.272 + -e s"#===\([^']*\)===#<h3>\1</h3>#"g \ 2.273 + -e s"#==\([^']*\)==#<h4>\1</h4>#"g \ 2.274 + -e s"#\*\*\([^']*\)\*\*#<strong>\1</strong>#"g \ 2.275 + -e s"#''\([^']*\)''#<em>\1</em>#"g \ 2.276 + -e s"#__\([^']*\)__#<u>\1</u>#"g \ 2.277 + -e s"#\[\([^]]*\)|\($doc\)\]#<a href='$script?d=\2'>\1</a>#"g \ 2.278 + -e s"#http://\([^']*\).png#<img src='\0' />#"g \ 2.279 + -e s"#http://\([^']*\).*# <a href='\0'>\1</a>#"g 2.280 + #-e s"/^$/<br \/>/"g 2.281 +} 2.282 + 2.283 +link_user() { 2.284 + echo "<a href='$script?user=$user'>$user</a>" 2.285 +} 2.286 + 2.287 +# Save a document. Do we need more than 1 backup and diff ? 2.288 +save_document() { 2.289 + mkdir -p $cache/$d $(dirname $wiki/$d) 2.290 + # May be a new page. 2.291 + if [ ! -f "$wiki/$d.txt" ]; then 2.292 + new=0 2.293 + touch $wiki/$d.txt 2.294 + fi 2.295 + cp $wiki/$d.txt $cache/$d/last.bak 2.296 + sed "s/$(echo -en '\r') /\n/g" > $wiki/$d.txt << EOT 2.297 +$(GET content) 2.298 +EOT 2.299 + diff $cache/$d/last.bak $wiki/$d.txt > $cache/$d/last.diff 2.300 + # Log 2.301 + if [ "$new" ]; then 2.302 + echo "Page created by: $(link_user)" | log 2.303 + if [ "$HG" == "yes" ]; then 2.304 + cd $content && hg -q add 2.305 + hg commit -q -u "$NAME <$MAIL>" -m "Created new document: $d" 2.306 + cd $tiny 2.307 + fi 2.308 + else 2.309 + # Here we will clean log: cat && tail -n 40 2.310 + echo "Page edited by: $(link_user)" | log 2.311 + if [ "$HG" == "yes" ]; then 2.312 + cd $content && hg commit -q -u "$NAME <$MAIL>" \ 2.313 + -m "Edited document: $d" 2.314 + cd $tiny 2.315 + fi 2.316 + fi 2.317 +} 2.318 + 2.319 +# CM tools (edit, diff, etc). 2.320 +wiki_tools() { 2.321 + cat << EOT 2.322 +<div id="tools"> 2.323 + <a href="$script?edit=$d">$(gettext "Edit document")</a> 2.324 + <a href="$script?diff=$d">$(gettext "Last diff")</a> 2.325 + <a href="$script?log=$d">$(gettext "Activity")</a> 2.326 + <a href="$script?dashboard">Dashboard</a> 2.327 + $([ "$HG" == "yes" ] && echo "<a href='$script?hg'>Hg Log</a>") 2.328 +</div> 2.329 +EOT 2.330 +} 2.331 + 2.332 +# Get and display Gravatar image: get_gravatar email size 2.333 +# Link to profile: <a href="http://www.gravatar.com/$md5">...</a> 2.334 +get_gravatar() { 2.335 + email=$1 2.336 + size=$2 2.337 + [ "$size" ] || size=48 2.338 + url="http://www.gravatar.com/avatar" 2.339 + md5=$(md5crypt $email) 2.340 + echo "<img src='$url/$md5?d=identicon&s=$size' alt='∗' />" 2.341 +} 2.342 + 2.343 +# List hg logs 2.344 +hg_log() { 2.345 + cd $content 2.346 + cat << EOT 2.347 +<table> 2.348 + <thead> 2.349 + <td>$(gettext "User")</td> 2.350 + <td>$(gettext "Description")</td> 2.351 + <td>$(gettext "Revision")</td> 2.352 + </thead> 2.353 +EOT 2.354 + hg log --template "<tr><td>{author}</td><td>{desc}</td><td>{rev}</td></tr>\n" 2.355 + echo '</table>' 2.356 +} 2.357 + 2.358 +# 2.359 +# POST actions 2.360 +# 2.361 + 2.362 +case " $(POST) " in 2.363 + *\ auth\ *) 2.364 + # Authenticate user. Create a session file in $sessions to be used 2.365 + # by check_auth. We have the user login name and a peer session 2.366 + # md5 string in the COOKIE. 2.367 + user="$(POST auth)" 2.368 + pass="$(md5crypt "$(POST pass)")" 2.369 + valid=$(fgrep "${user}:" $AUTH_FILE | cut -d ":" -f 2) 2.370 + if [ "$pass" == "$valid" ] && [ "$pass" != "" ]; then 2.371 + md5session=$(echo -n "$$:$user:$pass:$$" | md5sum | awk '{print $1}') 2.372 + [ -d $sessions ] || mkdir -p $sessions 2.373 + echo "$md5session" > $sessions/$user 2.374 + header "Location: $script" \ 2.375 + "Set-Cookie: auth=$user:$md5session; HttpOnly" 2.376 + else 2.377 + header "Location: $script?login&error" 2.378 + fi ;; 2.379 + *\ signup\ *) 2.380 + # POST action for signup 2.381 + name="$(POST name)" 2.382 + user="$(POST user)" 2.383 + mail="$(POST mail)" 2.384 + pass="$(md5crypt "$(POST pass)")" 2.385 + if ! grep "^${user}:" $AUTH_FILE; then 2.386 + new_user_config 2.387 + header "Location: $script?login" 2.388 + else 2.389 + header 2.390 + html_header 2.391 + user_box 2.392 + echo "<h2>gettext "User already exist: $user"</h2>" 2.393 + html_footer 2.394 + fi ;; 2.395 +esac 2.396 + 2.397 +# 2.398 +# Plugins 2.399 +# 2.400 +for p in $(ls -1 $plugins) 2.401 +do 2.402 + [ -f "$plugins/$p/$p.conf" ] && . $plugins/$p/$p.conf 2.403 + [ -x "$plugins/$p/$p.cgi" ] && . $plugins/$p/$p.cgi 2.404 +done 2.405 + 2.406 +# 2.407 +# GET actions 2.408 +# 2.409 + 2.410 +case " $(GET) " in 2.411 + *\ edit\ *) 2.412 + d="$(GET edit)" 2.413 + header 2.414 + html_header 2.415 + user_box 2.416 + get_lang 2.417 + if check_auth; then 2.418 + get_lang 2.419 + cat << EOT 2.420 +<h2>$(gettext "Edit $doc [ $i18n ]")</h2> 2.421 + 2.422 +<div id="edit"> 2.423 + 2.424 +<form method="get" action="$script" name="editor"> 2.425 + <input type="hidden" name="save" value="$d" /> 2.426 + <textarea name="content">$(cat "$wiki/$d.txt")</textarea> 2.427 + <input type="submit" value="$(gettext "Save document")" /> 2.428 + $(gettext "Code Helper:") 2.429 + $(cat lib/jseditor.html) 2.430 +</form> 2.431 + 2.432 +</div> 2.433 +EOT 2.434 + else 2.435 + gettext "You must be logged to edit pages" 2.436 + fi 2.437 + html_footer ;; 2.438 + *\ save\ *) 2.439 + d="$(GET save)" 2.440 + if check_auth; then 2.441 + save_document 2.442 + fi 2.443 + header "Location: $script?d=$d" ;; 2.444 + *\ log\ *) 2.445 + d="$(GET log)" 2.446 + header 2.447 + html_header 2.448 + user_box 2.449 + get_lang 2.450 + echo "<h2>$(gettext "Activity for:") <a href='$script?d=$d'>$d</a></h2>" 2.451 + echo '<pre>' 2.452 + if [ -f "$cache/$d/activity.log" ]; then 2.453 + tac $cache/$d/activity.log 2.454 + else 2.455 + gettext "No log for: $d"; echo 2.456 + fi 2.457 + echo '</pre>' 2.458 + if check_auth; then 2.459 + wiki_tools 2.460 + fi 2.461 + html_footer ;; 2.462 + *\ diff\ *) 2.463 + d="$(GET diff)" 2.464 + date="last" 2.465 + header 2.466 + html_header 2.467 + user_box 2.468 + get_lang 2.469 + echo "<h2>$(gettext "Diff for:") <a href='$script?d=$d'>$d</a></h2>" 2.470 + echo '<pre>' 2.471 + if [ -f "$cache/$d/$date.diff" ]; then 2.472 + cat $cache/$d/$date.diff | sed \ 2.473 + -e 's|&|\&|g' -e 's|<|\<|g' -e 's|>|\>|g' \ 2.474 + -e s"#^-\([^']*\).#<span style='color: red;'>\0</span>#"g \ 2.475 + -e s"#^+\([^']*\).#<span style='color: green;'>\0</span>#"g \ 2.476 + -e s"#@@\([^']*\)@@#<span style='color: blue;'>@@\1@@</span>#"g 2.477 + else 2.478 + gettext "No diff for: $d"; echo 2.479 + fi 2.480 + echo '</pre>' 2.481 + if check_auth; then 2.482 + wiki_tools 2.483 + fi 2.484 + html_footer ;; 2.485 + *\ login\ *) 2.486 + # The login page 2.487 + d="Login" 2.488 + [ "$(GET error)" ] && \ 2.489 + error="<p class="error">$(gettext "Bad login or pass")</p>" 2.490 + header 2.491 + html_header 2.492 + user_box 2.493 + login_page 2.494 + html_footer ;; 2.495 + *\ signup\ *) 2.496 + # The login page 2.497 + d="$(gettext "Sign Up")" 2.498 + header 2.499 + html_header 2.500 + user_box 2.501 + echo "<h2>$d</h2>" 2.502 + if [ "$ONLINE_SIGNUP" == "yes" ]; then 2.503 + signup_page 2.504 + else 2.505 + gettext "Online registration is disable" 2.506 + fi 2.507 + html_footer ;; 2.508 + *\ logout\ *) 2.509 + # Set a Cookie in the past to logout. 2.510 + expires="Expires=Wed, 01-Jan-1980 00:00:00 GMT" 2.511 + if check_auth; then 2.512 + rm -f "$sessions/$user" 2.513 + header "Location: $script" "Set-Cookie: auth=none; $expires; HttpOnly" 2.514 + fi ;; 2.515 + *\ user\ *) 2.516 + # User profile 2.517 + header 2.518 + html_header 2.519 + user_box 2.520 + . $PEOPLE/"$(GET user)"/account.conf 2.521 + echo "<h2>$(get_gravatar $MAIL) $(GET user)</h2>" 2.522 + loglines=$(fgrep $user $(find $cache -name *.log) | wc -l) 2.523 + gettext "Activities:"; echo " $loglines" 2.524 + if check_auth && [ "$(GET user)" == "$user" ]; then 2.525 + auth_people 2.526 + else 2.527 + public_people 2.528 + fi 2.529 + html_footer ;; 2.530 + *\ dashboard\ *) 2.531 + # For now simply list plugins and users info. We could have a 2.532 + # dashbord only for ADMINS found in the config file. The dashboard 2.533 + # should also be a plugin. 2.534 + d="Dashboard" 2.535 + header 2.536 + html_header 2.537 + user_box 2.538 + users=$(ls -1 $PEOPLE | wc -l) 2.539 + docs=$(find $wiki -type f | wc -l) 2.540 + size="$(du -sh $wiki | awk '{print $1}')" 2.541 + echo "<h2>$d</h2>" 2.542 + if check_auth; then 2.543 + echo "<p>$(gettext "Users:") $users</p>" 2.544 + echo "<p>$(gettext "Documents:") $docs ($size)</p>" 2.545 + echo "<h3>$(gettext "Plugins")</h3>" 2.546 + echo '<pre>' 2.547 + for p in $(ls -1 $plugins) 2.548 + do 2.549 + . $plugins/$p/$p.conf 2.550 + echo "<a href='?$p'>$PLUGIN</a> - $SHORT_DESC" 2.551 + done 2.552 + echo '</pre>' 2.553 + else 2.554 + gettext "You must be logged to view the dashboard." 2.555 + fi 2.556 + html_footer ;; 2.557 + *\ hg\ *) 2.558 + header 2.559 + [ "$HG" != "yes" ] && gettext "Hg is disabled" && exit 0 2.560 + [ ! -x /usr/bin/hg ] && gettext "Hg is not installed" && exit 0 2.561 + d="Hg Log" 2.562 + html_header 2.563 + user_box 2.564 + echo "<h2>$d</h2>" 2.565 + case " $(GET hg) " in 2.566 + *\ init\ *) 2.567 + if check_auth; then 2.568 + [ -d "$content/.hg" ] && exit 0 2.569 + echo '<pre>' 2.570 + gettext "Executing: hg init"; echo 2.571 + cd $content/ && hg init 2.572 + echo '[hooks]' > .hg/hgrc 2.573 + echo 'incoming = hg update' >> .hg/hgrc 2.574 + gettext "Adding current content and commiting"; echo 2.575 + [ ! -f "$wiki/index.txt" ] && touch $wiki/$index.txt 2.576 + hg add && hg commit -u "$NAME <$MAIL>" \ 2.577 + -m "Initial commit with curent content" 2.578 + echo '</pre>' && cd .. 2.579 + fi ;; 2.580 + esac 2.581 + hg_log 2.582 + html_footer ;; 2.583 + *) 2.584 + # Display requested page 2.585 + d="$(GET d)" 2.586 + [ "$d" ] || d=$index 2.587 + header 2.588 + html_header 2.589 + user_box 2.590 + get_lang 2.591 + [ ! -f "$wiki/$index.txt" ] && default_index 2.592 + if [ ! -f "$wiki/$d.txt" ]; then 2.593 + echo "<h2>$d</h2>" 2.594 + gettext "The document does not exist. You can create it or read the" 2.595 + echo " <a href='?d=help'>help</a>" 2.596 + else 2.597 + if fgrep NOWIKI $wiki/$d.txt; then 2.598 + cat $wiki/$d.txt 2.599 + else 2.600 + cat $wiki/$d.txt | wiki_parser 2.601 + fi 2.602 + fi 2.603 + if check_auth; then 2.604 + wiki_tools 2.605 + if [ "$HG" == "yes" ] && [ ! -d "$content/.hg" ]; then 2.606 + echo '<p class="error box">' 2.607 + gettext "Mercurial is enabled but no repository found" 2.608 + echo ": <a href='?hg=init'>Hg init</a>" 2.609 + echo '</p>' 2.610 + fi 2.611 + fi 2.612 + html_footer ;; 2.613 +esac 2.614 + 2.615 +exit 0