slitaz-forge rev 400

Add new CGI interface for irc.slitaz.org
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jan 14 16:12:03 2014 +0100 (2014-01-14)
parents 8db5b4592873
children 209fa693a790
files irc/README irc/images/logo.png irc/index.cgi irc/lib/header.html irc/style.css
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/irc/README	Tue Jan 14 16:12:03 2014 +0100
     1.3 @@ -0,0 +1,15 @@
     1.4 +SliTaz IRC
     1.5 +===============================================================================
     1.6 +
     1.7 +The main purpose of the logs is to provide records of meetings and dicussions
     1.8 +we have on IRC. TazIRC Log Bot may runs in a conspy session on Tank.
     1.9 +
    1.10 +	* index.cgi : The main CGI SHell script
    1.11 +	* lib/      : HTML template and eventual JS functions
    1.12 +	* log/      : All the logs produced by tazirc-lb
    1.13 +
    1.14 +Host: irc.slitaz.org
    1.15 +IP: 37.187.4.13 (tank)
    1.16 +
    1.17 +
    1.18 +===============================================================================
     2.1 Binary file irc/images/logo.png has changed
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/irc/index.cgi	Tue Jan 14 16:12:03 2014 +0100
     3.3 @@ -0,0 +1,106 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# Small CGI example to display TazIRC Log Bot logs.
     3.7 +#
     3.8 +. /usr/lib/slitaz/httphelper
     3.9 +
    3.10 +host="irc.freenode.net"
    3.11 +chan="slitaz"
    3.12 +logdir="log/$host/$chan"
    3.13 +
    3.14 +# HTML 5 header
    3.15 +html_header() {
    3.16 +	cat lib/header.html | sed -e s!'%LOG%'!"$log"!g
    3.17 +}
    3.18 +
    3.19 +# HTML 5 footer
    3.20 +html_footer() {
    3.21 +	if [ -f "lib/footer.html" ]; then
    3.22 +		cat $tiny/lib/footer.html
    3.23 +	else
    3.24 +		cat << EOT
    3.25 +
    3.26 +<!-- End content -->
    3.27 +</div>
    3.28 +
    3.29 +<div id="footer">&hearts;</div>
    3.30 +
    3.31 +</body>
    3.32 +</html>
    3.33 +EOT
    3.34 +	fi
    3.35 +}
    3.36 +
    3.37 +# Handle GET actions 
    3.38 +case " $(GET) " in
    3.39 +	*\ log\ *)
    3.40 +		# Display a daily log
    3.41 +		log="$(GET log)"
    3.42 +		header
    3.43 +		html_header
    3.44 +		echo "<h2>#${chan} $log</h2>"
    3.45 +		IFS="|"
    3.46 +		cat ${logdir}/${log}.log | while read time user text
    3.47 +		do
    3.48 +			cat << EOT
    3.49 +<div class="box">
    3.50 +<span class="date">[$time]</span> <span style="color: #0000FF;">$user:</span> $text
    3.51 +</div>
    3.52 +EOT
    3.53 +		done
    3.54 +		unset IFS
    3.55 +		html_footer ;;
    3.56 +	*\ webirc\ *)
    3.57 +		# Web IRC
    3.58 +		log="#slitaz"
    3.59 +		header
    3.60 +		html_header
    3.61 +		cat << EOT
    3.62 +<div style="text-align: center;">
    3.63 +	<iframe 
    3.64 +		src="http://webchat.freenode.net?channels=%23slitaz&uio=OT10cnVlJjExPTI0Ng32"
    3.65 +		width="647" height="400">
    3.66 +	</iframe>
    3.67 +</div>
    3.68 +EOT
    3.69 +		html_footer ;;
    3.70 +	*)
    3.71 +		# Info, log list and stats. 
    3.72 +		log="Logs"
    3.73 +		header
    3.74 +		html_header
    3.75 +		cat << EOT
    3.76 +<h2>Welcome to SliTaz IRC World!</h2>
    3.77 +<p>
    3.78 +	This service let you read online the SliTaz IRC support channel on
    3.79 +	Freenode and provide a <a href="?webirc">web IRC client</a>. On a
    3.80 +	SliTaz system you can also use a graphical or a text mode IRC client
    3.81 +	such as Xchat or TazIRC: 
    3.82 +</p>
    3.83 +<pre>
    3.84 +$ tazirc irc.freenode.net [nick] slitaz
    3.85 +</pre>
    3.86 +
    3.87 +<h2>#${chan} $log</h2>
    3.88 +
    3.89 +<pre>
    3.90 +EOT
    3.91 +		IFS=" "
    3.92 +		wc -l ${logdir}/*.log | while read count day
    3.93 +		do
    3.94 +			case "$day" in
    3.95 +				total)
    3.96 +					# Last line is total
    3.97 +					echo "</pre>"
    3.98 +					echo "<p>Total: $count messages</p>" ;;
    3.99 +				*)
   3.100 +					day=$(basename $day)
   3.101 +					log="${day%.log}"
   3.102 +					echo "<a href='?log=$log'>$log</a> $count messages" ;;
   3.103 +			esac
   3.104 +		done
   3.105 +		unset IFS
   3.106 +		html_footer
   3.107 +esac
   3.108 +
   3.109 +exit 0
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/irc/lib/header.html	Tue Jan 14 16:12:03 2014 +0100
     4.3 @@ -0,0 +1,36 @@
     4.4 +<!DOCTYPE html>
     4.5 +<html xmlns="http://www.w3.org/1999/xhtml">
     4.6 +<head>
     4.7 +	<title>SliTaz IRC - %LOG%</title>
     4.8 +	<meta charset="utf-8" />
     4.9 +	<link rel="shortcut icon" href="favicon.ico" />
    4.10 +	<link rel="stylesheet" type="text/css" href="style.css" />
    4.11 +	<!-- <script type="text/javascript" src="lib/functions.js"></script> -->
    4.12 +</head>
    4.13 +<body>
    4.14 +
    4.15 +<div id="header">
    4.16 +	<div id="logo"></div>
    4.17 +	<div id="network">
    4.18 +		<a href="http://www.slitaz.org/">Home
    4.19 +			<!-- <img src="images/home.png" alt="[ Home ]" /> --></a>
    4.20 +		<a href="http://scn.slitaz.org/">Community</a>
    4.21 +		<a href="http://doc.slitaz.org/">Doc</a>
    4.22 +		<a href="http://forum.slitaz.org/">Forum</a>
    4.23 +		<span>IRC</span>
    4.24 +		<a href="http://slitaz.pro/">Pro</a>
    4.25 +		<a href="http://shop.slitaz.org/">Shop</a>
    4.26 +		<a href="http://bugs.slitaz.org/">Bugs</a>
    4.27 +		<a href="http://hg.slitaz.org/">Hg</a>
    4.28 +	</div>
    4.29 +	<h1><a href="./">SliTaz IRC</a></h1>
    4.30 +</div>
    4.31 +
    4.32 +<!--<div id="search">
    4.33 +	<form method="get" action="./">
    4.34 +		<input type="text" name="search" placeholder="Search" />
    4.35 +	</form>
    4.36 +</div>-->
    4.37 +
    4.38 +<!-- Content -->
    4.39 +<div id="content">
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/irc/style.css	Tue Jan 14 16:12:03 2014 +0100
     5.3 @@ -0,0 +1,138 @@
     5.4 +/* CSS style for SliTaz IRC */
     5.5 +
     5.6 +html { min-height: 102%; }
     5.7 +body { font: 13px sans-serif, vernada, arial; margin: 0; }
     5.8 +h1 { margin: 0; padding: 8px; color: #fff; font-size: 20px; }
     5.9 +h1 a { color: #fff; text-decoration: none; }
    5.10 +h2 { color: #444; } h3 { color: #666; font-size: 140%; }
    5.11 +a { text-decoration: underline; color: #215090; }
    5.12 +a:hover { text-decoration: none; }
    5.13 +img { border: 0pt none; vertical-align: middle; }
    5.14 +pre {
    5.15 +	overflow: auto;
    5.16 +	font-size: 98%;
    5.17 +}
    5.18 +
    5.19 +/* Header */
    5.20 +
    5.21 +#header {
    5.22 +	background: #222;
    5.23 +	height: 40px;
    5.24 +	border-bottom: 4px solid #afafaf;
    5.25 +}
    5.26 +
    5.27 +#header h1 {
    5.28 +	margin: 0;
    5.29 +	padding: 8px 0 0 42px;
    5.30 +	width: 250px;
    5.31 +}
    5.32 +
    5.33 +#header h1 a { 
    5.34 +	color: white; 
    5.35 +	text-decoration: none;
    5.36 +	font-size: 20px;
    5.37 +	font-style: italic;
    5.38 +}
    5.39 +
    5.40 +#header h1 a:hover { 
    5.41 +	color: #afafaf;
    5.42 +}
    5.43 +
    5.44 +/* Header links */
    5.45 +
    5.46 +#network { 
    5.47 +	float: right; 
    5.48 +	padding: 14px 5px 0; 
    5.49 +	font-size: 12px;
    5.50 +}
    5.51 +
    5.52 +#network a, #network span {
    5.53 +	padding: 0 4px;
    5.54 +	color: #fff; 
    5.55 +	font-weight: bold;
    5.56 +	text-decoration: none;
    5.57 +}
    5.58 +
    5.59 +#network a:hover, #network span { color: #afafaf; }
    5.60 +
    5.61 +/* Logo */
    5.62 +
    5.63 +#logo {
    5.64 +	background: url(images/logo.png) no-repeat left;
    5.65 +	position: absolute;
    5.66 +	float: left;
    5.67 +	left: 0px;
    5.68 +	top: 0px;
    5.69 +	width: 40px;
    5.70 +	height: 40px;
    5.71 +}
    5.72 +
    5.73 +/* Search */
    5.74 +
    5.75 +#search {
    5.76 +	position: absolute;
    5.77 +	right: 20px;
    5.78 +	top: 60px;
    5.79 +}
    5.80 +
    5.81 +#search input[type="text"] {
    5.82 +	width: 200px;
    5.83 +	
    5.84 +	padding: 4px;
    5.85 +	margin: 4px 0px;
    5.86 +	font-size: 14px;
    5.87 +	line-height: 1.2em;
    5.88 +	background: #fefefe;
    5.89 +	border: 2px solid #afafaf;
    5.90 +	-webkit-appearance: none;
    5.91 +	-webkit-padding-end: 12px;
    5.92 +	-webkit-padding-start: 6px;
    5.93 +}
    5.94 +
    5.95 +/* Content */
    5.96 +
    5.97 +#content {
    5.98 +	margin: 40px auto;
    5.99 +	padding: 0 20px;
   5.100 +	text-align: justify;
   5.101 +	max-width: 720px;
   5.102 +}
   5.103 +
   5.104 +.box {
   5.105 +	padding: 6px;
   5.106 +	margin: 4px 0px;
   5.107 +}
   5.108 +
   5.109 +pre, .box {
   5.110 +	background-color: #f8f8f8;
   5.111 +	border: 1px solid #ddd;
   5.112 +}
   5.113 +
   5.114 +pre {
   5.115 +	padding: 10px;
   5.116 +}
   5.117 +
   5.118 +pre img { margin: 4px 4px 4px 0px; }
   5.119 +
   5.120 +.error { color: red; }
   5.121 +.ok { color: green; }
   5.122 +.date { color: #666; font-size: 96%; }
   5.123 +
   5.124 +/* Round corner */
   5.125 +
   5.126 +pre, img, .box, input[type="text"] {
   5.127 +	-moz-border-radius: 4px;
   5.128 +	-webkit-border-radius: 4px;
   5.129 +	border-radius: 4px;
   5.130 +}
   5.131 +
   5.132 +/* Footer */
   5.133 +
   5.134 +#footer {
   5.135 +	text-align: center;
   5.136 +	padding: 20px;
   5.137 +	border-top: 1px solid #ddd;
   5.138 +	font-size: 90%;
   5.139 +}
   5.140 +
   5.141 +#footer a { padding: 0 2px; }