tazpanel rev 10

Add configuration page in tazpkg.cgi
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 02 21:32:50 2011 +0200 (2011-04-02)
parents dfcc3f322885
children 588f5183f272
files styles/default/images/clear.png styles/default/style.css tazpanel.conf tazpkg.cgi
line diff
     1.1 Binary file styles/default/images/clear.png has changed
     2.1 --- a/styles/default/style.css	Sat Apr 02 17:35:09 2011 +0200
     2.2 +++ b/styles/default/style.css	Sat Apr 02 21:32:50 2011 +0200
     2.3 @@ -5,8 +5,8 @@
     2.4  html { min-height:  102%; }
     2.5  body { padding: 20px 80px; font: 13px sans; }
     2.6  h1 { color: #d66018; border-bottom: 1px dotted #ddd; }
     2.7 -h2 { color: #444; margin: 0 0 60px; }
     2.8 -h3 { color: #666; font-size: 140%; }
     2.9 +h2 { color: #444; margin: -20px 0 10px; }
    2.10 +h3 { color: #666; font-size: 140%; margin: 0; }
    2.11  h4 { color: #888; font-size: 120%; }
    2.12  img { border: 0pt none; vertical-align: middle; padding: 0 6px 0 0;}
    2.13  p { margin: 6px 0; }
    2.14 @@ -23,9 +23,11 @@
    2.15  	overflow: auto;
    2.16  }
    2.17  
    2.18 +.pre_main { margin: 40px 0 10px; }
    2.19  
    2.20  input[type=submit] {
    2.21  	padding: 2px 4px;
    2.22 +	margin: 4px 0 0;
    2.23  	background-color: #f1f1f1;
    2.24  	border: 1px solid #ddd;
    2.25  	cursor: pointer;
    2.26 @@ -36,15 +38,13 @@
    2.27  	border: 1px solid #999;
    2.28  }
    2.29  
    2.30 -input[type=text] { height: 16px; }
    2.31 +input[type=text] { height: 15px; }
    2.32  
    2.33  /* Blocks */
    2.34  
    2.35 -#list { margin: 20px 0 0; }
    2.36 -
    2.37  #block { float: left; }
    2.38  
    2.39 -#sub_block { margin: 50px 0 20px; }
    2.40 +#sub_block { margin: 50px 0; }
    2.41  
    2.42  /* Content */
    2.43  
    2.44 @@ -52,17 +52,18 @@
    2.45  
    2.46  .search {
    2.47  	position: absolute;
    2.48 -	right: 87px;
    2.49 -	top: 214px;
    2.50 +	right: 88px;
    2.51 +	top: 200px;
    2.52  }
    2.53  
    2.54  #actions {
    2.55  	position: absolute;
    2.56 -	left: 86px;
    2.57 -	top: 212px;
    2.58 +	left: 88px;
    2.59 +	top: 200px;
    2.60  }
    2.61  
    2.62  #actions p { padding: 0; }
    2.63 +
    2.64  .box {
    2.65  	margin: 10px 0;
    2.66  	padding: 12px;
    2.67 @@ -71,15 +72,20 @@
    2.68  }
    2.69  
    2.70  .debug {
    2.71 +	position: fixed;
    2.72 +	top: 5px;
    2.73 +	left: 5px;
    2.74  	padding: 6px 20px;
    2.75 -	background-color: #ADD8E6;
    2.76 +	background-color: #f8f8f8;
    2.77  	border: 1px solid #ddd;
    2.78  }
    2.79  
    2.80 +/* Table */
    2.81 +
    2.82  table {
    2.83  	background-color: #f8f8f8;
    2.84  	border: 1px solid #ddd;
    2.85 -	margin: 0;
    2.86 +	margin: 30px 0 0 0;
    2.87  	padding: 10px 10px 10px 0;
    2.88  	width: 100%;
    2.89  }
    2.90 @@ -93,6 +99,7 @@
    2.91  }
    2.92  
    2.93  /* Round corner */
    2.94 +
    2.95  table, pre, input[type=submit], .debug, .box {
    2.96  	-moz-border-radius: 4px;
    2.97  	-webkit-border-radius: 4px;
     3.1 --- a/tazpanel.conf	Sat Apr 02 17:35:09 2011 +0200
     3.2 +++ b/tazpanel.conf	Sat Apr 02 21:32:50 2011 +0200
     3.3 @@ -10,7 +10,7 @@
     3.4  HEADER="styles/$STYLE/header.html"
     3.5  FOOTER="styles/$STYLE/footer.html"
     3.6  
     3.7 -DEBUG="0"
     3.8 +DEBUG="1"
     3.9  
    3.10  # Busybox HTTP deamon config
    3.11  # /etc/slitaz/httpd.conf
     4.1 --- a/tazpkg.cgi	Sat Apr 02 17:35:09 2011 +0200
     4.2 +++ b/tazpkg.cgi	Sat Apr 02 21:32:50 2011 +0200
     4.3 @@ -24,7 +24,9 @@
     4.4  cat $HEADER | sed s'/%TITLE%/Tazpkg/'
     4.5  
     4.6  # DEBUG mode
     4.7 -[ $DEBUG == "1" ] && echo "<p class='debug'>$REQUEST_METHOD ${QUERY_STRING}</p>"
     4.8 +if [ $DEBUG == "1" ]; then
     4.9 +	echo "<p class='debug'>$REQUEST_METHOD ${QUERY_STRING}</p>"
    4.10 +fi
    4.11  
    4.12  # We need packages information for list and search
    4.13  parse_packages_desc() {
    4.14 @@ -70,6 +72,17 @@
    4.15  	cat $LOCALSTATE/blocked-packages.list | wc -l
    4.16  }
    4.17  
    4.18 +# Parse mirrors list to be able to have an icon an remove link
    4.19 +list_mirrors() {
    4.20 +	cat $LOCALSTATE/mirrors | while read line
    4.21 +	do
    4.22 +		cat << EOT
    4.23 +<li><a href="$SCRIPT_NAME?config=rm-mirror=$line"><img
    4.24 +	src="$IMAGES/clear.png" /></a><a href="$line">$line</a></li>
    4.25 +EOT
    4.26 +	done
    4.27 +}
    4.28 +
    4.29  #
    4.30  # xHTML functions
    4.31  #
    4.32 @@ -79,8 +92,9 @@
    4.33  <div class="search">
    4.34  <form method="get" action="$SCRIPT_NAME">
    4.35  	<p>
    4.36 -		`gettext "Search":`
    4.37 +		
    4.38  		<input type="text" name="search" size="20">
    4.39 +		<input type="submit" value="`gettext "Search"`">
    4.40  	</p>
    4.41  </form>
    4.42  </div>
    4.43 @@ -114,7 +128,8 @@
    4.44  	<a href='$SCRIPT_NAME?list'>`gettext "My packages"`</a> |
    4.45  	<a href='$SCRIPT_NAME?list-all'>`gettext "All packages"`</a> |
    4.46  	<a href='$SCRIPT_NAME?recharge'>`gettext "Recharge"`</a> |
    4.47 -	<a href='$SCRIPT_NAME?upgradeable'>`gettext "Upgradeable"`</a>
    4.48 +	<a href='$SCRIPT_NAME?upgradeable'>`gettext "Upgradeable"`</a> |
    4.49 +	<a href='$SCRIPT_NAME?config'>`gettext "Configuration"`</a>
    4.50  </div>
    4.51  EOT
    4.52  }
    4.53 @@ -233,7 +248,7 @@
    4.54  <div id="actions">
    4.55  	<p>`gettext "Recharge lists will check for new or updated packages"`</p>
    4.56  </div>	
    4.57 -<pre>
    4.58 +<pre class="pre_main">
    4.59  EOT
    4.60  		gettext "Recharging the packages list... please wait"; echo
    4.61  		tazpkg recharge | filter_tazpkg_msgs
    4.62 @@ -275,11 +290,13 @@
    4.63  <p>
    4.64  EOT
    4.65  		gettext "Performing task on packages"
    4.66 -		[ $DEBUG == "1" ] && echo "<p class='debug'>cmd: $cmd</p><p>pkgs: $pkgs </p>"
    4.67  		echo '</p></div>'
    4.68 +		echo '<pre class="pre_main">'
    4.69 +		gettext "Executing $cmd for:$pkgs"
    4.70 +		echo '</pre>'
    4.71  		for pkg in $pkgs
    4.72  		do
    4.73 -			echo '<pre class="nomargin">'
    4.74 +			echo '<pre>'
    4.75  			echo 'y' | tazpkg $cmd $pkg $opt 2>/dev/null | filter_tazpkg_msgs
    4.76  			echo '</pre>'
    4.77  		done ;;
    4.78 @@ -289,14 +306,15 @@
    4.79  		sub_block
    4.80  		. $INSTALLED/$pkg/receipt
    4.81  		cat << EOT
    4.82 -<h2>`gettext "Upgradeable packages"`</h2>
    4.83 +<h2>`gettext "Package info"`</h2>
    4.84  <div id="actions">
    4.85 -	<p>`gettext "Detailled information on:" $PACKAGE`</p>
    4.86 +	<p>`gettext "Detailled information on:"` $PACKAGE</p>
    4.87  </div>
    4.88 -<pre>
    4.89 +<pre class="pre_main">
    4.90  Name        : $PACKAGE
    4.91  Version     : $VERSION
    4.92  Description : $SHORT_DESC
    4.93 +Maintainer  : $MAINTAINER
    4.94  Depends     : `for i in $DEPENDS; do echo -n \
    4.95  	"<a href="$SCRIPT_NAME?info=$i">$i</a> "; done`
    4.96  Website     : <a href="$WEB_SITE">$WEB_SITE</a>
    4.97 @@ -310,21 +328,73 @@
    4.98  </pre>
    4.99  EOT
   4.100  		;;
   4.101 +	config*)
   4.102 +		# Tazpkg configuration page
   4.103 +		cmd=${QUERY_STRING#*=}
   4.104 +		case "$cmd" in
   4.105 +			clean)
   4.106 +				rm -rf /var/cache/tazpkg/* ;;
   4.107 +			add-mirror*=http*|add-mirror*=ftp*)
   4.108 +				# Decode url
   4.109 +				mirror=`httpd -d ${cmd#*=}`
   4.110 +				echo "$mirror" >> $LOCALSTATE/mirrors ;;
   4.111 +			rm-mirror=http://*|rm-mirror=ftp://*)
   4.112 +				mirror=${QUERY_STRING#*=rm-mirror=}
   4.113 +				sed -i -e "s@$mirror@@" -e '/^$/d' $LOCALSTATE/mirrors ;;
   4.114 +		esac
   4.115 +		cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
   4.116 +		cache_size=`du -sh /var/cache/tazpkg`
   4.117 +		sub_block
   4.118 +		cat << EOT
   4.119 +<h2>`gettext "Configuration"`</h2>
   4.120 +<div>
   4.121 +	<p>`gettext "Tazpkg configuration and settings"`</p>
   4.122 +</div>
   4.123 +<div>
   4.124 +	<h3>`gettext "Package in cache"`</h3>
   4.125 +	<form method="get" action="$SCRIPT_NAME">
   4.126 +	<p>
   4.127 +		`gettext "Packages in the cache:"` $cache_files ($cache_size)
   4.128 +		<input type="hidden" name="config" value="clean" />
   4.129 +		<input type="submit" value="Clean" />
   4.130 +	</p>
   4.131 +	</form>
   4.132 +</div>
   4.133 +<h3>`gettext "Current mirror list"`</h3>
   4.134 +<div class="box">
   4.135 +	<ul>
   4.136 +		`list_mirrors`
   4.137 +	</ul>
   4.138 +</div>
   4.139 +<form method="get" action="$SCRIPT_NAME">
   4.140 +	<p>
   4.141 +		<input type="hidden" name="config" value="add-mirror" />
   4.142 +		<input type="text" name="mirror" size="60">
   4.143 +		<input type="submit" value="Add mirror" />
   4.144 +	</p>
   4.145 +</form>
   4.146 +EOT
   4.147 +		 ;;
   4.148  	*)
   4.149  		# Default to summary
   4.150 -		
   4.151 +		search_form
   4.152  		sub_block
   4.153 -		search_form
   4.154  		cat << EOT
   4.155  <h2>`gettext "Summary"`</h2>
   4.156  <div id="actions">
   4.157  	<p>`gettext "Overview of all installed and mirrored packages"`</p>
   4.158  </div>
   4.159 -<pre>
   4.160 +<pre class="pre_main">
   4.161  `packages_summary`
   4.162  </pre>
   4.163 +<h3>`gettext "Latest log entries"`</h3>
   4.164 +<pre>
   4.165 +`tail -n 6 /var/log/tazpkg.log | fgrep "-" | \
   4.166 +	awk '{print $1, $2, $3, $4, $5, $6, $7}'`
   4.167 +</pre>
   4.168 +
   4.169  EOT
   4.170 -		echo "" ;;
   4.171 +		;;
   4.172  esac
   4.173  
   4.174  # xHTML 5 footer