tinycm diff index.cgi @ rev 15
index.cgi: fixes and small improvments
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Jan 04 18:49:08 2014 +0100 (2014-01-04) |
parents | b7629d639756 |
children | 9aa60a355760 |
line diff
1.1 --- a/index.cgi Sat Jan 04 05:46:42 2014 +0100 1.2 +++ b/index.cgi Sat Jan 04 18:49:08 2014 +0100 1.3 @@ -2,7 +2,7 @@ 1.4 # 1.5 # TinyCM - Small, fast and elegent CGI/SHell Content Manager 1.6 # 1.7 -# Copyright (C) 2012 SliTaz GNU/Linux - BSD License 1.8 +# Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License 1.9 # 1.10 . /usr/lib/slitaz/httphelper 1.11 1.12 @@ -19,7 +19,7 @@ 1.13 plugins="plugins" 1.14 tmp="/tmp/tinycm" 1.15 sessions="$tmp/sessions" 1.16 -script=$SCRIPT_NAME 1.17 +script="$SCRIPT_NAME" 1.18 1.19 # Content negotiation for Gettext 1.20 IFS="," 1.21 @@ -272,13 +272,13 @@ 1.22 -e s"#''\([^']*\)''#<em>\1</em>#"g \ 1.23 -e s"#__\([^']*\)__#<u>\1</u>#"g \ 1.24 -e s"#\[\([^]]*\)|\($doc\)\]#<a href='$script?d=\2'>\1</a>#"g \ 1.25 - -e s"#http://\([^']*\).png#<img src='\0' />#"g \ 1.26 + -e s"#http://\([^']*\).png#<img src='\0'> \/>#"g \ 1.27 -e s"#http://\([^']*\).*# <a href='\0'>\1</a>#"g 1.28 #-e s"/^$/<br \/>/"g 1.29 } 1.30 1.31 link_user() { 1.32 - echo "<a href='$script?user=$user'>$user</a>" 1.33 + echo "<a href='$(basename $script)?user=$user'>$user</a>" 1.34 } 1.35 1.36 # Save a document. Do we need more than 1 backup and diff ? 1.37 @@ -432,12 +432,14 @@ 1.38 gettext "You must be logged in to edit pages" 1.39 fi 1.40 html_footer ;; 1.41 + 1.42 *\ save\ *) 1.43 d="$(GET save)" 1.44 if check_auth; then 1.45 save_document 1.46 fi 1.47 header "Location: $script?d=$d" ;; 1.48 + 1.49 *\ log\ *) 1.50 d="$(GET log)" 1.51 header 1.52 @@ -456,6 +458,7 @@ 1.53 wiki_tools 1.54 fi 1.55 html_footer ;; 1.56 + 1.57 *\ diff\ *) 1.58 d="$(GET diff)" 1.59 date="last" 1.60 @@ -479,6 +482,7 @@ 1.61 wiki_tools 1.62 fi 1.63 html_footer ;; 1.64 + 1.65 *\ login\ *) 1.66 # The login page 1.67 d="Login" 1.68 @@ -489,6 +493,7 @@ 1.69 user_box 1.70 login_page 1.71 html_footer ;; 1.72 + 1.73 *\ signup\ *) 1.74 # The login page 1.75 d="$(gettext "Sign Up")" 1.76 @@ -502,6 +507,7 @@ 1.77 gettext "Online registration is disabled" 1.78 fi 1.79 html_footer ;; 1.80 + 1.81 *\ logout\ *) 1.82 # Set a Cookie in the past to logout. 1.83 expires="Expires=Wed, 01-Jan-1980 00:00:00 GMT" 1.84 @@ -509,8 +515,10 @@ 1.85 rm -f "$sessions/$user" 1.86 header "Location: $script" "Set-Cookie: auth=none; $expires; HttpOnly" 1.87 fi ;; 1.88 + 1.89 *\ user\ *) 1.90 # User profile 1.91 + d="$(GET user)" 1.92 header 1.93 html_header 1.94 user_box 1.95 @@ -524,6 +532,7 @@ 1.96 public_people 1.97 fi 1.98 html_footer ;; 1.99 + 1.100 *\ dashboard\ *) 1.101 # For now simply list plugins and users info. We could have a 1.102 # dashbord only for ADMINS found in the config file. The dashboard 1.103 @@ -537,8 +546,8 @@ 1.104 size="$(du -sh $wiki | awk '{print $1}')" 1.105 echo "<h2>$d</h2>" 1.106 if check_auth; then 1.107 - echo "<p>$(gettext "Users:") $users</p>" 1.108 - echo "<p>$(gettext "Documents:") $docs ($size)</p>" 1.109 + echo "<p><b>$(gettext "Users:")</b> $users" 1.110 + echo "| <b>$(gettext "Documents:")</b> $docs ($size)</p>" 1.111 [ "$HG" != "yes" ] && echo $(gettext "Hg is disabled") 1.112 echo "<h3>$(gettext "Plugins")</h3>" 1.113 echo '<pre>' 1.114 @@ -552,6 +561,7 @@ 1.115 gettext "You must be logged in to view the dashboard." 1.116 fi 1.117 html_footer ;; 1.118 + 1.119 *\ hg\ *) 1.120 header 1.121 [ "$HG" != "yes" ] && gettext "Hg is disabled" && exit 0 1.122 @@ -578,6 +588,7 @@ 1.123 esac 1.124 hg_log 1.125 html_footer ;; 1.126 + 1.127 *) 1.128 # Display requested page 1.129 d="$(GET d)" 1.130 @@ -586,6 +597,7 @@ 1.131 html_header 1.132 user_box 1.133 get_lang 1.134 + # Generate a default index on first run. 1.135 if [ ! -f "$wiki/$index.txt" ]; then 1.136 default_index 1.137 fi