tazpanel rev 411

boot.cgi: display log files in tabs
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jan 18 18:59:01 2015 +0100 (2015-01-18)
parents 197057e85b1a
children f3a7fb3d92ec
files boot.cgi lib/libtazpanel styles/default/header.html styles/default/style.css
line diff
     1.1 --- a/boot.cgi	Sun Jan 18 14:23:23 2015 +0100
     1.2 +++ b/boot.cgi	Sun Jan 18 18:59:01 2015 +0100
     1.3 @@ -13,37 +13,45 @@
     1.4  
     1.5  TITLE=$(gettext 'TazPanel - Boot')
     1.6  
     1.7 +loghead()
     1.8 +{
     1.9 +	tail -n 40 $1 | htmlize
    1.10 +	[ $(wc -l < $1) -gt 40 ] && cat <<EOT
    1.11 +<hr /><a href="/index.cgi?file=$1">$(gettext 'Show more...')</a>
    1.12 +EOT
    1.13 +}
    1.14 +
    1.15  #
    1.16  # Commands
    1.17  #
    1.18  
    1.19  case " $(GET) " in
    1.20  	*\ log\ *)
    1.21 +		unset actboot actslim actxlog actkernel
    1.22 +		case "$(GET log)" in
    1.23 +		boot)	actboot=' class="active"'
    1.24 +			output="$(filter_taztools_msgs < /var/log/boot.log)"
    1.25 +			;;
    1.26 +		slim)	actslim=' class="active"'
    1.27 +			output="$(loghead /var/log/slim.log)" ;;
    1.28 +		xlog)	actxlog=' class="active"'
    1.29 +			output="$(loghead /var/log/Xorg.0.log)" ;;
    1.30 +		*)	actkernel=' class="active"'
    1.31 +			output="$(syntax_highlighter kernel < /var/log/dmesg.log)"
    1.32 +		esac
    1.33  		xhtml_header
    1.34  		cat << EOT
    1.35  <div id="wrapper">
    1.36  	<h2>$(gettext 'Boot log files')</h2>
    1.37  </div>
    1.38 -<div>
    1.39 -	<a class="button" href="#kernel">
    1.40 -		<img src="$IMAGES/tux.png" />$(gettext 'Kernel messages')</a>
    1.41 -	<a class="button" href="#boot">$(gettext 'Boot scripts')</a>
    1.42 -	<a class="button" href="#slim">$(gettext 'X server')</a>
    1.43 -</div>
    1.44 -
    1.45 -	<h3 id="kernel">$(gettext 'Kernel messages')</h3>
    1.46 -
    1.47 -	<pre>$(cat /var/log/dmesg.log | syntax_highlighter kernel)</pre>
    1.48 -
    1.49 -	<h3 id="boot">$(gettext 'Boot scripts')</h3>
    1.50 -
    1.51 -	<pre>$(cat /var/log/boot.log | filter_taztools_msgs)</pre>
    1.52 -
    1.53 -	<h3 id="slim">$(gettext 'X server')</h3>
    1.54 -
    1.55 -	<pre>
    1.56 -$(tail -n 40 /var/log/slim.log | htmlize)
    1.57 -<hr /><a href="/index.cgi?file=/var/log/slim.log">$(gettext 'Show more...')</a>
    1.58 +<ul id="tabs">
    1.59 +	<li$actkernel><a href="?log=kernel">$(gettext 'Kernel messages')</a></li>
    1.60 +	<li$actboot><a href="?log=boot">$(gettext 'Boot scripts')</a></li>
    1.61 +	<li$actxlog><a href="?log=xlog">$(gettext 'X server')</a></li>
    1.62 +	<li$actslim><a href="?log=slim">$(gettext 'X session')</a></li>
    1.63 +</ul>
    1.64 +<pre>
    1.65 +$output
    1.66  </pre>
    1.67  EOT
    1.68  		;;
     2.1 --- a/lib/libtazpanel	Sun Jan 18 14:23:23 2015 +0100
     2.2 +++ b/lib/libtazpanel	Sun Jan 18 18:59:01 2015 +0100
     2.3 @@ -68,10 +68,14 @@
     2.4  
     2.5  # Remove status and ESC char from tazpkg/tazlito commands output
     2.6  filter_taztools_msgs() {
     2.7 -	sed	-e s'/\[^Gm]*.//g' \
     2.8 -		-e ':a;s/^\(.\{1,68\}\)\(\[ [A-Za-z]* \]\)/\1 \2/;ta' \
     2.9 -		-e 's#\[ OK \]#[ <span class="diff-add">OK</span> ]#' \
    2.10 -		-e 's#\[ Failed \]#[ <span class="diff-rm">Failed</span> ]#'
    2.11 +	sed	-e s'|.\[1;32m|<span style="color: green">|g' \
    2.12 +		-e s'|.\[1;31m|<span style="color: red">|g' \
    2.13 +		-e s'|.\[1;33m|<span style="color: yellow">|g' \
    2.14 +		-e s'|.\[1;34m|<span style="color: blue">|g' \
    2.15 +		-e s'|.\[1;36m|<span style="color: lightblue">|g' \
    2.16 +		-e s'|.\[0;39m|</span>|g' \
    2.17 +		-e s'/\[^Gm]*.//g' \
    2.18 +		-e ':a;s/^\(.\{1,68\}\)\(\[ *<span style="color\)/\1 \2/;ta'
    2.19  }
    2.20  
    2.21  # LOG activities
     3.1 --- a/styles/default/header.html	Sun Jan 18 14:23:23 2015 +0100
     3.2 +++ b/styles/default/header.html	Sun Jan 18 18:59:01 2015 +0100
     3.3 @@ -63,9 +63,10 @@
     3.4  				<li><a href="/boot.cgi?log"><img
     3.5  					src="/styles/$STYLE/images/text.png" />$(gettext 'Boot logs')</a>
     3.6  					<ul>
     3.7 -						<li><a href="/boot.cgi?log#kernel">$(gettext 'Kernel messages')</a>
     3.8 -						<li><a href="/boot.cgi?log#boot">$(gettext 'Boot scripts')</a>
     3.9 -						<li><a href="/boot.cgi?log#slim">$(gettext 'X server')</a>
    3.10 +						<li><a href="/boot.cgi?log=kernel">$(gettext 'Kernel messages')</a>
    3.11 +						<li><a href="/boot.cgi?log=boot">$(gettext 'Boot scripts')</a>
    3.12 +						<li><a href="/boot.cgi?log=xlog">$(gettext 'X server')</a>
    3.13 +						<li><a href="/boot.cgi?log=slim">$(gettext 'X session')</a>
    3.14  					</ul>
    3.15  				</li>
    3.16  				<li><a href="/boot.cgi?daemons"><img
     4.1 --- a/styles/default/style.css	Sun Jan 18 14:23:23 2015 +0100
     4.2 +++ b/styles/default/style.css	Sun Jan 18 18:59:01 2015 +0100
     4.3 @@ -422,3 +422,37 @@
     4.4  section h3 {
     4.5  	margin: 0 0 0.5em 0; }
     4.6  */
     4.7 +
     4.8 +#tabs {
     4.9 +	font-weight: bold;
    4.10 +	font-size: 14px;
    4.11 +	list-style-type: none;
    4.12 +	padding-bottom: 25px;
    4.13 +	border-bottom: 1px solid #aaa;
    4.14 +}
    4.15 +
    4.16 +#tabs li {
    4.17 +	float: left;
    4.18 +	height: 15px;
    4.19 +	background-color: #eee;
    4.20 +	/* margin: 2px 2px 0 2px !important; */
    4.21 +	margin: 1px 1px 0 1px;
    4.22 +	border: 1px solid #aaa;
    4.23 +	text-align: center;
    4.24 +	min-width: 100px;
    4.25 +	-moz-border-top-right-radius: 4px;
    4.26 +	-moz-border-top-left-radius: 4px;
    4.27 +	-webkit-border-top-right-radius: 4px;
    4.28 +	-webkit-border-top-left-radius: 4px;
    4.29 +	border-top-right-radius: 4px;
    4.30 +	border-top-left-radius: 4px;
    4.31 +}
    4.32 +
    4.33 +#tabs li.active {
    4.34 +	border-bottom: 1px solid #fff;
    4.35 +	background-color: #fff;
    4.36 +}
    4.37 +
    4.38 +#tabs a {
    4.39 +	padding: 8px;
    4.40 +}