# HG changeset patch # User Christophe Lincoln # Date 1388936834 0 # Node ID 558dc3b9d373f60739dac9405dfe378edb525706 # Parent 75c2b9d58c4ea77a7fb5038ce14db639d5c72432 Allow user to have handle a personnal profile page diff -r 75c2b9d58c4e -r 558dc3b9d373 index.cgi --- a/index.cgi Sun Jan 05 08:51:16 2014 +0000 +++ b/index.cgi Sun Jan 05 15:47:14 2014 +0000 @@ -249,6 +249,10 @@ Real name : $NAME EOT + # Display personnal user profile + if [ -f "$PEOPLE/$USER/profile.txt" ]; then + cat $PEOPLE/$USER/profile.txt | wiki_parser + fi } # Display authentified user profile. TODO: change password @@ -260,6 +264,21 @@ Secure key : $KEY EOT + # Each user can have personal profile page + if [ -f "$PEOPLE/$USER/profile.txt" ]; then + cat $PEOPLE/$USER/profile.txt | wiki_parser + cat << EOT +
+ $(gettext "Edit profile") +
+EOT + else + cat << EOT +
+ $(gettext "Create a profile page") +
+EOT + fi } # The CM style parser. Just a title, simple text formating and internal @@ -317,6 +336,15 @@ fi } +# Save a user profile. +save_profile() { + path="$PEOPLE/$user" + cp -f ${path}/${d}.txt ${path}/${d}.bak + sed "s/$(echo -en '\r') /\n/g" > ${path}/${d}.txt << EOT +$(GET content) +EOT +} + # CM tools (edit, diff, etc). wiki_tools() { cat << EOT @@ -416,7 +444,9 @@ user_box get_lang if check_auth; then - get_lang + if [ "$doc" == "profile" ]; then + wiki="$PEOPLE/$user" + fi cat << EOT

$(gettext "Edit $doc [ $i18n ]")

@@ -440,7 +470,13 @@ *\ save\ *) d="$(GET save)" if check_auth; then - save_document + # User profile + if [ "$d" == "profile" ]; then + save_profile + header "Location: $script?user=$user" + else + save_document + fi fi header "Location: $script?d=$d" ;; @@ -535,10 +571,6 @@ else public_people fi - # Each user can have personal profile page - if [ -f "$PEOPLE/$USER/profile.txt" ]; then - cat $PEOPLE/$USER/profile.txt | wiki_parser - fi html_footer ;; *\ dashboard\ *)