tazpanel diff lib/libtazpanel @ rev 538

Speed-up interface: cache xhtml header; need to use 'tazpanel cc' to clean cache when TazPanel menu changes (in post-install and post-remove functions for TazPanel modules)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Aug 30 23:46:37 2015 +0300 (2015-08-30)
parents c0f8e615df7d
children 71e797397c58
line diff
     1.1 --- a/lib/libtazpanel	Sun Aug 30 18:07:27 2015 +0200
     1.2 +++ b/lib/libtazpanel	Sun Aug 30 23:46:37 2015 +0300
     1.3 @@ -255,14 +255,23 @@
     1.4  
     1.5  xhtml_header() {
     1.6  	[ -n "$(GET noheader)" ] && return
     1.7 -	SUBTITLE="$1"
     1.8 -	. ${PANEL}$HEADER
     1.9 -	cat <<EOT
    1.10 +
    1.11 +	local subtitle="$1" header="/var/cache/tazpanel/header.$(id -un)"
    1.12 +
    1.13 +	# Cache header
    1.14 +	if [ ! -f "$header" ]; then
    1.15 +		SUBTITLE='@@SUBTITLE@@'
    1.16 +		. ${PANEL}$HEADER > "$header"
    1.17 +		cat >> "$header" <<EOT
    1.18  <script type="text/javascript">
    1.19  	document.cookie = "guiuser=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
    1.20  	document.cookie = "guiuser=$GUI_USER";
    1.21  </script>
    1.22  EOT
    1.23 +	fi
    1.24 +	sed "s|@@SUBTITLE@@|$subtitle|" "$header"
    1.25 +
    1.26 +	# Show debug output
    1.27  	if [ "$DEBUG" -eq 1 ]; then
    1.28  		local i j x
    1.29  		args=''
    1.30 @@ -293,6 +302,7 @@
    1.31  
    1.32  xhtml_footer() {
    1.33  	[ -n "$(GET noheader)" ] && return
    1.34 +
    1.35  	export TEXTDOMAIN='tazpkg'
    1.36  	. ${PANEL}$FOOTER
    1.37  }