slitaz-forge rev 639

Up SCN style and add sdt plugin
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 11 22:07:58 2017 +0100 (2017-02-11)
parents 8ad41e93bda4
children 01a0c06f87b6
files scn/README scn/header.html scn/plugins/sdt/sdt.cgi scn/plugins/sdt/sdt.conf scn/style.css tank/tank
line diff
     1.1 --- a/scn/README	Fri Feb 10 13:13:33 2017 +0100
     1.2 +++ b/scn/README	Sat Feb 11 22:07:58 2017 +0100
     1.3 @@ -2,6 +2,10 @@
     1.4  SCN is powered by TinyCM. This folder has the custom CSS style and
     1.5  header skeleton.
     1.6  
     1.7 -Receipts folder is the custom packages receipts for the old wordpress
     1.8 -SliTaz SCN. Note that all receipts are made for tazwok 3.1 and SliTaz 3.0.
     1.9 +plugins/
    1.10 +	Is for custom TinyCM/SliTaz pluging such as SDT web interface
    1.11  
    1.12 +receipts/
    1.13 +	Is the custom packages receipts for the first wordpress SCN.
    1.14 +	Note that all receipts are made for tazwok 3.1 and SliTaz 3.0.
    1.15 +
     2.1 --- a/scn/header.html	Fri Feb 10 13:13:33 2017 +0100
     2.2 +++ b/scn/header.html	Sat Feb 11 22:07:58 2017 +0100
     2.3 @@ -27,8 +27,9 @@
     2.4  
     2.5  <nav id="nav" role="navigation" tabindex="0">
     2.6  	<ul>
     2.7 -		<li><a class="nav1" href="?blog">Blog</a></li>
     2.8 -		<li><a class="nav2" href="?log">Activity</a></li>
     2.9 +		<li><a class="nav2" href="?blog">Blog</a></li>
    2.10 +		<li><a class="nav1" href="?wall">Wall</a></li>
    2.11 +		<li><a class="nav2" href="?sdt">Sdt DB</a></li>
    2.12  		<li><a class="nav1" href="?d=en/about">About</a></li>
    2.13  		<li><a class="nav2" href="http://twitter.com/slitaz" 
    2.14  			title="Follow us on Twitter"><img src="images/twitter.png"
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/scn/plugins/sdt/sdt.cgi	Sat Feb 11 22:07:58 2017 +0100
     3.3 @@ -0,0 +1,127 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# TinyCM Plugin - SliTaz Distro Tracker
     3.7 +#
     3.8 +# sdt.cgi: SliTaz Distro over the world. We dont track users
     3.9 +# info, no mail or IP but the localization. The goal of Sdt is to help 
    3.10 +# show where SliTaz OS's are in the world. DB is in the flat file: 
    3.11 +# sdt.txt & using | as separator for easy parsing.
    3.12 +#
    3.13 +. /usr/lib/slitaz/httphelper.sh
    3.14 +
    3.15 +std_summary() {
    3.16 +	cat << EOT
    3.17 +<pre>
    3.18 +DB file    : <a href="content/sdt/sdt.txt">sdt.txt</a>
    3.19 +DB size    : $(du -sh $sdtdb | cut -d "	" -f 1)
    3.20 +Distro     : $(wc -l $sdtdb | cut -d " " -f 1)
    3.21 +</pre>
    3.22 +EOT
    3.23 +}
    3.24 +
    3.25 +std_table() {
    3.26 +	cat << EOT
    3.27 +<table>
    3.28 +	<thead>
    3.29 +		<td>$(gettext "Date")</td>
    3.30 +		<td>$(gettext "User")</td>
    3.31 +		<td>$(gettext "Country")</td>
    3.32 +		<td>$(gettext "Release")</td>
    3.33 +		<td>$(gettext "Kernel")</td>
    3.34 +		<td>$(gettext "Mode")</td>
    3.35 +	</thead>
    3.36 +EOT
    3.37 +	IFS="|"
    3.38 +	cat ${sdtdb} | while read date user country release kernel mode;
    3.39 +	do
    3.40 +		cat << EOT
    3.41 +	<tr>
    3.42 +		<td>$date</td>
    3.43 +		<td>$user</td>
    3.44 +		<td>$country</td>
    3.45 +		<td>$release</td>
    3.46 +		<td>$kernel</td>
    3.47 +		<td>$mode</td>
    3.48 +	</tr>
    3.49 +EOT
    3.50 +	done && unset IFS
    3.51 +	echo "</table>"
    3.52 +}
    3.53 +
    3.54 +std_check_ua() {
    3.55 +	if ! echo "$HTTP_USER_AGENT" | fgrep -q "SliTaz/SDT"; then
    3.56 +		echo "Only SDT clients are accepted" && exit 1
    3.57 +	fi
    3.58 +}
    3.59 +
    3.60 +case " $(GET sdt) " in
    3.61 +	*\ add\ *)
    3.62 +		std_check_ua
    3.63 +		sdtdb="../../content/sdt/sdt.txt"
    3.64 +		date="$(date +%Y%m%d)"
    3.65 +		user=$(GET user)
    3.66 +		release=$(GET release)
    3.67 +		kernel=$(GET kernel)
    3.68 +		mode=$(GET mode)
    3.69 +		country=$(GET country)
    3.70 +		message=$(GET message)
    3.71 +		cat << EOT
    3.72 +SliTaz Distro Tracker
    3.73 +--------------------------------------------------------------------------------
    3.74 +Date       : ${date}
    3.75 +User       : ${user}
    3.76 +Country    : ${country}
    3.77 +Release    : ${release}
    3.78 +Kernel     : ${kernel}
    3.79 +Mode       : ${mode}
    3.80 +--------------------------------------------------------------------------------
    3.81 +EOT
    3.82 +		# Add to DB
    3.83 +		echo "$date|$user|$country|$release|$kernel|$mode" >> ${sdtdb}
    3.84 +		echo "Distro added to the database. Thank you :-)"; echo
    3.85 +		exit 0 ;;
    3.86 +	
    3.87 +	*\ geoloc\ *) 
    3.88 +		# Show IP and country
    3.89 +		header "Content-Type: text/plain"
    3.90 +		#echo "$REMOTE_ADDR"
    3.91 +		echo "178.196.15.131" 
    3.92 +		exit 0 ;;
    3.93 +	
    3.94 +	*\ country\ *) 
    3.95 +		# Show distro's by country
    3.96 +		;;
    3.97 +	
    3.98 +	*\ sdt\ *)
    3.99 +		d="SliTaz Distro Tracker"
   3.100 +		sdtdb="$tiny/$content/sdt/sdt.txt"
   3.101 +		header
   3.102 +		html_header
   3.103 +		user_box
   3.104 +		cat << EOT
   3.105 +<h2>$d</h2>
   3.106 +<p>
   3.107 +	$(gettext "Add your SliTaz distro to the database. Open a terminal and execute:") 
   3.108 +	<b>sdt send [username]</b>
   3.109 +<p>
   3.110 +EOT
   3.111 +		std_summary
   3.112 +		echo "<h3>Distro's table</h3>"
   3.113 +		echo "<pre>"
   3.114 +		std_table
   3.115 +		echo "</pre>"
   3.116 +		html_footer
   3.117 +		exit 0 ;;
   3.118 +	
   3.119 +	*\ raw\ *)
   3.120 +		# Plain text stats if the script is called directly
   3.121 +		. /usr/lib/slitaz/httphelper.sh
   3.122 +		sdtdb="../../content/sdt/sdt.txt"
   3.123 +		header "Content-Type: text/plain"
   3.124 +		cat << EOT
   3.125 +Server time      : $(date)
   3.126 +Database size    : $(du -sh $sdtdb | cut -d "	" -f 1)
   3.127 +Distro tracked   : $(wc -l $sdtdb | cut -d " " -f 1)
   3.128 +EOT
   3.129 +		exit 0 ;;
   3.130 +esac
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/scn/plugins/sdt/sdt.conf	Sat Feb 11 22:07:58 2017 +0100
     4.3 @@ -0,0 +1,7 @@
     4.4 +# TinyCM Plugin configuration
     4.5 +
     4.6 +PLUGIN="SliTaz Distro Tracker"
     4.7 +SHORT_DESC="Web interface for SliTaz Distro Tracker (SDT)"
     4.8 +MAINTAINER="devel@slitaz.org"
     4.9 +
    4.10 +# Configurable variables used in plugin.cgi
     5.1 --- a/scn/style.css	Fri Feb 10 13:13:33 2017 +0100
     5.2 +++ b/scn/style.css	Sat Feb 11 22:07:58 2017 +0100
     5.3 @@ -264,7 +264,7 @@
     5.4  /* Round corner */
     5.5  
     5.6  pre, .button, .pctbar, .box, #login, #account-info, #user, img,
     5.7 -input, textarea, select, #tools a, nav a {
     5.8 +input, textarea, select, #tools a, nav a, #cloud-upload, .wall-message {
     5.9  	-moz-border-radius: 4px;
    5.10  	-webkit-border-radius: 4px;
    5.11  	border-radius: 4px;
    5.12 @@ -323,7 +323,56 @@
    5.13  
    5.14  /* Plugins CSS */
    5.15  
    5.16 -.post-tools { border-bottom: 1px dotted #ccc; 
    5.17 -	border-top: 1px dotted #ccc; padding: 4px 0;}
    5.18 +/* Blog */
    5.19 +.post-tools { 
    5.20 +	border-top: 1px dotted #ddd;
    5.21 +	border-bottom: 1px dotted #ddd;
    5.22 +	padding: 4px 0; }
    5.23  .post-tools a { text-decoration: none; }
    5.24  .post-tools a:hover { text-decoration: underline; }
    5.25 +
    5.26 +/* Forum */
    5.27 +#hashtags { font-size: 16px; font-weight: bold; }
    5.28 +#hashtags a { text-decoration: none; padding: 0 4px; }
    5.29 +.topic { padding: 6px; margin: 4px; }
    5.30 +.topic span a { text-decoration: none; color: #666;
    5.31 +	font-weight: bold; padding-left: 2px; }
    5.32 +.forum-msg { background-color: #eee; padding: 10px; 
    5.33 +		border: 2px solid #ddd; width: 98%;}
    5.34 +
    5.35 +/* Cloud */
    5.36 +#cloud-upload { 
    5.37 +	text-align: center;
    5.38 +	color: #444444;
    5.39 +	border: 1px solid #cccccc;
    5.40 +	padding: 0px;
    5.41 +	margin: 4px 0px;
    5.42 +	background-image: -webkit-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5);
    5.43 +	background-image: -moz-linear-gradient(#FAFAFA, #F4F4F4 40%, #E5E5E5);
    5.44 +}
    5.45 +
    5.46 +#cloud-upload input[type="file"] {
    5.47 +	border: 0px solid #cccccc;
    5.48 +	width: 85%;
    5.49 +	-webkit-appearance: none;
    5.50 +	-webkit-padding-end: 0px;
    5.51 +	-webkit-padding-start: 0px;
    5.52 +}
    5.53 +
    5.54 +/* Community */
    5.55 +#wall-form textarea { height: 50px; background: #f8f8f8; }
    5.56 +.wall-message {
    5.57 +	border: 1px solid #ddd;
    5.58 +	background: #fafafa;
    5.59 +	margin: 20px 0;
    5.60 +	padding: 0;
    5.61 +}
    5.62 +.wall-message div {
    5.63 +	padding: 10px 0 0 10px;
    5.64 +}
    5.65 +.wall-message p {
    5.66 +	border-top: 1px solid #eee;
    5.67 +	padding: 10px;
    5.68 +}
    5.69 +
    5.70 +
     6.1 --- a/tank/tank	Fri Feb 10 13:13:33 2017 +0100
     6.2 +++ b/tank/tank	Sat Feb 11 22:07:58 2017 +0100
     6.3 @@ -2,7 +2,7 @@
     6.4  #
     6.5  # Tank - Admin Tank, backup, update and give stats.
     6.6  #
     6.7 -# (C) 2012-2014 SliTaz - GNU General Public License.
     6.8 +# (C) 2012-2017 SliTaz - GNU General Public License.
     6.9  # Author: Christophe Lincoln <pankso@slitaz.org>
    6.10  #
    6.11  . /lib/libtaz.sh
    6.12 @@ -33,7 +33,7 @@
    6.13    up-bugs      Update http://bugs.slitaz.org/
    6.14    up-irc       Update http://irc.slitaz.org/
    6.15    up-arm       Update http://arm.slitaz.org/
    6.16 -  up-piclass   Update http://piclass.org/
    6.17 +  up-scn       Update http://scn.slitaz.org/
    6.18  
    6.19  EOT
    6.20  }
    6.21 @@ -140,11 +140,17 @@
    6.22  		echo "Updating: slitaz-arm Hg repo..."
    6.23  		cd $REPOS/slitaz-arm && hg pull -u
    6.24  		echo "" ;;
    6.25 -	up-piclass)
    6.26 -		# Update piclass.org
    6.27 -		echo -e "\nUpdating: piclass.org..."
    6.28 -		cd /home/piclass/website
    6.29 -		git pull && echo "" ;;
    6.30 +	up-scn)
    6.31 +		# Update scn.slitaz.org
    6.32 +		echo -e "\nUpdating: scn.slitaz.org..."
    6.33 +		cd $REPOS/slitaz-forge && hg pull -u
    6.34 +		cp -f scn/style* $WWW/scn
    6.35 +		cp -f scn/header.html $WWW/scn/lib
    6.36 +		cp -a scn/plugins $WWW/scn
    6.37 +		# Use TinyCM cmdline tool
    6.38 +		cd $REPOS/tinycm && hg pull -u
    6.39 +		./tinycm up $WWW/scn
    6.40 +		echo "" ;;
    6.41  	up-stats)
    6.42  		echo -e "\nUpdating all awstats databases..." | tee -a $LOGFILE
    6.43  		date >> $LOGFILE