tazpanel rev 74

move syntax_highlighter to libtazpanel to be used in other case than file and put colors in CSS so it themeable
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 12 03:36:52 2011 +0200 (2011-04-12)
parents 9cb3773c29ff
children 1780ef64bcd5
files index.cgi lib/libtazpanel network.cgi styles/default/style.css
line diff
     1.1 --- a/index.cgi	Tue Apr 12 03:00:12 2011 +0200
     1.2 +++ b/index.cgi	Tue Apr 12 03:36:52 2011 +0200
     1.3 @@ -49,11 +49,7 @@
     1.4  		# HTML entities: -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g'
     1.5  		case "$WANT" in
     1.6  			*.conf|*.lst)
     1.7 -				cat $WANT | sed \
     1.8 -					-e s"#^\#\([^']*\)#<span style='color: \#555;'>\0</span>#"g \
     1.9 -					-e s"#^[A-Z]\([^']*\)=#<span style='color: \#000073;'>\0</span>#"g \
    1.10 -					-e s"#^[a-z]\([^']*\)#<span style='color: \#730c00;'>\0</span>#"g \
    1.11 -					-e s"#\"\([^']*\)\"#<span style='color: \#730c00;'>\0</span>#"g ;;
    1.12 +				cat $WANT | syntax_highlighter conf ;;
    1.13  			*)
    1.14  				cat $WANT ;;
    1.15  		esac
     2.1 --- a/lib/libtazpanel	Tue Apr 12 03:00:12 2011 +0200
     2.2 +++ b/lib/libtazpanel	Tue Apr 12 03:36:52 2011 +0200
     2.3 @@ -24,7 +24,6 @@
     2.4  # we use that to help get URL string variables and user names
     2.5  query_string_parser() {
     2.6  	id=0
     2.7 -	#IFS="&"
     2.8  	for var in $(echo "$QUERY_STRING" | sed s'@=@ @'g)
     2.9  	do
    2.10  		id=$((id + 1))
    2.11 @@ -36,7 +35,17 @@
    2.12  			'4') VAR_2=${var% } ;;
    2.13  		esac
    2.14  	done
    2.15 -	#unset IFS
    2.16 +}
    2.17 +
    2.18 +# Syntax highlighting for config file and SHell scripts
    2.19 +syntax_highlighter() {
    2.20 +	case $1 in
    2.21 +		conf)
    2.22 +			sed -e s"#^\#\([^']*\)#<span class='conf-comment'>\0</span>#"g \
    2.23 +				-e s"#^[A-Z]\([^']*\)=#<span class='conf-var'>\0</span>#"g \
    2.24 +				-e s"#^[a-z]\([^']*\)#<span class='conf-var'>\0</span>#"g \
    2.25 +				-e s"#\"\([^']*\)\"#<span class='conf-val'>\0</span>#"g ;;
    2.26 +	esac
    2.27  }
    2.28  
    2.29  # LOG activities
     3.1 --- a/network.cgi	Tue Apr 12 03:00:12 2011 +0200
     3.2 +++ b/network.cgi	Tue Apr 12 03:36:52 2011 +0200
     3.3 @@ -68,11 +68,15 @@
     3.4  	`gettext "Manage network connections and services`
     3.5  </p>
     3.6  <div id="actions">
     3.7 -	<p>
     3.8 +	<div class="float-left">
     3.9  		`gettext "Connection:"`
    3.10  		<a class="button" href="$SCRIPT_NAME?start">`gettext "Start"`</a>
    3.11  		<a class="button" href="$SCRIPT_NAME?stop">`gettext "Stop"`</a>
    3.12 -	</p>
    3.13 +	</div>
    3.14 +	<div class="float-right">
    3.15 +		`gettext "Configuration file:"`
    3.16 +		<a class="button" href="index.cgi?file=/etc/network.conf">network.conf</a>
    3.17 +	</div>
    3.18  </div>
    3.19  
    3.20  `list_network_interfaces`
     4.1 --- a/styles/default/style.css	Tue Apr 12 03:00:12 2011 +0200
     4.2 +++ b/styles/default/style.css	Tue Apr 12 03:36:52 2011 +0200
     4.3 @@ -180,6 +180,12 @@
     4.4  	font-weight: bold;
     4.5  }
     4.6  
     4.7 +/* syntax_highlighter */
     4.8 +
     4.9 +span.conf-comment { color: #666; }
    4.10 +span.conf-var { color: #1F1500; }
    4.11 +span.conf-val { color: #F35A00; }
    4.12 +
    4.13  /* Misc */
    4.14  
    4.15  pre, .pre-main {