# HG changeset patch # User Christophe Lincoln # Date 1486844042 -3600 # Node ID d6f01c5019bb3bc364ddef86a767e30c52f13058 # Parent f587a0fa54354a41d93ff42ba2cd8c803b6b3fd3 Small fixes and add community plugin diff -r f587a0fa5435 -r d6f01c5019bb .hgignore --- a/.hgignore Sat Feb 11 17:34:44 2017 +0100 +++ b/.hgignore Sat Feb 11 21:14:02 2017 +0100 @@ -3,3 +3,4 @@ content/blog/ content/cloud/ content/forum/ +content/wall/ diff -r f587a0fa5435 -r d6f01c5019bb index.cgi --- a/index.cgi Sat Feb 11 17:34:44 2017 +0100 +++ b/index.cgi Sat Feb 11 21:14:02 2017 +0100 @@ -4,7 +4,7 @@ # # Copyright (C) 2012-2017 SliTaz GNU/Linux - BSD License # -. /usr/lib/slitaz/httphelper +. /usr/lib/slitaz/httphelper.sh # Let's have a peer site config file with a .cgi extension so content # is secure even if left in a web server directory. diff -r f587a0fa5435 -r d6f01c5019bb lib/functions.js --- a/lib/functions.js Sat Feb 11 17:34:44 2017 +0100 +++ b/lib/functions.js Sat Feb 11 21:14:02 2017 +0100 @@ -29,3 +29,13 @@ return false; } } + +// Check for empty messages on Community Wall +function checkWall() { + if(document.forms["wall"]["message"].value == "") + { + alert("Empty message box :-) Write down and then press ENTER"); + document.forms["signup"]["message"].focus(); + return false; + } +} diff -r f587a0fa5435 -r d6f01c5019bb plugins/cloud/cloud.conf --- a/plugins/cloud/cloud.conf Sat Feb 11 17:34:44 2017 +0100 +++ b/plugins/cloud/cloud.conf Sat Feb 11 21:14:02 2017 +0100 @@ -5,6 +5,6 @@ MAINTAINER="devel@slitaz.org" # This is a tool for auth users -DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Cloud files" +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Cloud" # Configurable variables used in plugin.cgi diff -r f587a0fa5435 -r d6f01c5019bb plugins/community/community.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/community/community.cgi Sat Feb 11 21:14:02 2017 +0100 @@ -0,0 +1,94 @@ +#!/bin/sh +# +# TinyCM/TazBug Plugin - Community Tools +# + +case " $(GET) " in + *\ wall\ *) + d="Community Wall" + wall="$tiny/$content/wall" + date=$(date '+%Y-%m-%d %H:%M') + header + html_header + user_box + + # Save any new message first + if [ "$(GET message)" ] && check_auth; then + # Prevent more than one message by minute peer user + file="$(date '+%Y-%m-%d_%H:%M')_$user.txt" + [ -d "$wall" ] || mkdir -p ${wall} + # Write content to file + sed "s/$(echo -en '\r') /\n/g" > ${wall}/${file} << EOT +$(GET message) +EOT + fi + + # Delete message if requested + if [ "$(GET delmsg)" ] && check_auth; then + m=$(GET delmsg) + author=$(echo ${m} | cut -d "_" -f 3) + if [ "$user" == "${author%.txt}" ] || admin_user; then + rm -f ${wall}/${m} + fi + fi + + # Message form + cat << EOT +

$d

+ +
+ + +
+ + $(eval_gettext "Date: $date - Max char:") ${MESSAGE_LENGTH} - + $(gettext "Wiki syntax is supported:") + $(gettext "Help page") +
+
+ +

$(gettext "Latest Messages")

