You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jo...@apache.org on 2006/10/03 10:11:06 UTC

svn commit: r452340 - in /lenya/trunk/src/webapp: global-sitemap.xmap lenya/xslt/menu/filter-menu.xsl lenya/xslt/menu/menu2xhtml.xsl

Author: josias
Date: Tue Oct  3 01:11:06 2006
New Revision: 452340

URL: http://svn.apache.org/viewvc?view=rev&rev=452340
Log:
remove menu blocks/items which will not be displayed in the current view ('area') before the UsecaseMenuTransformer step. this is a performance optimization, it reduces the number of usecase precondition checks in the menu generation.

Added:
    lenya/trunk/src/webapp/lenya/xslt/menu/filter-menu.xsl   (with props)
Modified:
    lenya/trunk/src/webapp/global-sitemap.xmap
    lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl

Modified: lenya/trunk/src/webapp/global-sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/global-sitemap.xmap?view=diff&rev=452340&r1=452339&r2=452340
==============================================================================
--- lenya/trunk/src/webapp/global-sitemap.xmap (original)
+++ lenya/trunk/src/webapp/global-sitemap.xmap Tue Oct  3 01:11:06 2006
@@ -141,6 +141,10 @@
 
         <map:transform src="lenya/xslt/menu/merge-menus.xsl"/>
         
+        <map:transform src="lenya/xslt/menu/filter-menu.xsl">
+          <map:parameter name="usecase" value="{request-param:lenya.usecase}"/>
+        </map:transform>
+        
         <map:call resource="i18n"/>
         
         <!-- Disable menu items according to usecase policies -->

Added: lenya/trunk/src/webapp/lenya/xslt/menu/filter-menu.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/xslt/menu/filter-menu.xsl?view=auto&rev=452340
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/menu/filter-menu.xsl (added)
+++ lenya/trunk/src/webapp/lenya/xslt/menu/filter-menu.xsl Tue Oct  3 01:11:06 2006
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+  Removes blocks and items which will not be displayed in the current view.
+-->
+
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+    xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
+    xmlns:menu="http://apache.org/cocoon/lenya/menubar/1.0"
+    xmlns="http://www.w3.org/1999/xhtml">
+
+  <xsl:param name="usecase"/>
+
+  <xsl:variable name="currentTab">
+    <xsl:choose>
+      <xsl:when test="starts-with($usecase, 'admin.')">admin</xsl:when>
+      <xsl:when test="starts-with($usecase, 'tab.')">site</xsl:when>
+      <xsl:otherwise>authoring</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:template match="menu:block[(@info = 'false' and $currentTab = 'site') or (@*[local-name() = $currentTab] = 'false' and $currentTab != 'site')]"/>
+
+  <xsl:template match="menu:item[(@info = 'false' and $currentTab = 'site') or (@*[local-name() = $currentTab] = 'false' and $currentTab != 'site')]"/>
+
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+
+</xsl:stylesheet>

Propchange: lenya/trunk/src/webapp/lenya/xslt/menu/filter-menu.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl?view=diff&rev=452340&r1=452339&r2=452340
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl (original)
+++ lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl Tue Oct  3 01:11:06 2006
@@ -174,7 +174,7 @@
   <xsl:template match="menu:menu" mode="nav">
     <li id="nav{position()}"><xsl:value-of select="@name"/>
       <ul id="menu{position()}">
-        <xsl:apply-templates select="menu:block[not(@info = 'false') and ($currentTab = 'site') or not(@*[local-name() = $currentTab] = 'false') and not($currentTab = 'site')]"/>
+        <xsl:apply-templates select="menu:block"/>
       </ul>
     </li>
   </xsl:template>
@@ -190,10 +190,9 @@
     </li>
   </xsl:template>
  
-  <!-- match blocks with not area='false' -->
   <xsl:template match="menu:block">
     <xsl:apply-templates select="menu:title"/>
-    <xsl:apply-templates select="menu:menu | menu:item[not(@info = 'false') and ($currentTab = 'site') or not(@*[local-name() = $currentTab] = 'false') and not($currentTab = 'site')]"/>
+    <xsl:apply-templates select="menu:menu | menu:item"/>
 		
     <xsl:if test="position() != last()">
       <li class="lenya-menu-separator"></li>
@@ -223,7 +222,6 @@
   </xsl:template>
   
   	
-  <!-- match items with not area='false' -->
   <xsl:template match="menu:item">
     <xsl:choose>
       <xsl:when test="@href">



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org