tinycm diff index.cgi @ rev 76

Move user profile stuff to plugin and improve user functions
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 10 22:53:14 2017 +0100 (2017-02-10)
parents 007a950f9808
children 2778498112c0
line diff
     1.1 --- a/index.cgi	Sun Feb 16 23:36:43 2014 +0100
     1.2 +++ b/index.cgi	Fri Feb 10 22:53:14 2017 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4  #
     1.5  # TinyCM - Small, fast and elegant CGI/SHell Content Manager
     1.6  #
     1.7 -# Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
     1.8 +# Copyright (C) 2012-2017 SliTaz GNU/Linux - BSD License
     1.9  #
    1.10  . /usr/lib/slitaz/httphelper
    1.11  
    1.12 @@ -267,41 +267,6 @@
    1.13  	fi
    1.14  }
    1.15  
    1.16 -# Display user public profile.
    1.17 -public_people() {
    1.18 -	echo "</pre>"
    1.19 -	# Display personal user profile
    1.20 -	if [ -f "$PEOPLE/$USER/profile.txt" ]; then
    1.21 -		cat $PEOPLE/$USER/profile.txt | wiki_parser
    1.22 -	fi
    1.23 -}
    1.24 -
    1.25 -# Display authenticated user profile. TODO: change password
    1.26 -auth_people() {
    1.27 -	cat << EOT
    1.28 -Email      : $MAIL
    1.29 -Secure key : $KEY
    1.30 -</pre>
    1.31 -EOT
    1.32 -	# Each user can have personal profile page
    1.33 -	if [ -f "$PEOPLE/$USER/profile.txt" ]; then
    1.34 -		cat $PEOPLE/$USER/profile.txt | wiki_parser
    1.35 -		cat << EOT
    1.36 -<div id="tools">
    1.37 -	<a href="$script?edit=profile">$(gettext "Edit profile")</a>
    1.38 -	<a href="$script?dashboard">Dashboard</a>
    1.39 -</div>
    1.40 -EOT
    1.41 -	else
    1.42 -		cat << EOT
    1.43 -<div id="tools">
    1.44 -	<a href="$script?edit=profile">$(gettext "Create a profile page")</a>
    1.45 -	<a href="$script?dashboard">Dashboard</a>
    1.46 -</div>
    1.47 -EOT
    1.48 -	fi
    1.49 -}
    1.50 -
    1.51  # The CM style parser. Just a title, simple text formatting and internal
    1.52  # links, as well as images and use HTML for other stuff. Keep it fast!
    1.53  # To make TinyCM as easy as possible we have a small HTML editor/helper
    1.54 @@ -358,15 +323,6 @@
    1.55  	fi
    1.56  }
    1.57  
    1.58 -# Save a user profile.
    1.59 -save_profile() {
    1.60 -	path="$PEOPLE/$user"
    1.61 -	cp -f ${path}/${d}.txt ${path}/${d}.bak
    1.62 -	sed "s/$(echo -en '\r') /\n/g" > ${path}/${d}.txt << EOT
    1.63 -$(GET content)
    1.64 -EOT
    1.65 -}
    1.66 -
    1.67  # CM tools (edit, diff, etc) for auth users
    1.68  wiki_tools() {
    1.69  	if check_auth; then
    1.70 @@ -483,9 +439,6 @@
    1.71  		get_lang
    1.72  		wiki_tools
    1.73  		if check_auth; then
    1.74 -			if [ "$doc" == "profile" ]; then
    1.75 -				wiki="$PEOPLE/$user"
    1.76 -			fi
    1.77  			cat << EOT
    1.78  <h2>$(gettext "Edit $doc [ $i18n ]")</h2>
    1.79  
    1.80 @@ -509,13 +462,7 @@
    1.81  	*\ save\ *)
    1.82  		d="$(GET save)"
    1.83  		if check_auth; then
    1.84 -			# User profile
    1.85 -			if [ "$d" == "profile" ]; then
    1.86 -				save_profile
    1.87 -				header "Location: $script?user=$user"
    1.88 -			else
    1.89 -				save_document
    1.90 -			fi
    1.91 +			save_document
    1.92  		fi 
    1.93  		header "Location: $script?d=$d" ;;
    1.94  		
    1.95 @@ -647,7 +594,7 @@
    1.96  		fi ;;
    1.97  		
    1.98  	*\ user\ *)
    1.99 -		# User profile
   1.100 +		# Basic user profile. Use the users plugin for more functions
   1.101  		d="$(GET user)"
   1.102  		last="$(cat $PEOPLE/"$(GET user)"/last)"
   1.103  		header
   1.104 @@ -660,14 +607,8 @@
   1.105  <pre>
   1.106  $(gettext "User name  :") $USER
   1.107  $(gettext "Last login :") $last
   1.108 +</pre>
   1.109  EOT
   1.110 -		if check_auth && [ "$(GET user)" == "$user" ]; then
   1.111 -			auth_people
   1.112 -		else
   1.113 -			# check_auth will set VARS to current logged user: re-source
   1.114 -			. $PEOPLE/"$(GET user)"/account.conf
   1.115 -			public_people
   1.116 -		fi
   1.117  		html_footer ;;
   1.118  		
   1.119  	*\ hg\ *)