tinycm diff plugins/community/community.cgi @ rev 86
Update French translation
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Feb 12 00:13:50 2017 +0100 (2017-02-12) |
parents | |
children | b3511ea2c6a6 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/plugins/community/community.cgi Sun Feb 12 00:13:50 2017 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# TinyCM/TazBug Plugin - Community Tools 1.7 +# 1.8 + 1.9 +case " $(GET) " in 1.10 + *\ wall\ *) 1.11 + d="Community Wall" 1.12 + wall="$tiny/$content/wall" 1.13 + date=$(date '+%Y-%m-%d %H:%M') 1.14 + header 1.15 + html_header 1.16 + user_box 1.17 + 1.18 + # Save any new message first 1.19 + if [ "$(GET message)" ] && check_auth; then 1.20 + # Prevent more than one message by minute peer user 1.21 + file="$(date '+%Y-%m-%d_%H:%M')_$user.txt" 1.22 + [ -d "$wall" ] || mkdir -p ${wall} 1.23 + # Write content to file 1.24 + sed "s/$(echo -en '\r') /\n/g" > ${wall}/${file} << EOT 1.25 +$(GET message) 1.26 +EOT 1.27 + fi 1.28 + 1.29 + # Delete message if requested 1.30 + if [ "$(GET delmsg)" ] && check_auth; then 1.31 + m=$(GET delmsg) 1.32 + author=$(echo ${m} | cut -d "_" -f 3) 1.33 + if [ "$user" == "${author%.txt}" ] || admin_user; then 1.34 + rm -f ${wall}/${m} 1.35 + fi 1.36 + fi 1.37 + 1.38 + # Message form 1.39 + cat << EOT 1.40 +<h2>$d</h2> 1.41 + 1.42 +<form method="get" action="$script" id="wall-form" name ="wall" onsubmit="return checkWall();"> 1.43 + <input type="hidden" name="wall" /> 1.44 + <textarea name="message" maxlength="${MESSAGE_LENGTH}"></textarea> 1.45 + <div> 1.46 + <input type="submit" value="$(gettext 'Send message')" /> 1.47 + $(eval_gettext "Date: $date - Max char:") ${MESSAGE_LENGTH} - 1.48 + $(gettext "Wiki syntax is supported:") 1.49 + <a href="?d=en/help">$(gettext "Help page")</a> 1.50 + </div> 1.51 +</form> 1.52 + 1.53 +<h2>$(gettext "Latest Messages")</h2> 1.54 +EOT 1.55 + # Display messages &nb=40 1.56 + msg_nb=40 1.57 + if [ "$(GET nb)" ]; then 1.58 + msg_nb=$(GET nb) 1.59 + fi 1.60 + for m in $(ls -r $wall | head -n ${msg_nb}) 1.61 + do 1.62 + author=$(echo ${m} | cut -d "_" -f 3) 1.63 + pubdate=$(echo ${m} | cut -d "_" -f 1-2 | sed s"/_/ /") 1.64 + cat << EOT 1.65 +<div class="wall-message"> 1.66 + <div>By <a href='?user=${author%.txt}'>${author%.txt}</a> 1.67 + - <span class="date">${pubdate}</span> 1.68 +EOT 1.69 + if [ "$user" == "${author%.txt}" ] || admin_user; then 1.70 + echo " - <span class='del'><a href='?wall&delmsg=$m'>Delete</a></span>" 1.71 + fi 1.72 + echo "</div><p>" 1.73 + cat ${wall}/${m} | wiki_parser 1.74 + echo "</p></div>" 1.75 + done 1.76 + cat << EOT 1.77 +<div id="tools"> 1.78 + <a href="$script?community">$(gettext "Community Tools")</a> 1.79 +</div> 1.80 +EOT 1.81 + html_footer && exit 0 ;; 1.82 + 1.83 + *\ community\ *) 1.84 + d="Community Tools" 1.85 + header 1.86 + html_header 1.87 + user_box 1.88 + cat << EOT 1.89 +<h2>$d</h2> 1.90 +<p>$SHORT_DESC</p> 1.91 +<div id="tools"> 1.92 + <a href="$script?wall">Community Wall</a> 1.93 +</div> 1.94 +EOT 1.95 + 1.96 + html_footer && exit 0 ;; 1.97 +esac