tinycm rev 23
Allow user to have handle a personnal profile page
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jan 05 15:47:14 2014 +0000 (2014-01-05) |
parents | 75c2b9d58c4e |
children | a944149de641 |
files | index.cgi |
line diff
1.1 --- a/index.cgi Sun Jan 05 08:51:16 2014 +0000 1.2 +++ b/index.cgi Sun Jan 05 15:47:14 2014 +0000 1.3 @@ -249,6 +249,10 @@ 1.4 Real name : $NAME 1.5 </pre> 1.6 EOT 1.7 + # Display personnal user profile 1.8 + if [ -f "$PEOPLE/$USER/profile.txt" ]; then 1.9 + cat $PEOPLE/$USER/profile.txt | wiki_parser 1.10 + fi 1.11 } 1.12 1.13 # Display authentified user profile. TODO: change password 1.14 @@ -260,6 +264,21 @@ 1.15 Secure key : $KEY 1.16 </pre> 1.17 EOT 1.18 + # Each user can have personal profile page 1.19 + if [ -f "$PEOPLE/$USER/profile.txt" ]; then 1.20 + cat $PEOPLE/$USER/profile.txt | wiki_parser 1.21 + cat << EOT 1.22 +<div id="tools"> 1.23 + <a href="$script?edit=profile">$(gettext "Edit profile")</a> 1.24 +</div> 1.25 +EOT 1.26 + else 1.27 + cat << EOT 1.28 +<div id="tools"> 1.29 + <a href="$script?edit=profile">$(gettext "Create a profile page")</a> 1.30 +</div> 1.31 +EOT 1.32 + fi 1.33 } 1.34 1.35 # The CM style parser. Just a title, simple text formating and internal 1.36 @@ -317,6 +336,15 @@ 1.37 fi 1.38 } 1.39 1.40 +# Save a user profile. 1.41 +save_profile() { 1.42 + path="$PEOPLE/$user" 1.43 + cp -f ${path}/${d}.txt ${path}/${d}.bak 1.44 + sed "s/$(echo -en '\r') /\n/g" > ${path}/${d}.txt << EOT 1.45 +$(GET content) 1.46 +EOT 1.47 +} 1.48 + 1.49 # CM tools (edit, diff, etc). 1.50 wiki_tools() { 1.51 cat << EOT 1.52 @@ -416,7 +444,9 @@ 1.53 user_box 1.54 get_lang 1.55 if check_auth; then 1.56 - get_lang 1.57 + if [ "$doc" == "profile" ]; then 1.58 + wiki="$PEOPLE/$user" 1.59 + fi 1.60 cat << EOT 1.61 <h2>$(gettext "Edit $doc [ $i18n ]")</h2> 1.62 1.63 @@ -440,7 +470,13 @@ 1.64 *\ save\ *) 1.65 d="$(GET save)" 1.66 if check_auth; then 1.67 - save_document 1.68 + # User profile 1.69 + if [ "$d" == "profile" ]; then 1.70 + save_profile 1.71 + header "Location: $script?user=$user" 1.72 + else 1.73 + save_document 1.74 + fi 1.75 fi 1.76 header "Location: $script?d=$d" ;; 1.77 1.78 @@ -535,10 +571,6 @@ 1.79 else 1.80 public_people 1.81 fi 1.82 - # Each user can have personal profile page 1.83 - if [ -f "$PEOPLE/$USER/profile.txt" ]; then 1.84 - cat $PEOPLE/$USER/profile.txt | wiki_parser 1.85 - fi 1.86 html_footer ;; 1.87 1.88 *\ dashboard\ *)