tazpanel diff index.cgi @ rev 463

Add prism.js syntax highlighter; now files can be edited "in place" without page reloading; allow ANY characters in the Wi-Fi password (bug 126); change web-app layout: main window isn't scrollable, with scrollable contents.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Apr 24 16:00:14 2015 +0300 (2015-04-24)
parents d0dbe11a2060
children 836e45b5567b
line diff
     1.1 --- a/index.cgi	Sat Apr 18 16:26:58 2015 +0300
     1.2 +++ b/index.cgi	Fri Apr 24 16:00:14 2015 +0300
     1.3 @@ -112,6 +112,7 @@
     1.4  		header
     1.5  		file="$(GET file)"
     1.6  		action="$(POST action)"; [ -z "$action" ] && action="$(GET action)" # receive 'action' both on POST or GET
     1.7 +		title="$(POST title)";   [ -z "$title"  ] && title="$(GET title)"   # (optional)
     1.8  
     1.9  		case $file in
    1.10  			*.html)
    1.11 @@ -125,8 +126,8 @@
    1.12  				cat <<EOT
    1.13  <section>
    1.14  	<header>
    1.15 -		<span data-icon="edit">$file</span>
    1.16 -		<form id="editform" method="post" action="?file=$file" class="nogap">
    1.17 +		<span data-icon="edit">${title:-$file}</span>
    1.18 +		<form id="editform" method="post" action="?file=$file">
    1.19  			<button data-icon="save">$(_ 'Save')</button>
    1.20  			<button name="action" value="diff" data-icon="diff">$(_ 'Differences')</button>
    1.21  		</form>
    1.22 @@ -173,17 +174,22 @@
    1.23  			fi
    1.24  
    1.25  			cat <<EOT
    1.26 -<section>
    1.27 +<section class="bigNoScrollable">
    1.28  	<header>
    1.29 -		<span data-icon="text">$file</span>
    1.30 +		<span data-icon="text">${title:-$file}</span>
    1.31  EOT
    1.32  			if [ -w "$file" ]; then
    1.33  				cat <<EOT
    1.34 -		<form>
    1.35 +		<span class="float-right">
    1.36 +			<button onclick='editFile()' id="edit_button" data-icon="edit">$(_ 'Edit')</button>
    1.37 +			<button onclick='saveFile("$file", "$title")' id="save_button" 
    1.38 +				data-icon="save" style="display:none">$(_ 'Save')</button>
    1.39 +		</span>
    1.40 +		<!--form>
    1.41  			<input type="hidden" name="file" value="$file"/>
    1.42  			<button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button><!--
    1.43  			-->$(file_is_modified $file button)
    1.44 -		</form>
    1.45 +		</form-->
    1.46  EOT
    1.47  			elif [ -r "$file" ]; then
    1.48  				cat <<EOT
    1.49 @@ -197,25 +203,28 @@
    1.50  	</header>
    1.51  
    1.52  	<div>
    1.53 -		<pre>
    1.54 +		<pre id="fileContent" class="bigScrollable">
    1.55  EOT
    1.56 +			end_code=''
    1.57  			# Handle file type by extension as a Web Server does it.
    1.58  			case "$file" in
    1.59 +				*.sh|*.cgi|*/receipt|*.conf)
    1.60 +					echo '<code class="language-bash">'; end_code='</code>'
    1.61 +					cat | htmlize ;;
    1.62 +				*.ini)
    1.63 +					echo '<code class="language-ini">'; end_code='</code>'
    1.64 +					cat | htmlize ;;
    1.65  				*.conf|*.lst)
    1.66  					syntax_highlighter conf ;;
    1.67 -				*.sh|*.cgi)
    1.68 -					syntax_highlighter sh ;;
    1.69  				*Xorg.0.log)
    1.70  					syntax_highlighter xlog ;;
    1.71  				*dmesg.log)
    1.72  					syntax_highlighter kernel ;;
    1.73 -				*/receipt)
    1.74 -					syntax_highlighter sh ;;
    1.75  				*)
    1.76  					cat | htmlize ;;
    1.77  			esac < $file
    1.78  			cat <<EOT
    1.79 -		</pre>
    1.80 +$end_code</pre>
    1.81  	</div>
    1.82  </section>
    1.83  EOT
    1.84 @@ -295,7 +304,7 @@
    1.85  		case "$cmd" in
    1.86  		usage|help)
    1.87  			_ 'Small non-interactive terminal emulator.'; echo
    1.88 -			_ 'Run any command at your own risk, avoid interactive commands (%s)' "nano, mc, ..."; echo
    1.89 +			_ 'Run any command at your own risk, avoid interactive commands (%s)' 'nano, mc, ...'; echo
    1.90  			;;
    1.91  		wget*)
    1.92  			dl=/var/cache/downloads
    1.93 @@ -398,7 +407,7 @@
    1.94  		fi
    1.95  
    1.96  		cat <<EOT
    1.97 -<section>
    1.98 +<section style="position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0.5rem;">
    1.99  	<header>
   1.100  		$(_ 'Terminal settings')
   1.101  		<form>