slitaz-base-files rev 139 5.1.2

Add libtaz and httphelper man a like documentation
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 24 10:26:35 2012 +0200 (2012-04-24)
parents 4ea029af10e8
children 79e8ce52a628
files Makefile doc/httphelper.txt doc/libtaz.txt rootfs/lib/libtaz.sh rootfs/usr/bin/man rootfs/usr/lib/slitaz/httphelper.sh
line diff
     1.1 --- a/Makefile	Mon Apr 23 23:33:27 2012 +0200
     1.2 +++ b/Makefile	Tue Apr 24 10:26:35 2012 +0200
     1.3 @@ -33,6 +33,14 @@
     1.4  
     1.5  install-libtaz:
     1.6  	install -m 0744 rootfs/lib/libtaz.sh $(DESTDIR)/lib
     1.7 +	install -m 0755 -d $(DESTDIR)/usr/share/doc/slitaz
     1.8 +	install -m 0644 doc/libtaz.txt $(DESTDIR)/usr/share/doc/slitaz
     1.9 +
    1.10 +install-httphelper:
    1.11 +	install -m 0744 rootfs/usr/lib/slitaz/httphelper.sh \
    1.12 +		$(DESTDIR)/usr/lib/slitaz
    1.13 +	install -m 0755 -d $(DESTDIR)/usr/share/doc/slitaz
    1.14 +	install -m 0644 doc/httphelper.txt $(DESTDIR)/usr/share/doc/slitaz
    1.15  	
    1.16  install-msg: msgfmt
    1.17  	install -m 0755 -d $(DESTDIR)$(PREFIX)/share/locale
    1.18 @@ -40,6 +48,8 @@
    1.19  	
    1.20  install: install-msg
    1.21  	cp -a rootfs/* $(DESTDIR)
    1.22 +	install -m 0755 -d $(DESTDIR)/usr/share/doc/slitaz
    1.23 +	cp -a doc/* $(DESTDIR)/usr/share/doc/slitaz
    1.24  	chown -R root.root $(DESTDIR)
    1.25  
    1.26  # Clean source
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/doc/httphelper.txt	Tue Apr 24 10:26:35 2012 +0200
     2.3 @@ -0,0 +1,35 @@
     2.4 +
     2.5 +SYNOPSIS
     2.6 +	. /usr/lib/slitaz/httphelper.sh
     2.7 +	function
     2.8 +
     2.9 +DESCRIPTION
    2.10 +	Httphelper is a CGI SHell helper providing PHP a like syntax and
    2.11 +	usefull functions to encode or crypt strings. Httphelper let you
    2.12 +	easily parse QUERY_STRING and work on any webserver supporting CGI.
    2.13 +	
    2.14 +FUNCTIONS
    2.15 +	GET [var [index]]
    2.16 +	POST [var [index]]
    2.17 +	COOKIE [var [index]]
    2.18 +	FILE [var {name|tmpname|size|type}]
    2.19 +	header [strings]
    2.20 +	http_urlencode string
    2.21 +	urlencode string
    2.22 +	urldecode string
    2.23 +	htmlentities string
    2.24 +	md5crypt string
    2.25 +	sha512crypt string
    2.26 +	httpinfo
    2.27 +	httphelper
    2.28 +
    2.29 +EXAMPLES
    2.30 +	header "Content-type: text/html" "Set-Cookie: name=value; HttpOnly"
    2.31 +	
    2.32 +	value=$(GET name)
    2.33 +	if [ "$value" ]; then
    2.34 +		echo "Input name has a value: $value"
    2.35 +	fi
    2.36 +	
    2.37 +AUTHOR
    2.38 +	Written by Pascal Bellard and Christophe Lincoln
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/doc/libtaz.txt	Tue Apr 24 10:26:35 2012 +0200
     3.3 @@ -0,0 +1,25 @@
     3.4 +
     3.5 +SYNOPSIS
     3.6 +	. /lib/libtaz.sh
     3.7 +	function
     3.8 +
     3.9 +DESCRIPTION
    3.10 +	LibTaz is the base SliTaz SHell library used by almost all tools and
    3.11 +	utilities. It provide common SHell script functions, parse the cmdline
    3.12 +	options and store values in a variable. The output messages can be 
    3.13 +	formated for raw/text, gtk, html and by default they are formated for
    3.14 +	a standard terminal supporting colors. LibTaz is in the directory
    3.15 +	/lib/libtaz.sh since it is used when /usr may not be mounted.
    3.16 +	
    3.17 +FUNCTIONS
    3.18 +	status
    3.19 +	separator
    3.20 +	boldify [string]
    3.21 +	check_root
    3.22 +
    3.23 +OPTIONS
    3.24 +	--output=[raw|gtk|html]
    3.25 +
    3.26 +AUTHOR
    3.27 +	Written by Christophe Lincoln
    3.28 +	
     4.1 --- a/rootfs/lib/libtaz.sh	Mon Apr 23 23:33:27 2012 +0200
     4.2 +++ b/rootfs/lib/libtaz.sh	Tue Apr 24 10:26:35 2012 +0200
     4.3 @@ -3,10 +3,9 @@
     4.4  # SliTaz Base functions used from boot scripts to end user tools. Use
     4.5  # gettext and not echo for messages. Keep output suitable for GTK boxes
     4.6  # and Ncurses dialog. LibTaz should not depend on any configuration file.
     4.7 -# No bloated code here, function must be used by at least 3-4 tools. See
     4.8 -# libtaz() for a list of functions and options or run: tazdev libtaz.sh
     4.9 -# Libtaz is located in /lib/libtaz.sh since it is used when /usr may not
    4.10 -# be mounted.
    4.11 +# No bloated code here, function must be used by at least 3-4 tools.
    4.12 +#
    4.13 +# Documentation: man libtaz or /usr/share/doc/slitaz/libtaz.txt
    4.14  #
    4.15  # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
    4.16  #
    4.17 @@ -32,25 +31,6 @@
    4.18  done
    4.19  [ "$HTTP_REFERER" ] && output="html"
    4.20  
    4.21 -# Help and usage.
    4.22 -libtaz() {
    4.23 -	cat << EOT
    4.24 -
    4.25 -Include this library in a script:
    4.26 -  . /lib/libtaz.sh
    4.27 -
    4.28 -Functions:
    4.29 -  status
    4.30 -  separator
    4.31 -  boldify string
    4.32 -  check_root
    4.33 -
    4.34 -Options:
    4.35 -  --output=[raw|gtk|html]
    4.36 - 
    4.37 -EOT
    4.38 -}
    4.39 -
    4.40  # Return command status. Default to colored console output.
    4.41  status() {
    4.42  	local check=$?
     5.1 --- a/rootfs/usr/bin/man	Mon Apr 23 23:33:27 2012 +0200
     5.2 +++ b/rootfs/usr/bin/man	Tue Apr 24 10:26:35 2012 +0200
     5.3 @@ -3,6 +3,7 @@
     5.4  # Tiny man fake using online manuals.
     5.5  # Copyright (C) 2009-2012 SliTaz GNU/Linux.
     5.6  #
     5.7 +. /lib/libtaz.sh
     5.8  
     5.9  if [ ! -x /usr/bin/retawq ]; then
    5.10  	echo -e "\nMissing Retawq web browser..."
    5.11 @@ -20,7 +21,7 @@
    5.12  	''|-*)
    5.13  		cat <<EOT
    5.14  
    5.15 -Usage: man [section] command
    5.16 +$(boldify "Usage:") man [section] command
    5.17  
    5.18  EOT
    5.19  		return ;;
    5.20 @@ -45,6 +46,10 @@
    5.21  elif [ -x /usr/bin/retawq -a -f /usr/share/doc/slitaz-tools/$TOPIC.html ]; then
    5.22  	retawq --dump=file:///usr/share/doc/slitaz-tools/$TOPIC.html | less -M
    5.23  	return
    5.24 +elif [ -f /usr/share/doc/slitaz/$TOPIC.txt ]; then
    5.25 +	# SliTaz tools/libraries documentation (man a like format)
    5.26 +	less -M /usr/share/doc/slitaz/$TOPIC.txt
    5.27 +	return
    5.28  fi
    5.29  
    5.30  for i in /usr/share/$LC_ALL/man$MAN_SECTION /usr/share/man$MAN_SECTION; do
     6.1 --- a/rootfs/usr/lib/slitaz/httphelper.sh	Mon Apr 23 23:33:27 2012 +0200
     6.2 +++ b/rootfs/usr/lib/slitaz/httphelper.sh	Tue Apr 24 10:26:35 2012 +0200
     6.3 @@ -7,44 +7,14 @@
     6.4  # project and Busybox httpd server applet since it is used for URL 
     6.5  # [en|de]coding.
     6.6  #
     6.7 +# Documentation: man httphelper or /usr/share/doc/slitaz/httpelper.txt
     6.8 +#
     6.9  # Copyright (C) SliTaz 2012 - GNU gpl v2
    6.10  #
    6.11  
    6.12  alias urlencode='busybox httpd -e'
    6.13  alias urldecode='busybox httpd -d'
    6.14  
    6.15 -# Help and usage.
    6.16 -httphelper() {
    6.17 -	cat << EOT
    6.18 -
    6.19 -Include this helper in a script:
    6.20 -  . /usr/lib/slitaz/httphelper
    6.21 -
    6.22 -Functions:
    6.23 -  GET [var [index]]
    6.24 -  POST [var [index]]
    6.25 -  COOKIE [var [index]]
    6.26 -  FILE [var {name|tmpname|size|type}]
    6.27 -  header [strings]
    6.28 -  http_urlencode string
    6.29 -  urlencode string
    6.30 -  urldecode string
    6.31 -  htmlentities string
    6.32 -  md5crypt string
    6.33 -  sha512crypt string
    6.34 -  httpinfo
    6.35 -  httphelper
    6.36 -
    6.37 -Example:
    6.38 -  header "Content-type: text/html" "Set-Cookie: name=value; HttpOnly"
    6.39 -  
    6.40 -  if [ "\$(GET name)" ]; then
    6.41 -      echo "Input name has a value from HTML form"
    6.42 -  fi
    6.43 -
    6.44 -EOT
    6.45 -}
    6.46 -
    6.47  # Send headers.
    6.48  header() {
    6.49  	local i