tinycm rev 84
Small fixes and add community plugin
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Feb 11 21:14:02 2017 +0100 (2017-02-11) |
parents | f587a0fa5435 |
children | c12a5ad81972 |
files | .hgignore index.cgi lib/functions.js plugins/cloud/cloud.conf plugins/community/community.cgi plugins/community/community.conf plugins/forum/forum.cgi plugins/keygen/keygen.conf plugins/skel/skel.cgi style.css |
line diff
1.1 --- a/.hgignore Sat Feb 11 17:34:44 2017 +0100 1.2 +++ b/.hgignore Sat Feb 11 21:14:02 2017 +0100 1.3 @@ -3,3 +3,4 @@ 1.4 content/blog/ 1.5 content/cloud/ 1.6 content/forum/ 1.7 +content/wall/
2.1 --- a/index.cgi Sat Feb 11 17:34:44 2017 +0100 2.2 +++ b/index.cgi Sat Feb 11 21:14:02 2017 +0100 2.3 @@ -4,7 +4,7 @@ 2.4 # 2.5 # Copyright (C) 2012-2017 SliTaz GNU/Linux - BSD License 2.6 # 2.7 -. /usr/lib/slitaz/httphelper 2.8 +. /usr/lib/slitaz/httphelper.sh 2.9 2.10 # Let's have a peer site config file with a .cgi extension so content 2.11 # is secure even if left in a web server directory.
3.1 --- a/lib/functions.js Sat Feb 11 17:34:44 2017 +0100 3.2 +++ b/lib/functions.js Sat Feb 11 21:14:02 2017 +0100 3.3 @@ -29,3 +29,13 @@ 3.4 return false; 3.5 } 3.6 } 3.7 + 3.8 +// Check for empty messages on Community Wall 3.9 +function checkWall() { 3.10 + if(document.forms["wall"]["message"].value == "") 3.11 + { 3.12 + alert("Empty message box :-) Write down and then press ENTER"); 3.13 + document.forms["signup"]["message"].focus(); 3.14 + return false; 3.15 + } 3.16 +}
4.1 --- a/plugins/cloud/cloud.conf Sat Feb 11 17:34:44 2017 +0100 4.2 +++ b/plugins/cloud/cloud.conf Sat Feb 11 21:14:02 2017 +0100 4.3 @@ -5,6 +5,6 @@ 4.4 MAINTAINER="devel@slitaz.org" 4.5 4.6 # This is a tool for auth users 4.7 -DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?cloud'>Cloud files</a>" 4.8 +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?cloud'>Cloud</a>" 4.9 4.10 # Configurable variables used in plugin.cgi
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/plugins/community/community.cgi Sat Feb 11 21:14:02 2017 +0100 5.3 @@ -0,0 +1,94 @@ 5.4 +#!/bin/sh 5.5 +# 5.6 +# TinyCM/TazBug Plugin - Community Tools 5.7 +# 5.8 + 5.9 +case " $(GET) " in 5.10 + *\ wall\ *) 5.11 + d="Community Wall" 5.12 + wall="$tiny/$content/wall" 5.13 + date=$(date '+%Y-%m-%d %H:%M') 5.14 + header 5.15 + html_header 5.16 + user_box 5.17 + 5.18 + # Save any new message first 5.19 + if [ "$(GET message)" ] && check_auth; then 5.20 + # Prevent more than one message by minute peer user 5.21 + file="$(date '+%Y-%m-%d_%H:%M')_$user.txt" 5.22 + [ -d "$wall" ] || mkdir -p ${wall} 5.23 + # Write content to file 5.24 + sed "s/$(echo -en '\r') /\n/g" > ${wall}/${file} << EOT 5.25 +$(GET message) 5.26 +EOT 5.27 + fi 5.28 + 5.29 + # Delete message if requested 5.30 + if [ "$(GET delmsg)" ] && check_auth; then 5.31 + m=$(GET delmsg) 5.32 + author=$(echo ${m} | cut -d "_" -f 3) 5.33 + if [ "$user" == "${author%.txt}" ] || admin_user; then 5.34 + rm -f ${wall}/${m} 5.35 + fi 5.36 + fi 5.37 + 5.38 + # Message form 5.39 + cat << EOT 5.40 +<h2>$d</h2> 5.41 + 5.42 +<form method="get" action="$script" id="wall-form" name ="wall" onsubmit="return checkWall();"> 5.43 + <input type="hidden" name="wall" /> 5.44 + <textarea name="message" maxlength="${MESSAGE_LENGTH}"></textarea> 5.45 + <div> 5.46 + <input type="submit" value="$(gettext 'Send message')" /> 5.47 + $(eval_gettext "Date: $date - Max char:") ${MESSAGE_LENGTH} - 5.48 + $(gettext "Wiki syntax is supported:") 5.49 + <a href="?d=en/help">$(gettext "Help page")</a> 5.50 + </div> 5.51 +</form> 5.52 + 5.53 +<h2>$(gettext "Latest Messages")</h2> 5.54 +EOT 5.55 + # Display messages &nb=40 5.56 + msg_nb=40 5.57 + if [ "$(GET nb)" ]; then 5.58 + msg_nb=$(GET nb) 5.59 + fi 5.60 + for m in $(ls -r $wall | head -n ${msg_nb}) 5.61 + do 5.62 + author=$(echo ${m} | cut -d "_" -f 3) 5.63 + pubdate=$(echo ${m} | cut -d "_" -f 1-2 | sed s"/_/ /") 5.64 + cat << EOT 5.65 +<div class="wall-message"> 5.66 + <div>By <a href='?user=${author%.txt}'>${author%.txt}</a> 5.67 + - <span class="date">${pubdate}</span> 5.68 +EOT 5.69 + if [ "$user" == "${author%.txt}" ] || admin_user; then 5.70 + echo " - <span class='del'><a href='?wall&delmsg=$m'>Delete</a></span>" 5.71 + fi 5.72 + echo "</div><p>" 5.73 + cat ${wall}/${m} | wiki_parser 5.74 + echo "</p></div>" 5.75 + done 5.76 + cat << EOT 5.77 +<div id="tools"> 5.78 + <a href="$script?community">$(gettext "Community Tools")</a> 5.79 +</div> 5.80 +EOT 5.81 + html_footer && exit 0 ;; 5.82 + 5.83 + *\ community\ *) 5.84 + d="Community Tools" 5.85 + header 5.86 + html_header 5.87 + user_box 5.88 + cat << EOT 5.89 +<h2>$d</h2> 5.90 +<p>$SHORT_DESC</p> 5.91 +<div id="tools"> 5.92 + <a href="$script?wall">Community Wall</a> 5.93 +</div> 5.94 +EOT 5.95 + 5.96 + html_footer && exit 0 ;; 5.97 +esac
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/plugins/community/community.conf Sat Feb 11 21:14:02 2017 +0100 6.3 @@ -0,0 +1,12 @@ 6.4 +# TinyCM Plugin configuration 6.5 + 6.6 +PLUGIN="Community Tools" 6.7 +SHORT_DESC="Small social community functions and tools for TinyCM" 6.8 +MAINTAINER="pankso@slitaz.org" 6.9 + 6.10 +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?community'>Community</a>" 6.11 + 6.12 +# Configurable variables used in plugin.cgi 6.13 + 6.14 +# Max length for messages on the Wall. 6.15 +MESSAGE_LENGTH="240"
7.1 --- a/plugins/forum/forum.cgi Sat Feb 11 17:34:44 2017 +0100 7.2 +++ b/plugins/forum/forum.cgi Sat Feb 11 21:14:02 2017 +0100 7.3 @@ -6,7 +6,6 @@ 7.4 # d= is used by html_header to set page title 7.5 # t= is used to set the topic number 7.6 # 7.7 -. /usr/lib/slitaz/httphelper 7.8 7.9 forum="$tiny/$content/forum" 7.10
8.1 --- a/plugins/keygen/keygen.conf Sat Feb 11 17:34:44 2017 +0100 8.2 +++ b/plugins/keygen/keygen.conf Sat Feb 11 21:14:02 2017 +0100 8.3 @@ -7,6 +7,6 @@ 8.4 # This is a public service or local tool. 8.5 # Example url to add in a HTML template: http://site/index.cgi?keygen 8.6 8.7 -DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?keygen'>Key gen</a>" 8.8 +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?keygen'>Keygen</a>" 8.9 8.10 # Configurable variables used in plugin.cgi
9.1 --- a/plugins/skel/skel.cgi Sat Feb 11 17:34:44 2017 +0100 9.2 +++ b/plugins/skel/skel.cgi Sat Feb 11 21:14:02 2017 +0100 9.3 @@ -2,7 +2,6 @@ 9.4 # 9.5 # TinyCM/TazBug Plugin - Skeleton 9.6 # 9.7 -. /usr/lib/slitaz/httphelper 9.8 9.9 if [ "$(GET skel)" ]; then 9.10 d="Skel"
10.1 --- a/style.css Sat Feb 11 17:34:44 2017 +0100 10.2 +++ b/style.css Sat Feb 11 21:14:02 2017 +0100 10.3 @@ -155,6 +155,7 @@ 10.4 .error { color: red; } 10.5 .ok { color: green; } 10.6 .date { color: #666; font-size: 96%; } 10.7 +.del a { color: #942929; font-size: 96%; } 10.8 10.9 /* Progress bar */ 10.10 10.11 @@ -225,7 +226,7 @@ 10.12 /* Round corner */ 10.13 10.14 pre, .button, .pctbar, .box, #login, #account-info, #user, img, 10.15 -input, textarea, select, #tools a, #cloud-upload { 10.16 +input, textarea, select, #tools a, #cloud-upload, .wall-message { 10.17 -moz-border-radius: 4px; 10.18 -webkit-border-radius: 4px; 10.19 border-radius: 4px; 10.20 @@ -322,4 +323,19 @@ 10.21 -webkit-padding-start: 0px; 10.22 } 10.23 10.24 +/* Community */ 10.25 +#wall-form textarea { height: 50px; background: #f8f8f8; } 10.26 +.wall-message { 10.27 + border: 1px solid #ddd; 10.28 + background: #fafafa; 10.29 + margin: 20px 0; 10.30 + padding: 0; 10.31 +} 10.32 +.wall-message div { 10.33 + padding: 10px 0 0 10px; 10.34 +} 10.35 +.wall-message p { 10.36 + border-top: 1px solid #eee; 10.37 + padding: 10px; 10.38 +} 10.39