tazpanel rev 523
lib/libtazpanel: add edit_button()
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Aug 08 16:06:55 2015 +0200 (2015-08-08) |
parents | 8b67a70440c2 |
children | f8e0ae0ac1d9 |
files | boot.cgi hardware.cgi index.cgi lib/libtazpanel network.cgi |
line diff
1.1 --- a/boot.cgi Fri Aug 07 02:33:24 2015 +0300 1.2 +++ b/boot.cgi Sat Aug 08 16:06:55 2015 +0200 1.3 @@ -45,12 +45,7 @@ 1.4 $(_ 'System logs') 1.5 EOT 1.6 1.7 - [ -w /etc/syslog.conf ] && cat <<EOT 1.8 - <form action="index.cgi"> 1.9 - <input type="hidden" name="file" value="/etc/syslog.conf"/> 1.10 - <button name="action" value="edit" data-icon="edit">syslog.conf</button> 1.11 - </form> 1.12 -EOT 1.13 + edit_button /etc/syslog.conf syslog.conf 1.14 1.15 cat <<EOT 1.16 </header> 1.17 @@ -518,14 +513,7 @@ 1.18 <section> 1.19 <header> 1.20 $(_ 'Local startup commands') 1.21 - <form action="index.cgi"> 1.22 - <input type="hidden" name="file" value="/etc/init.d/local.sh"/> 1.23 -EOT 1.24 - [ -w /etc/init.d/local.sh ] && cat <<EOT 1.25 - <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button> 1.26 -EOT 1.27 - cat <<EOT 1.28 - </form> 1.29 + $(edit_button /etc/init.d/local.sh) 1.30 </header> 1.31 <pre><code class="language-bash">$(htmlize < /etc/init.d/local.sh)</code></pre> 1.32 </section>
2.1 --- a/hardware.cgi Fri Aug 07 02:33:24 2015 +0300 2.2 +++ b/hardware.cgi Sat Aug 08 16:06:55 2015 +0200 2.3 @@ -485,14 +485,7 @@ 2.4 <section> 2.5 <header> 2.6 $(_ 'Filesystems table') 2.7 -EOT 2.8 - [ -w /etc/fstab ] && cat <<EOT 2.9 - <form action="index.cgi"> 2.10 - <input type="hidden" name="file" value="/etc/fstab"/> 2.11 - <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button> 2.12 - </form> 2.13 -EOT 2.14 - cat <<EOT 2.15 + $(edit_button /etc/fstab) 2.16 </header> 2.17 <table class="wide zebra center"> 2.18 <thead>
3.1 --- a/index.cgi Fri Aug 07 02:33:24 2015 +0300 3.2 +++ b/index.cgi Sat Aug 08 16:06:55 2015 +0200 3.3 @@ -618,9 +618,9 @@ 3.4 print "<pre>" 3.5 for (i in pkg) for (j = split(pkg[i], p, " "); j > 2; j--) { 3.6 if (pkg[p[j]] || alias[p[j]]) kill[p[j]]=1 3.7 - else print "Missing dep " p[j] " for " name(p[1]) 3.8 + else { miss=1 ; print "Missing dep " p[j] " for " name(p[1]) } 3.9 } 3.10 - print "" 3.11 + if (miss) print "" 3.12 n=0 3.13 for (i=0; i < c; i++) { 3.14 if (kill[idx[i]]) continue
4.1 --- a/lib/libtazpanel Fri Aug 07 02:33:24 2015 +0300 4.2 +++ b/lib/libtazpanel Sat Aug 08 16:06:55 2015 +0200 4.3 @@ -369,6 +369,17 @@ 4.4 } 4.5 4.6 4.7 +# Show "Edit" button 4.8 + 4.9 +edit_button() { 4.10 + [ -w "$1" ] && cat <<EOT 4.11 + <form action="index.cgi"> 4.12 + <input type="hidden" name="file" value="$1"/> 4.13 + <button name="action" value="edit" data-icon="edit">${2:-$(_ 'Edit')}</button> 4.14 + </form> 4.15 +EOT 4.16 +} 4.17 + 4.18 # Mark select option as checked 4.19 4.20 selected() {
5.1 --- a/network.cgi Fri Aug 07 02:33:24 2015 +0300 5.2 +++ b/network.cgi Sat Aug 08 16:06:55 2015 +0200 5.3 @@ -321,12 +321,7 @@ 5.4 <header> 5.5 $(_ 'Configuration file') 5.6 EOT 5.7 - [ -w /etc/network.conf ] && cat <<EOT 5.8 - <form action="index.cgi"> 5.9 - <input type="hidden" name="file" value="/etc/network.conf"/> 5.10 - <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button> 5.11 - </form> 5.12 -EOT 5.13 + edit_button /etc/network.conf 5.14 cat <<EOT 5.15 </header> 5.16 <div>$(_ "These values are the ethernet settings in the main /etc/network.conf configuration file")</div> 5.17 @@ -661,12 +656,7 @@ 5.18 <header> 5.19 $(_ 'Configuration file') 5.20 EOT 5.21 - [ -w /etc/network.conf ] && cat <<EOT 5.22 - <form action="index.cgi"> 5.23 - <input type="hidden" name="file" value="/etc/network.conf"/> 5.24 - <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button> 5.25 - </form> 5.26 -EOT 5.27 + edit_button /etc/network.conf 5.28 cat <<EOT 5.29 </header> 5.30 <div>$(_ "These values are the wifi settings in the main /etc/network.conf configuration file")</div> 5.31 @@ -735,12 +725,7 @@ 5.32 <header id="hosts"> 5.33 $(_ 'Hosts') 5.34 EOT 5.35 - [ -w '/etc/hosts' ] && cat <<EOT 5.36 - <form action="index.cgi"> 5.37 - <input type="hidden" name="file" value="/etc/hosts"/> 5.38 - <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button> 5.39 - </form> 5.40 -EOT 5.41 + edit_button /etc/hosts 5.42 cat <<EOT 5.43 </header> 5.44 <footer> 5.45 @@ -785,12 +770,7 @@ 5.46 <header id="dns"> 5.47 $(_ 'Domain name resolution') 5.48 EOT 5.49 - [ -w /etc/resolv.conf ] && cat <<EOT 5.50 - <form action="index.cgi"> 5.51 - <input type="hidden" name="file" value="/etc/resolv.conf"/> 5.52 - <button name="action" value="edit" data-icon="edit">$(_ 'Edit')</button> 5.53 - </form> 5.54 -EOT 5.55 + edit_button /etc/resolv.conf 5.56 cat <<EOT 5.57 </header> 5.58 <footer><pre>$(cat /etc/resolv.conf)</pre></footer> 5.59 @@ -842,7 +822,9 @@ 5.60 EOT 5.61 [ "$REMOTE_USER" == "root" -a "$(which iptables-save)" ] && cat <<EOT 5.62 <section> 5.63 - <header id="iptables">$(_ 'Firewall')</header> 5.64 + <header id="iptables">$(_ 'Firewall') 5.65 + $(edit_button /etc/knockd.conf "$(_ 'Port knocker')") 5.66 + </header> 5.67 <footer> 5.68 <pre>$(iptables-save)</pre> 5.69 </footer>