+EOT + # Display messages &nb=40 + msg_nb=40 + if [ "$(GET nb)" ]; then + msg_nb=$(GET nb) + fi + for m in $(ls -r $wall | head -n ${msg_nb}) + do + author=$(echo ${m} | cut -d "_" -f 3) + pubdate=$(echo ${m} | cut -d "_" -f 1-2 | sed s"/_/ /") + cat << EOT +
+
By ${author%.txt} + - ${pubdate} +EOT + if [ "$user" == "${author%.txt}" ] || admin_user; then + echo " - Delete" + fi + echo "

" + cat ${wall}/${m} | wiki_parser + echo "

" + done + cat << EOT +
+ $(gettext "Community Tools") +
+EOT + html_footer && exit 0 ;; + + *\ community\ *) + d="Community Tools" + header + html_header + user_box + cat << EOT +

$d

+

$SHORT_DESC

+
+ Community Wall +
+EOT + + html_footer && exit 0 ;; +esac diff -r f587a0fa5435 -r d6f01c5019bb plugins/community/community.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/community/community.conf Sat Feb 11 21:14:02 2017 +0100 @@ -0,0 +1,12 @@ +# TinyCM Plugin configuration + +PLUGIN="Community Tools" +SHORT_DESC="Small social community functions and tools for TinyCM" +MAINTAINER="pankso@slitaz.org" + +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Community" + +# Configurable variables used in plugin.cgi + +# Max length for messages on the Wall. +MESSAGE_LENGTH="240" diff -r f587a0fa5435 -r d6f01c5019bb plugins/forum/forum.cgi --- a/plugins/forum/forum.cgi Sat Feb 11 17:34:44 2017 +0100 +++ b/plugins/forum/forum.cgi Sat Feb 11 21:14:02 2017 +0100 @@ -6,7 +6,6 @@ # d= is used by html_header to set page title # t= is used to set the topic number # -. /usr/lib/slitaz/httphelper forum="$tiny/$content/forum" diff -r f587a0fa5435 -r d6f01c5019bb plugins/keygen/keygen.conf --- a/plugins/keygen/keygen.conf Sat Feb 11 17:34:44 2017 +0100 +++ b/plugins/keygen/keygen.conf Sat Feb 11 21:14:02 2017 +0100 @@ -7,6 +7,6 @@ # This is a public service or local tool. # Example url to add in a HTML template: http://site/index.cgi?keygen -DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Key gen" +DASHBOARD_TOOLS="${DASHBOARD_TOOLS} Keygen" # Configurable variables used in plugin.cgi diff -r f587a0fa5435 -r d6f01c5019bb plugins/skel/skel.cgi --- a/plugins/skel/skel.cgi Sat Feb 11 17:34:44 2017 +0100 +++ b/plugins/skel/skel.cgi Sat Feb 11 21:14:02 2017 +0100 @@ -2,7 +2,6 @@ # # TinyCM/TazBug Plugin - Skeleton # -. /usr/lib/slitaz/httphelper if [ "$(GET skel)" ]; then d="Skel" diff -r f587a0fa5435 -r d6f01c5019bb style.css --- a/style.css Sat Feb 11 17:34:44 2017 +0100 +++ b/style.css Sat Feb 11 21:14:02 2017 +0100 @@ -155,6 +155,7 @@ .error { color: red; } .ok { color: green; } .date { color: #666; font-size: 96%; } +.del a { color: #942929; font-size: 96%; } /* Progress bar */ @@ -225,7 +226,7 @@ /* Round corner */ pre, .button, .pctbar, .box, #login, #account-info, #user, img, -input, textarea, select, #tools a, #cloud-upload { +input, textarea, select, #tools a, #cloud-upload, .wall-message { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; @@ -322,4 +323,19 @@ -webkit-padding-start: 0px; } +/* Community */ +#wall-form textarea { height: 50px; background: #f8f8f8; } +.wall-message { + border: 1px solid #ddd; + background: #fafafa; + margin: 20px 0; + padding: 0; +} +.wall-message div { + padding: 10px 0 0 10px; +} +.wall-message p { + border-top: 1px solid #eee; + padding: 10px; +}