tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r909887 - in /tomcat/trunk: conf/web.xml java/org/apache/catalina/servlets/DefaultServlet.java webapps/docs/default-servlet.xml
Date Sat, 13 Feb 2010 20:12:14 GMT
Author: markt
Date: Sat Feb 13 20:12:11 2010
New Revision: 909887

URL: http://svn.apache.org/viewvc?rev=909887&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48384
Add a per context xslt option for directory listings
Make the fallback options work as described in the docs

Modified:
    tomcat/trunk/conf/web.xml
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/trunk/webapps/docs/default-servlet.xml

Modified: tomcat/trunk/conf/web.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/conf/web.xml?rev=909887&r1=909886&r2=909887&view=diff
==============================================================================
--- tomcat/trunk/conf/web.xml (original)
+++ tomcat/trunk/conf/web.xml Sat Feb 13 20:12:11 2010
@@ -80,7 +80,12 @@
   <!--   localXsltFile       Make directory listings an XML doc and         -->
   <!--                       pass the result to this style sheet residing   -->
   <!--                       in that directory. This overrides              -->
-  <!--                        globalXsltFile[null]                          -->
+  <!--                       contextXsltFile and globalXsltFile[null]       -->
+  <!--                                                                      -->
+  <!--   contextXsltFile     Make directory listings an XML doc and         -->
+  <!--                       pass the result to this style sheet which is   -->
+  <!--                       relative to the context root. This overrides   -->
+  <!--                       globalXsltFile[null]                           -->
   <!--                                                                      -->
   <!--   globalXsltFile      Site wide configuration version of             -->
   <!--                       localXsltFile This argument is expected        -->

Modified: tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=909887&r1=909886&r2=909887&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Sat Feb 13 20:12:11
2010
@@ -124,13 +124,19 @@
     /**
      * Allow customized directory listing per directory.
      */
-    protected String  localXsltFile = null;
+    protected String localXsltFile = null;
 
 
     /**
+     * Allow customized directory listing per context.
+     */
+    protected String contextXsltFile = null;
+    
+    
+    /**
      * Allow customized directory listing per instance.
      */
-    protected String  globalXsltFile = null;
+    protected String globalXsltFile = null;
 
 
     /**
@@ -248,6 +254,7 @@
         fileEncoding = getServletConfig().getInitParameter("fileEncoding");
 
         globalXsltFile = getServletConfig().getInitParameter("globalXsltFile");
+        contextXsltFile = getServletConfig().getInitParameter("contextXsltFile");
         localXsltFile = getServletConfig().getInitParameter("localXsltFile");
         readmeFile = getServletConfig().getInitParameter("readmeFile");
 
@@ -1195,6 +1202,9 @@
                     trimmed.equalsIgnoreCase(localXsltFile))
                     continue;
 
+                if ((cacheEntry.name + trimmed).equals(contextXsltFile))
+                    continue;
+
                 CacheEntry childCacheEntry =
                     resources.lookupCache(cacheEntry.name + resourceName);
                 if (!childCacheEntry.exists) {
@@ -1492,11 +1502,19 @@
             } catch (NamingException e) {
                 if (debug > 10)
                     log("localXsltFile '" + localXsltFile + "' not found", e);
-
-                return null;
             }
         }
 
+        if (contextXsltFile != null) {
+            InputStream is =
+                getServletContext().getResourceAsStream(contextXsltFile);
+            if (is != null)
+                return is;
+
+            if (debug > 10)
+                log("contextXsltFile '" + contextXsltFile + "' not found");
+        }
+
         /*  Open and read in file in one fell swoop to reduce chance
          *  chance of leaving handle open.
          */

Modified: tomcat/trunk/webapps/docs/default-servlet.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/default-servlet.xml?rev=909887&r1=909886&r2=909887&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/default-servlet.xml (original)
+++ tomcat/trunk/webapps/docs/default-servlet.xml Sat Feb 13 20:12:11 2010
@@ -125,9 +125,21 @@
         If you wish to customize your directory listing, you
         can use an XSL transformation. This value is an absolute
         file name which be used for all directory listings.
-        This can be disabled by per webapp by also declaring the
-        default servlet in your local webapp's web.xml. The format
-        of the xml is shown below.
+        This can be overridden per context and/or per directory. See
+        <strong>contextXsltFile</strong> and <strong>localXsltFile</strong>
+        below. The format of the xml is shown below.
+    </td>
+  </tr>
+  <tr>
+    <th valign='top'>contextXsltFile</th>
+    <td valign='top'>
+        You may also customize your directory listing by context by
+        configuring <code>contextXsltFile</code>. This should be a context
+        relative path (e.g.: <code>/path/to/context.xslt</code>). This
+        overrides <code>globalXsltFile</code>. If this value is present but a
+        file does not exist, then <code>globalXsltFile</code> will be used. If
+        <code>globalXsltFile</code> does not exist, then the default
+        directory listing will be shown.
     </td>
   </tr>
   <tr>
@@ -136,8 +148,10 @@
         You may also customize your directory listing by directory by
         configuring <code>localXsltFile</code>. This should be a relative
         file name in the directory where the listing will take place.
-        This overrides <code>globalXsltFile</code>. If this value
-        is present but a file does not exist, then
+        This overrides <code>globalXsltFile</code> and
+        <code>contextXsltFile</code>. If this value is present but a file
+        does not exist, then <code>contextXsltFile</code> will be used. If
+        <code>contextXsltFile</code> does not exist, then
         <code>globalXsltFile</code> will be used. If
         <code>globalXsltFile</code> does not exist, then the default
         directory listing will be shown.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message