tazpanel rev 44

Add a loading mechanism for page that take long to be generated
author Christophe Lincoln <pankso@slitaz.org>
date Fri Apr 08 01:17:37 2011 +0200 (2011-04-08)
parents af4b1f0b3110
children 5b7e9a6565c9
files README data/tazpanel.png lib/libtazpanel pkgs.cgi styles/default/header.html styles/default/images/loader.gif styles/default/style.css tazpanel tazpanel.conf
line diff
     1.1 --- a/README	Thu Apr 07 03:12:38 2011 +0200
     1.2 +++ b/README	Fri Apr 08 01:17:37 2011 +0200
     1.3 @@ -7,6 +7,14 @@
     1.4  and all theming is done with standard CSS 3.
     1.5  
     1.6  
     1.7 +Use it!
     1.8 +------
     1.9 +You can clone the tazpanel repo into /var/www/tazpanel and work on this
    1.10 +copy or clone it someweher esle and 'make install'. After, add tazpanel to
    1.11 +your /etc/hosts, type './tazpanel start' to start the server and go to the
    1.12 +URL: http://tazpanel:8090
    1.13 +
    1.14 +
    1.15  i18n
    1.16  ----
    1.17  TazPanel have been coded from the beginning with gettext support. Please
    1.18 @@ -43,11 +51,16 @@
    1.19  in an other script you can eventually creat a new CGI page and update all
    1.20  links, but please to talk to the AUTHORS before.
    1.21  
    1.22 -	* index.cgi   Main Tazpanel CGI script (some stuff may be splited
    1.23 -	              into users.cgi, boot.cgi, etc if too big or slow)
    1.24 -	* pkgs.cgi    Tazpkg packages CGI interface
    1.25 -	* live.cgi    All tools related to Live systems (CD, USB, Frugal)
    1.26 -	
    1.27 +	* index.cgi    Main Tazpanel CGI script (some stuff may be splited
    1.28 +	               into users.cgi, boot.cgi, etc if too big or slow)
    1.29 +	* network.cgi  All related stuff to networking (eth, wifi, servives)
    1.30 +	* pkgs.cgi     Tazpkg packages CGI interface
    1.31 +	* settings.cgi System settings such as time, users accounts, locales
    1.32 +	* live.cgi     All tools related to Live systems (CD, USB, Frugal)
    1.33 +
    1.34 +For common function have a look to lib/libtazpanel you may founf functions
    1.35 +yoou need already coded such as xhtml_header to get the style header.html
    1.36 +in you CGI script. For the loading message you can use loading_msg
    1.37  
    1.38  Web server
    1.39  ----------
     2.1 Binary file data/tazpanel.png has changed
     3.1 --- a/lib/libtazpanel	Thu Apr 07 03:12:38 2011 +0200
     3.2 +++ b/lib/libtazpanel	Fri Apr 08 01:17:37 2011 +0200
     3.3 @@ -67,6 +67,14 @@
     3.4  # xHTML 5 (header and footer skel are from the style)
     3.5  #
     3.6  
     3.7 +loading_msg() {
     3.8 +	cat << EOT
     3.9 +<script type="text/javascript">
    3.10 +	document.write('<div id="loading"><img src="/styles/default/images/loader.gif" />$LOADING_MSG</div>');
    3.11 +</script>
    3.12 +EOT
    3.13 +}
    3.14 +
    3.15  xhtml_header() {
    3.16  	cat ${PANEL}$HEADER | sed s/'- %TITLE%'/"$TITLE"/
    3.17  }
     4.1 --- a/pkgs.cgi	Thu Apr 07 03:12:38 2011 +0200
     4.2 +++ b/pkgs.cgi	Fri Apr 08 01:17:37 2011 +0200
     4.3 @@ -6,7 +6,7 @@
     4.4  # it own code for some tasks. Please KISS it important and keep speed
     4.5  # in mind. Thanks, Pankso.
     4.6  #
     4.7 -# (C) 2011 SliTaz GNU/Linux - GNU gpl v2
     4.8 +# (C) 2011 SliTaz GNU/Linux - GNU gpl v3
     4.9  #
    4.10  echo "Content-Type: text/html"
    4.11  echo ""
    4.12 @@ -77,8 +77,8 @@
    4.13  	cat $LOCALSTATE/packages.list | wc -l
    4.14  	gettext "Upgradeable packages : "
    4.15  	cat $LOCALSTATE/upgradeable-packages.list | wc -l
    4.16 -	gettext "Installed files      : "
    4.17 -	cat $INSTALLED/*/files.list | wc -l
    4.18 +	#gettext "Installed files      : "
    4.19 +	#cat $INSTALLED/*/files.list | wc -l
    4.20  	gettext "Blocked packages     : "
    4.21  	cat $LOCALSTATE/blocked-packages.list | wc -l
    4.22  }
    4.23 @@ -226,6 +226,8 @@
    4.24  		cd $INSTALLED
    4.25  		search_form
    4.26  		sidebar
    4.27 +		LOADING_MSG="Listing... please wait"
    4.28 +		loading_msg
    4.29  		cat << EOT
    4.30  <h2>`gettext "My packages"`</h2>
    4.31  <form method='get' action='$SCRIPT_NAME'>
     5.1 --- a/styles/default/header.html	Thu Apr 07 03:12:38 2011 +0200
     5.2 +++ b/styles/default/header.html	Fri Apr 08 01:17:37 2011 +0200
     5.3 @@ -5,8 +5,20 @@
     5.4  	<meta charset="utf-8" />
     5.5  	<link rel="shortcut icon" href="/styles/default/favicon.ico" />
     5.6  	<link rel="stylesheet" type="text/css" href="/styles/default/style.css" />
     5.7 +	<!--
     5.8 +		This function will hide the the loading message when page is fully
     5.9 +		loaded. We use div id="loading", function in <head> and body onload=
    5.10 +	-->
    5.11 +	<script type="text/javascript">
    5.12 +		function showLoading(){
    5.13 +			//hide loading status...
    5.14 +			document.getElementById("loading").style.display='none';
    5.15 +			
    5.16 +			document.getElementById("content").style.display='block';
    5.17 +		}
    5.18 +	</script>
    5.19  </head>
    5.20 -<body>
    5.21 +<body onload="showLoading()"> 
    5.22  
    5.23  <div id="toolbar">
    5.24  	<div id="icons">
     6.1 Binary file styles/default/images/loader.gif has changed
     7.1 --- a/styles/default/style.css	Thu Apr 07 03:12:38 2011 +0200
     7.2 +++ b/styles/default/style.css	Fri Apr 08 01:17:37 2011 +0200
     7.3 @@ -25,6 +25,15 @@
     7.4  a { text-decoration: none; color: #666; }
     7.5  a:hover { color: #000; }
     7.6  
     7.7 +#loading {
     7.8 +  /* font-weight: bold; */
     7.9 +  color: #666;
    7.10 +  position: fixed;
    7.11 +  top: 92px;
    7.12 +  right: 80px;
    7.13 +  width: 200px;
    7.14 +}
    7.15 +
    7.16  /* Header and main title */
    7.17  
    7.18  #header {
    7.19 @@ -46,8 +55,10 @@
    7.20  	z-index: 200;
    7.21  	cursor: default;
    7.22  }
    7.23 +
    7.24  #menu { margin: 4px 8px; }
    7.25 -#menu a { padding: 2px 4px; color: #000; cursor: default; }
    7.26 +#menu a { padding: 2px 4px; color: #000;
    7.27 +	cursor: default; }
    7.28  #menu a:hover { color: #444; }
    7.29  #icons { margin: 2px 8px; float: right; }
    7.30  #icons img { padding: 0; }
    7.31 @@ -193,12 +204,14 @@
    7.32  
    7.33  input[type=text] { height: 18px; }
    7.34  
    7.35 -div.scroll { height: 200px; overflow: auto; border: 1px solid #ddd; }
    7.36 +div.scroll { height: 200px; overflow: auto;
    7.37 +	border: 1px solid #ddd; }
    7.38  div.scroll table { border: 0px solid #fff; }
    7.39  
    7.40  /* Round corner */
    7.41  
    7.42 -table, pre, input[type=submit], .debug, .box, .button, div.scroll {
    7.43 +table, pre, input[type=submit], .debug, .box,
    7.44 +.button, div.scroll {
    7.45  	/*-moz-border-radius: 4px;
    7.46  	-webkit-border-radius: 4px; */
    7.47  	border-radius: 4px;
     8.1 --- a/tazpanel	Thu Apr 07 03:12:38 2011 +0200
     8.2 +++ b/tazpanel	Fri Apr 08 01:17:37 2011 +0200
     8.3 @@ -8,7 +8,7 @@
     8.4  # Get the configuration file and functions
     8.5  CONFIG="/etc/slitaz/tazpanel.conf"
     8.6  [ -f $CONFIG ] && . $CONFIG
     8.7 -[ -f $PWD/tazpanel.conf ] && . tazpanel.conf
     8.8 +[ -f tazpanel.conf ] && . tazpanel.conf
     8.9  [ ! -f $PANEL/lib/libtazpanel ] && \
    8.10  	echo "No config file or libtazpanel found: $CONFIG" && exit 1
    8.11  . $PANEL/lib/libtazpanel
     9.1 --- a/tazpanel.conf	Thu Apr 07 03:12:38 2011 +0200
     9.2 +++ b/tazpanel.conf	Fri Apr 08 01:17:37 2011 +0200
     9.3 @@ -14,7 +14,10 @@
     9.4  DEBUG="0"
     9.5  
     9.6  # Xterm options
     9.7 -XTERM_OPTS="-geometry 80x16 -bg black -fg white"
     9.8 +XTERM_OPTS="-geometry 80x16-0+24 -bg black -fg white"
     9.9 +
    9.10 +# Generic page loading message
    9.11 +LOADING_MSG="Loading... please wait"
    9.12  
    9.13  # Busybox HTTP deamon config
    9.14  HTTPD_CONF="/etc/slitaz/httpd.conf"