tazbug rev 140

Add 'mybugs' plugin with user profile support
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 22 20:51:46 2017 +0100 (2017-02-22)
parents 3a17904702fc
children b4700d7f9d42
files web/images/bug.png web/plugins/mybugs/mybugs.cgi web/plugins/mybugs/mybugs.conf web/plugins/mybugs/user.sh web/plugins/users/users.cgi
line diff
     1.1 Binary file web/images/bug.png has changed
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/web/plugins/mybugs/mybugs.cgi	Wed Feb 22 20:51:46 2017 +0100
     2.3 @@ -0,0 +1,18 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# TinyCM/TazBug Plugin - List bugs for a user
     2.7 +#
     2.8 +
     2.9 +if [ "$(GET mybugs)" ]; then
    2.10 +	d="My bugs"
    2.11 +	header
    2.12 +	html_header
    2.13 +	user_box
    2.14 +	if ! check_auth; then
    2.15 +		echo "You must logged to view user bugs" 
    2.16 +		html_footer && exit 0
    2.17 +	fi
    2.18 +	echo "<h2><a href='?user=$USER'>$(get_gravatar "$MAIL" 48)</a> $USER</h2>"
    2.19 +	. $plugins/mybugs/user.sh
    2.20 +	html_footer && exit 0
    2.21 +fi
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/web/plugins/mybugs/mybugs.conf	Wed Feb 22 20:51:46 2017 +0100
     3.3 @@ -0,0 +1,15 @@
     3.4 +# TinyCM/TazBug Plugin configuration
     3.5 +
     3.6 +PLUGIN="My bugs"
     3.7 +SHORT_DESC="Show bugs for a user (also on profile page)"
     3.8 +MAINTAINER="devel@slitaz.org"
     3.9 +
    3.10 +# All users
    3.11 +BUGS_TOOLS="${BUGS_TOOLS} <a href="?mybugs">My bugs</a>"
    3.12 +
    3.13 +# Authenticated users
    3.14 +PLUGINS_TOOLS="${PLUGINS_TOOLS}"
    3.15 +DASHBOARD_TOOLS="${DASHBOARD_TOOLS}"
    3.16 +
    3.17 +# Admin only in Dashboard
    3.18 +ADMIN_TOOLS="${ADMIN_TOOLS}"
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/web/plugins/mybugs/user.sh	Wed Feb 22 20:51:46 2017 +0100
     4.3 @@ -0,0 +1,20 @@
     4.4 +#!/bin/sh
     4.5 +#
     4.6 +# This script display bug for a given user. A copy is used on SCN to
     4.7 +# display user bugs on profile page with a custom config file to set
     4.8 +# $bugdir.
     4.9 +#
    4.10 +[ -f "$plugins/mybugs/user.conf" ] && . $plugins/mybugs/user.conf
    4.11 +
    4.12 +echo "<h3>My bugs</h3>"
    4.13 +echo "<pre>"
    4.14 +for bug in $(fgrep -l $user ${bugdir}/*/*/bug.conf | xargs ls -lt | awk '{print $9}')
    4.15 +do
    4.16 +	. ${bug}
    4.17 +	id=$(basename $(dirname $bug))
    4.18 +	cat << EOT
    4.19 +<img src='images/bug.png' alt='' /> \
    4.20 +Bug $id: <a href="?id=$id">$BUG</a> <span class="date">- $DATE</span>
    4.21 +EOT
    4.22 +done
    4.23 +echo "</pre>"
     5.1 --- a/web/plugins/users/users.cgi	Wed Feb 22 19:03:30 2017 +0100
     5.2 +++ b/web/plugins/users/users.cgi	Wed Feb 22 20:51:46 2017 +0100
     5.3 @@ -176,14 +176,26 @@
     5.4  		user_box
     5.5  		account_config="$PEOPLE/$(GET user)/account.conf"
     5.6  		profile_config="$PEOPLE/$(GET user)/profile.conf"
     5.7 +		# account.conf
     5.8  		if [ ! -f "$account_config" ]; then
     5.9  			echo "No user profile for: $(GET user)"
    5.10  			html_footer && exit 0
    5.11  		else
    5.12  			. ${account_config}
    5.13  		fi
    5.14 -		[ -f "$profile_config" ] && . ${profile_config}
    5.15 -cat << EOT
    5.16 +		# Init profile.conf
    5.17 +		if [ -f "${profile_config}" ]; then
    5.18 +			. ${profile_config}
    5.19 +		else
    5.20 +			cat > $PEOPLE/$user/profile.conf << EOT
    5.21 +# User profile
    5.22 +WEBSITE="$website"
    5.23 +FACEBOOK="$facebook"
    5.24 +TWITTER="$twitter"
    5.25 +EOT
    5.26 +			chmod 0600 $PEOPLE/$user/profile.conf
    5.27 +		fi
    5.28 +		cat << EOT
    5.29  <h2>$(get_gravatar $MAIL) $NAME</h2>
    5.30  
    5.31  <pre>
    5.32 @@ -198,22 +210,17 @@
    5.33  			public_people
    5.34  		fi
    5.35  		
    5.36 -		# Messages plugin integration
    5.37 -		if [ -x "$plugins/messages/messages.cgi" ]; then
    5.38 -			if check_auth && [ "$(GET user)" != "$user" ]; then
    5.39 -				cat << EOT
    5.40 -<div id="tools">
    5.41 -<a href="$script?messages&amp;to=$(GET user)">$(gettext "Send message")</a>
    5.42 -</div>
    5.43 -EOT
    5.44 -			fi
    5.45 -		fi
    5.46 -		
    5.47  		# Display personal user profile
    5.48  		if [ -f "$PEOPLE/$USER/profile.txt" ]; then
    5.49  			echo "<h2>$(gettext "About me")</h2>"
    5.50  			cat $PEOPLE/$USER/profile.txt | wiki_parser
    5.51  		fi
    5.52 +		
    5.53 +		# Run user.sh that plugins can provide to add content to a profile
    5.54 +		for script in $(ls $plugins/*/user.sh); do
    5.55 +			. ${script}
    5.56 +		done
    5.57 +		
    5.58  		html_footer && exit 0 ;;
    5.59  		
    5.60  	*\ modprofile\ *)