You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Janne Jalkanen <ja...@iki.fi> on 2010/03/03 17:21:13 UTC

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Why would we include the plain text editor in the case that the user
preferences state FCK editor?  Or vice versa?

>From the point of view of the layouts editors and plugins should be
equal.  The other one just happens to be implemented in JSP...

The choice of the editor is user-specific and has nothing to do with
the template choice.

/Janne

On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
> That isn't a good example. The layout JSPs define a standard look, and  
> standard resources, which can be overridden in the template JSPs when  
> they need something special. Essentially, the template JSP uses the  
> s:layout-render tag to instruct which layout to use, and one more  
> s:layout-component tags to override the JS, CSS, page title, etc.
>
> For example, the template JSP templates/default/Preferences.jsp  
> overrides the JavaScript component so that jspwiki-prefs.js is included. 
> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp, 
> for example.
>
> The plugin resources example is a valid example, though. I've got some  
> ideas on how to do this safely but haven't had time to document them.  
> (This is a very crazy week for me, professionally.)
>
> Andrew
>
>
> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>  
> wrote:
>
>>
>> Yup, this is also good example.  I don't think having to edit layout  
>> jsp's is a good admin experience when you're deploying a new  
>> component.
>>
>> /Janne
>>
>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>
>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>
>>> However, currenly, jspwiki-edit.js is injected in another jsp (a  
>>> layout jsp)
>>>
>>>
>>> When you would use the FCK editor, however, another javascript (and  
>>> probably
>>> also css) is needed.
>>> However, the layout jsp is not aware of every editor to add-in the  
>>> correct
>>> resources.
>>>
>>>
>>> dirk
>>>
>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen 
>>> <ja...@ecyrd.com>wrote:
>>>
>>>>
>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then  
>>>> how do
>>>> plugins request resources, and how do individual templates then  
>>>> fall back to
>>>> resources they don't include?  I've got a bunch of code that  
>>>> assumes that
>>>> templates can fall back to resources (e.g. images) from default  
>>>> template,
>>>> and plugins which request CSS and other components.
>>>>
>>>> /Janne
>>>>
>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>
>>>>> Author: ajaquith
>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>> New Revision: 917390
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>> Log:
>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and  
>>>> should) be
>>>> included directly in template JSPs.
>>>>>
>>>>> Modified:
>>>>>  incubator/jspwiki/trunk/ChangeLog
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/ 
>>>> Preferences.java
>>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/ 
>>>> JSONRPCManager.java
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> ContentTag.java
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> EditorTag.java
>>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IncludeResourcesTag.java
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IncludeTag.java
>>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> RequestResourceTag.java
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>>> EditorManager.java
>>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> TemplateManager.java
>>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/ 
>>>> TemplateResolution.java
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>> @@ -1,3 +1,30 @@
>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>> +
>>>>> +        * 3.0.0-svn-212
>>>>> +
>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)  
>>>>> are now
>>>>> +        re-thrown so that they propagate upstream. Previously,  
>>>>> doCatch()
>>>>> +        was swallowing them, which made for "interesting" JSP  
>>>>> debugging.
>>>>> +
>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>> +        edit tab on the right. For editing, the live-preview  
>>>>> feature was
>>>>> +        moved to a new "Preview" tab, also on the right. The  
>>>>> View tab
>>>>> +        now simply displays the most recent save.
>>>>> +
>>>>> +        * The Error.jsp references were made consistent in all  
>>>>> JSPs.
>>>>> +        Rather than use JSTL syntax (which won't evaluate when  
>>>>> used
>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>> +        Error.jsp using JSTL. This makes the error page  
>>>>> customizable
>>>>> +        per-template, but still very easy to use.
>>>>> +
>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.  
>>>>> Resources
>>>>> +        can (and should) be included directly in template JSPs.
>>>>> +
>>>>> +        * Small changes to Admin/AdministerProfiles action beans 
>>>>> as part
>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>> Stripesed.
>>>>> +
>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>
>>>>>       * v3.0.0-svn-211 : line up with latest template/stripes  
>>>>> changes
>>>>> @@ -35,7 +62,7 @@
>>>>>       * fixed a couple of Plugin unit tests (support for wiki  
>>>>> spaces is
>>>>>         not yet there), only the ReferringPagesPlugin still fails.
>>>>>
>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>
>>>>>       * 3.0.0-svn-209
>>>>>
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>> Release.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java 
>>>>> Mon Mar
>>>> 1 05:23:10 2010
>>>>> @@ -77,7 +77,7 @@
>>>>>    *  <p>
>>>>>    *  If the build identifier is empty, it is not added.
>>>>>    */
>>>>> -    public static final String     BUILD         = "211";
>>>>> +    public static final String     BUILD         = "212";
>>>>>
>>>>>   /**
>>>>>    *  This is the generic version string you should use
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ 
>>>>> Note.java
>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ 
>>>>> Note.java Mon
>>>> Mar  1 05:23:10 2010
>>>>> @@ -27,6 +27,7 @@
>>>>> import org.apache.wiki.WikiContext;
>>>>> import org.apache.wiki.WikiEngine;
>>>>> import org.apache.wiki.api.PluginException;
>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>> import org.apache.wiki.util.TextUtil;
>>>>>
>>>>>
>>>>> @@ -86,9 +87,7 @@
>>>>>
>>>>>       commentImage = "images/"+commentImage;
>>>>>
>>>>> -        String resource = engine.getTemplateManager 
>>>>> ().findResource( ctx,
>>>>> -
>>>> engine.getTemplateDir(),
>>>>> -
>>>> commentImage );
>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>> engine.getServletContext() ).get( commentImage );
>>>>>
>>>>>       return ctx.getURL( WikiContext.NONE, resource );
>>>>>   }
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/ 
>>>> Preferences.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/ 
>>>> Preferences.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/ 
>>>> Preferences.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -310,7 +310,7 @@
>>>>>       }
>>>>>       else if( "availableSkins".equals( key ) )
>>>>>       {
>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>       }
>>>>>       else if( "availableTimeFormats".equals( key ) )
>>>>>       {
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/ 
>>>> JSONRPCManager.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/ 
>>>> JSONRPCManager.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/ 
>>>> JSONRPCManager.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -38,7 +38,6 @@
>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>
>>>>> @@ -149,15 +148,6 @@
>>>>>    */
>>>>>   public static void requestJSON( WikiContext context )
>>>>>   {
>>>>> -        TemplateManager.addResourceRequest(context,
>>>>> -
>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>> -
>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>> -
>>>>> -        String jsonurl = context.getURL( WikiContext.NONE, 
>>>>> "JSON-RPC" );
>>>>> -        TemplateManager.addResourceRequest(context,
>>>>> -
>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>> -                                           "jsonrpc = new
>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>> -
>>>>>       getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>> HttpServletRequest.class);
>>>>>   }
>>>>>
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> ContentTag.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> ContentTag.java
>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> ContentTag.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -28,6 +28,7 @@
>>>>>
>>>>> import org.apache.wiki.*;
>>>>> import org.apache.wiki.providers.ProviderException;
>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>
>>>>>
>>>>> /**
>>>>> @@ -181,9 +182,7 @@
>>>>>               contentTemplate = beanName + "Content.jsp";
>>>>>           }
>>>>>
>>>>> -            String page =
>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>> -
>>>>        m_wikiContext.getTemplate(),
>>>>> -
>>>>        contentTemplate );
>>>>> +            String page = TemplateManager.getResourceResolver(
>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>           pageContext.include( page );
>>>>>       }
>>>>>       catch( ServletException e )
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> EditorTag.java
>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> EditorTag.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -27,6 +27,7 @@
>>>>>
>>>>> import org.apache.wiki.WikiEngine;
>>>>> import org.apache.wiki.ui.EditorManager;
>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>
>>>>>
>>>>> /**
>>>>> @@ -58,10 +59,7 @@
>>>>>
>>>>>       try
>>>>>       {
>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>> pageContext,
>>>>> -
>>>> m_wikiContext.getTemplate(),
>>>>> -
>>>> editorPath );
>>>>> -
>>>>> +            String page = TemplateManager.getResourceResolver(
>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>           if( page == null )
>>>>>           {
>>>>>               //FIXME: should be I18N ...
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IncludeResourcesTag.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IncludeResourcesTag.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IncludeResourcesTag.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -20,41 +20,34 @@
>>>>> */
>>>>> package org.apache.wiki.tags;
>>>>>
>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>
>>>>> /**
>>>>> - *  This tag is used to include any programmatic includes into the
>>>>> - *  output stream.  Actually, what it does is that it simply  
>>>>> emits a
>>>>> - *  tiny marker into the stream, and then a ServletFilter will  
>>>>> take
>>>>> - *  care of the actual inclusion.
>>>>> - *
>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>> instead
>>>>> + *  <p>This tag is used to include any programmatic includes  
>>>>> into the
>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>> + *  tiny marker into the stream which was replaced by  
>>>>> ServletFilter.
>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>  
>>>>> The
>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions  
>>>>> on how
>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>> instead
>>>>> */
>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    private String m_type;
>>>>> -
>>>>>   public void initTag()
>>>>>   {
>>>>>       super.initTag();
>>>>> -        m_type = null;
>>>>>   }
>>>>>
>>>>>   public void setType( String type )
>>>>>   {
>>>>> -        m_type = type;
>>>>>   }
>>>>>
>>>>>   public int doWikiStartTag() throws Exception
>>>>>   {
>>>>> -        //String marker =
>>>> m_wikiContext.getEngine().getTemplateManager().getMarker 
>>>> (m_wikiContext,
>>>> m_type);
>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>> m_type);
>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>> m_type);
>>>>> -
>>>>> -        pageContext.getOut().println( marker );
>>>>> -
>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>> layout tags instead " +
>>>>> +                     "of IncludeResourcesTag. See
>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>       return SKIP_BODY;
>>>>>   }
>>>>>
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IncludeTag.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IncludeTag.java
>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IncludeTag.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -25,6 +25,7 @@
>>>>> import javax.servlet.ServletException;
>>>>>
>>>>> import org.apache.wiki.providers.ProviderException;
>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>> import org.apache.wiki.util.TextUtil;
>>>>>
>>>>>
>>>>> @@ -72,10 +73,7 @@
>>>>>   {
>>>>>       try
>>>>>       {
>>>>> -            String page =
>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>> -
>>>>        m_wikiContext.getTemplate(),
>>>>> -
>>>>        m_page );
>>>>> -
>>>>> +            String page = TemplateManager.getResourceResolver(
>>>> pageContext.getServletContext() ).get( m_page );
>>>>>           if( page == null )
>>>>>           {
>>>>>               pageContext.getOut().println("No template file called
>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> RequestResourceTag.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> RequestResourceTag.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> RequestResourceTag.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -20,21 +20,17 @@
>>>>> */
>>>>> package org.apache.wiki.tags;
>>>>>
>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>> -
>>>>> /**
>>>>> - *  Provides easy access to TemplateManager.addResourceRequest 
>>>>> ().  You
>>>> may use
>>>>> - *  any of the request types defined there.
>>>>> - *
>>>>> - *  @see TemplateManager
>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct  
>>>>> JSPWiki to
>>>> insert
>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>> because it
>>>>> + *  is unsafe.</em> The Stripes layout tags should be used  
>>>>> instead. See
>>>> the default
>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions  
>>>>> on how
>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>> instead
>>>>> */
>>>>> public class RequestResourceTag extends WikiTagBase
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>> -
>>>>> -    private String m_type;
>>>>> -    private String m_resource;
>>>>>
>>>>>   /**
>>>>>    *  {@inheritDoc}
>>>>> @@ -43,7 +39,6 @@
>>>>>   public void initTag()
>>>>>   {
>>>>>       super.initTag();
>>>>> -        m_type = m_resource = null;
>>>>>   }
>>>>>
>>>>>   /**
>>>>> @@ -52,57 +47,47 @@
>>>>>   @Override
>>>>>   public int doWikiStartTag() throws Exception
>>>>>   {
>>>>> -        if( m_type != null && m_resource != null )
>>>>> -        {
>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,  
>>>>> m_type,
>>>> m_resource );
>>>>> -        }
>>>>> -
>>>>>       return SKIP_BODY;
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     *  Returns the resource that is to be added.
>>>>> +     *  Always returns the empty string.
>>>>>    *
>>>>>    *  @return The resource name.
>>>>>    */
>>>>>   public String getResource()
>>>>>   {
>>>>> -        return m_resource;
>>>>> +        return "";
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     *  Sets the resource name to be added.
>>>>> +     *  This method does nothing.
>>>>>    *
>>>>>    *  @param r Resource identifier.
>>>>>    */
>>>>>   public void setResource(String r)
>>>>>   {
>>>>> -        m_resource = r;
>>>>> +        // No-op.
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     *  Get the resource type.
>>>>> +     *  Always returns the empty string.
>>>>>    *
>>>>>    *  @return The type of the resource.
>>>>>    */
>>>>>   public String getType()
>>>>>   {
>>>>> -        return m_type;
>>>>> +        return "";
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     *  Set the type of the resource to be included.  For example,
>>>> "script".  Please
>>>>> -     *  see the TemplateManager class for more information about 
>>>>> the
>>>> different kinds
>>>>> -     *  of types you can use.
>>>>> -     *
>>>>> -     *  @see TemplateManager
>>>>> +     *  This method does nothing.
>>>>>    *
>>>>>    *  @param type The type to be set.
>>>>>    */
>>>>>
>>>>>   public void setType(String type)
>>>>>   {
>>>>> -        m_type = type;
>>>>>   }
>>>>>
>>>>> }
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> EditorManager.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> EditorManager.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> EditorManager.java Mon
>>>> Mar  1 05:23:10 2010
>>>>> @@ -73,9 +73,6 @@
>>>>>   /** Known name for the plain wikimarkup editor. */
>>>>>   public static final String       EDITOR_PLAIN    = "plain";
>>>>>
>>>>> -    /** Known name for the preview editor component. */
>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>> -
>>>>>   /** Known attribute name for storing the user edited text  
>>>>> inside a
>>>> HTTP parameter. */
>>>>>   public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>
>>>>> @@ -189,9 +186,6 @@
>>>>>    */
>>>>>   public String getEditorName( WikiContext context )
>>>>>   {
>>>>> -        if( context.getRequestContext().equals 
>>>>> (WikiContext.PREVIEW) )
>>>>> -            return EDITOR_PREVIEW;
>>>>> -
>>>>>       String editor = null;
>>>>>
>>>>>       // User has set an editor in preferences
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> TemplateManager.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> TemplateManager.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/ 
>>>> TemplateManager.java Mon
>>>> Mar  1 05:23:10 2010
>>>>> @@ -20,8 +20,6 @@
>>>>> */
>>>>> package org.apache.wiki.ui;
>>>>>
>>>>> -import java.io.IOException;
>>>>> -import java.io.InputStream;
>>>>> import java.util.*;
>>>>>
>>>>> import javax.servlet.ServletContext;
>>>>> @@ -46,7 +44,7 @@
>>>>> */
>>>>> public class TemplateManager extends ModuleManager
>>>>> {
>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>
>>>>>   /**
>>>>>    * Attribute name for the resource resolver map returned by
>>>>> @@ -55,61 +53,14 @@
>>>>>    */
>>>>>   private static final String RESOURCE_RESOLVER =  
>>>>> "resourceResolver";
>>>>>
>>>>> -    /**
>>>>> -     * Requests a JavaScript function to be called during  
>>>>> window.onload.
>>>> Value
>>>>> -     * is {@value}.
>>>>> -     */
>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>> -
>>>>> -    /**
>>>>> -     * Requests a JavaScript associative array with all localized
>>>> strings.
>>>>> -     */
>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>> "jslocalizedstrings";
>>>>> -
>>>>> -    /**
>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>> -     */
>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>> -
>>>>> -    /**
>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>> -     */
>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>> -
>>>>> -    /**
>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>> -     */
>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>> -
>>>>>   /** The default directory for template resources. Value is  
>>>>> {@value}.
>>>> */
>>>>> -    public static final String DIRECTORY = "templates";
>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>
>>>>>   /** The name of the default template. Value is {@value}. */
>>>>>   public static final String DEFAULT_TEMPLATE = "default";
>>>>>
>>>>> -    /** Name of the file that contains the properties. */
>>>>> -    public static final String PROPERTYFILE =  
>>>>> "template.properties";
>>>>> -
>>>>> -    /** I18N string to mark the default locale */
>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>> "prefs.user.language.default";
>>>>> -
>>>>> -    /**
>>>>> -     * The name under which the resource includes map is stored  
>>>>> in the
>>>>> -     * WikiContext.
>>>>> -     */
>>>>> -    public static final String RESOURCE_INCLUDES =
>>>> "jspwiki.resourceincludes";
>>>>> -
>>>>> -    // private Cache m_propertyCache;
>>>>> -
>>>>>   protected static final Logger log = LoggerFactory.getLogger(
>>>> TemplateManager.class );
>>>>>
>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>> -
>>>>> -    private WikiEngine m_engine;
>>>>> -
>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>> Collections.emptyList();
>>>>> -
>>>>>   /**
>>>>>    * <p>Resolves requests for resources relative to the
>>>>>    * <code>templates/<var>template</var></code> path to the actual
>>>> resources,
>>>>> @@ -125,8 +76,8 @@
>>>>>    * for certain keys to return <code>null</code>. The map itself 
>>>>> is
>>>>>    * immutable.
>>>>>    * </p>
>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>> ServletContext
>>>>> -     * is active, even if the WikiEngine cannot initialize for  
>>>>> some
>>>> reason.
>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>    * If the WikiEngine does not initialize, the default template
>>>>>    * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>> requests.</p>
>>>>>    * @param servletContext the servlet context
>>>>> @@ -156,10 +107,10 @@
>>>>>
>>>>>           // Add all of the resources the template contains
>>>>>           resolver = new HashMap<String,String>();
>>>>> -            addResources( context, resolver, "/" + DIRECTORY +  
>>>>> "/" +
>>>> template + "/", null );
>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR  
>>>>> + "/" +
>>>> template + "/", null );
>>>>>
>>>>>           // Add resources the template does not contain, but  
>>>>> default
>>>> does
>>>>> -            addResources( context, resolver, "/" + DIRECTORY +  
>>>>> "/" +
>>>> DEFAULT_TEMPLATE + "/", null );
>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR  
>>>>> + "/" +
>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>           resolver = Collections.unmodifiableMap( resolver );
>>>>>           context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>       }
>>>>> @@ -167,18 +118,49 @@
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     * Creates a new TemplateManager. There is typically one  
>>>>> manager per
>>>> engine.
>>>>> -     *
>>>>> -     * @param engine The owning engine.
>>>>> -     * @param properties The property list used to initialize  
>>>>> this.
>>>>> +     * Adds all of the resources under a specified path prefix  
>>>>> to the
>>>>> +     * resource resolver map, with the "short name" of the path  
>>>>> as the
>>>>> +     * key, and the full path as the value. The short name is the
>>>> portion
>>>>> +     * of the path after the prefix. If a resource with that  
>>>>> short name
>>>>> +     * has already been added to the resource map, it will not  
>>>>> be added
>>>>> +     * again. Any resources ending in {@code /} (i.e., a  
>>>>> directory path)
>>>>> +     * will be processed recursively.
>>>>> +     * @param context the servlet context
>>>>> +     * @param resolver the resource resolver map
>>>>> +     * @param prefix the path prefix that the search initiates  
>>>>> from
>>>>> +     * @param dir the directory to search relative to the path  
>>>>> prefix.
>>>> If not
>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>    */
>>>>> -    public TemplateManager( WikiEngine engine, Properties  
>>>>> properties )
>>>>> +    @SuppressWarnings("unchecked")
>>>>> +    private static void addResources( ServletContext context,
>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>   {
>>>>> -        super( engine );
>>>>> -        m_engine = engine;
>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>> -    }
>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>> +        Set<String> resources = context.getResourcePaths( 
>>>>> searchPath );
>>>>> +        if ( resources != null )
>>>>> +        {
>>>>> +            for ( String resource : resources )
>>>>> +            {
>>>>> +                String shortName = resource.substring( 
>>>>> prefix.length()
>>>> );
>>>>> +
>>>>> +                // Directory: process these entries too
>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>> +                {
>>>>> +                    addResources( context, resolver, prefix,  
>>>>> shortName
>>>> );
>>>>> +                }
>>>>>
>>>>> +                // Regular resource: add it if we don't have it  
>>>>> already
>>>>> +                else
>>>>> +                {
>>>>> +                    boolean alreadyProcessed =  
>>>>> resolver.containsKey(
>>>> shortName );
>>>>> +                    if ( !alreadyProcessed )
>>>>> +                    {
>>>>> +                        resolver.put( shortName, resource );
>>>>> +                    }
>>>>> +                }
>>>>> +            }
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>>   /**
>>>>>    * Tries to locate a given resource from the template directory,
>>>> relative to
>>>>>    * the root of the JSPWiki webapp context (for example,  
>>>>> relative to
>>>>> @@ -188,63 +170,62 @@
>>>>>    * default template path either, <code>null</code> is returned.
>>>>>    *
>>>>>    *
>>>>> -     * @param sContext the servlet context
>>>>> +     * @param servletContext the servlet context
>>>>>    * @param path the path to the resource; for example,
>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code  
>>>>> jspwiki.css}.
>>>>> +     * If the path starts with a slash (/), the resource is  
>>>>> looked up
>>>>> +     * relative to the webapp root
>>>>>    * @return The name of the resource which was found; for example,
>>>>>    * <code>/templates/custom/FindContent.jsp</code> (if it exists 
>>>>> in
>>>> the
>>>>>    * <code>custom</code> template directory), or
>>>>>    * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>    */
>>>>> -    private static String findResource( ServletContext sContext, 
>>>>> String
>>>> path )
>>>>> +    private static String findResource( ServletContext  
>>>>> servletContext,
>>>> String path )
>>>>>   {
>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>> -
>>>>> -        if( is == null )
>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>       {
>>>>> -            String defaultPath = makeFullJSPName( 
>>>>> DEFAULT_TEMPLATE,
>>>> removeTemplatePart( path ) );
>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>> -
>>>>> -            if( is != null )
>>>>> -                path = defaultPath;
>>>>> -            else
>>>>> -                path = null;
>>>>> -        }
>>>>> -
>>>>> -        if( is != null )
>>>>> -        {
>>>>> -            try
>>>>> -            {
>>>>> -                is.close();
>>>>> -            }
>>>>> -            catch( IOException e )
>>>>> -            {
>>>>> -            }
>>>>> +            // This is already a full path
>>>>> +            return findResource( servletContext, path );
>>>>>       }
>>>>> -
>>>>> -        return path;
>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     * Attempts to find a resource from the given template, and  
>>>>> if it's
>>>> not
>>>>> -     * found attempts to locate it from the default template.
>>>>> -     *
>>>>> -     * @param sContext
>>>>> -     * @param template
>>>>> -     * @param name
>>>>> -     * @return
>>>>> +     * Returns a property, as defined in the template. The  
>>>>> evaluation is
>>>> lazy,
>>>>> +     * i.e. the properties are not loaded until the template is  
>>>>> actually
>>>> used
>>>>> +     * for the first time.
>>>>> +     */
>>>>> +    /*
>>>>> +     * public String getTemplateProperty( WikiContext context,  
>>>>> String
>>>> key ) {
>>>>> +     * String template = context.getTemplate(); try { Properties 
>>>>> props =
>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 ); 
>>>>> if(
>>>> props ==
>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>> IOException e ) {
>>>>> +     * log.warn("IO Exception while reading template  
>>>>> properties",e);
>>>> return
>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>> NeedsRefreshException
>>>>> +     * ex ) { // FIXME return null; } }
>>>>>    */
>>>>> -    private static String findResource( ServletContext sContext, 
>>>>> String
>>>> template, String name )
>>>>> +    /**
>>>>> +     * Returns an absolute path to a given template.
>>>>> +     */
>>>>> +    private static final String getPath( String template )
>>>>>   {
>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>> -        {
>>>>> -            // This is already a full path
>>>>> -            return findResource( sContext, name );
>>>>> -        }
>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>> +    }
>>>>>
>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>> +    private WikiEngine m_engine;
>>>>>
>>>>> -        return findResource( sContext, fullname );
>>>>> +    /**
>>>>> +     * Creates a new TemplateManager. There is typically one  
>>>>> manager per
>>>> engine.
>>>>> +     *
>>>>> +     * @param engine The owning engine.
>>>>> +     * @param properties The property list used to initialize  
>>>>> this.
>>>>> +     */
>>>>> +    public TemplateManager( WikiEngine engine, Properties  
>>>>> properties )
>>>>> +    {
>>>>> +        super( engine );
>>>>> +        m_engine = engine;
>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>   }
>>>>>
>>>>>   /**
>>>>> @@ -252,53 +233,17 @@
>>>>>    * current context or by the absolute name.
>>>>>    *
>>>>>    * @param pageContext the JSP PageContext
>>>>> -     * @param name The name of the JSP page to look for (e.g  
>>>>> "Wiki.jsp")
>>>>> +     * @param name The name of the JSP page to look for (e.g  
>>>>> {@code
>>>> Wiki.jsp})
>>>>>    * @return The context path to the resource
>>>>> +     * @deprecated use {@link #getResourceResolver 
>>>>> (ServletContext)}
>>>> instead
>>>>>    */
>>>>>   public String findJSP( PageContext pageContext, String name )
>>>>>   {
>>>>>       ServletContext sContext = pageContext.getServletContext();
>>>>> -
>>>>>       return findResource( sContext, name );
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     * Removes the template part of a name.
>>>>> -     */
>>>>> -    private static final String removeTemplatePart( String name )
>>>>> -    {
>>>>> -        int idx = 0;
>>>>> -        if( name.startsWith( "/" ) )
>>>>> -            idx = 1;
>>>>> -
>>>>> -        idx = name.indexOf( '/', idx );
>>>>> -        if( idx != -1 )
>>>>> -        {
>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>> -
>>>>> -            if( idx != -1 )
>>>>> -            {
>>>>> -                name = name.substring( idx + 1 );
>>>>> -            }
>>>>> -        }
>>>>> -
>>>>> -        log.info( "Final name = " + name );
>>>>> -        return name;
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>> template=foo.
>>>>> -     *
>>>>> -     * @param template The name of the template.
>>>>> -     * @param name The name of the resource.
>>>>> -     * @return The full name for a template.
>>>>> -     */
>>>>> -    private static final String makeFullJSPName( String  
>>>>> template, String
>>>> name )
>>>>> -    {
>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>>    * Attempts to locate a resource under the given template. If  
>>>>> that
>>>> template
>>>>>    * does not exist, or the page does not exist under that  
>>>>> template,
>>>> will
>>>>>    * attempt to locate a similarly named file under the default
>>>> template.
>>>>> @@ -310,6 +255,7 @@
>>>>>    * @param template From which template we should seek initially?
>>>>>    * @param name Which resource are we looking for (e.g.
>>>> "DefaultLayout.jsp")
>>>>>    * @return path to the JSP page; null, if it was not found.
>>>>> +     * @deprecated use {@link #getResourceResolver 
>>>>> (ServletContext)}
>>>> instead
>>>>>    */
>>>>>   public String findJSP( PageContext pageContext, String template,
>>>> String name )
>>>>>   {
>>>>> @@ -319,8 +265,7 @@
>>>>>                      + ((HttpServletRequest)
>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>           throw new InternalWikiException( "Illegal arguments to
>>>> findJSP(); please check logs." );
>>>>>       }
>>>>> -
>>>>> -        return findResource( pageContext.getServletContext(),  
>>>>> template,
>>>> name );
>>>>> +        return findResource( pageContext.getServletContext(),  
>>>>> name );
>>>>>   }
>>>>>
>>>>>   /**
>>>>> @@ -337,45 +282,23 @@
>>>>>    * @param template the name of the template to use
>>>>>    * @param name the name of the resource to fine
>>>>>    * @return the path to the resource
>>>>> +     * @deprecated use {@link #getResourceResolver 
>>>>> (ServletContext)}
>>>> instead
>>>>>    */
>>>>>   public String findResource( WikiContext ctx, String template,  
>>>>> String
>>>> name )
>>>>>   {
>>>>>       if( m_engine.getServletContext() != null )
>>>>>       {
>>>>> -            return findResource( m_engine.getServletContext(),  
>>>>> template,
>>>> name );
>>>>> +            return findResource( m_engine.getServletContext(),  
>>>>> name );
>>>>>       }
>>>>>
>>>>>       return getPath( template ) + "/" + name;
>>>>>   }
>>>>>
>>>>>   /**
>>>>> -     * Returns a property, as defined in the template. The  
>>>>> evaluation is
>>>> lazy,
>>>>> -     * i.e. the properties are not loaded until the template is  
>>>>> actually
>>>> used
>>>>> -     * for the first time.
>>>>> -     */
>>>>> -    /*
>>>>> -     * public String getTemplateProperty( WikiContext context,  
>>>>> String
>>>> key ) {
>>>>> -     * String template = context.getTemplate(); try { Properties 
>>>>> props =
>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 ); 
>>>>> if(
>>>> props ==
>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>> IOException e ) {
>>>>> -     * log.warn("IO Exception while reading template  
>>>>> properties",e);
>>>> return
>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>> NeedsRefreshException
>>>>> -     * ex ) { // FIXME return null; } }
>>>>> -     */
>>>>> -    /**
>>>>> -     * Returns an absolute path to a given template.
>>>>> -     */
>>>>> -    private static final String getPath( String template )
>>>>> -    {
>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Lists the skins available under this template. Returns an 
>>>>> empty
>>>> Set, if
>>>>> -     * there are no extra skins available. Note that this method 
>>>>> does
>>>> not check
>>>>> -     * whether there is anything actually in the directories, it 
>>>>> just
>>>> lists
>>>>> -     * them. This may change in the future.
>>>>> +     * Lists the skins available under the current template.
>>>>> +     * Returns an empty Set, if there are no extra skins  
>>>>> available.
>>>>> +     * Note that this method does not check whether there is  
>>>>> anything
>>>>> +     * actually in the directories, it just lists them.
>>>>>    *
>>>>>    * @param servletContext the servlet context
>>>>>    * @param template The template to search
>>>>> @@ -383,14 +306,14 @@
>>>>>    * @since 2.3.26
>>>>>    */
>>>>>   @SuppressWarnings( "unchecked" )
>>>>> -    public Set<String> listSkins( ServletContext servletContext, 
>>>>> String
>>>> template )
>>>>> +    public Set<String> listSkins()
>>>>>   {
>>>>> -        String place = makeFullJSPName( template,  
>>>>> SKIN_DIRECTORY );
>>>>> -        Set<String> skinSet = servletContext.getResourcePaths( 
>>>>> place );
>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>> +        Set<String> skinSet =
>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>       TreeSet<String> resultSet = new TreeSet<String>();
>>>>>
>>>>>       if( log.isDebugEnabled() )
>>>>> -            log.debug( "Listings skins from " + place );
>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>
>>>>>       if( skinSet != null )
>>>>>       {
>>>>> @@ -414,215 +337,7 @@
>>>>>
>>>>>       return resultSet;
>>>>>   }
>>>>> -
>>>>> -    /**
>>>>> -     * Always returns a valid property map.
>>>>> -     */
>>>>> -    /*
>>>>> -     * private Properties getTemplateProperties( String  
>>>>> templateName )
>>>> throws
>>>>> -     * IOException { Properties p = new Properties();  
>>>>> ServletContext
>>>> context =
>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>> -     * context.getResourceAsStream(getPath(templateName) 
>>>>> +PROPERTYFILE);
>>>> if(
>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>> '"+templateName+"'
>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }  
>>>>> return p; }
>>>>> -     */
>>>>> -    /**
>>>>> -     * Returns the include resources marker for a given type.  
>>>>> This is in
>>>> a HTML
>>>>> -     * or Javascript comment format.
>>>>> -     *
>>>>> -     * @param context the wiki context
>>>>> -     * @param type the marker
>>>>> -     * @return the generated marker comment
>>>>> -     * @deprecated use the Stripes <code>layout-component</code> 
>>>>> tags
>>>> instead
>>>>> -     */
>>>>> -    public static String getMarker( WikiContext context, String  
>>>>> type )
>>>>> -    {
>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>> -        {
>>>>> -            return getJSLocalizedStrings( context );
>>>>> -        }
>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>> -        {
>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>> -        }
>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Extract all i18n strings in the javascript domain.  
>>>>> (javascript.*)
>>>> Returns
>>>>> -     * a javascript snippet which defines the LoacalizedStings  
>>>>> array.
>>>>> -     *
>>>>> -     * @param wiki context
>>>>> -     * @return Javascript snippet which defines the  
>>>>> LocaliedStrings
>>>> array
>>>>> -     * @since 2.5.108
>>>>> -     * @deprecated use the Stripes <code>layout-component</code> 
>>>>> tags
>>>> instead
>>>>> -     */
>>>>> -    private static String getJSLocalizedStrings( WikiContext  
>>>>> context )
>>>>> -    {
>>>>> -        StringBuilder sb = new StringBuilder();
>>>>> -
>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>> -
>>>>> -        ResourceBundle rb = context.getBundle( 
>>>>> "templates.default" );
>>>>> -
>>>>> -        boolean first = true;
>>>>> -
>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>> en.hasMoreElements(); )
>>>>> -        {
>>>>> -            String key = en.nextElement();
>>>>> -
>>>>> -            if( key.startsWith( "javascript" ) )
>>>>> -            {
>>>>> -                if( first )
>>>>> -                {
>>>>> -                    first = false;
>>>>> -                }
>>>>> -                else
>>>>> -                {
>>>>> -                    sb.append( ",\n" );
>>>>> -                }
>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString( 
>>>>> key ) +
>>>> "\"" );
>>>>> -            }
>>>>> -        }
>>>>> -        sb.append( "\n};\n" );
>>>>> -
>>>>> -        return(sb.toString());
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Adds a resource request to the current request context. The
>>>> content will
>>>>> -     * be added at the resource-type marker (see  
>>>>> IncludeResourcesTag) in
>>>>> -     * WikiJSPFilter.
>>>>> -     * <p>
>>>>> -     * The resources can be of different types. For  
>>>>> RESOURCE_SCRIPT and
>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource  
>>>>> (a script
>>>> file or
>>>>> -     * an external stylesheet) that needs to be included. For
>>>> RESOURCE_INLINECSS
>>>>> -     * the resource should be something that can be added between
>>>>> -     * &lt;style>&lt;/style> in the header file  
>>>>> (commonheader.jsp). For
>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript  
>>>>> function
>>>> that should
>>>>> -     * be run at page load.
>>>>> -     * <p>
>>>>> -     * The IncludeResourceTag inserts code in the template  
>>>>> files, which
>>>> is then
>>>>> -     * filled by the WikiFilter after the request has been  
>>>>> rendered but
>>>> not yet
>>>>> -     * sent to the recipient.
>>>>> -     * <p>
>>>>> -     * Note that ALL resource requests get rendered, so this  
>>>>> method does
>>>> not
>>>>> -     * check if the request already exists in the resources.  
>>>>> Therefore,
>>>> if you
>>>>> -     * have a plugin which makes a new resource request every  
>>>>> time,
>>>> you'll end
>>>>> -     * up with multiple resource requests rendered. It's thus a  
>>>>> good
>>>> idea to
>>>>> -     * make this request only once during the page life cycle.
>>>>> -     *
>>>>> -     * @param ctx The current wiki context
>>>>> -     * @param type What kind of a request should be added?
>>>>> -     * @param resource The resource to add.
>>>>> -     * @deprecated use the Stripes <code>layout-component</code> 
>>>>> tags
>>>> instead
>>>>> -     */
>>>>> -    @SuppressWarnings( "unchecked" )
>>>>> -    public static void addResourceRequest( WikiContext ctx,  
>>>>> String type,
>>>> String resource )
>>>>> -    {
>>>>> -        HashMap<String, Vector<String>> resourcemap =  
>>>>> (HashMap<String,
>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>> -
>>>>> -        if( resourcemap == null )
>>>>> -        {
>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>> -        }
>>>>> -
>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>> -
>>>>> -        if( resources == null )
>>>>> -        {
>>>>> -            resources = new Vector<String>();
>>>>> -        }
>>>>> -
>>>>> -        String resourceString = null;
>>>>> -
>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>> -        {
>>>>> -            resourceString = "<script type='text/javascript'  
>>>>> src='" +
>>>> resource + "'></script>";
>>>>> -        }
>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>> -        {
>>>>> -            resourceString = "<link rel='stylesheet' type='text/ 
>>>>> css'
>>>> href='" + resource + "' />";
>>>>> -        }
>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>> -        {
>>>>> -            resourceString = "<style type='text/css'>\n" +  
>>>>> resource +
>>>> "\n</style>\n";
>>>>> -        }
>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>> -        {
>>>>> -            resourceString = resource;
>>>>> -        }
>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>> -        {
>>>>> -            resourceString = resource;
>>>>> -        }
>>>>> -
>>>>> -        if( resourceString != null )
>>>>> -        {
>>>>> -            resources.add( resourceString );
>>>>> -        }
>>>>> -
>>>>> -        log.debug( "Request to add a resource: " +  
>>>>> resourceString );
>>>>> -
>>>>> -        resourcemap.put( type, resources );
>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Returns resource requests for a particular type. If there 
>>>>> are no
>>>>> -     * resources, returns an empty array.
>>>>> -     *
>>>>> -     * @param ctx WikiContext
>>>>> -     * @param type The resource request type
>>>>> -     * @return a String array for the resource requests
>>>>> -     * @deprecated use the Stripes <code>layout-component</code> 
>>>>> tags
>>>> instead
>>>>> -     */
>>>>> -    @SuppressWarnings( "unchecked" )
>>>>> -    public static String[] getResourceRequests( WikiContext ctx, 
>>>>> String
>>>> type )
>>>>> -    {
>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>> -
>>>>> -        if( hm == null )
>>>>> -            return new String[0];
>>>>> -
>>>>> -        Vector<String> resources = hm.get( type );
>>>>> -
>>>>> -        if( resources == null )
>>>>> -            return new String[0];
>>>>> -
>>>>> -        String[] res = new String[resources.size()];
>>>>> -
>>>>> -        return resources.toArray( res );
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Returns all those types that have been requested so far.
>>>>> -     *
>>>>> -     * @param ctx the wiki context
>>>>> -     * @return the array of types requested
>>>>> -     * @deprecated use the Stripes <code>layout-component</code> 
>>>>> tags
>>>> instead
>>>>> -     */
>>>>> -    @SuppressWarnings( "unchecked" )
>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>> -    {
>>>>> -        String[] res = new String[0];
>>>>> -
>>>>> -        if( ctx != null )
>>>>> -        {
>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>> -
>>>>> -            if( hm != null )
>>>>> -            {
>>>>> -                Set<String> keys = hm.keySet();
>>>>> -
>>>>> -                res = keys.toArray( res );
>>>>> -            }
>>>>> -        }
>>>>> -
>>>>> -        return res;
>>>>> -    }
>>>>> -
>>>>> +
>>>>>   /**
>>>>>    * Returns an empty collection, since at the moment the
>>>> TemplateManager does
>>>>>    * not manage any modules.
>>>>> @@ -631,50 +346,6 @@
>>>>>    */
>>>>>   public Collection<WikiModuleInfo> modules()
>>>>>   {
>>>>> -        return EMPTY_MODULE_LIST;
>>>>> -    }
>>>>> -
>>>>> -    /**
>>>>> -     * Adds all of the resources under a specified path prefix  
>>>>> to the
>>>>> -     * resource resolver map, with the "short name" of the path  
>>>>> as the
>>>>> -     * key, and the full path as the value. The short name is the
>>>> portion
>>>>> -     * of the path after the prefix. If a resource with that  
>>>>> short name
>>>>> -     * has already been added to the resource map, it will not  
>>>>> be added
>>>>> -     * again. Any resources ending in {@code /} (i.e., a  
>>>>> directory path)
>>>>> -     * will be processed recursively.
>>>>> -     * @param context the servlet context
>>>>> -     * @param resolver the resource resolver map
>>>>> -     * @param prefix the path prefix that the search initiates  
>>>>> from
>>>>> -     * @param dir the directory to search relative to the path  
>>>>> prefix.
>>>> If not
>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>> -     */
>>>>> -    @SuppressWarnings("unchecked")
>>>>> -    private static void addResources( ServletContext context,
>>>> Map<String,String> resolver, String prefix, String dir )
>>>>> -    {
>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>> -        Set<String> resources = context.getResourcePaths( 
>>>>> searchPath );
>>>>> -        if ( resources != null )
>>>>> -        {
>>>>> -            for ( String resource : resources )
>>>>> -            {
>>>>> -                String shortName = resource.substring( 
>>>>> prefix.length()
>>>> );
>>>>> -
>>>>> -                // Directory: process these entries too
>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>> -                {
>>>>> -                    addResources( context, resolver, prefix,  
>>>>> shortName
>>>> );
>>>>> -                }
>>>>> -
>>>>> -                // Regular resource: add it if we don't have it  
>>>>> already
>>>>> -                else
>>>>> -                {
>>>>> -                    boolean alreadyProcessed =  
>>>>> resolver.containsKey(
>>>> shortName );
>>>>> -                    if ( !alreadyProcessed )
>>>>> -                    {
>>>>> -                        resolver.put( shortName, resource );
>>>>> -                    }
>>>>> -                }
>>>>> -            }
>>>>> -        }
>>>>> +        return Collections.emptyList();
>>>>>   }
>>>>> }
>>>>>
>>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/ 
>>>> TemplateResolution.java
>>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>
>>>> ============ 
>>>> ==================================================================
>>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/ 
>>>> TemplateResolution.java
>>>> (original)
>>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/ 
>>>> TemplateResolution.java
>>>> Mon Mar  1 05:23:10 2010
>>>>> @@ -22,6 +22,8 @@
>>>>> {
>>>>>   private static final Logger LOG = LoggerFactory.getLogger(
>>>> TemplateResolution.class );
>>>>>
>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>> TemplateManager.TEMPLATE_DIR + "/" +  
>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>> +
>>>>>   /**
>>>>>    * Constructs a new TemplateResolution
>>>>>    *
>>>>> @@ -41,7 +43,7 @@
>>>>>       String path = TemplateManager.getResourceResolver( 
>>>>> servletContext
>>>> ).get( getPath() );
>>>>>       if( path == null )
>>>>>       {
>>>>> -            path = "/templates/" +  
>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>> "/" + getPath();
>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>       }
>>>>>       setPath( path );
>>>>>
>>>>>
>>>>
>>>>
>>

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
If you can figure out something cool and dynamic, I'm all for it :-).  However, I'm not sure that there's anything that really can be done differently (I recall doing the same exercise a few years back). Buffering the response seems to be the standard way of doing things, though it does not necessarily have to be through a Filter. Obviously, attachments should not be buffered, since they can be fairly large.

Note that in practice it's not much of a performance hit, since JSPWiki returns a massive String anyway, which means that in effect the buffering is done anyway; the actual page decoration isn't necessarily that much extra.

/Janne

On 4 Mar 2010, at 20:28, Andrew Jaquith wrote:

> Janne, I'm out of bandwidth and time today. Would like to do something
> other than buffer the whole page via filter. Let me noodle on this and
> get back to you -- ok? (You've got the kid, I've got the job & travel
> -- both barriers to conversation.)
> 
> Andrew
> 
> On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
> <ja...@ecyrd.com> wrote:
>> 
>> Sorry, kid interrupted the message....
>> 
>> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>> 
>> /Janne
>> 
>> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>> 
>>> 
>>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>> 
>>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>> 
>>> /Janne
>>> 
>>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>> 
>>>> Janne and Dirk --
>>>> 
>>>> Here's my proposal to resolve the resource-inclusion issue.
>>>> 
>>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>>> works fine. I'll check this in at my next opportunity (not for a few
>>>> days, probably).
>>>> 
>>>> 2. Plugin resources. It turns out we have a ready-made class,
>>>> WikiModuleInfo, that enumerates the resources that modules (like
>>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>>> before forwarding to the JSP, we simply inspect the page text before
>>>> to see what plugins are asked for in the wiki markup. For any that are
>>>> encountered, we add any script or css resources requirements to a
>>>> request "queue," which is processed when the JSP actually renders (by
>>>> IncludeResourcesTag or JSTL code).
>>>> 
>>>> I am satisfied that (2) will be safe because we would just be fetching
>>>> resources the developer specifically required, as the modules XML
>>>> file, or (better) class annotations specify.
>>>> 
>>>> Andrew
>>>> 
>>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>>> <an...@gmail.com> wrote:
>>>>> Janne --
>>>>> 
>>>>> Agreed. Each editor has special needs that ought to be specified in
>>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>> 
>>>>> In the current implementation, the scripts needed for the plain editor
>>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>>> how this would be specified instead in the editor JSPs directly.
>>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>>> yet.
>>>>> 
>>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>>> the editors working and to allow them to specify their own resources.
>>>>> It will be done soon enough.
>>>>> 
>>>>> In the meantime, I received your message -- that you need a way to
>>>>> allow plugins to include their own resources -- loud and clear. I
>>>>> don't have an answer for that today, but will propose some options
>>>>> shortly.
>>>>> 
>>>>> Andrew
>>>>> 
>>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>>> Why would we include the plain text editor in the case that the user
>>>>>> preferences state FCK editor?  Or vice versa?
>>>>>> 
>>>>>> From the point of view of the layouts editors and plugins should be
>>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>> 
>>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>>> the template choice.
>>>>>> 
>>>>>> /Janne
>>>>>> 
>>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>> 
>>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>>> for example.
>>>>>>> 
>>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>> 
>>>>>>> Andrew
>>>>>>> 
>>>>>>> 
>>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> 
>>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>>> component.
>>>>>>>> 
>>>>>>>> /Janne
>>>>>>>> 
>>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>> 
>>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>> 
>>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>>> layout jsp)
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>>> probably
>>>>>>>>> also css) is needed.
>>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>>> correct
>>>>>>>>> resources.
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> dirk
>>>>>>>>> 
>>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>>> how do
>>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>>> fall back to
>>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>>> assumes that
>>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>>> template,
>>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>> 
>>>>>>>>>> /Janne
>>>>>>>>>> 
>>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>> 
>>>>>>>>>>> Author: ajaquith
>>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>>> New Revision: 917390
>>>>>>>>>>> 
>>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>>> Log:
>>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>>> should) be
>>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> EditorTag.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> EditorManager.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>> 
>>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>> +
>>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>>> +
>>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>>> are now
>>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>>> doCatch()
>>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>>> debugging.
>>>>>>>>>>> +
>>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>>> feature was
>>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>>> View tab
>>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>>> +
>>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>>> JSPs.
>>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>>> used
>>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>>> customizable
>>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>>> +
>>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>>> Resources
>>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>>> +
>>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>>> as part
>>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>>> Stripesed.
>>>>>>>>>>> +
>>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>> 
>>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>>> changes
>>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>>> spaces is
>>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>> 
>>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>> 
>>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>>> Release.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>> Mon Mar
>>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>>   *  <p>
>>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>>   */
>>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>> Note.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>> Note.java Mon
>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>> 
>>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>> 
>>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>>> -
>>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>>> -
>>>>>>>>>> commentImage );
>>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>> 
>>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>>      }
>>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>>      {
>>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>>      }
>>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>>      {
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>> 
>>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>>  {
>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>> -
>>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>>> -
>>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>>> -
>>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>> -
>>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>>> -
>>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>> 
>>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> /**
>>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>>          }
>>>>>>>>>>> 
>>>>>>>>>>> -            String page =
>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>> -
>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>> -
>>>>>>>>>>       contentTemplate );
>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>>      }
>>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> EditorTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> EditorTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>> 
>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> /**
>>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>> 
>>>>>>>>>>>      try
>>>>>>>>>>>      {
>>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>>> pageContext,
>>>>>>>>>>> -
>>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>>> -
>>>>>>>>>> editorPath );
>>>>>>>>>>> -
>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>          {
>>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>>> */
>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>> 
>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> 
>>>>>>>>>>> /**
>>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>>> emits a
>>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>>> take
>>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>>> - *
>>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>> instead
>>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>>> into the
>>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>>> ServletFilter.
>>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>>> The
>>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>> on how
>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>> instead
>>>>>>>>>>> */
>>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>>> {
>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>> 
>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>> -
>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>  {
>>>>>>>>>>>      super.initTag();
>>>>>>>>>>> -        m_type = null;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>>  {
>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>  {
>>>>>>>>>>> -        //String marker =
>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>>> (m_wikiContext,
>>>>>>>>>> m_type);
>>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>>> m_type);
>>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>>> m_type);
>>>>>>>>>>> -
>>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>>> -
>>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>>> layout tags instead " +
>>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>> 
>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>>  {
>>>>>>>>>>>      try
>>>>>>>>>>>      {
>>>>>>>>>>> -            String page =
>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>> -
>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>> -
>>>>>>>>>>       m_page );
>>>>>>>>>>> -
>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>          {
>>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>>> */
>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>> 
>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> -
>>>>>>>>>>> /**
>>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>>> ().  You
>>>>>>>>>> may use
>>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>>> - *
>>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>>> JSPWiki to
>>>>>>>>>> insert
>>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>>> because it
>>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>>> instead. See
>>>>>>>>>> the default
>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>> on how
>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>> instead
>>>>>>>>>>> */
>>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>>> {
>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>> -
>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>  {
>>>>>>>>>>>      super.initTag();
>>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>>  @Override
>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>  {
>>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>>> m_type,
>>>>>>>>>> m_resource );
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>>   */
>>>>>>>>>>>  public String getResource()
>>>>>>>>>>>  {
>>>>>>>>>>> -        return m_resource;
>>>>>>>>>>> +        return "";
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>>   */
>>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>>  {
>>>>>>>>>>> -        m_resource = r;
>>>>>>>>>>> +        // No-op.
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>>   */
>>>>>>>>>>>  public String getType()
>>>>>>>>>>>  {
>>>>>>>>>>> -        return m_type;
>>>>>>>>>>> +        return "";
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>>> "script".  Please
>>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>>> the
>>>>>>>>>> different kinds
>>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>>   */
>>>>>>>>>>> 
>>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>>  {
>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> }
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java Mon
>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>> 
>>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>>> -
>>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>>> inside a
>>>>>>>>>> HTTP parameter. */
>>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>> 
>>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>>  {
>>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>>> -
>>>>>>>>>>>      String editor = null;
>>>>>>>>>>> 
>>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java Mon
>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>>> */
>>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>> 
>>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>>> import java.util.*;
>>>>>>>>>>> 
>>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>>> */
>>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>>> {
>>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>>> "resourceResolver";
>>>>>>>>>>> 
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>>> window.onload.
>>>>>>>>>> Value
>>>>>>>>>>> -     * is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>>> strings.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>>> -
>>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>>> {@value}.
>>>>>>>>>> */
>>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>> 
>>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>> 
>>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>>> "template.properties";
>>>>>>>>>>> -
>>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>>> in the
>>>>>>>>>>> -     * WikiContext.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>>> -
>>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>>> -
>>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>>> TemplateManager.class );
>>>>>>>>>>> 
>>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>>> -
>>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>>> -
>>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>>> Collections.emptyList();
>>>>>>>>>>> -
>>>>>>>>>>>  /**
>>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>>> resources,
>>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>>> is
>>>>>>>>>>>   * immutable.
>>>>>>>>>>>   * </p>
>>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>>> ServletContext
>>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>>> some
>>>>>>>>>> reason.
>>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>>> requests.</p>
>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>> 
>>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>> "/" +
>>>>>>>>>> template + "/", null );
>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>> + "/" +
>>>>>>>>>> template + "/", null );
>>>>>>>>>>> 
>>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>>> default
>>>>>>>>>> does
>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>> "/" +
>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>> + "/" +
>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>>      }
>>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>> manager per
>>>>>>>>>> engine.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>>> this.
>>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>>> to the
>>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>>> as the
>>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>>> portion
>>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>>> short name
>>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>>> be added
>>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>> directory path)
>>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>>> from
>>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>>> prefix.
>>>>>>>>>> If not
>>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>   */
>>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>> properties )
>>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>  {
>>>>>>>>>>> -        super( engine );
>>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>> -    }
>>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>> searchPath );
>>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>>> +        {
>>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>>> +            {
>>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>>> prefix.length()
>>>>>>>>>> );
>>>>>>>>>>> +
>>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>> +                {
>>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>>> shortName
>>>>>>>>>> );
>>>>>>>>>>> +                }
>>>>>>>>>>> 
>>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>>> already
>>>>>>>>>>> +                else
>>>>>>>>>>> +                {
>>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>> shortName );
>>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>>> +                    {
>>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>>> +                    }
>>>>>>>>>>> +                }
>>>>>>>>>>> +            }
>>>>>>>>>>> +        }
>>>>>>>>>>> +    }
>>>>>>>>>>> +
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>>> relative to
>>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>>> relative to
>>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>>   *
>>>>>>>>>>>   *
>>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>>> jspwiki.css}.
>>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>>> looked up
>>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>>> in
>>>>>>>>>> the
>>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>>   */
>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>> String
>>>>>>>>>> path )
>>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>>> servletContext,
>>>>>>>>>> String path )
>>>>>>>>>>>  {
>>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( is == null )
>>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>>      {
>>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>>> -
>>>>>>>>>>> -            if( is != null )
>>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>>> -            else
>>>>>>>>>>> -                path = null;
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        if( is != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            try
>>>>>>>>>>> -            {
>>>>>>>>>>> -                is.close();
>>>>>>>>>>> -            }
>>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>>> -            {
>>>>>>>>>>> -            }
>>>>>>>>>>> +            // This is already a full path
>>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>>      }
>>>>>>>>>>> -
>>>>>>>>>>> -        return path;
>>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>>> if it's
>>>>>>>>>> not
>>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param sContext
>>>>>>>>>>> -     * @param template
>>>>>>>>>>> -     * @param name
>>>>>>>>>>> -     * @return
>>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>>> evaluation is
>>>>>>>>>> lazy,
>>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>>> actually
>>>>>>>>>> used
>>>>>>>>>>> +     * for the first time.
>>>>>>>>>>> +     */
>>>>>>>>>>> +    /*
>>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>> String
>>>>>>>>>> key ) {
>>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>> props =
>>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>> if(
>>>>>>>>>> props ==
>>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>> IOException e ) {
>>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>>> properties",e);
>>>>>>>>>> return
>>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>>   */
>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>> String
>>>>>>>>>> template, String name )
>>>>>>>>>>> +    /**
>>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>>> +     */
>>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>>  {
>>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            // This is already a full path
>>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>>> -        }
>>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>>> +    }
>>>>>>>>>>> 
>>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>> 
>>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>>> +    /**
>>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>> manager per
>>>>>>>>>> engine.
>>>>>>>>>>> +     *
>>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>>> this.
>>>>>>>>>>> +     */
>>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>> properties )
>>>>>>>>>>> +    {
>>>>>>>>>>> +        super( engine );
>>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>>   *
>>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>> {@code
>>>>>>>>>> Wiki.jsp})
>>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>> (ServletContext)}
>>>>>>>>>> instead
>>>>>>>>>>>   */
>>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>>  {
>>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>>> -
>>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        int idx = 0;
>>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>>> -            idx = 1;
>>>>>>>>>>> -
>>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>>> -
>>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>>> -        return name;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>>> template=foo.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>>> template, String
>>>>>>>>>> name )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>>> that
>>>>>>>>>> template
>>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>>> template,
>>>>>>>>>> will
>>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>>> template.
>>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>> (ServletContext)}
>>>>>>>>>> instead
>>>>>>>>>>>   */
>>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>>> String name )
>>>>>>>>>>>  {
>>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>>      }
>>>>>>>>>>> -
>>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>>> template,
>>>>>>>>>> name );
>>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>>> name );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>> (ServletContext)}
>>>>>>>>>> instead
>>>>>>>>>>>   */
>>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>>> String
>>>>>>>>>> name )
>>>>>>>>>>>  {
>>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>>      {
>>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>>> template,
>>>>>>>>>> name );
>>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>>> name );
>>>>>>>>>>>      }
>>>>>>>>>>> 
>>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>>> evaluation is
>>>>>>>>>> lazy,
>>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>>> actually
>>>>>>>>>> used
>>>>>>>>>>> -     * for the first time.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /*
>>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>> String
>>>>>>>>>> key ) {
>>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>> props =
>>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>> if(
>>>>>>>>>> props ==
>>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>> IOException e ) {
>>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>>> properties",e);
>>>>>>>>>> return
>>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>>> empty
>>>>>>>>>> Set, if
>>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>>> does
>>>>>>>>>> not check
>>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>>> just
>>>>>>>>>> lists
>>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>>> available.
>>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>>> anything
>>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>>   *
>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>   * @param template The template to search
>>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>>   */
>>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>>> String
>>>>>>>>>> template )
>>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>>  {
>>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>>> place );
>>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>> 
>>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>> 
>>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>>      {
>>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>> 
>>>>>>>>>>>      return resultSet;
>>>>>>>>>>>  }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /*
>>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>>> templateName )
>>>>>>>>>> throws
>>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>>> ServletContext
>>>>>>>>>> context =
>>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>>> if(
>>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>>> '"+templateName+"'
>>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>>> return p; }
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>>> This is in
>>>>>>>>>> a HTML
>>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>>> -     * @param type the marker
>>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>>> type )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>>> (javascript.*)
>>>>>>>>>> Returns
>>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>>> array.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param wiki context
>>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>>> LocaliedStrings
>>>>>>>>>> array
>>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>>> context )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>>> -
>>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>>> -
>>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>>> "templates.default" );
>>>>>>>>>>> -
>>>>>>>>>>> -        boolean first = true;
>>>>>>>>>>> -
>>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>>> -
>>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                if( first )
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    first = false;
>>>>>>>>>>> -                }
>>>>>>>>>>> -                else
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>>> -                }
>>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>>> key ) +
>>>>>>>>>> "\"" );
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>>> -
>>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>>> content will
>>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>>> -     * <p>
>>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>>> (a script
>>>>>>>>>> file or
>>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>>> function
>>>>>>>>>> that should
>>>>>>>>>>> -     * be run at page load.
>>>>>>>>>>> -     * <p>
>>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>>> files, which
>>>>>>>>>> is then
>>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>>> rendered but
>>>>>>>>>> not yet
>>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>>> -     * <p>
>>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>>> method does
>>>>>>>>>> not
>>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>>> Therefore,
>>>>>>>>>> if you
>>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>>> time,
>>>>>>>>>> you'll end
>>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>>> good
>>>>>>>>>> idea to
>>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>>> String type,
>>>>>>>>>> String resource )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>>> (HashMap<String,
>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>>> -
>>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>>> src='" +
>>>>>>>>>> resource + "'></script>";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>>> css'
>>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>>> resource +
>>>>>>>>>> "\n</style>\n";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>>> resourceString );
>>>>>>>>>>> -
>>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>>> are no
>>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>>> String
>>>>>>>>>> type )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( hm == null )
>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>> -
>>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>> -
>>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>>> -
>>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>>> -
>>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>> -
>>>>>>>>>>> -            if( hm != null )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>>> -
>>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        return res;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> +
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>>> TemplateManager does
>>>>>>>>>>>   * not manage any modules.
>>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>>  {
>>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>>> to the
>>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>>> as the
>>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>>> portion
>>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>>> short name
>>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>>> be added
>>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>> directory path)
>>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>>> from
>>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>>> prefix.
>>>>>>>>>> If not
>>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>> searchPath );
>>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>>> prefix.length()
>>>>>>>>>> );
>>>>>>>>>>> -
>>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>>> shortName
>>>>>>>>>> );
>>>>>>>>>>> -                }
>>>>>>>>>>> -
>>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>>> already
>>>>>>>>>>> -                else
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>> shortName );
>>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>>> -                    {
>>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>>> -                    }
>>>>>>>>>>> -                }
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>>  }
>>>>>>>>>>> }
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>>> {
>>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>> 
>>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>>> +
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>>   *
>>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>>> servletContext
>>>>>>>>>> ).get( getPath() );
>>>>>>>>>>>      if( path == null )
>>>>>>>>>>>      {
>>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>>> "/" + getPath();
>>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>>      }
>>>>>>>>>>>      setPath( path );
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>> 
>> 
>> 


Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Andrew Jaquith <an...@gmail.com>.
Janne, I'm out of bandwidth and time today. Would like to do something
other than buffer the whole page via filter. Let me noodle on this and
get back to you -- ok? (You've got the kid, I've got the job & travel
-- both barriers to conversation.)

Andrew

On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
<ja...@ecyrd.com> wrote:
>
> Sorry, kid interrupted the message....
>
> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>
> /Janne
>
> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>
>>
>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>
>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>
>> /Janne
>>
>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>
>>> Janne and Dirk --
>>>
>>> Here's my proposal to resolve the resource-inclusion issue.
>>>
>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>> works fine. I'll check this in at my next opportunity (not for a few
>>> days, probably).
>>>
>>> 2. Plugin resources. It turns out we have a ready-made class,
>>> WikiModuleInfo, that enumerates the resources that modules (like
>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>> before forwarding to the JSP, we simply inspect the page text before
>>> to see what plugins are asked for in the wiki markup. For any that are
>>> encountered, we add any script or css resources requirements to a
>>> request "queue," which is processed when the JSP actually renders (by
>>> IncludeResourcesTag or JSTL code).
>>>
>>> I am satisfied that (2) will be safe because we would just be fetching
>>> resources the developer specifically required, as the modules XML
>>> file, or (better) class annotations specify.
>>>
>>> Andrew
>>>
>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>> <an...@gmail.com> wrote:
>>>> Janne --
>>>>
>>>> Agreed. Each editor has special needs that ought to be specified in
>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>
>>>> In the current implementation, the scripts needed for the plain editor
>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>> how this would be specified instead in the editor JSPs directly.
>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>> yet.
>>>>
>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>> the editors working and to allow them to specify their own resources.
>>>> It will be done soon enough.
>>>>
>>>> In the meantime, I received your message -- that you need a way to
>>>> allow plugins to include their own resources -- loud and clear. I
>>>> don't have an answer for that today, but will propose some options
>>>> shortly.
>>>>
>>>> Andrew
>>>>
>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>> Why would we include the plain text editor in the case that the user
>>>>> preferences state FCK editor?  Or vice versa?
>>>>>
>>>>> From the point of view of the layouts editors and plugins should be
>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>
>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>> the template choice.
>>>>>
>>>>> /Janne
>>>>>
>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>
>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>> for example.
>>>>>>
>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>
>>>>>> Andrew
>>>>>>
>>>>>>
>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>> component.
>>>>>>>
>>>>>>> /Janne
>>>>>>>
>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>
>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>
>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>> layout jsp)
>>>>>>>>
>>>>>>>>
>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>> probably
>>>>>>>> also css) is needed.
>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>> correct
>>>>>>>> resources.
>>>>>>>>
>>>>>>>>
>>>>>>>> dirk
>>>>>>>>
>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>> how do
>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>> fall back to
>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>> assumes that
>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>> template,
>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>
>>>>>>>>> /Janne
>>>>>>>>>
>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>
>>>>>>>>>> Author: ajaquith
>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>> New Revision: 917390
>>>>>>>>>>
>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>> Log:
>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>> should) be
>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> EditorTag.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>>>
>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>> +
>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>> +
>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>> are now
>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>> doCatch()
>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>> debugging.
>>>>>>>>>> +
>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>> feature was
>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>> View tab
>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>> +
>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>> JSPs.
>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>> used
>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>> customizable
>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>> +
>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>> Resources
>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>> +
>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>> as part
>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>> Stripesed.
>>>>>>>>>> +
>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>
>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>> changes
>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>> spaces is
>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>
>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>
>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>> Release.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>> Mon Mar
>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>   *  <p>
>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>   */
>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>> Note.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>> Note.java Mon
>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>
>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>
>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>> -
>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>> -
>>>>>>>>> commentImage );
>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>
>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>      }
>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>      {
>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>      }
>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>      {
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>
>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>   */
>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>  {
>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>> -
>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>> -
>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>> -
>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>> -
>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>> -
>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> ContentTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>
>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>          }
>>>>>>>>>>
>>>>>>>>>> -            String page =
>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>> -
>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>> -
>>>>>>>>>       contentTemplate );
>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>      }
>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> EditorTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> EditorTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>
>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>
>>>>>>>>>>      try
>>>>>>>>>>      {
>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>> pageContext,
>>>>>>>>>> -
>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>> -
>>>>>>>>> editorPath );
>>>>>>>>>> -
>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>          if( page == null )
>>>>>>>>>>          {
>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>> */
>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>
>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>> emits a
>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>> take
>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>> - *
>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>> instead
>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>> into the
>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>> ServletFilter.
>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>> The
>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>> on how
>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>> instead
>>>>>>>>>> */
>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>> {
>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>
>>>>>>>>>> -    private String m_type;
>>>>>>>>>> -
>>>>>>>>>>  public void initTag()
>>>>>>>>>>  {
>>>>>>>>>>      super.initTag();
>>>>>>>>>> -        m_type = null;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>  {
>>>>>>>>>> -        m_type = type;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>  {
>>>>>>>>>> -        //String marker =
>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>> (m_wikiContext,
>>>>>>>>> m_type);
>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>> m_type);
>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>> m_type);
>>>>>>>>>> -
>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>> -
>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>> layout tags instead " +
>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>
>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>  {
>>>>>>>>>>      try
>>>>>>>>>>      {
>>>>>>>>>> -            String page =
>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>> -
>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>> -
>>>>>>>>>       m_page );
>>>>>>>>>> -
>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>          if( page == null )
>>>>>>>>>>          {
>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>> */
>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>
>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> -
>>>>>>>>>> /**
>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>> ().  You
>>>>>>>>> may use
>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>> - *
>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>> JSPWiki to
>>>>>>>>> insert
>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>> because it
>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>> instead. See
>>>>>>>>> the default
>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>> on how
>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>> instead
>>>>>>>>>> */
>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>> {
>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>> -
>>>>>>>>>> -    private String m_type;
>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>  public void initTag()
>>>>>>>>>>  {
>>>>>>>>>>      super.initTag();
>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>  @Override
>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>  {
>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>> m_type,
>>>>>>>>> m_resource );
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>   *
>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>   */
>>>>>>>>>>  public String getResource()
>>>>>>>>>>  {
>>>>>>>>>> -        return m_resource;
>>>>>>>>>> +        return "";
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>   *
>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>   */
>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>  {
>>>>>>>>>> -        m_resource = r;
>>>>>>>>>> +        // No-op.
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>   *
>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>   */
>>>>>>>>>>  public String getType()
>>>>>>>>>>  {
>>>>>>>>>> -        return m_type;
>>>>>>>>>> +        return "";
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>> "script".  Please
>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>> the
>>>>>>>>> different kinds
>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>> -     *
>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>   *
>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>   */
>>>>>>>>>>
>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>  {
>>>>>>>>>> -        m_type = type;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java Mon
>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>
>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>> -
>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>> inside a
>>>>>>>>> HTTP parameter. */
>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>
>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>   */
>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>  {
>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>> -
>>>>>>>>>>      String editor = null;
>>>>>>>>>>
>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java Mon
>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>> */
>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>
>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>> import java.util.*;
>>>>>>>>>>
>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>> */
>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>> {
>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>   */
>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>> "resourceResolver";
>>>>>>>>>>
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>> window.onload.
>>>>>>>>> Value
>>>>>>>>>> -     * is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>> strings.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>> -
>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>> {@value}.
>>>>>>>>> */
>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>
>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>
>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>> "template.properties";
>>>>>>>>>> -
>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>> in the
>>>>>>>>>> -     * WikiContext.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>> -
>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>> -
>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>> TemplateManager.class );
>>>>>>>>>>
>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>> -
>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>> -
>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>> Collections.emptyList();
>>>>>>>>>> -
>>>>>>>>>>  /**
>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>> resources,
>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>> is
>>>>>>>>>>   * immutable.
>>>>>>>>>>   * </p>
>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>> ServletContext
>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>> some
>>>>>>>>> reason.
>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>> requests.</p>
>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>
>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>> "/" +
>>>>>>>>> template + "/", null );
>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>> + "/" +
>>>>>>>>> template + "/", null );
>>>>>>>>>>
>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>> default
>>>>>>>>> does
>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>> "/" +
>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>> + "/" +
>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>      }
>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>> manager per
>>>>>>>>> engine.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>> this.
>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>> to the
>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>> as the
>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>> portion
>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>> short name
>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>> be added
>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>> directory path)
>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>> from
>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>> prefix.
>>>>>>>>> If not
>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>   */
>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>> properties )
>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>  {
>>>>>>>>>> -        super( engine );
>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>> -    }
>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>> searchPath );
>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>> +        {
>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>> +            {
>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>> prefix.length()
>>>>>>>>> );
>>>>>>>>>> +
>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>> +                {
>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>> shortName
>>>>>>>>> );
>>>>>>>>>> +                }
>>>>>>>>>>
>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>> already
>>>>>>>>>> +                else
>>>>>>>>>> +                {
>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>> resolver.containsKey(
>>>>>>>>> shortName );
>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>> +                    {
>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>> +                    }
>>>>>>>>>> +                }
>>>>>>>>>> +            }
>>>>>>>>>> +        }
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>>  /**
>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>> relative to
>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>> relative to
>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>   *
>>>>>>>>>>   *
>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>> jspwiki.css}.
>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>> looked up
>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>> in
>>>>>>>>> the
>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>   */
>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>> String
>>>>>>>>> path )
>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>> servletContext,
>>>>>>>>> String path )
>>>>>>>>>>  {
>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>> -
>>>>>>>>>> -        if( is == null )
>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>      {
>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>> -
>>>>>>>>>> -            if( is != null )
>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>> -            else
>>>>>>>>>> -                path = null;
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        if( is != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            try
>>>>>>>>>> -            {
>>>>>>>>>> -                is.close();
>>>>>>>>>> -            }
>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>> -            {
>>>>>>>>>> -            }
>>>>>>>>>> +            // This is already a full path
>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>      }
>>>>>>>>>> -
>>>>>>>>>> -        return path;
>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>> if it's
>>>>>>>>> not
>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param sContext
>>>>>>>>>> -     * @param template
>>>>>>>>>> -     * @param name
>>>>>>>>>> -     * @return
>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>> evaluation is
>>>>>>>>> lazy,
>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>> actually
>>>>>>>>> used
>>>>>>>>>> +     * for the first time.
>>>>>>>>>> +     */
>>>>>>>>>> +    /*
>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>> String
>>>>>>>>> key ) {
>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>> props =
>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>> if(
>>>>>>>>> props ==
>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>> IOException e ) {
>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>> properties",e);
>>>>>>>>> return
>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>> NeedsRefreshException
>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>   */
>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>> String
>>>>>>>>> template, String name )
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>> +     */
>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>  {
>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>> -        {
>>>>>>>>>> -            // This is already a full path
>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>> -        }
>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>> +    }
>>>>>>>>>>
>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>
>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>> manager per
>>>>>>>>> engine.
>>>>>>>>>> +     *
>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>> this.
>>>>>>>>>> +     */
>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>> properties )
>>>>>>>>>> +    {
>>>>>>>>>> +        super( engine );
>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>   *
>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>> {@code
>>>>>>>>> Wiki.jsp})
>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>> (ServletContext)}
>>>>>>>>> instead
>>>>>>>>>>   */
>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>  {
>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>> -
>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>> -     */
>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>> -    {
>>>>>>>>>> -        int idx = 0;
>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>> -            idx = 1;
>>>>>>>>>> -
>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>> -        {
>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>> -
>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>> -            {
>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>> -        return name;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>> template=foo.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>> -     */
>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>> template, String
>>>>>>>>> name )
>>>>>>>>>> -    {
>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>> that
>>>>>>>>> template
>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>> template,
>>>>>>>>> will
>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>> template.
>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>> (ServletContext)}
>>>>>>>>> instead
>>>>>>>>>>   */
>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>> String name )
>>>>>>>>>>  {
>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>      }
>>>>>>>>>> -
>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>> template,
>>>>>>>>> name );
>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>> name );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>> (ServletContext)}
>>>>>>>>> instead
>>>>>>>>>>   */
>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>> String
>>>>>>>>> name )
>>>>>>>>>>  {
>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>      {
>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>> template,
>>>>>>>>> name );
>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>> name );
>>>>>>>>>>      }
>>>>>>>>>>
>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>> evaluation is
>>>>>>>>> lazy,
>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>> actually
>>>>>>>>> used
>>>>>>>>>> -     * for the first time.
>>>>>>>>>> -     */
>>>>>>>>>> -    /*
>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>> String
>>>>>>>>> key ) {
>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>> props =
>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>> if(
>>>>>>>>> props ==
>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>> IOException e ) {
>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>> properties",e);
>>>>>>>>> return
>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>> NeedsRefreshException
>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>> -     */
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>> -     */
>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>> -    {
>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>> empty
>>>>>>>>> Set, if
>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>> does
>>>>>>>>> not check
>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>> just
>>>>>>>>> lists
>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>> available.
>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>> anything
>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>   *
>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>   * @param template The template to search
>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>   */
>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>> String
>>>>>>>>> template )
>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>  {
>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>> place );
>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>
>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>
>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>      {
>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>
>>>>>>>>>>      return resultSet;
>>>>>>>>>>  }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>> -     */
>>>>>>>>>> -    /*
>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>> templateName )
>>>>>>>>> throws
>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>> ServletContext
>>>>>>>>> context =
>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>> if(
>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>> '"+templateName+"'
>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>> return p; }
>>>>>>>>>> -     */
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>> This is in
>>>>>>>>> a HTML
>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>> -     * @param type the marker
>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>> type )
>>>>>>>>>> -    {
>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>> -        }
>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>> (javascript.*)
>>>>>>>>> Returns
>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>> array.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param wiki context
>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>> LocaliedStrings
>>>>>>>>> array
>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>> context )
>>>>>>>>>> -    {
>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>> -
>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>> -
>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>> "templates.default" );
>>>>>>>>>> -
>>>>>>>>>> -        boolean first = true;
>>>>>>>>>> -
>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>> -        {
>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>> -
>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>> -            {
>>>>>>>>>> -                if( first )
>>>>>>>>>> -                {
>>>>>>>>>> -                    first = false;
>>>>>>>>>> -                }
>>>>>>>>>> -                else
>>>>>>>>>> -                {
>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>> -                }
>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>> key ) +
>>>>>>>>> "\"" );
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>> -
>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>> content will
>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>> -     * <p>
>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>> (a script
>>>>>>>>> file or
>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>> function
>>>>>>>>> that should
>>>>>>>>>> -     * be run at page load.
>>>>>>>>>> -     * <p>
>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>> files, which
>>>>>>>>> is then
>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>> rendered but
>>>>>>>>> not yet
>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>> -     * <p>
>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>> method does
>>>>>>>>> not
>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>> Therefore,
>>>>>>>>> if you
>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>> time,
>>>>>>>>> you'll end
>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>> good
>>>>>>>>> idea to
>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>> String type,
>>>>>>>>> String resource )
>>>>>>>>>> -    {
>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>> (HashMap<String,
>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>> -
>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>> -
>>>>>>>>>> -        if( resources == null )
>>>>>>>>>> -        {
>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>> -
>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>> src='" +
>>>>>>>>> resource + "'></script>";
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>> css'
>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>> resource +
>>>>>>>>> "\n</style>\n";
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>> resourceString );
>>>>>>>>>> -
>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>> are no
>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>> String
>>>>>>>>> type )
>>>>>>>>>> -    {
>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>> -
>>>>>>>>>> -        if( hm == null )
>>>>>>>>>> -            return new String[0];
>>>>>>>>>> -
>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>> -
>>>>>>>>>> -        if( resources == null )
>>>>>>>>>> -            return new String[0];
>>>>>>>>>> -
>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>> -
>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>> -    {
>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>> -
>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>> -
>>>>>>>>>> -            if( hm != null )
>>>>>>>>>> -            {
>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>> -
>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        return res;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> +
>>>>>>>>>>  /**
>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>> TemplateManager does
>>>>>>>>>>   * not manage any modules.
>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>   */
>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>  {
>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>> to the
>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>> as the
>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>> portion
>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>> short name
>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>> be added
>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>> directory path)
>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>> from
>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>> prefix.
>>>>>>>>> If not
>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>> -    {
>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>> searchPath );
>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>> -            {
>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>> prefix.length()
>>>>>>>>> );
>>>>>>>>>> -
>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>> -                {
>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>> shortName
>>>>>>>>> );
>>>>>>>>>> -                }
>>>>>>>>>> -
>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>> already
>>>>>>>>>> -                else
>>>>>>>>>> -                {
>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>> resolver.containsKey(
>>>>>>>>> shortName );
>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>> -                    {
>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>> -                    }
>>>>>>>>>> -                }
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>  }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>> {
>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>
>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>> +
>>>>>>>>>>  /**
>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>   *
>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>> servletContext
>>>>>>>>> ).get( getPath() );
>>>>>>>>>>      if( path == null )
>>>>>>>>>>      {
>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>> "/" + getPath();
>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>      }
>>>>>>>>>>      setPath( path );
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>>>
>
>

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
On 7 Mar 2010, at 17:40, Andrew Jaquith wrote:

>> Can you detail exactly which security issue is raised by this?
> 
> I'm worried about cross-site scripting. It should only be possible to
> source scripts that are stored on the server. That's why I want to
> check the requested resource against the ServletContext resource list.
> This check provides protection against plugins that are written
> maliciously, poorly or without security in mind. I don't think we can
> guarantee that every plugin will behave the way we expect -- even the
> ones that may someday be part of JSPWiki -- so this "origin check"
> provides a last line of defense.

...but you can include the script already *directly*, if you want to make the damage.

Also, the admin needs to make the call whether they want to install a plugin or not.  So it's not our problem.

>> After all, plugins are a) already running at the exact same rights as the rest of JSPWiki,
> 
> That's true, but sooner or later we're going to get it to work in a
> security manager -- that's been a JIRA issue forever. And by "we" I
> mean "me", because nobody else is gonna do it. At some point, what
> JSPWiki (and third party JARs) can do will be more constrained when
> it's running in a security manager. But this issue doesn't relate to
> my real concern -- XSS.

But we don't have it now.  Besides, any plugin can write XSS code directly on the page.

> 
>> I just simply cannot see that your method provides ANY added security, and it simply adds a TON of implementational complexity, pain to the developer, and still does not resolve the dynamic problem.
> 
> Personal opinion: I don't see it as particularly complex. I'm also
> offering to do the work -- in case that wasn't clear -- and I work
> cheap. :)

But I do see that as a plugin writer, *I* need to essentially stick to 2.8.  If adding dynamic code with plugins is not possible, I have no reason whatsoever to use 3.0 anywhere.

> On the security front, I hope you can understand that my concerns
> about XSS are well-founded. Here is a cheat sheet:
> http://ha.ckers.org/xss.html

I *do* know about XSS. It's my opinion that as long as a plugin can write <script> tags into HTML, any concerns about putting <script src> in the HEAD of the document are irrelevant.

>> This isn't really a theoretical question for future plugins, I've got a number of plugins that rely on this functionality.  We did, after all, agree to keep the API similar so that transferring from 2.x to 3.0 is not that complicated.
> 
> I've offered you two opportunities already to name the plugins you
> have that require this capability, and you haven't named any. Not a
> single built-in JSPWiki plugin needs to add resources. But I take your
> word for it that this is something you (Janne) require even though
> JSPWiki itself does not.

*shrug* Not all of my plugins are available in an open source manner, and it should not matter - it is a removal of functionality and therefore breaks the API promise, and hence should be voted on.

>> Also, I don't think that page rendering code (incl. WikiPlugin.execute()) is guaranteed to execute before layout code.
> 
> I've tested this. The layout code DOES render after the plugins.
> Assuming layout tags are used, it's guaranteed.

We don't guarantee it.  It may work that way right now, but we don't guarantee it.  Saying that we do would again create an API promise, and we should test for it and decide that that's how we're going to work in the future.

> - Add back the TemplateManager.addResourceRequest() method, as a
> deprecated method.

> This will delegate back to
> WikiContext.addResourceRequest(), which is a better place for this
> code.

Moving the API is fine, but this is exactly why I've called for the creation of an API package.

> - Add origin-validation logic when the resources are added to protect
> against XSS. The resources allowed would be limited just to those on
> the server. To keep it simple, we could just perform this check only,
> and not worry about checking against annotation/XML manifests until
> after Alpha.

I think this is much easier to do - just simply check whether the resource request contains "://".  This should be admin-configurable though; I don't use it personally but I do people who like to include Javascript files from CDN servers.  Like if you want to include YUI libs, you want to use Yahoo's CDN instead of hosting everything on your own.

> - Restore the InsertResources and ResourceRequest tags (retrofitted to
> use the new WikiContext method). The internal workings would be
> refactored a bit, but the results would be similar.

Since we're changing the JSP layout completely anyway, I don't think that those tags are necessarily needed, as long as the equivalent functionality is in there.

> - Rely on the assumption that because the layout tags are used, we do
> not need use markers or buffer the response. If we determine these
> things are needed, we can add them after the Alpha release.

I think this needs a set of tests.

> I'm sorry this has been so contentious. Really.

No worries. My only concern is that this discussion has been "after the fact" - this sort of discussion should be done on the JIRA or on the mailing list BEFORE the code modifications are committed to allow everyone to participate and weigh in - not just those of us who actually read commit logs.

/Janne


Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Andrew Jaquith <an...@gmail.com>.
> Can you detail exactly which security issue is raised by this?

I'm worried about cross-site scripting. It should only be possible to
source scripts that are stored on the server. That's why I want to
check the requested resource against the ServletContext resource list.
This check provides protection against plugins that are written
maliciously, poorly or without security in mind. I don't think we can
guarantee that every plugin will behave the way we expect -- even the
ones that may someday be part of JSPWiki -- so this "origin check"
provides a last line of defense.

> After all, plugins are a) already running at the exact same rights as the rest of JSPWiki,

That's true, but sooner or later we're going to get it to work in a
security manager -- that's been a JIRA issue forever. And by "we" I
mean "me", because nobody else is gonna do it. At some point, what
JSPWiki (and third party JARs) can do will be more constrained when
it's running in a security manager. But this issue doesn't relate to
my real concern -- XSS.

> I just simply cannot see that your method provides ANY added security, and it simply adds a TON of implementational complexity, pain to the developer, and still does not resolve the dynamic problem.

Personal opinion: I don't see it as particularly complex. I'm also
offering to do the work -- in case that wasn't clear -- and I work
cheap. :)

On the security front, I hope you can understand that my concerns
about XSS are well-founded. Here is a cheat sheet:
http://ha.ckers.org/xss.html

> This isn't really a theoretical question for future plugins, I've got a number of plugins that rely on this functionality.  We did, after all, agree to keep the API similar so that transferring from 2.x to 3.0 is not that complicated.

I've offered you two opportunities already to name the plugins you
have that require this capability, and you haven't named any. Not a
single built-in JSPWiki plugin needs to add resources. But I take your
word for it that this is something you (Janne) require even though
JSPWiki itself does not.

> Also, I don't think that page rendering code (incl. WikiPlugin.execute()) is guaranteed to execute before layout code.

I've tested this. The layout code DOES render after the plugins.
Assuming layout tags are used, it's guaranteed. Using the layout tags
is a safe assumption, because the layout provides the look-and-feel
for the site. In 2.8 and earlier, it would be like saying "assuming
you use View|Edit|AdminTemplate.jsp" -- that would have been a safe
assumption too.

I have been striving to come up with an approach that satisfies my
concerns and gives you what you need. Here's what I'm prepared to do:

- Add back the TemplateManager.addResourceRequest() method, as a
deprecated method. This will delegate back to
WikiContext.addResourceRequest(), which is a better place for this
code.
- Add origin-validation logic when the resources are added to protect
against XSS. The resources allowed would be limited just to those on
the server. To keep it simple, we could just perform this check only,
and not worry about checking against annotation/XML manifests until
after Alpha.
- Restore the InsertResources and ResourceRequest tags (retrofitted to
use the new WikiContext method). The internal workings would be
refactored a bit, but the results would be similar.
- Rely on the assumption that because the layout tags are used, we do
not need use markers or buffer the response. If we determine these
things are needed, we can add them after the Alpha release.

I'm sorry this has been so contentious. Really.

Andrew

>
> On 6 Mar 2010, at 17:47, Andrew Jaquith wrote:
>
>> Hey Janne,
>>
>> The discussion -- from my viewpoint -- is really about how to request
>> resources safely, not whether the feature needs to be there. That puts
>> it squarely into the realm of bug-fixing, not feature removal. As
>> discussed, I felt I had a method that covered the JSP case without
>> needing the TemplateManager.addResourceRequest() technique. You'll see
>> that in a checkin I'll make later this morning. (The editor issues are
>> fixed, for example).
>>
>> I *did* make a mistake in not understanding that plugins need to
>> request resources too. But to be fair, there isn't a single built-in
>> plugin today that uses TemplateManager.addResourceRequest(). With the
>> JSP case taken care of elsewhere, it seemed like an easy call to
>> remove it -- it is dangerous code that no plugins use today. Seemed
>> like a bug fix to me.
>>
>> Now, as for FUTURE plugins, I agree that this it makes sense to give
>> them a way to request resources. You've argued that including
>> resources named in plugin annotations isn't good enough. Let me try
>> and sketch out an approach that could work that would be more dynamic:
>>
>> 1. Each plugin defines the script and CSS resources they require via
>> annotations or XML. These resources encompass the total set of
>> resources they might need, even if they don't need them all in a
>> particular request. In other words, the annotations or XML elements
>> create a "whitelist." These resource needs are stored at runtime in
>> WikiModuleInfo.
>>
>> 2. When PluginManager.execute() causes a plugin's execute() method to
>> run, it looks up the WikiModuleInfo resource metadata. If any CSS or
>> script resources are enumerated, each of these is checked against the
>> resource path list for the servlet context. If it is found, it is
>> added to the "resource request queue." If a resource isn't found, it's
>> not added to the request queue. Put simply: the resource has to
>> already exist in the set of resources known to the ServletContext, so
>> no off-server resources could be requested. Thus, every resource
>> request is validated, and therefore safe.
>>
>> 3. For dynamic resource requests, PluginManager could optionally
>> execute the plugin methods getScriptLocation() and
>> getStylesheetLocation(), which would allow additional resources to be
>> specified at runtime. These, too, would be checked against the
>> ServletContext list for safety.
>>
>> 4. The "request queue" for storing resource requests would be stored
>> in the WikiContext or ActionBeanContext; probably as a
>> Map<String,Set<String>>, where the keys are "css" or "script."
>> Actually, Map retrieval is probably the best time to check resource
>> requests against the ServletContext resource list, to figure out what
>> to return, and what to drop on the floor.
>>
>> 5. In the appropriate places in DefaultLayout.jsp, we iterate through
>> the Set of resources for each key ("css" or "script"), and format the
>> link or script tags as needed.
>>
>> Is this a little more complicated than
>> TemplateManager.addResourceRequest()? Only the initial coding. Plugin
>> developers should just have to add a quickie annotation and be done.
>> Is this safer? Yes, much safer, because plugins can request only
>> certain resource types (scripts and CSS), and they must already exist
>> on the server. I also like that it moves responsibility for vetting
>> and adding resource requests from TemplateManager to
>> Wiki[ActionBean]Context.
>>
>> Oh, and if we do it this way, we don't need a response wrapper because
>> the page-rendering code is guaranteed to execute before the layout
>> JSP. :)
>>
>> There are probably variations on this approach that would make sense,
>> too. I hope you'll see this discussion, as I do, to increase plugin
>> security while still giving plugin developers the flexibility they
>> need. You have my apology for not fully considering plugin
>> requirements before.
>>
>> Andrew
>>
>> On Fri, Mar 5, 2010 at 2:47 AM, Janne Jalkanen <ja...@ecyrd.com> wrote:
>>>
>>> Well, first of all, since this is an already existing functionality, we need to vote to remove it anyway, so this discussion should've been done *before* it got removed.
>>>
>>> Second, a good example is a plugin which allows multiple styles to be used based on user choice. For example, if I have a plugin which can have a regular and 3d style, the simplest way is to simply request the correct CSS file. Otherwise you need to hard-code everything, whereas with style changes all you need to do is to compare the plugin arguments to a fixed list (for security).
>>>
>>> Another good example is that I can optimize some of the Javascript loading similarly - if I have a particular Form component which can insert a WYSIWYG editor, I might want to give the user a choice which WYSIWYG editor component to include, or which additional components to include to avoid loading everything.
>>>
>>> /Janne
>>>
>>> On 4 Mar 2010, at 23:47, Andrew Jaquith wrote:
>>>
>>>> Janne, when you say "dynamic," what do you mean? I understand the need
>>>> to insert pages, based on wiki markup, which may load other plugins.
>>>> That is, when a page renders, it might need Plugin 1, Plugin 2 and
>>>> Plugin 3, and each of which have needs. It might also selectively load
>>>> another page, which needs Plugin 4. So, I understand that.
>>>>
>>>> Beyond that, though, what other dynamic capabilities are needed? Do
>>>> you really think that the path of a stylesheet or script file that a
>>>> SPECIFIC plugin needs would change based on runtime conditions? Can
>>>> you provide some specific examples? (Either your own plugins, or
>>>> others you may know of...)
>>>>
>>>> Just trying to understand...
>>>>
>>>> Andrew
>>>>
>>>> On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
>>>> <ja...@ecyrd.com> wrote:
>>>>>
>>>>> Sorry, kid interrupted the message....
>>>>>
>>>>> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>>>>>
>>>>> /Janne
>>>>>
>>>>> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>>>>>
>>>>>>
>>>>>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>>>>>
>>>>>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>>>>>
>>>>>> /Janne
>>>>>>
>>>>>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>>>>>
>>>>>>> Janne and Dirk --
>>>>>>>
>>>>>>> Here's my proposal to resolve the resource-inclusion issue.
>>>>>>>
>>>>>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>>>>>> works fine. I'll check this in at my next opportunity (not for a few
>>>>>>> days, probably).
>>>>>>>
>>>>>>> 2. Plugin resources. It turns out we have a ready-made class,
>>>>>>> WikiModuleInfo, that enumerates the resources that modules (like
>>>>>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>>>>>> before forwarding to the JSP, we simply inspect the page text before
>>>>>>> to see what plugins are asked for in the wiki markup. For any that are
>>>>>>> encountered, we add any script or css resources requirements to a
>>>>>>> request "queue," which is processed when the JSP actually renders (by
>>>>>>> IncludeResourcesTag or JSTL code).
>>>>>>>
>>>>>>> I am satisfied that (2) will be safe because we would just be fetching
>>>>>>> resources the developer specifically required, as the modules XML
>>>>>>> file, or (better) class annotations specify.
>>>>>>>
>>>>>>> Andrew
>>>>>>>
>>>>>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>>>>>> <an...@gmail.com> wrote:
>>>>>>>> Janne --
>>>>>>>>
>>>>>>>> Agreed. Each editor has special needs that ought to be specified in
>>>>>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>>>>>
>>>>>>>> In the current implementation, the scripts needed for the plain editor
>>>>>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>>>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>>>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>>>>>> how this would be specified instead in the editor JSPs directly.
>>>>>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>>>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>>>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>>>>>> yet.
>>>>>>>>
>>>>>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>>>>>> the editors working and to allow them to specify their own resources.
>>>>>>>> It will be done soon enough.
>>>>>>>>
>>>>>>>> In the meantime, I received your message -- that you need a way to
>>>>>>>> allow plugins to include their own resources -- loud and clear. I
>>>>>>>> don't have an answer for that today, but will propose some options
>>>>>>>> shortly.
>>>>>>>>
>>>>>>>> Andrew
>>>>>>>>
>>>>>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>>>>>> Why would we include the plain text editor in the case that the user
>>>>>>>>> preferences state FCK editor?  Or vice versa?
>>>>>>>>>
>>>>>>>>> From the point of view of the layouts editors and plugins should be
>>>>>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>>>>>
>>>>>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>>>>>> the template choice.
>>>>>>>>>
>>>>>>>>> /Janne
>>>>>>>>>
>>>>>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>>>>>
>>>>>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>>>>>> for example.
>>>>>>>>>>
>>>>>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>>>>>
>>>>>>>>>> Andrew
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>>>>>> component.
>>>>>>>>>>>
>>>>>>>>>>> /Janne
>>>>>>>>>>>
>>>>>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>>>>>
>>>>>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>>>>>> layout jsp)
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>>>>>> probably
>>>>>>>>>>>> also css) is needed.
>>>>>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>>>>>> correct
>>>>>>>>>>>> resources.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> dirk
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>>>>>> how do
>>>>>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>>>>>> fall back to
>>>>>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>>>>>> assumes that
>>>>>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>>>>>> template,
>>>>>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>>>>>
>>>>>>>>>>>>> /Janne
>>>>>>>>>>>>>
>>>>>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Author: ajaquith
>>>>>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> New Revision: 917390
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>>>>>> Log:
>>>>>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>>>>>> should) be
>>>>>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>>>>>> are now
>>>>>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>>>>>> doCatch()
>>>>>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>>>>>> debugging.
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>>>>>> feature was
>>>>>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>>>>>> View tab
>>>>>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>>>>>> JSPs.
>>>>>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>>>>>> used
>>>>>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>>>>>> customizable
>>>>>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>>>>>> Resources
>>>>>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>>>>>> as part
>>>>>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>>>>>> Stripesed.
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>>>>>> changes
>>>>>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>>>>>> spaces is
>>>>>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>>>>>> Release.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>>>> Mon Mar
>>>>>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>>>>>   *  <p>
>>>>>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>>>>> Note.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>>>>> Note.java Mon
>>>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> commentImage );
>>>>>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /**
>>>>>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>>>>>          }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -            String page =
>>>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>       contentTemplate );
>>>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /**
>>>>>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      try
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>>>>>> pageContext,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>>>>>> -
>>>>>>>>>>>>> editorPath );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>>>>          {
>>>>>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>>>>>> */
>>>>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> /**
>>>>>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>>>>>> emits a
>>>>>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>>>>>> take
>>>>>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>>>>>> - *
>>>>>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>>>>>> into the
>>>>>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>>>>>> ServletFilter.
>>>>>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>>>>>> The
>>>>>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>>>>> on how
>>>>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> */
>>>>>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>>      super.initTag();
>>>>>>>>>>>>>> -        m_type = null;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        //String marker =
>>>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>>>>>> (m_wikiContext,
>>>>>>>>>>>>> m_type);
>>>>>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>>>>>> m_type);
>>>>>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>>>>>> m_type);
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>>>>>> layout tags instead " +
>>>>>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>>      try
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> -            String page =
>>>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>       m_page );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>>>>          {
>>>>>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>>>>>> */
>>>>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> /**
>>>>>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>>>>>> ().  You
>>>>>>>>>>>>> may use
>>>>>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>>>>>> - *
>>>>>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>>>>>> JSPWiki to
>>>>>>>>>>>>> insert
>>>>>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>>>>>> because it
>>>>>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>>>>>> instead. See
>>>>>>>>>>>>> the default
>>>>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>>>>> on how
>>>>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> */
>>>>>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>>      super.initTag();
>>>>>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>>>>>  @Override
>>>>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>>>>>> m_type,
>>>>>>>>>>>>> m_resource );
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public String getResource()
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        return m_resource;
>>>>>>>>>>>>>> +        return "";
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        m_resource = r;
>>>>>>>>>>>>>> +        // No-op.
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public String getType()
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        return m_type;
>>>>>>>>>>>>>> +        return "";
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>>>>>> "script".  Please
>>>>>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>>>>>> the
>>>>>>>>>>>>> different kinds
>>>>>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> EditorManager.java Mon
>>>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>>>>>> inside a
>>>>>>>>>>>>> HTTP parameter. */
>>>>>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>      String editor = null;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> TemplateManager.java Mon
>>>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>>>>>> */
>>>>>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>>>>>> import java.util.*;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>>>>>> */
>>>>>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>>>>>> "resourceResolver";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>>>>>> window.onload.
>>>>>>>>>>>>> Value
>>>>>>>>>>>>>> -     * is {@value}.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>>>>>> strings.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>>>>>> {@value}.
>>>>>>>>>>>>> */
>>>>>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>>>>>> "template.properties";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>>>>>> in the
>>>>>>>>>>>>>> -     * WikiContext.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>>>>>> TemplateManager.class );
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>>>>>> Collections.emptyList();
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>>>>>> resources,
>>>>>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>>>>>> is
>>>>>>>>>>>>>>   * immutable.
>>>>>>>>>>>>>>   * </p>
>>>>>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>>>>>> ServletContext
>>>>>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>>>>>> some
>>>>>>>>>>>>> reason.
>>>>>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>>>>>> requests.</p>
>>>>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>>>>> "/" +
>>>>>>>>>>>>> template + "/", null );
>>>>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>>>>> + "/" +
>>>>>>>>>>>>> template + "/", null );
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>>>>>> default
>>>>>>>>>>>>> does
>>>>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>>>>> "/" +
>>>>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>>>>> + "/" +
>>>>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>>>>> manager per
>>>>>>>>>>>>> engine.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>>>>>> this.
>>>>>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>>>>>> to the
>>>>>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>>>>>> as the
>>>>>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>>>>>> portion
>>>>>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>>>>>> short name
>>>>>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>>>>>> be added
>>>>>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>>>>> directory path)
>>>>>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>>>>>> prefix.
>>>>>>>>>>>>> If not
>>>>>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>>>>> properties )
>>>>>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        super( engine );
>>>>>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>>>>> searchPath );
>>>>>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>>>>>> +        {
>>>>>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>>>>>> +            {
>>>>>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>>>>>> prefix.length()
>>>>>>>>>>>>> );
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>>>>> +                {
>>>>>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>>>>>> shortName
>>>>>>>>>>>>> );
>>>>>>>>>>>>>> +                }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>>>>>> already
>>>>>>>>>>>>>> +                else
>>>>>>>>>>>>>> +                {
>>>>>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>>>>> shortName );
>>>>>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>>>>>> +                    {
>>>>>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>>>>>> +                    }
>>>>>>>>>>>>>> +                }
>>>>>>>>>>>>>> +            }
>>>>>>>>>>>>>> +        }
>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>>>>>> relative to
>>>>>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>>>>>> relative to
>>>>>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>>>>>> jspwiki.css}.
>>>>>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>>>>>> looked up
>>>>>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>>>>>> in
>>>>>>>>>>>>> the
>>>>>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> path )
>>>>>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>>>>>> servletContext,
>>>>>>>>>>>>> String path )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( is == null )
>>>>>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -            if( is != null )
>>>>>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>>>>>> -            else
>>>>>>>>>>>>>> -                path = null;
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( is != null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            try
>>>>>>>>>>>>>> -            {
>>>>>>>>>>>>>> -                is.close();
>>>>>>>>>>>>>> -            }
>>>>>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>>>>>> -            {
>>>>>>>>>>>>>> -            }
>>>>>>>>>>>>>> +            // This is already a full path
>>>>>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        return path;
>>>>>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>>>>>> if it's
>>>>>>>>>>>>> not
>>>>>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param sContext
>>>>>>>>>>>>>> -     * @param template
>>>>>>>>>>>>>> -     * @param name
>>>>>>>>>>>>>> -     * @return
>>>>>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>>>>>> evaluation is
>>>>>>>>>>>>> lazy,
>>>>>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>>>>>> actually
>>>>>>>>>>>>> used
>>>>>>>>>>>>>> +     * for the first time.
>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>> +    /*
>>>>>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> key ) {
>>>>>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>>>>> props =
>>>>>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>>>>> if(
>>>>>>>>>>>>> props ==
>>>>>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>>>>> IOException e ) {
>>>>>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>>>>>> properties",e);
>>>>>>>>>>>>> return
>>>>>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> template, String name )
>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            // This is already a full path
>>>>>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>>>>>> +    }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>>>>> manager per
>>>>>>>>>>>>> engine.
>>>>>>>>>>>>>> +     *
>>>>>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>>>>>> this.
>>>>>>>>>>>>>> +     */
>>>>>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>>>>> properties )
>>>>>>>>>>>>>> +    {
>>>>>>>>>>>>>> +        super( engine );
>>>>>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>>>>> {@code
>>>>>>>>>>>>> Wiki.jsp})
>>>>>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        int idx = 0;
>>>>>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>>>>>> -            idx = 1;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>>>>>> -            {
>>>>>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>>>>>> -            }
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>>>>>> -        return name;
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>>>>>> template=foo.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>>>>>> template, String
>>>>>>>>>>>>> name )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>>>>>> that
>>>>>>>>>>>>> template
>>>>>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>>>>>> template,
>>>>>>>>>>>>> will
>>>>>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>>>>>> template.
>>>>>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>>>>>> String name )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>>>>>> template,
>>>>>>>>>>>>> name );
>>>>>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>>>>>> name );
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> name )
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>>>>>> template,
>>>>>>>>>>>>> name );
>>>>>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>>>>>> name );
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>>>>>> evaluation is
>>>>>>>>>>>>> lazy,
>>>>>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>>>>>> actually
>>>>>>>>>>>>> used
>>>>>>>>>>>>>> -     * for the first time.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    /*
>>>>>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> key ) {
>>>>>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>>>>> props =
>>>>>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>>>>> if(
>>>>>>>>>>>>> props ==
>>>>>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>>>>> IOException e ) {
>>>>>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>>>>>> properties",e);
>>>>>>>>>>>>> return
>>>>>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>>>>>> empty
>>>>>>>>>>>>> Set, if
>>>>>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>>>>>> does
>>>>>>>>>>>>> not check
>>>>>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>>>>>> just
>>>>>>>>>>>>> lists
>>>>>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>>>>>> available.
>>>>>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>>>>>> anything
>>>>>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>>>>   * @param template The template to search
>>>>>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> template )
>>>>>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>>>>>> place );
>>>>>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      return resultSet;
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    /*
>>>>>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>>>>>> templateName )
>>>>>>>>>>>>> throws
>>>>>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>>>>>> ServletContext
>>>>>>>>>>>>> context =
>>>>>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>>>>>> if(
>>>>>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>>>>>> '"+templateName+"'
>>>>>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>>>>>> return p; }
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>>>>>> This is in
>>>>>>>>>>>>> a HTML
>>>>>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>>>>>> -     * @param type the marker
>>>>>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>>> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>>>>>> type )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>>>>>> (javascript.*)
>>>>>>>>>>>>> Returns
>>>>>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>>>>>> array.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param wiki context
>>>>>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>>>>>> LocaliedStrings
>>>>>>>>>>>>> array
>>>>>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>>> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>>>>>> context )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>>>>>> "templates.default" );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        boolean first = true;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>>>>>> -            {
>>>>>>>>>>>>>> -                if( first )
>>>>>>>>>>>>>> -                {
>>>>>>>>>>>>>> -                    first = false;
>>>>>>>>>>>>>> -                }
>>>>>>>>>>>>>> -                else
>>>>>>>>>>>>>> -                {
>>>>>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>>>>>> -                }
>>>>>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>>>>>> key ) +
>>>>>>>>>>>>> "\"" );
>>>>>>>>>>>>>> -            }
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>>>>>> content will
>>>>>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>>>>>> (a script
>>>>>>>>>>>>> file or
>>>>>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>>>>>> function
>>>>>>>>>>>>> that should
>>>>>>>>>>>>>> -     * be run at page load.
>>>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>>>>>> files, which
>>>>>>>>>>>>> is then
>>>>>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>>>>>> rendered but
>>>>>>>>>>>>> not yet
>>>>>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>>>>>> method does
>>>>>>>>>>>>> not
>>>>>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>>>>>> Therefore,
>>>>>>>>>>>>> if you
>>>>>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>>>>>> time,
>>>>>>>>>>>>> you'll end
>>>>>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>>>>>> good
>>>>>>>>>>>>> idea to
>>>>>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>>> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>>>>>> String type,
>>>>>>>>>>>>> String resource )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>>>>>> (HashMap<String,
>>>>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>>>>>> src='" +
>>>>>>>>>>>>> resource + "'></script>";
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>>>>>> css'
>>>>>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>>>>>> resource +
>>>>>>>>>>>>> "\n</style>\n";
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>>>>>> resourceString );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>>>>>> are no
>>>>>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>>> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>>>>>> String
>>>>>>>>>>>>> type )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( hm == null )
>>>>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>>>>>> -     *
>>>>>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>>> tags
>>>>>>>>>>>>> instead
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -            if( hm != null )
>>>>>>>>>>>>>> -            {
>>>>>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>>>>>> -            }
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -        return res;
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>>>>>> TemplateManager does
>>>>>>>>>>>>>>   * not manage any modules.
>>>>>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>>>>>   */
>>>>>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>>>>>  {
>>>>>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>>>>>> -    }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>>>>>> to the
>>>>>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>>>>>> as the
>>>>>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>>>>>> portion
>>>>>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>>>>>> short name
>>>>>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>>>>>> be added
>>>>>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>>>>> directory path)
>>>>>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>>>>>> prefix.
>>>>>>>>>>>>> If not
>>>>>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>>>> -     */
>>>>>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>>>> -    {
>>>>>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>>>>> searchPath );
>>>>>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>>>>>> -        {
>>>>>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>>>>>> -            {
>>>>>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>>>>>> prefix.length()
>>>>>>>>>>>>> );
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>>>>> -                {
>>>>>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>>>>>> shortName
>>>>>>>>>>>>> );
>>>>>>>>>>>>>> -                }
>>>>>>>>>>>>>> -
>>>>>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>>>>>> already
>>>>>>>>>>>>>> -                else
>>>>>>>>>>>>>> -                {
>>>>>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>>>>> shortName );
>>>>>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>>>>>> -                    {
>>>>>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>>>>>> -                    }
>>>>>>>>>>>>>> -                }
>>>>>>>>>>>>>> -            }
>>>>>>>>>>>>>> -        }
>>>>>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>>>>>  }
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>>> URL:
>>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ============
>>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>>> ---
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>> (original)
>>>>>>>>>>>>>> +++
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>>>>>> {
>>>>>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>>>>>> +
>>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>>>>>   *
>>>>>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>>>>>> servletContext
>>>>>>>>>>>>> ).get( getPath() );
>>>>>>>>>>>>>>      if( path == null )
>>>>>>>>>>>>>>      {
>>>>>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>>>>>> "/" + getPath();
>>>>>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>>>>>      }
>>>>>>>>>>>>>>      setPath( path );
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
Can you detail exactly which security issue is raised by this? After all, plugins are a) already running at the exact same rights as the rest of JSPWiki, and b) can insert full HTML code into the body of the page, including arbitrary <script> -tags. It even has direct access to the HttpRequest and Response objects through WikiContext.  I just simply cannot see that your method provides ANY added security, and it simply adds a TON of implementational complexity, pain to the developer, and still does not resolve the dynamic problem.

This isn't really a theoretical question for future plugins, I've got a number of plugins that rely on this functionality.  We did, after all, agree to keep the API similar so that transferring from 2.x to 3.0 is not that complicated.

Also, I don't think that page rendering code (incl. WikiPlugin.execute()) is guaranteed to execute before layout code. That would mean that Stripes needs to buffer the body content on its own, which it doesn't do, AFAIK.

/Janne

On 6 Mar 2010, at 17:47, Andrew Jaquith wrote:

> Hey Janne,
> 
> The discussion -- from my viewpoint -- is really about how to request
> resources safely, not whether the feature needs to be there. That puts
> it squarely into the realm of bug-fixing, not feature removal. As
> discussed, I felt I had a method that covered the JSP case without
> needing the TemplateManager.addResourceRequest() technique. You'll see
> that in a checkin I'll make later this morning. (The editor issues are
> fixed, for example).
> 
> I *did* make a mistake in not understanding that plugins need to
> request resources too. But to be fair, there isn't a single built-in
> plugin today that uses TemplateManager.addResourceRequest(). With the
> JSP case taken care of elsewhere, it seemed like an easy call to
> remove it -- it is dangerous code that no plugins use today. Seemed
> like a bug fix to me.
> 
> Now, as for FUTURE plugins, I agree that this it makes sense to give
> them a way to request resources. You've argued that including
> resources named in plugin annotations isn't good enough. Let me try
> and sketch out an approach that could work that would be more dynamic:
> 
> 1. Each plugin defines the script and CSS resources they require via
> annotations or XML. These resources encompass the total set of
> resources they might need, even if they don't need them all in a
> particular request. In other words, the annotations or XML elements
> create a "whitelist." These resource needs are stored at runtime in
> WikiModuleInfo.
> 
> 2. When PluginManager.execute() causes a plugin's execute() method to
> run, it looks up the WikiModuleInfo resource metadata. If any CSS or
> script resources are enumerated, each of these is checked against the
> resource path list for the servlet context. If it is found, it is
> added to the "resource request queue." If a resource isn't found, it's
> not added to the request queue. Put simply: the resource has to
> already exist in the set of resources known to the ServletContext, so
> no off-server resources could be requested. Thus, every resource
> request is validated, and therefore safe.
> 
> 3. For dynamic resource requests, PluginManager could optionally
> execute the plugin methods getScriptLocation() and
> getStylesheetLocation(), which would allow additional resources to be
> specified at runtime. These, too, would be checked against the
> ServletContext list for safety.
> 
> 4. The "request queue" for storing resource requests would be stored
> in the WikiContext or ActionBeanContext; probably as a
> Map<String,Set<String>>, where the keys are "css" or "script."
> Actually, Map retrieval is probably the best time to check resource
> requests against the ServletContext resource list, to figure out what
> to return, and what to drop on the floor.
> 
> 5. In the appropriate places in DefaultLayout.jsp, we iterate through
> the Set of resources for each key ("css" or "script"), and format the
> link or script tags as needed.
> 
> Is this a little more complicated than
> TemplateManager.addResourceRequest()? Only the initial coding. Plugin
> developers should just have to add a quickie annotation and be done.
> Is this safer? Yes, much safer, because plugins can request only
> certain resource types (scripts and CSS), and they must already exist
> on the server. I also like that it moves responsibility for vetting
> and adding resource requests from TemplateManager to
> Wiki[ActionBean]Context.
> 
> Oh, and if we do it this way, we don't need a response wrapper because
> the page-rendering code is guaranteed to execute before the layout
> JSP. :)
> 
> There are probably variations on this approach that would make sense,
> too. I hope you'll see this discussion, as I do, to increase plugin
> security while still giving plugin developers the flexibility they
> need. You have my apology for not fully considering plugin
> requirements before.
> 
> Andrew
> 
> On Fri, Mar 5, 2010 at 2:47 AM, Janne Jalkanen <ja...@ecyrd.com> wrote:
>> 
>> Well, first of all, since this is an already existing functionality, we need to vote to remove it anyway, so this discussion should've been done *before* it got removed.
>> 
>> Second, a good example is a plugin which allows multiple styles to be used based on user choice. For example, if I have a plugin which can have a regular and 3d style, the simplest way is to simply request the correct CSS file. Otherwise you need to hard-code everything, whereas with style changes all you need to do is to compare the plugin arguments to a fixed list (for security).
>> 
>> Another good example is that I can optimize some of the Javascript loading similarly - if I have a particular Form component which can insert a WYSIWYG editor, I might want to give the user a choice which WYSIWYG editor component to include, or which additional components to include to avoid loading everything.
>> 
>> /Janne
>> 
>> On 4 Mar 2010, at 23:47, Andrew Jaquith wrote:
>> 
>>> Janne, when you say "dynamic," what do you mean? I understand the need
>>> to insert pages, based on wiki markup, which may load other plugins.
>>> That is, when a page renders, it might need Plugin 1, Plugin 2 and
>>> Plugin 3, and each of which have needs. It might also selectively load
>>> another page, which needs Plugin 4. So, I understand that.
>>> 
>>> Beyond that, though, what other dynamic capabilities are needed? Do
>>> you really think that the path of a stylesheet or script file that a
>>> SPECIFIC plugin needs would change based on runtime conditions? Can
>>> you provide some specific examples? (Either your own plugins, or
>>> others you may know of...)
>>> 
>>> Just trying to understand...
>>> 
>>> Andrew
>>> 
>>> On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
>>> <ja...@ecyrd.com> wrote:
>>>> 
>>>> Sorry, kid interrupted the message....
>>>> 
>>>> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>>>> 
>>>> /Janne
>>>> 
>>>> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>>>> 
>>>>> 
>>>>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>>>> 
>>>>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>>>> 
>>>>> /Janne
>>>>> 
>>>>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>>>> 
>>>>>> Janne and Dirk --
>>>>>> 
>>>>>> Here's my proposal to resolve the resource-inclusion issue.
>>>>>> 
>>>>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>>>>> works fine. I'll check this in at my next opportunity (not for a few
>>>>>> days, probably).
>>>>>> 
>>>>>> 2. Plugin resources. It turns out we have a ready-made class,
>>>>>> WikiModuleInfo, that enumerates the resources that modules (like
>>>>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>>>>> before forwarding to the JSP, we simply inspect the page text before
>>>>>> to see what plugins are asked for in the wiki markup. For any that are
>>>>>> encountered, we add any script or css resources requirements to a
>>>>>> request "queue," which is processed when the JSP actually renders (by
>>>>>> IncludeResourcesTag or JSTL code).
>>>>>> 
>>>>>> I am satisfied that (2) will be safe because we would just be fetching
>>>>>> resources the developer specifically required, as the modules XML
>>>>>> file, or (better) class annotations specify.
>>>>>> 
>>>>>> Andrew
>>>>>> 
>>>>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>>>>> <an...@gmail.com> wrote:
>>>>>>> Janne --
>>>>>>> 
>>>>>>> Agreed. Each editor has special needs that ought to be specified in
>>>>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>>>> 
>>>>>>> In the current implementation, the scripts needed for the plain editor
>>>>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>>>>> how this would be specified instead in the editor JSPs directly.
>>>>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>>>>> yet.
>>>>>>> 
>>>>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>>>>> the editors working and to allow them to specify their own resources.
>>>>>>> It will be done soon enough.
>>>>>>> 
>>>>>>> In the meantime, I received your message -- that you need a way to
>>>>>>> allow plugins to include their own resources -- loud and clear. I
>>>>>>> don't have an answer for that today, but will propose some options
>>>>>>> shortly.
>>>>>>> 
>>>>>>> Andrew
>>>>>>> 
>>>>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>>>>> Why would we include the plain text editor in the case that the user
>>>>>>>> preferences state FCK editor?  Or vice versa?
>>>>>>>> 
>>>>>>>> From the point of view of the layouts editors and plugins should be
>>>>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>>>> 
>>>>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>>>>> the template choice.
>>>>>>>> 
>>>>>>>> /Janne
>>>>>>>> 
>>>>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>>>> 
>>>>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>>>>> for example.
>>>>>>>>> 
>>>>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>>>> 
>>>>>>>>> Andrew
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>>>>> component.
>>>>>>>>>> 
>>>>>>>>>> /Janne
>>>>>>>>>> 
>>>>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>>>> 
>>>>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>>>> 
>>>>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>>>>> layout jsp)
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>>>>> probably
>>>>>>>>>>> also css) is needed.
>>>>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>>>>> correct
>>>>>>>>>>> resources.
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> dirk
>>>>>>>>>>> 
>>>>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>>>>> how do
>>>>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>>>>> fall back to
>>>>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>>>>> assumes that
>>>>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>>>>> template,
>>>>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>>>> 
>>>>>>>>>>>> /Janne
>>>>>>>>>>>> 
>>>>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>>> Author: ajaquith
>>>>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> New Revision: 917390
>>>>>>>>>>>>> 
>>>>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>>>>> Log:
>>>>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>>>>> should) be
>>>>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>>>> 
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>> 
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>>> 
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>> 
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>>> 
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>>> 
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>>>>> are now
>>>>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>>>>> doCatch()
>>>>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>>>>> debugging.
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>>>>> feature was
>>>>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>>>>> View tab
>>>>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>>>>> JSPs.
>>>>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>>>>> used
>>>>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>>>>> customizable
>>>>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>>>>> Resources
>>>>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>>>>> as part
>>>>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>>>>> Stripesed.
>>>>>>>>>>>>> +
>>>>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>>>>> changes
>>>>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>>>>> spaces is
>>>>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>>>>> Release.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>>> Mon Mar
>>>>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>>>>   *  <p>
>>>>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>>>>   */
>>>>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>>>> Note.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>>>> Note.java Mon
>>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>>>>> -
>>>>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>>>>> -
>>>>>>>>>>>> commentImage );
>>>>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>>> Preferences.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>>>>      }
>>>>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>>>>      }
>>>>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>>>> -
>>>>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>>>>> -
>>>>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>>>> -
>>>>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>>>>> -
>>>>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>>>> 
>>>>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> /**
>>>>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>>>>          }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -            String page =
>>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>>>> -
>>>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>>>> -
>>>>>>>>>>>>       contentTemplate );
>>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>>>>      }
>>>>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>>>> 
>>>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> /**
>>>>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      try
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>>>>> pageContext,
>>>>>>>>>>>>> -
>>>>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>>>>> -
>>>>>>>>>>>> editorPath );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>>>          {
>>>>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>>>>> */
>>>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> /**
>>>>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>>>>> emits a
>>>>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>>>>> take
>>>>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>>>>> - *
>>>>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>>>>> into the
>>>>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>>>>> ServletFilter.
>>>>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>>>>> The
>>>>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>>>> on how
>>>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> */
>>>>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>>>>> {
>>>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>>>> -
>>>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>>>  {
>>>>>>>>>>>>>      super.initTag();
>>>>>>>>>>>>> -        m_type = null;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        //String marker =
>>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>>>>> (m_wikiContext,
>>>>>>>>>>>> m_type);
>>>>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>>>>> m_type);
>>>>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>>>>> m_type);
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>>>>> layout tags instead " +
>>>>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>>>>  {
>>>>>>>>>>>>>      try
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> -            String page =
>>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>>>> -
>>>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>>>> -
>>>>>>>>>>>>       m_page );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>>>          {
>>>>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>>>>> */
>>>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>> -
>>>>>>>>>>>>> /**
>>>>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>>>>> ().  You
>>>>>>>>>>>> may use
>>>>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>>>>> - *
>>>>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>>>>> JSPWiki to
>>>>>>>>>>>> insert
>>>>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>>>>> because it
>>>>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>>>>> instead. See
>>>>>>>>>>>> the default
>>>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>>>> on how
>>>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> */
>>>>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>>>>> {
>>>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>>>  {
>>>>>>>>>>>>>      super.initTag();
>>>>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>>>>  @Override
>>>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>>>>> m_type,
>>>>>>>>>>>> m_resource );
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public String getResource()
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        return m_resource;
>>>>>>>>>>>>> +        return "";
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        m_resource = r;
>>>>>>>>>>>>> +        // No-op.
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public String getType()
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        return m_type;
>>>>>>>>>>>>> +        return "";
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>>>>> "script".  Please
>>>>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>>>>> the
>>>>>>>>>>>> different kinds
>>>>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>>>>   */
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> EditorManager.java Mon
>>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>>>>> -
>>>>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>>>>> inside a
>>>>>>>>>>>> HTTP parameter. */
>>>>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>>>> 
>>>>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>>>>> -
>>>>>>>>>>>>>      String editor = null;
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> TemplateManager.java Mon
>>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>>>>> */
>>>>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>>>>> import java.util.*;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>>>>> */
>>>>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>>>>> {
>>>>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>>>>> "resourceResolver";
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>>>>> window.onload.
>>>>>>>>>>>> Value
>>>>>>>>>>>>> -     * is {@value}.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>>>>> strings.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>>>>> -
>>>>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>>>>> {@value}.
>>>>>>>>>>>> */
>>>>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>>>>> "template.properties";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>>>>> in the
>>>>>>>>>>>>> -     * WikiContext.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>>>>> -
>>>>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>>>>> TemplateManager.class );
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>>>>> Collections.emptyList();
>>>>>>>>>>>>> -
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>>>>> resources,
>>>>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>>>>> is
>>>>>>>>>>>>>   * immutable.
>>>>>>>>>>>>>   * </p>
>>>>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>>>>> ServletContext
>>>>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>>>>> some
>>>>>>>>>>>> reason.
>>>>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>>>>> requests.</p>
>>>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>>>> 
>>>>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>>>> "/" +
>>>>>>>>>>>> template + "/", null );
>>>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>>>> + "/" +
>>>>>>>>>>>> template + "/", null );
>>>>>>>>>>>>> 
>>>>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>>>>> default
>>>>>>>>>>>> does
>>>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>>>> "/" +
>>>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>>>> + "/" +
>>>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>>>>      }
>>>>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>>>> manager per
>>>>>>>>>>>> engine.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>>>>> this.
>>>>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>>>>> to the
>>>>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>>>>> as the
>>>>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>>>>> portion
>>>>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>>>>> short name
>>>>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>>>>> be added
>>>>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>>>> directory path)
>>>>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>>>>> from
>>>>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>>>>> prefix.
>>>>>>>>>>>> If not
>>>>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>>>   */
>>>>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>>>> properties )
>>>>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        super( engine );
>>>>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>>>> searchPath );
>>>>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>>>>> +        {
>>>>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>>>>> +            {
>>>>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>>>>> prefix.length()
>>>>>>>>>>>> );
>>>>>>>>>>>>> +
>>>>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>>>> +                {
>>>>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>>>>> shortName
>>>>>>>>>>>> );
>>>>>>>>>>>>> +                }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>>>>> already
>>>>>>>>>>>>> +                else
>>>>>>>>>>>>> +                {
>>>>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>>>> shortName );
>>>>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>>>>> +                    {
>>>>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>>>>> +                    }
>>>>>>>>>>>>> +                }
>>>>>>>>>>>>> +            }
>>>>>>>>>>>>> +        }
>>>>>>>>>>>>> +    }
>>>>>>>>>>>>> +
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>>>>> relative to
>>>>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>>>>> relative to
>>>>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   *
>>>>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>>>>> jspwiki.css}.
>>>>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>>>>> looked up
>>>>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>>>>> in
>>>>>>>>>>>> the
>>>>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>>>>   */
>>>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>>>> String
>>>>>>>>>>>> path )
>>>>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>>>>> servletContext,
>>>>>>>>>>>> String path )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( is == null )
>>>>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -            if( is != null )
>>>>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>>>>> -            else
>>>>>>>>>>>>> -                path = null;
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( is != null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            try
>>>>>>>>>>>>> -            {
>>>>>>>>>>>>> -                is.close();
>>>>>>>>>>>>> -            }
>>>>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>>>>> -            {
>>>>>>>>>>>>> -            }
>>>>>>>>>>>>> +            // This is already a full path
>>>>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>>>>      }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        return path;
>>>>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>>>>> if it's
>>>>>>>>>>>> not
>>>>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param sContext
>>>>>>>>>>>>> -     * @param template
>>>>>>>>>>>>> -     * @param name
>>>>>>>>>>>>> -     * @return
>>>>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>>>>> evaluation is
>>>>>>>>>>>> lazy,
>>>>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>>>>> actually
>>>>>>>>>>>> used
>>>>>>>>>>>>> +     * for the first time.
>>>>>>>>>>>>> +     */
>>>>>>>>>>>>> +    /*
>>>>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>>>> String
>>>>>>>>>>>> key ) {
>>>>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>>>> props =
>>>>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>>>> if(
>>>>>>>>>>>> props ==
>>>>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>>>> IOException e ) {
>>>>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>>>>> properties",e);
>>>>>>>>>>>> return
>>>>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>>>>   */
>>>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>>>> String
>>>>>>>>>>>> template, String name )
>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>>>>> +     */
>>>>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            // This is already a full path
>>>>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>>>>> +    }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>>>>> +    /**
>>>>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>>>> manager per
>>>>>>>>>>>> engine.
>>>>>>>>>>>>> +     *
>>>>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>>>>> this.
>>>>>>>>>>>>> +     */
>>>>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>>>> properties )
>>>>>>>>>>>>> +    {
>>>>>>>>>>>>> +        super( engine );
>>>>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>>>> {@code
>>>>>>>>>>>> Wiki.jsp})
>>>>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>>> instead
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>>>>> -
>>>>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        int idx = 0;
>>>>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>>>>> -            idx = 1;
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>>>>> -            {
>>>>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>>>>> -            }
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>>>>> -        return name;
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>>>>> template=foo.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>>>>> template, String
>>>>>>>>>>>> name )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>>>>> that
>>>>>>>>>>>> template
>>>>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>>>>> template,
>>>>>>>>>>>> will
>>>>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>>>>> template.
>>>>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>>> instead
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>>>>> String name )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>>>>      }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>>>>> template,
>>>>>>>>>>>> name );
>>>>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>>>>> name );
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>>> instead
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>>>>> String
>>>>>>>>>>>> name )
>>>>>>>>>>>>>  {
>>>>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>>>>> template,
>>>>>>>>>>>> name );
>>>>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>>>>> name );
>>>>>>>>>>>>>      }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>>>>> evaluation is
>>>>>>>>>>>> lazy,
>>>>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>>>>> actually
>>>>>>>>>>>> used
>>>>>>>>>>>>> -     * for the first time.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    /*
>>>>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>>>> String
>>>>>>>>>>>> key ) {
>>>>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>>>> props =
>>>>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>>>> if(
>>>>>>>>>>>> props ==
>>>>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>>>> IOException e ) {
>>>>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>>>>> properties",e);
>>>>>>>>>>>> return
>>>>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>>>>> empty
>>>>>>>>>>>> Set, if
>>>>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>>>>> does
>>>>>>>>>>>> not check
>>>>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>>>>> just
>>>>>>>>>>>> lists
>>>>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>>>>> available.
>>>>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>>>>> anything
>>>>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>>>>   *
>>>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>>>   * @param template The template to search
>>>>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>>>>> String
>>>>>>>>>>>> template )
>>>>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>>>>> place );
>>>>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      return resultSet;
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    /*
>>>>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>>>>> templateName )
>>>>>>>>>>>> throws
>>>>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>>>>> ServletContext
>>>>>>>>>>>> context =
>>>>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>>>>> if(
>>>>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>>>>> '"+templateName+"'
>>>>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>>>>> return p; }
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>>>>> This is in
>>>>>>>>>>>> a HTML
>>>>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>>>>> -     * @param type the marker
>>>>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>>>>> type )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>>>>> (javascript.*)
>>>>>>>>>>>> Returns
>>>>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>>>>> array.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param wiki context
>>>>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>>>>> LocaliedStrings
>>>>>>>>>>>> array
>>>>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>>>>> context )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>>>>> "templates.default" );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        boolean first = true;
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>>>>> -            {
>>>>>>>>>>>>> -                if( first )
>>>>>>>>>>>>> -                {
>>>>>>>>>>>>> -                    first = false;
>>>>>>>>>>>>> -                }
>>>>>>>>>>>>> -                else
>>>>>>>>>>>>> -                {
>>>>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>>>>> -                }
>>>>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>>>>> key ) +
>>>>>>>>>>>> "\"" );
>>>>>>>>>>>>> -            }
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>>>>> content will
>>>>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>>>>> (a script
>>>>>>>>>>>> file or
>>>>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>>>>> function
>>>>>>>>>>>> that should
>>>>>>>>>>>>> -     * be run at page load.
>>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>>>>> files, which
>>>>>>>>>>>> is then
>>>>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>>>>> rendered but
>>>>>>>>>>>> not yet
>>>>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>>>>> method does
>>>>>>>>>>>> not
>>>>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>>>>> Therefore,
>>>>>>>>>>>> if you
>>>>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>>>>> time,
>>>>>>>>>>>> you'll end
>>>>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>>>>> good
>>>>>>>>>>>> idea to
>>>>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>>>>> String type,
>>>>>>>>>>>> String resource )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>>>>> (HashMap<String,
>>>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>>>>> src='" +
>>>>>>>>>>>> resource + "'></script>";
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>>>>> css'
>>>>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>>>>> resource +
>>>>>>>>>>>> "\n</style>\n";
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>>>>> resourceString );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>>>>> are no
>>>>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>>>>> String
>>>>>>>>>>>> type )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( hm == null )
>>>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>>>>> -     *
>>>>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>>> tags
>>>>>>>>>>>> instead
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -            if( hm != null )
>>>>>>>>>>>>> -            {
>>>>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>>>>> -            }
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -        return res;
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> +
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>>>>> TemplateManager does
>>>>>>>>>>>>>   * not manage any modules.
>>>>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>>>>   */
>>>>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>>>>  {
>>>>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>>>>> -    }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -    /**
>>>>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>>>>> to the
>>>>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>>>>> as the
>>>>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>>>>> portion
>>>>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>>>>> short name
>>>>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>>>>> be added
>>>>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>>>> directory path)
>>>>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>>>>> from
>>>>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>>>>> prefix.
>>>>>>>>>>>> If not
>>>>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>>> -     */
>>>>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>>> -    {
>>>>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>>>> searchPath );
>>>>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>>>>> -        {
>>>>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>>>>> -            {
>>>>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>>>>> prefix.length()
>>>>>>>>>>>> );
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>>>> -                {
>>>>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>>>>> shortName
>>>>>>>>>>>> );
>>>>>>>>>>>>> -                }
>>>>>>>>>>>>> -
>>>>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>>>>> already
>>>>>>>>>>>>> -                else
>>>>>>>>>>>>> -                {
>>>>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>>>> shortName );
>>>>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>>>>> -                    {
>>>>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>>>>> -                    }
>>>>>>>>>>>>> -                }
>>>>>>>>>>>>> -            }
>>>>>>>>>>>>> -        }
>>>>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>>>>  }
>>>>>>>>>>>>> }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>> URL:
>>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>> 
>>>>>>>>>>>> ============
>>>>>>>>>>>> ==================================================================
>>>>>>>>>>>>> ---
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>> (original)
>>>>>>>>>>>>> +++
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>>>>> {
>>>>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>>>> 
>>>>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>>>>> +
>>>>>>>>>>>>>  /**
>>>>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>>>>   *
>>>>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>>>>> servletContext
>>>>>>>>>>>> ).get( getPath() );
>>>>>>>>>>>>>      if( path == null )
>>>>>>>>>>>>>      {
>>>>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>>>>> "/" + getPath();
>>>>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>>>>      }
>>>>>>>>>>>>>      setPath( path );
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Andrew Jaquith <an...@gmail.com>.
Hey Janne,

The discussion -- from my viewpoint -- is really about how to request
resources safely, not whether the feature needs to be there. That puts
it squarely into the realm of bug-fixing, not feature removal. As
discussed, I felt I had a method that covered the JSP case without
needing the TemplateManager.addResourceRequest() technique. You'll see
that in a checkin I'll make later this morning. (The editor issues are
fixed, for example).

I *did* make a mistake in not understanding that plugins need to
request resources too. But to be fair, there isn't a single built-in
plugin today that uses TemplateManager.addResourceRequest(). With the
JSP case taken care of elsewhere, it seemed like an easy call to
remove it -- it is dangerous code that no plugins use today. Seemed
like a bug fix to me.

Now, as for FUTURE plugins, I agree that this it makes sense to give
them a way to request resources. You've argued that including
resources named in plugin annotations isn't good enough. Let me try
and sketch out an approach that could work that would be more dynamic:

1. Each plugin defines the script and CSS resources they require via
annotations or XML. These resources encompass the total set of
resources they might need, even if they don't need them all in a
particular request. In other words, the annotations or XML elements
create a "whitelist." These resource needs are stored at runtime in
WikiModuleInfo.

2. When PluginManager.execute() causes a plugin's execute() method to
run, it looks up the WikiModuleInfo resource metadata. If any CSS or
script resources are enumerated, each of these is checked against the
resource path list for the servlet context. If it is found, it is
added to the "resource request queue." If a resource isn't found, it's
not added to the request queue. Put simply: the resource has to
already exist in the set of resources known to the ServletContext, so
no off-server resources could be requested. Thus, every resource
request is validated, and therefore safe.

3. For dynamic resource requests, PluginManager could optionally
execute the plugin methods getScriptLocation() and
getStylesheetLocation(), which would allow additional resources to be
specified at runtime. These, too, would be checked against the
ServletContext list for safety.

4. The "request queue" for storing resource requests would be stored
in the WikiContext or ActionBeanContext; probably as a
Map<String,Set<String>>, where the keys are "css" or "script."
Actually, Map retrieval is probably the best time to check resource
requests against the ServletContext resource list, to figure out what
to return, and what to drop on the floor.

5. In the appropriate places in DefaultLayout.jsp, we iterate through
the Set of resources for each key ("css" or "script"), and format the
link or script tags as needed.

Is this a little more complicated than
TemplateManager.addResourceRequest()? Only the initial coding. Plugin
developers should just have to add a quickie annotation and be done.
Is this safer? Yes, much safer, because plugins can request only
certain resource types (scripts and CSS), and they must already exist
on the server. I also like that it moves responsibility for vetting
and adding resource requests from TemplateManager to
Wiki[ActionBean]Context.

Oh, and if we do it this way, we don't need a response wrapper because
the page-rendering code is guaranteed to execute before the layout
JSP. :)

There are probably variations on this approach that would make sense,
too. I hope you'll see this discussion, as I do, to increase plugin
security while still giving plugin developers the flexibility they
need. You have my apology for not fully considering plugin
requirements before.

Andrew

On Fri, Mar 5, 2010 at 2:47 AM, Janne Jalkanen <ja...@ecyrd.com> wrote:
>
> Well, first of all, since this is an already existing functionality, we need to vote to remove it anyway, so this discussion should've been done *before* it got removed.
>
> Second, a good example is a plugin which allows multiple styles to be used based on user choice. For example, if I have a plugin which can have a regular and 3d style, the simplest way is to simply request the correct CSS file. Otherwise you need to hard-code everything, whereas with style changes all you need to do is to compare the plugin arguments to a fixed list (for security).
>
> Another good example is that I can optimize some of the Javascript loading similarly - if I have a particular Form component which can insert a WYSIWYG editor, I might want to give the user a choice which WYSIWYG editor component to include, or which additional components to include to avoid loading everything.
>
> /Janne
>
> On 4 Mar 2010, at 23:47, Andrew Jaquith wrote:
>
>> Janne, when you say "dynamic," what do you mean? I understand the need
>> to insert pages, based on wiki markup, which may load other plugins.
>> That is, when a page renders, it might need Plugin 1, Plugin 2 and
>> Plugin 3, and each of which have needs. It might also selectively load
>> another page, which needs Plugin 4. So, I understand that.
>>
>> Beyond that, though, what other dynamic capabilities are needed? Do
>> you really think that the path of a stylesheet or script file that a
>> SPECIFIC plugin needs would change based on runtime conditions? Can
>> you provide some specific examples? (Either your own plugins, or
>> others you may know of...)
>>
>> Just trying to understand...
>>
>> Andrew
>>
>> On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
>> <ja...@ecyrd.com> wrote:
>>>
>>> Sorry, kid interrupted the message....
>>>
>>> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>>>
>>> /Janne
>>>
>>> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>>>
>>>>
>>>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>>>
>>>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>>>
>>>> /Janne
>>>>
>>>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>>>
>>>>> Janne and Dirk --
>>>>>
>>>>> Here's my proposal to resolve the resource-inclusion issue.
>>>>>
>>>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>>>> works fine. I'll check this in at my next opportunity (not for a few
>>>>> days, probably).
>>>>>
>>>>> 2. Plugin resources. It turns out we have a ready-made class,
>>>>> WikiModuleInfo, that enumerates the resources that modules (like
>>>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>>>> before forwarding to the JSP, we simply inspect the page text before
>>>>> to see what plugins are asked for in the wiki markup. For any that are
>>>>> encountered, we add any script or css resources requirements to a
>>>>> request "queue," which is processed when the JSP actually renders (by
>>>>> IncludeResourcesTag or JSTL code).
>>>>>
>>>>> I am satisfied that (2) will be safe because we would just be fetching
>>>>> resources the developer specifically required, as the modules XML
>>>>> file, or (better) class annotations specify.
>>>>>
>>>>> Andrew
>>>>>
>>>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>>>> <an...@gmail.com> wrote:
>>>>>> Janne --
>>>>>>
>>>>>> Agreed. Each editor has special needs that ought to be specified in
>>>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>>>
>>>>>> In the current implementation, the scripts needed for the plain editor
>>>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>>>> how this would be specified instead in the editor JSPs directly.
>>>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>>>> yet.
>>>>>>
>>>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>>>> the editors working and to allow them to specify their own resources.
>>>>>> It will be done soon enough.
>>>>>>
>>>>>> In the meantime, I received your message -- that you need a way to
>>>>>> allow plugins to include their own resources -- loud and clear. I
>>>>>> don't have an answer for that today, but will propose some options
>>>>>> shortly.
>>>>>>
>>>>>> Andrew
>>>>>>
>>>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>>>> Why would we include the plain text editor in the case that the user
>>>>>>> preferences state FCK editor?  Or vice versa?
>>>>>>>
>>>>>>> From the point of view of the layouts editors and plugins should be
>>>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>>>
>>>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>>>> the template choice.
>>>>>>>
>>>>>>> /Janne
>>>>>>>
>>>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>>>
>>>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>>>> for example.
>>>>>>>>
>>>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>>>
>>>>>>>> Andrew
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>>>> component.
>>>>>>>>>
>>>>>>>>> /Janne
>>>>>>>>>
>>>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>>>
>>>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>>>
>>>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>>>> layout jsp)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>>>> probably
>>>>>>>>>> also css) is needed.
>>>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>>>> correct
>>>>>>>>>> resources.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> dirk
>>>>>>>>>>
>>>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>>>> how do
>>>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>>>> fall back to
>>>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>>>> assumes that
>>>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>>>> template,
>>>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>>>
>>>>>>>>>>> /Janne
>>>>>>>>>>>
>>>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Author: ajaquith
>>>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> New Revision: 917390
>>>>>>>>>>>>
>>>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>>>> Log:
>>>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>>>> should) be
>>>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>>>
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>> Preferences.java
>>>>>>>>>>>>
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>>>
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>>
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>>
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>>
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>>
>>>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>> +
>>>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>>>> +
>>>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>>>> are now
>>>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>>>> doCatch()
>>>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>>>> debugging.
>>>>>>>>>>>> +
>>>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>>>> feature was
>>>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>>>> View tab
>>>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>>>> +
>>>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>>>> JSPs.
>>>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>>>> used
>>>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>>>> customizable
>>>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>>>> +
>>>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>>>> Resources
>>>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>>>> +
>>>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>>>> as part
>>>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>>>> Stripesed.
>>>>>>>>>>>> +
>>>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>>>
>>>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>>>> changes
>>>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>>>> spaces is
>>>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>>>
>>>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>>>
>>>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>>>> Release.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>>> Mon Mar
>>>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>>>   *  <p>
>>>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>>>   */
>>>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>>> Note.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>>> Note.java Mon
>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>>>
>>>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>>>
>>>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>>>> -
>>>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>>>> -
>>>>>>>>>>> commentImage );
>>>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>>>
>>>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>> Preferences.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>> Preferences.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>>> Preferences.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>>>      }
>>>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>>>      {
>>>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>>>      }
>>>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>>>      {
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>>>
>>>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>>> -
>>>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>>>> -
>>>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>>>> -
>>>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>>> -
>>>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>>>> -
>>>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> ContentTag.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>>>
>>>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> /**
>>>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>>>          }
>>>>>>>>>>>>
>>>>>>>>>>>> -            String page =
>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>>> -
>>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>>> -
>>>>>>>>>>>       contentTemplate );
>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>>>      }
>>>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> EditorTag.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>>>
>>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> /**
>>>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>>>
>>>>>>>>>>>>      try
>>>>>>>>>>>>      {
>>>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>>>> pageContext,
>>>>>>>>>>>> -
>>>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>>>> -
>>>>>>>>>>> editorPath );
>>>>>>>>>>>> -
>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>>          {
>>>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>>>> */
>>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>>>
>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>>
>>>>>>>>>>>> /**
>>>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>>>> emits a
>>>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>>>> take
>>>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>>>> - *
>>>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>>>> into the
>>>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>>>> ServletFilter.
>>>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>>>> The
>>>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>>> on how
>>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> */
>>>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>>>> {
>>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>>>
>>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>>> -
>>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>>  {
>>>>>>>>>>>>      super.initTag();
>>>>>>>>>>>> -        m_type = null;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        //String marker =
>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>>>> (m_wikiContext,
>>>>>>>>>>> m_type);
>>>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>>>> m_type);
>>>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>>>> m_type);
>>>>>>>>>>>> -
>>>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>>>> -
>>>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>>>> layout tags instead " +
>>>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>>>
>>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>>>  {
>>>>>>>>>>>>      try
>>>>>>>>>>>>      {
>>>>>>>>>>>> -            String page =
>>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>>> -
>>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>>> -
>>>>>>>>>>>       m_page );
>>>>>>>>>>>> -
>>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>>          {
>>>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>>>> */
>>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>>>
>>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>>> -
>>>>>>>>>>>> /**
>>>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>>>> ().  You
>>>>>>>>>>> may use
>>>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>>>> - *
>>>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>>>> JSPWiki to
>>>>>>>>>>> insert
>>>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>>>> because it
>>>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>>>> instead. See
>>>>>>>>>>> the default
>>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>>> on how
>>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> */
>>>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>>>> {
>>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>>> -
>>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>>  {
>>>>>>>>>>>>      super.initTag();
>>>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>>>  @Override
>>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>>>> m_type,
>>>>>>>>>>> m_resource );
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public String getResource()
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        return m_resource;
>>>>>>>>>>>> +        return "";
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        m_resource = r;
>>>>>>>>>>>> +        // No-op.
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public String getType()
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        return m_type;
>>>>>>>>>>>> +        return "";
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>>>> "script".  Please
>>>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>>>> the
>>>>>>>>>>> different kinds
>>>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>>>   */
>>>>>>>>>>>>
>>>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> EditorManager.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> EditorManager.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> EditorManager.java Mon
>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>>>
>>>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>>>> -
>>>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>>>> inside a
>>>>>>>>>>> HTTP parameter. */
>>>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>>>
>>>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>>>> -
>>>>>>>>>>>>      String editor = null;
>>>>>>>>>>>>
>>>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> TemplateManager.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> TemplateManager.java Mon
>>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>>>> */
>>>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>>>
>>>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>>>> import java.util.*;
>>>>>>>>>>>>
>>>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>>>> */
>>>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>>>> {
>>>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>>>   */
>>>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>>>> "resourceResolver";
>>>>>>>>>>>>
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>>>> window.onload.
>>>>>>>>>>> Value
>>>>>>>>>>>> -     * is {@value}.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>>>> strings.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>>>> -
>>>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>>>> {@value}.
>>>>>>>>>>> */
>>>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>>>
>>>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>>>
>>>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>>>> "template.properties";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>>>> in the
>>>>>>>>>>>> -     * WikiContext.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>>>> -
>>>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>>>> TemplateManager.class );
>>>>>>>>>>>>
>>>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>>>> -
>>>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>>>> -
>>>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>>>> Collections.emptyList();
>>>>>>>>>>>> -
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>>>> resources,
>>>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>>>> is
>>>>>>>>>>>>   * immutable.
>>>>>>>>>>>>   * </p>
>>>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>>>> ServletContext
>>>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>>>> some
>>>>>>>>>>> reason.
>>>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>>>> requests.</p>
>>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>>>
>>>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>>> "/" +
>>>>>>>>>>> template + "/", null );
>>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>>> + "/" +
>>>>>>>>>>> template + "/", null );
>>>>>>>>>>>>
>>>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>>>> default
>>>>>>>>>>> does
>>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>>> "/" +
>>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>>> + "/" +
>>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>>>      }
>>>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>>> manager per
>>>>>>>>>>> engine.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>>>> this.
>>>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>>>> to the
>>>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>>>> as the
>>>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>>>> portion
>>>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>>>> short name
>>>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>>>> be added
>>>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>>> directory path)
>>>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>>>> from
>>>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>>>> prefix.
>>>>>>>>>>> If not
>>>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>>   */
>>>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>>> properties )
>>>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        super( engine );
>>>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>> -    }
>>>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>>> searchPath );
>>>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>>>> +        {
>>>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>>>> +            {
>>>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>>>> prefix.length()
>>>>>>>>>>> );
>>>>>>>>>>>> +
>>>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>>> +                {
>>>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>>>> shortName
>>>>>>>>>>> );
>>>>>>>>>>>> +                }
>>>>>>>>>>>>
>>>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>>>> already
>>>>>>>>>>>> +                else
>>>>>>>>>>>> +                {
>>>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>>> shortName );
>>>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>>>> +                    {
>>>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>>>> +                    }
>>>>>>>>>>>> +                }
>>>>>>>>>>>> +            }
>>>>>>>>>>>> +        }
>>>>>>>>>>>> +    }
>>>>>>>>>>>> +
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>>>> relative to
>>>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>>>> relative to
>>>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   *
>>>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>>>> jspwiki.css}.
>>>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>>>> looked up
>>>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>>>> in
>>>>>>>>>>> the
>>>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>>>   */
>>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>>> String
>>>>>>>>>>> path )
>>>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>>>> servletContext,
>>>>>>>>>>> String path )
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( is == null )
>>>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>>>      {
>>>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>>>> -
>>>>>>>>>>>> -            if( is != null )
>>>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>>>> -            else
>>>>>>>>>>>> -                path = null;
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( is != null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            try
>>>>>>>>>>>> -            {
>>>>>>>>>>>> -                is.close();
>>>>>>>>>>>> -            }
>>>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>>>> -            {
>>>>>>>>>>>> -            }
>>>>>>>>>>>> +            // This is already a full path
>>>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>>>      }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        return path;
>>>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>>>> if it's
>>>>>>>>>>> not
>>>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param sContext
>>>>>>>>>>>> -     * @param template
>>>>>>>>>>>> -     * @param name
>>>>>>>>>>>> -     * @return
>>>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>>>> evaluation is
>>>>>>>>>>> lazy,
>>>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>>>> actually
>>>>>>>>>>> used
>>>>>>>>>>>> +     * for the first time.
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    /*
>>>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>>> String
>>>>>>>>>>> key ) {
>>>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>>> props =
>>>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>>> if(
>>>>>>>>>>> props ==
>>>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>>> IOException e ) {
>>>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>>>> properties",e);
>>>>>>>>>>> return
>>>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>>>   */
>>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>>> String
>>>>>>>>>>> template, String name )
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            // This is already a full path
>>>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>>>> -        }
>>>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>>>> +    }
>>>>>>>>>>>>
>>>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>>>
>>>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>>>> +    /**
>>>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>>> manager per
>>>>>>>>>>> engine.
>>>>>>>>>>>> +     *
>>>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>>>> this.
>>>>>>>>>>>> +     */
>>>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>>> properties )
>>>>>>>>>>>> +    {
>>>>>>>>>>>> +        super( engine );
>>>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>>> {@code
>>>>>>>>>>> Wiki.jsp})
>>>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>> instead
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>>>  {
>>>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>>>> -
>>>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        int idx = 0;
>>>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>>>> -            idx = 1;
>>>>>>>>>>>> -
>>>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>>>> -
>>>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>>>> -            {
>>>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>>>> -            }
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>>>> -        return name;
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>>>> template=foo.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>>>> template, String
>>>>>>>>>>> name )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>>>> that
>>>>>>>>>>> template
>>>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>>>> template,
>>>>>>>>>>> will
>>>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>>>> template.
>>>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>> instead
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>>>> String name )
>>>>>>>>>>>>  {
>>>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>>>      }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>>>> template,
>>>>>>>>>>> name );
>>>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>>>> name );
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>>> (ServletContext)}
>>>>>>>>>>> instead
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>>>> String
>>>>>>>>>>> name )
>>>>>>>>>>>>  {
>>>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>>>      {
>>>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>>>> template,
>>>>>>>>>>> name );
>>>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>>>> name );
>>>>>>>>>>>>      }
>>>>>>>>>>>>
>>>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>>>  }
>>>>>>>>>>>>
>>>>>>>>>>>>  /**
>>>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>>>> evaluation is
>>>>>>>>>>> lazy,
>>>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>>>> actually
>>>>>>>>>>> used
>>>>>>>>>>>> -     * for the first time.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    /*
>>>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>>> String
>>>>>>>>>>> key ) {
>>>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>>> props =
>>>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>>> if(
>>>>>>>>>>> props ==
>>>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>>> IOException e ) {
>>>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>>>> properties",e);
>>>>>>>>>>> return
>>>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>>>> empty
>>>>>>>>>>> Set, if
>>>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>>>> does
>>>>>>>>>>> not check
>>>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>>>> just
>>>>>>>>>>> lists
>>>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>>>> available.
>>>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>>>> anything
>>>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>>>   *
>>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>>   * @param template The template to search
>>>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>>>   */
>>>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>>>> String
>>>>>>>>>>> template )
>>>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>>>> place );
>>>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>>>
>>>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>>>
>>>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>>>      {
>>>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>>>
>>>>>>>>>>>>      return resultSet;
>>>>>>>>>>>>  }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    /*
>>>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>>>> templateName )
>>>>>>>>>>> throws
>>>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>>>> ServletContext
>>>>>>>>>>> context =
>>>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>>>> if(
>>>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>>>> '"+templateName+"'
>>>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>>>> return p; }
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>>>> This is in
>>>>>>>>>>> a HTML
>>>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>>>> -     * @param type the marker
>>>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>>>> type )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>>>> (javascript.*)
>>>>>>>>>>> Returns
>>>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>>>> array.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param wiki context
>>>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>>>> LocaliedStrings
>>>>>>>>>>> array
>>>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>>>> context )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>>>> -
>>>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>>>> "templates.default" );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        boolean first = true;
>>>>>>>>>>>> -
>>>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>>>> -
>>>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>>>> -            {
>>>>>>>>>>>> -                if( first )
>>>>>>>>>>>> -                {
>>>>>>>>>>>> -                    first = false;
>>>>>>>>>>>> -                }
>>>>>>>>>>>> -                else
>>>>>>>>>>>> -                {
>>>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>>>> -                }
>>>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>>>> key ) +
>>>>>>>>>>> "\"" );
>>>>>>>>>>>> -            }
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>>>> content will
>>>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>>>> (a script
>>>>>>>>>>> file or
>>>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>>>> function
>>>>>>>>>>> that should
>>>>>>>>>>>> -     * be run at page load.
>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>>>> files, which
>>>>>>>>>>> is then
>>>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>>>> rendered but
>>>>>>>>>>> not yet
>>>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>>>> -     * <p>
>>>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>>>> method does
>>>>>>>>>>> not
>>>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>>>> Therefore,
>>>>>>>>>>> if you
>>>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>>>> time,
>>>>>>>>>>> you'll end
>>>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>>>> good
>>>>>>>>>>> idea to
>>>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>>>> String type,
>>>>>>>>>>> String resource )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>>>> (HashMap<String,
>>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>>>> src='" +
>>>>>>>>>>> resource + "'></script>";
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>>>> css'
>>>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>>>> resource +
>>>>>>>>>>> "\n</style>\n";
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>>>> resourceString );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>>>> are no
>>>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>>>> String
>>>>>>>>>>> type )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( hm == null )
>>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>>> -
>>>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>>> -
>>>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>>>> -
>>>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>>>> -     *
>>>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>>> tags
>>>>>>>>>>> instead
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>>>> -
>>>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>>> -
>>>>>>>>>>>> -            if( hm != null )
>>>>>>>>>>>> -            {
>>>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>>>> -
>>>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>>>> -            }
>>>>>>>>>>>> -        }
>>>>>>>>>>>> -
>>>>>>>>>>>> -        return res;
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> +
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>>>> TemplateManager does
>>>>>>>>>>>>   * not manage any modules.
>>>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>>>   */
>>>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>>>  {
>>>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>>>> -    }
>>>>>>>>>>>> -
>>>>>>>>>>>> -    /**
>>>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>>>> to the
>>>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>>>> as the
>>>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>>>> portion
>>>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>>>> short name
>>>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>>>> be added
>>>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>>> directory path)
>>>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>>>> from
>>>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>>>> prefix.
>>>>>>>>>>> If not
>>>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>> -     */
>>>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>> -    {
>>>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>>> searchPath );
>>>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>>>> -        {
>>>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>>>> -            {
>>>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>>>> prefix.length()
>>>>>>>>>>> );
>>>>>>>>>>>> -
>>>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>>> -                {
>>>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>>>> shortName
>>>>>>>>>>> );
>>>>>>>>>>>> -                }
>>>>>>>>>>>> -
>>>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>>>> already
>>>>>>>>>>>> -                else
>>>>>>>>>>>> -                {
>>>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>>> shortName );
>>>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>>>> -                    {
>>>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>>>> -                    }
>>>>>>>>>>>> -                }
>>>>>>>>>>>> -            }
>>>>>>>>>>>> -        }
>>>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>>>  }
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>>> URL:
>>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>>>
>>>>>>>>>>> ============
>>>>>>>>>>> ==================================================================
>>>>>>>>>>>> ---
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>> (original)
>>>>>>>>>>>> +++
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>>>> {
>>>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>>>
>>>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>>>> +
>>>>>>>>>>>>  /**
>>>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>>>   *
>>>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>>>> servletContext
>>>>>>>>>>> ).get( getPath() );
>>>>>>>>>>>>      if( path == null )
>>>>>>>>>>>>      {
>>>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>>>> "/" + getPath();
>>>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>>>      }
>>>>>>>>>>>>      setPath( path );
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>
>>>
>>>
>
>

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
Well, first of all, since this is an already existing functionality, we need to vote to remove it anyway, so this discussion should've been done *before* it got removed.

Second, a good example is a plugin which allows multiple styles to be used based on user choice. For example, if I have a plugin which can have a regular and 3d style, the simplest way is to simply request the correct CSS file. Otherwise you need to hard-code everything, whereas with style changes all you need to do is to compare the plugin arguments to a fixed list (for security).

Another good example is that I can optimize some of the Javascript loading similarly - if I have a particular Form component which can insert a WYSIWYG editor, I might want to give the user a choice which WYSIWYG editor component to include, or which additional components to include to avoid loading everything.

/Janne

On 4 Mar 2010, at 23:47, Andrew Jaquith wrote:

> Janne, when you say "dynamic," what do you mean? I understand the need
> to insert pages, based on wiki markup, which may load other plugins.
> That is, when a page renders, it might need Plugin 1, Plugin 2 and
> Plugin 3, and each of which have needs. It might also selectively load
> another page, which needs Plugin 4. So, I understand that.
> 
> Beyond that, though, what other dynamic capabilities are needed? Do
> you really think that the path of a stylesheet or script file that a
> SPECIFIC plugin needs would change based on runtime conditions? Can
> you provide some specific examples? (Either your own plugins, or
> others you may know of...)
> 
> Just trying to understand...
> 
> Andrew
> 
> On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
> <ja...@ecyrd.com> wrote:
>> 
>> Sorry, kid interrupted the message....
>> 
>> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>> 
>> /Janne
>> 
>> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>> 
>>> 
>>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>> 
>>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>> 
>>> /Janne
>>> 
>>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>> 
>>>> Janne and Dirk --
>>>> 
>>>> Here's my proposal to resolve the resource-inclusion issue.
>>>> 
>>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>>> works fine. I'll check this in at my next opportunity (not for a few
>>>> days, probably).
>>>> 
>>>> 2. Plugin resources. It turns out we have a ready-made class,
>>>> WikiModuleInfo, that enumerates the resources that modules (like
>>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>>> before forwarding to the JSP, we simply inspect the page text before
>>>> to see what plugins are asked for in the wiki markup. For any that are
>>>> encountered, we add any script or css resources requirements to a
>>>> request "queue," which is processed when the JSP actually renders (by
>>>> IncludeResourcesTag or JSTL code).
>>>> 
>>>> I am satisfied that (2) will be safe because we would just be fetching
>>>> resources the developer specifically required, as the modules XML
>>>> file, or (better) class annotations specify.
>>>> 
>>>> Andrew
>>>> 
>>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>>> <an...@gmail.com> wrote:
>>>>> Janne --
>>>>> 
>>>>> Agreed. Each editor has special needs that ought to be specified in
>>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>> 
>>>>> In the current implementation, the scripts needed for the plain editor
>>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>>> how this would be specified instead in the editor JSPs directly.
>>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>>> yet.
>>>>> 
>>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>>> the editors working and to allow them to specify their own resources.
>>>>> It will be done soon enough.
>>>>> 
>>>>> In the meantime, I received your message -- that you need a way to
>>>>> allow plugins to include their own resources -- loud and clear. I
>>>>> don't have an answer for that today, but will propose some options
>>>>> shortly.
>>>>> 
>>>>> Andrew
>>>>> 
>>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>>> Why would we include the plain text editor in the case that the user
>>>>>> preferences state FCK editor?  Or vice versa?
>>>>>> 
>>>>>> From the point of view of the layouts editors and plugins should be
>>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>> 
>>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>>> the template choice.
>>>>>> 
>>>>>> /Janne
>>>>>> 
>>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>> 
>>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>>> for example.
>>>>>>> 
>>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>> 
>>>>>>> Andrew
>>>>>>> 
>>>>>>> 
>>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> 
>>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>>> component.
>>>>>>>> 
>>>>>>>> /Janne
>>>>>>>> 
>>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>> 
>>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>> 
>>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>>> layout jsp)
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>>> probably
>>>>>>>>> also css) is needed.
>>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>>> correct
>>>>>>>>> resources.
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> dirk
>>>>>>>>> 
>>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>>> how do
>>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>>> fall back to
>>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>>> assumes that
>>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>>> template,
>>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>> 
>>>>>>>>>> /Janne
>>>>>>>>>> 
>>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>> 
>>>>>>>>>>> Author: ajaquith
>>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>>> New Revision: 917390
>>>>>>>>>>> 
>>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>>> Log:
>>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>>> should) be
>>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> EditorTag.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>>> EditorManager.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java
>>>>>>>>>>> 
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>> 
>>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>> +
>>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>>> +
>>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>>> are now
>>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>>> doCatch()
>>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>>> debugging.
>>>>>>>>>>> +
>>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>>> feature was
>>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>>> View tab
>>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>>> +
>>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>>> JSPs.
>>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>>> used
>>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>>> customizable
>>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>>> +
>>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>>> Resources
>>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>>> +
>>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>>> as part
>>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>>> Stripesed.
>>>>>>>>>>> +
>>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>> 
>>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>>> changes
>>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>>> spaces is
>>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>> 
>>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>> 
>>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>>> Release.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>>> Mon Mar
>>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>>   *  <p>
>>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>>   */
>>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>> Note.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>>> Note.java Mon
>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>> 
>>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>> 
>>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>>> -
>>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>>> -
>>>>>>>>>> commentImage );
>>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>> 
>>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>>> Preferences.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>>      }
>>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>>      {
>>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>>      }
>>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>>      {
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>> 
>>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>>  {
>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>> -
>>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>>> -
>>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>>> -
>>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>>> -
>>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>>> -
>>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> ContentTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>> 
>>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> /**
>>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>>          }
>>>>>>>>>>> 
>>>>>>>>>>> -            String page =
>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>> -
>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>> -
>>>>>>>>>>       contentTemplate );
>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>>      }
>>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> EditorTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> EditorTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>> 
>>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> /**
>>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>> 
>>>>>>>>>>>      try
>>>>>>>>>>>      {
>>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>>> pageContext,
>>>>>>>>>>> -
>>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>>> -
>>>>>>>>>> editorPath );
>>>>>>>>>>> -
>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>          {
>>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>>> */
>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>> 
>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> 
>>>>>>>>>>> /**
>>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>>> emits a
>>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>>> take
>>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>>> - *
>>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>> instead
>>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>>> into the
>>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>>> ServletFilter.
>>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>>> The
>>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>> on how
>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>> instead
>>>>>>>>>>> */
>>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>>> {
>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>> 
>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>> -
>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>  {
>>>>>>>>>>>      super.initTag();
>>>>>>>>>>> -        m_type = null;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>>  {
>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>  {
>>>>>>>>>>> -        //String marker =
>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>>> (m_wikiContext,
>>>>>>>>>> m_type);
>>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>>> m_type);
>>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>>> m_type);
>>>>>>>>>>> -
>>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>>> -
>>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>>> layout tags instead " +
>>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>>> IncludeTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>> 
>>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>>  {
>>>>>>>>>>>      try
>>>>>>>>>>>      {
>>>>>>>>>>> -            String page =
>>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>>> -
>>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>>> -
>>>>>>>>>>       m_page );
>>>>>>>>>>> -
>>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>>          if( page == null )
>>>>>>>>>>>          {
>>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>>> */
>>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>> 
>>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>> -
>>>>>>>>>>> /**
>>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>>> ().  You
>>>>>>>>>> may use
>>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>>> - *
>>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>>> JSPWiki to
>>>>>>>>>> insert
>>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>>> because it
>>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>>> instead. See
>>>>>>>>>> the default
>>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>>> on how
>>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>>> instead
>>>>>>>>>>> */
>>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>>> {
>>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>> -
>>>>>>>>>>> -    private String m_type;
>>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>>  public void initTag()
>>>>>>>>>>>  {
>>>>>>>>>>>      super.initTag();
>>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>>  @Override
>>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>>  {
>>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>>> m_type,
>>>>>>>>>> m_resource );
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>>   */
>>>>>>>>>>>  public String getResource()
>>>>>>>>>>>  {
>>>>>>>>>>> -        return m_resource;
>>>>>>>>>>> +        return "";
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>>   */
>>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>>  {
>>>>>>>>>>> -        m_resource = r;
>>>>>>>>>>> +        // No-op.
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>>   */
>>>>>>>>>>>  public String getType()
>>>>>>>>>>>  {
>>>>>>>>>>> -        return m_type;
>>>>>>>>>>> +        return "";
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>>> "script".  Please
>>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>>> the
>>>>>>>>>> different kinds
>>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>>   *
>>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>>   */
>>>>>>>>>>> 
>>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>>  {
>>>>>>>>>>> -        m_type = type;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>> }
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java Mon
>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>> 
>>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>>> -
>>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>>> inside a
>>>>>>>>>> HTTP parameter. */
>>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>> 
>>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>>  {
>>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>>> -
>>>>>>>>>>>      String editor = null;
>>>>>>>>>>> 
>>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> TemplateManager.java Mon
>>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>>> */
>>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>> 
>>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>>> import java.util.*;
>>>>>>>>>>> 
>>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>>> */
>>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>>> {
>>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>>> "resourceResolver";
>>>>>>>>>>> 
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>>> window.onload.
>>>>>>>>>> Value
>>>>>>>>>>> -     * is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>>> strings.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>>> -
>>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>>> {@value}.
>>>>>>>>>> */
>>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>> 
>>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>> 
>>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>>> "template.properties";
>>>>>>>>>>> -
>>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>>> in the
>>>>>>>>>>> -     * WikiContext.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>>> -
>>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>>> -
>>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>>> TemplateManager.class );
>>>>>>>>>>> 
>>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>>> -
>>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>>> -
>>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>>> Collections.emptyList();
>>>>>>>>>>> -
>>>>>>>>>>>  /**
>>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>>> resources,
>>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>>> is
>>>>>>>>>>>   * immutable.
>>>>>>>>>>>   * </p>
>>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>>> ServletContext
>>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>>> some
>>>>>>>>>> reason.
>>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>>> requests.</p>
>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>> 
>>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>> "/" +
>>>>>>>>>> template + "/", null );
>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>> + "/" +
>>>>>>>>>> template + "/", null );
>>>>>>>>>>> 
>>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>>> default
>>>>>>>>>> does
>>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>>> "/" +
>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>>> + "/" +
>>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>>      }
>>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>> manager per
>>>>>>>>>> engine.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>>> this.
>>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>>> to the
>>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>>> as the
>>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>>> portion
>>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>>> short name
>>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>>> be added
>>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>> directory path)
>>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>>> from
>>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>>> prefix.
>>>>>>>>>> If not
>>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>>   */
>>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>> properties )
>>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>>  {
>>>>>>>>>>> -        super( engine );
>>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>> -    }
>>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>> searchPath );
>>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>>> +        {
>>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>>> +            {
>>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>>> prefix.length()
>>>>>>>>>> );
>>>>>>>>>>> +
>>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>> +                {
>>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>>> shortName
>>>>>>>>>> );
>>>>>>>>>>> +                }
>>>>>>>>>>> 
>>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>>> already
>>>>>>>>>>> +                else
>>>>>>>>>>> +                {
>>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>> shortName );
>>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>>> +                    {
>>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>>> +                    }
>>>>>>>>>>> +                }
>>>>>>>>>>> +            }
>>>>>>>>>>> +        }
>>>>>>>>>>> +    }
>>>>>>>>>>> +
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>>> relative to
>>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>>> relative to
>>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>>   *
>>>>>>>>>>>   *
>>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>>> jspwiki.css}.
>>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>>> looked up
>>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>>> in
>>>>>>>>>> the
>>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>>   */
>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>> String
>>>>>>>>>> path )
>>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>>> servletContext,
>>>>>>>>>> String path )
>>>>>>>>>>>  {
>>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( is == null )
>>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>>      {
>>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>>> -
>>>>>>>>>>> -            if( is != null )
>>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>>> -            else
>>>>>>>>>>> -                path = null;
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        if( is != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            try
>>>>>>>>>>> -            {
>>>>>>>>>>> -                is.close();
>>>>>>>>>>> -            }
>>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>>> -            {
>>>>>>>>>>> -            }
>>>>>>>>>>> +            // This is already a full path
>>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>>      }
>>>>>>>>>>> -
>>>>>>>>>>> -        return path;
>>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>>> if it's
>>>>>>>>>> not
>>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param sContext
>>>>>>>>>>> -     * @param template
>>>>>>>>>>> -     * @param name
>>>>>>>>>>> -     * @return
>>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>>> evaluation is
>>>>>>>>>> lazy,
>>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>>> actually
>>>>>>>>>> used
>>>>>>>>>>> +     * for the first time.
>>>>>>>>>>> +     */
>>>>>>>>>>> +    /*
>>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>> String
>>>>>>>>>> key ) {
>>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>> props =
>>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>> if(
>>>>>>>>>> props ==
>>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>> IOException e ) {
>>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>>> properties",e);
>>>>>>>>>> return
>>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>>   */
>>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>>> String
>>>>>>>>>> template, String name )
>>>>>>>>>>> +    /**
>>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>>> +     */
>>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>>  {
>>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            // This is already a full path
>>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>>> -        }
>>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>>> +    }
>>>>>>>>>>> 
>>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>> 
>>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>>> +    /**
>>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>>> manager per
>>>>>>>>>> engine.
>>>>>>>>>>> +     *
>>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>>> this.
>>>>>>>>>>> +     */
>>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>>> properties )
>>>>>>>>>>> +    {
>>>>>>>>>>> +        super( engine );
>>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>>   *
>>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>>> {@code
>>>>>>>>>> Wiki.jsp})
>>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>> (ServletContext)}
>>>>>>>>>> instead
>>>>>>>>>>>   */
>>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>>  {
>>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>>> -
>>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        int idx = 0;
>>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>>> -            idx = 1;
>>>>>>>>>>> -
>>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>>> -
>>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>>> -        return name;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>>> template=foo.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>>> template, String
>>>>>>>>>> name )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>>> that
>>>>>>>>>> template
>>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>>> template,
>>>>>>>>>> will
>>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>>> template.
>>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>> (ServletContext)}
>>>>>>>>>> instead
>>>>>>>>>>>   */
>>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>>> String name )
>>>>>>>>>>>  {
>>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>>      }
>>>>>>>>>>> -
>>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>>> template,
>>>>>>>>>> name );
>>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>>> name );
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>>> (ServletContext)}
>>>>>>>>>> instead
>>>>>>>>>>>   */
>>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>>> String
>>>>>>>>>> name )
>>>>>>>>>>>  {
>>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>>      {
>>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>>> template,
>>>>>>>>>> name );
>>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>>> name );
>>>>>>>>>>>      }
>>>>>>>>>>> 
>>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>>  }
>>>>>>>>>>> 
>>>>>>>>>>>  /**
>>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>>> evaluation is
>>>>>>>>>> lazy,
>>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>>> actually
>>>>>>>>>> used
>>>>>>>>>>> -     * for the first time.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /*
>>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>>> String
>>>>>>>>>> key ) {
>>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>>> props =
>>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>>> if(
>>>>>>>>>> props ==
>>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>>> IOException e ) {
>>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>>> properties",e);
>>>>>>>>>> return
>>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>>> NeedsRefreshException
>>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>>> empty
>>>>>>>>>> Set, if
>>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>>> does
>>>>>>>>>> not check
>>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>>> just
>>>>>>>>>> lists
>>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>>> available.
>>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>>> anything
>>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>>   *
>>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>>   * @param template The template to search
>>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>>   */
>>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>>> String
>>>>>>>>>> template )
>>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>>  {
>>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>>> place );
>>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>> 
>>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>> 
>>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>>      {
>>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>> 
>>>>>>>>>>>      return resultSet;
>>>>>>>>>>>  }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /*
>>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>>> templateName )
>>>>>>>>>> throws
>>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>>> ServletContext
>>>>>>>>>> context =
>>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>>> if(
>>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>>> '"+templateName+"'
>>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>>> return p; }
>>>>>>>>>>> -     */
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>>> This is in
>>>>>>>>>> a HTML
>>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>>> -     * @param type the marker
>>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>>> type )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>>> (javascript.*)
>>>>>>>>>> Returns
>>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>>> array.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param wiki context
>>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>>> LocaliedStrings
>>>>>>>>>> array
>>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>>> context )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>>> -
>>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>>> -
>>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>>> "templates.default" );
>>>>>>>>>>> -
>>>>>>>>>>> -        boolean first = true;
>>>>>>>>>>> -
>>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>>> -
>>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                if( first )
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    first = false;
>>>>>>>>>>> -                }
>>>>>>>>>>> -                else
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>>> -                }
>>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>>> key ) +
>>>>>>>>>> "\"" );
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>>> -
>>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>>> content will
>>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>>> -     * <p>
>>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>>> (a script
>>>>>>>>>> file or
>>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>>> function
>>>>>>>>>> that should
>>>>>>>>>>> -     * be run at page load.
>>>>>>>>>>> -     * <p>
>>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>>> files, which
>>>>>>>>>> is then
>>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>>> rendered but
>>>>>>>>>> not yet
>>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>>> -     * <p>
>>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>>> method does
>>>>>>>>>> not
>>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>>> Therefore,
>>>>>>>>>> if you
>>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>>> time,
>>>>>>>>>> you'll end
>>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>>> good
>>>>>>>>>> idea to
>>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>>> String type,
>>>>>>>>>> String resource )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>>> (HashMap<String,
>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>>> -
>>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>>> src='" +
>>>>>>>>>> resource + "'></script>";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>>> css'
>>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>>> resource +
>>>>>>>>>> "\n</style>\n";
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>> -        }
>>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>>> resourceString );
>>>>>>>>>>> -
>>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>>> are no
>>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>>> String
>>>>>>>>>> type )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( hm == null )
>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>> -
>>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>>> -
>>>>>>>>>>> -        if( resources == null )
>>>>>>>>>>> -            return new String[0];
>>>>>>>>>>> -
>>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>>> -
>>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>>> -     *
>>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>>> tags
>>>>>>>>>> instead
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>>> -
>>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>>> -
>>>>>>>>>>> -            if( hm != null )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>>> -
>>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> -
>>>>>>>>>>> -        return res;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> +
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>>> TemplateManager does
>>>>>>>>>>>   * not manage any modules.
>>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>>   */
>>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>>  {
>>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>>> -    }
>>>>>>>>>>> -
>>>>>>>>>>> -    /**
>>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>>> to the
>>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>>> as the
>>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>>> portion
>>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>>> short name
>>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>>> be added
>>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>>> directory path)
>>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>>> from
>>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>>> prefix.
>>>>>>>>>> If not
>>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>> -     */
>>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>> -    {
>>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>>> searchPath );
>>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>>> -        {
>>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>>> -            {
>>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>>> prefix.length()
>>>>>>>>>> );
>>>>>>>>>>> -
>>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>>> shortName
>>>>>>>>>> );
>>>>>>>>>>> -                }
>>>>>>>>>>> -
>>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>>> already
>>>>>>>>>>> -                else
>>>>>>>>>>> -                {
>>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>>> resolver.containsKey(
>>>>>>>>>> shortName );
>>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>>> -                    {
>>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>>> -                    }
>>>>>>>>>>> -                }
>>>>>>>>>>> -            }
>>>>>>>>>>> -        }
>>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>>  }
>>>>>>>>>>> }
>>>>>>>>>>> 
>>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>>> URL:
>>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>> 
>>>>>>>>>> ============
>>>>>>>>>> ==================================================================
>>>>>>>>>>> ---
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>> (original)
>>>>>>>>>>> +++
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>>> TemplateResolution.java
>>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>>> {
>>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>> 
>>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>>> +
>>>>>>>>>>>  /**
>>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>>   *
>>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>>> servletContext
>>>>>>>>>> ).get( getPath() );
>>>>>>>>>>>      if( path == null )
>>>>>>>>>>>      {
>>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>>> "/" + getPath();
>>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>>      }
>>>>>>>>>>>      setPath( path );
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>> 
>> 
>> 


Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Andrew Jaquith <an...@gmail.com>.
Janne, when you say "dynamic," what do you mean? I understand the need
to insert pages, based on wiki markup, which may load other plugins.
That is, when a page renders, it might need Plugin 1, Plugin 2 and
Plugin 3, and each of which have needs. It might also selectively load
another page, which needs Plugin 4. So, I understand that.

Beyond that, though, what other dynamic capabilities are needed? Do
you really think that the path of a stylesheet or script file that a
SPECIFIC plugin needs would change based on runtime conditions? Can
you provide some specific examples? (Either your own plugins, or
others you may know of...)

Just trying to understand...

Andrew

On Thu, Mar 4, 2010 at 10:04 AM, Janne Jalkanen
<ja...@ecyrd.com> wrote:
>
> Sorry, kid interrupted the message....
>
> So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.
>
> /Janne
>
> On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:
>
>>
>> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
>>
>> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
>>
>> /Janne
>>
>> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
>>
>>> Janne and Dirk --
>>>
>>> Here's my proposal to resolve the resource-inclusion issue.
>>>
>>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>>> works fine. I'll check this in at my next opportunity (not for a few
>>> days, probably).
>>>
>>> 2. Plugin resources. It turns out we have a ready-made class,
>>> WikiModuleInfo, that enumerates the resources that modules (like
>>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>>> before forwarding to the JSP, we simply inspect the page text before
>>> to see what plugins are asked for in the wiki markup. For any that are
>>> encountered, we add any script or css resources requirements to a
>>> request "queue," which is processed when the JSP actually renders (by
>>> IncludeResourcesTag or JSTL code).
>>>
>>> I am satisfied that (2) will be safe because we would just be fetching
>>> resources the developer specifically required, as the modules XML
>>> file, or (better) class annotations specify.
>>>
>>> Andrew
>>>
>>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>>> <an...@gmail.com> wrote:
>>>> Janne --
>>>>
>>>> Agreed. Each editor has special needs that ought to be specified in
>>>> the "editor JSP" (e.g., plain.jsp) itself.
>>>>
>>>> In the current implementation, the scripts needed for the plain editor
>>>> are included via a s:layout-component tag in Edit.jsp -- which
>>>> encapsulates ALL editors. That means, indeed, that it is included for
>>>> all editors, regardless of the user choice. But it is easy to imagine
>>>> how this would be specified instead in the editor JSPs directly.
>>>> Essentially, this would be done by turning Edit.jsp into a layout
>>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>>> yet.
>>>>
>>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>>> the editors working and to allow them to specify their own resources.
>>>> It will be done soon enough.
>>>>
>>>> In the meantime, I received your message -- that you need a way to
>>>> allow plugins to include their own resources -- loud and clear. I
>>>> don't have an answer for that today, but will propose some options
>>>> shortly.
>>>>
>>>> Andrew
>>>>
>>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>>> Why would we include the plain text editor in the case that the user
>>>>> preferences state FCK editor?  Or vice versa?
>>>>>
>>>>> From the point of view of the layouts editors and plugins should be
>>>>> equal.  The other one just happens to be implemented in JSP...
>>>>>
>>>>> The choice of the editor is user-specific and has nothing to do with
>>>>> the template choice.
>>>>>
>>>>> /Janne
>>>>>
>>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>>> standard resources, which can be overridden in the template JSPs when
>>>>>> they need something special. Essentially, the template JSP uses the
>>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>>>
>>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>>> for example.
>>>>>>
>>>>>> The plugin resources example is a valid example, though. I've got some
>>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>>> (This is a very crazy week for me, professionally.)
>>>>>>
>>>>>> Andrew
>>>>>>
>>>>>>
>>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>>> component.
>>>>>>>
>>>>>>> /Janne
>>>>>>>
>>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>>>
>>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>>>
>>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>>> layout jsp)
>>>>>>>>
>>>>>>>>
>>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>>> probably
>>>>>>>> also css) is needed.
>>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>>> correct
>>>>>>>> resources.
>>>>>>>>
>>>>>>>>
>>>>>>>> dirk
>>>>>>>>
>>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>>> how do
>>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>>> fall back to
>>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>>> assumes that
>>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>>> template,
>>>>>>>>> and plugins which request CSS and other components.
>>>>>>>>>
>>>>>>>>> /Janne
>>>>>>>>>
>>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>>>
>>>>>>>>>> Author: ajaquith
>>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>>> New Revision: 917390
>>>>>>>>>>
>>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>>> Log:
>>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>>> should) be
>>>>>>>>> included directly in template JSPs.
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> EditorTag.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>>> EditorManager.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java
>>>>>>>>>>
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>>>
>>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>> +
>>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>>> +
>>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>>> are now
>>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>>> doCatch()
>>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>>> debugging.
>>>>>>>>>> +
>>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>>> feature was
>>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>>> View tab
>>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>>> +
>>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>>> JSPs.
>>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>>> used
>>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>>> customizable
>>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>>> +
>>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>>> Resources
>>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>>> +
>>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>>> as part
>>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>>> Stripesed.
>>>>>>>>>> +
>>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>>>
>>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>>> changes
>>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>>> spaces is
>>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>>>
>>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>>>
>>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>>> Release.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>>> Mon Mar
>>>>>>>>> 1 05:23:10 2010
>>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>>   *  <p>
>>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>>   */
>>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>> Note.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>>> Note.java Mon
>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>>>
>>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>>>
>>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>>> ().findResource( ctx,
>>>>>>>>>> -
>>>>>>>>> engine.getTemplateDir(),
>>>>>>>>>> -
>>>>>>>>> commentImage );
>>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>>>
>>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>>> Preferences.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>>      }
>>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>>      {
>>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>>      }
>>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>>      {
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>>> JSONRPCManager.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>>>
>>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>>   */
>>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>>  {
>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>> -
>>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>>> -
>>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>>> -
>>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>>> "JSON-RPC" );
>>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>>> -
>>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>>> -
>>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>>> HttpServletRequest.class);
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> ContentTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> ContentTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>>
>>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>>          }
>>>>>>>>>>
>>>>>>>>>> -            String page =
>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>> -
>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>> -
>>>>>>>>>       contentTemplate );
>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>>          pageContext.include( page );
>>>>>>>>>>      }
>>>>>>>>>>      catch( ServletException e )
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> EditorTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> EditorTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>>>
>>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>>>
>>>>>>>>>>      try
>>>>>>>>>>      {
>>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>>> pageContext,
>>>>>>>>>> -
>>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>>> -
>>>>>>>>> editorPath );
>>>>>>>>>> -
>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>>          if( page == null )
>>>>>>>>>>          {
>>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeResourcesTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>>> */
>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>
>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>>
>>>>>>>>>> /**
>>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>>> emits a
>>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>>> take
>>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>>> - *
>>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>> instead
>>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>>> into the
>>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>>> ServletFilter.
>>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>>> The
>>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>> on how
>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>> instead
>>>>>>>>>> */
>>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>>> {
>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>>
>>>>>>>>>> -    private String m_type;
>>>>>>>>>> -
>>>>>>>>>>  public void initTag()
>>>>>>>>>>  {
>>>>>>>>>>      super.initTag();
>>>>>>>>>> -        m_type = null;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  public void setType( String type )
>>>>>>>>>>  {
>>>>>>>>>> -        m_type = type;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>  {
>>>>>>>>>> -        //String marker =
>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>>> (m_wikiContext,
>>>>>>>>> m_type);
>>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>>> m_type);
>>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>>> m_type);
>>>>>>>>>> -
>>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>>> -
>>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>>> layout tags instead " +
>>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>>> IncludeTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>>>
>>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>>  {
>>>>>>>>>>      try
>>>>>>>>>>      {
>>>>>>>>>> -            String page =
>>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>>> -
>>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>>> -
>>>>>>>>>       m_page );
>>>>>>>>>> -
>>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>>          if( page == null )
>>>>>>>>>>          {
>>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> RequestResourceTag.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>>> */
>>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>>>
>>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>>> -
>>>>>>>>>> /**
>>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>>> ().  You
>>>>>>>>> may use
>>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>>> - *
>>>>>>>>>> - *  @see TemplateManager
>>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>>> JSPWiki to
>>>>>>>>> insert
>>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>>> because it
>>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>>> instead. See
>>>>>>>>> the default
>>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>>> on how
>>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>>> instead
>>>>>>>>>> */
>>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>>> {
>>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>>> -
>>>>>>>>>> -    private String m_type;
>>>>>>>>>> -    private String m_resource;
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>>  public void initTag()
>>>>>>>>>>  {
>>>>>>>>>>      super.initTag();
>>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>>  @Override
>>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>>  {
>>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>>> m_type,
>>>>>>>>> m_resource );
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>   *
>>>>>>>>>>   *  @return The resource name.
>>>>>>>>>>   */
>>>>>>>>>>  public String getResource()
>>>>>>>>>>  {
>>>>>>>>>> -        return m_resource;
>>>>>>>>>> +        return "";
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>   *
>>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>>   */
>>>>>>>>>>  public void setResource(String r)
>>>>>>>>>>  {
>>>>>>>>>> -        m_resource = r;
>>>>>>>>>> +        // No-op.
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Get the resource type.
>>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>>   *
>>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>>   */
>>>>>>>>>>  public String getType()
>>>>>>>>>>  {
>>>>>>>>>> -        return m_type;
>>>>>>>>>> +        return "";
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>>> "script".  Please
>>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>>> the
>>>>>>>>> different kinds
>>>>>>>>>> -     *  of types you can use.
>>>>>>>>>> -     *
>>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>>   *
>>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>>   */
>>>>>>>>>>
>>>>>>>>>>  public void setType(String type)
>>>>>>>>>>  {
>>>>>>>>>> -        m_type = type;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java Mon
>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>>>
>>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>>> -
>>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>>> inside a
>>>>>>>>> HTTP parameter. */
>>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>>>
>>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>>   */
>>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>>  {
>>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>>> -
>>>>>>>>>>      String editor = null;
>>>>>>>>>>
>>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> TemplateManager.java Mon
>>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>>> */
>>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>>>
>>>>>>>>>> -import java.io.IOException;
>>>>>>>>>> -import java.io.InputStream;
>>>>>>>>>> import java.util.*;
>>>>>>>>>>
>>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>>> */
>>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>>> {
>>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>>   */
>>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>>> "resourceResolver";
>>>>>>>>>>
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>>> window.onload.
>>>>>>>>> Value
>>>>>>>>>> -     * is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>>> strings.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>>> "jslocalizedstrings";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>>> -
>>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>>> {@value}.
>>>>>>>>> */
>>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>>>
>>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>>>
>>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>>> "template.properties";
>>>>>>>>>> -
>>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>>> "prefs.user.language.default";
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>>> in the
>>>>>>>>>> -     * WikiContext.
>>>>>>>>>> -     */
>>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>>> -
>>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>>> -
>>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>>> TemplateManager.class );
>>>>>>>>>>
>>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>>> -
>>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>>> -
>>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>>> Collections.emptyList();
>>>>>>>>>> -
>>>>>>>>>>  /**
>>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>>> resources,
>>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>>> is
>>>>>>>>>>   * immutable.
>>>>>>>>>>   * </p>
>>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>>> ServletContext
>>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>>> some
>>>>>>>>> reason.
>>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>>> requests.</p>
>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>>>
>>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>> "/" +
>>>>>>>>> template + "/", null );
>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>> + "/" +
>>>>>>>>> template + "/", null );
>>>>>>>>>>
>>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>>> default
>>>>>>>>> does
>>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>>> "/" +
>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>>> + "/" +
>>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>>      }
>>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>>> manager per
>>>>>>>>> engine.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>>> this.
>>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>>> to the
>>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>>> as the
>>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>>> portion
>>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>>> short name
>>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>>> be added
>>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>> directory path)
>>>>>>>>>> +     * will be processed recursively.
>>>>>>>>>> +     * @param context the servlet context
>>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>>> from
>>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>>> prefix.
>>>>>>>>> If not
>>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>>   */
>>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>> properties )
>>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>>  {
>>>>>>>>>> -        super( engine );
>>>>>>>>>> -        m_engine = engine;
>>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>>> -    }
>>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>>> searchPath );
>>>>>>>>>> +        if ( resources != null )
>>>>>>>>>> +        {
>>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>>> +            {
>>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>>> prefix.length()
>>>>>>>>> );
>>>>>>>>>> +
>>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>>> +                {
>>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>>> shortName
>>>>>>>>> );
>>>>>>>>>> +                }
>>>>>>>>>>
>>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>>> already
>>>>>>>>>> +                else
>>>>>>>>>> +                {
>>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>>> resolver.containsKey(
>>>>>>>>> shortName );
>>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>>> +                    {
>>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>>> +                    }
>>>>>>>>>> +                }
>>>>>>>>>> +            }
>>>>>>>>>> +        }
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>>  /**
>>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>>> relative to
>>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>>> relative to
>>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>>   *
>>>>>>>>>>   *
>>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>>> jspwiki.css}.
>>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>>> looked up
>>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>>> in
>>>>>>>>> the
>>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>>   */
>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>> String
>>>>>>>>> path )
>>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>>> servletContext,
>>>>>>>>> String path )
>>>>>>>>>>  {
>>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>>> -
>>>>>>>>>> -        if( is == null )
>>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>>      {
>>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>>> -
>>>>>>>>>> -            if( is != null )
>>>>>>>>>> -                path = defaultPath;
>>>>>>>>>> -            else
>>>>>>>>>> -                path = null;
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        if( is != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            try
>>>>>>>>>> -            {
>>>>>>>>>> -                is.close();
>>>>>>>>>> -            }
>>>>>>>>>> -            catch( IOException e )
>>>>>>>>>> -            {
>>>>>>>>>> -            }
>>>>>>>>>> +            // This is already a full path
>>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>>      }
>>>>>>>>>> -
>>>>>>>>>> -        return path;
>>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>>> if it's
>>>>>>>>> not
>>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param sContext
>>>>>>>>>> -     * @param template
>>>>>>>>>> -     * @param name
>>>>>>>>>> -     * @return
>>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>>> evaluation is
>>>>>>>>> lazy,
>>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>>> actually
>>>>>>>>> used
>>>>>>>>>> +     * for the first time.
>>>>>>>>>> +     */
>>>>>>>>>> +    /*
>>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>> String
>>>>>>>>> key ) {
>>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>>> props =
>>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>> if(
>>>>>>>>> props ==
>>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>> IOException e ) {
>>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>>> properties",e);
>>>>>>>>> return
>>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>> NeedsRefreshException
>>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>>   */
>>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>>> String
>>>>>>>>> template, String name )
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>>> +     */
>>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>>  {
>>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>>> -        {
>>>>>>>>>> -            // This is already a full path
>>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>>> -        }
>>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>>> +    }
>>>>>>>>>>
>>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>>>
>>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>>> +    /**
>>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>>> manager per
>>>>>>>>> engine.
>>>>>>>>>> +     *
>>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>>> this.
>>>>>>>>>> +     */
>>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>>> properties )
>>>>>>>>>> +    {
>>>>>>>>>> +        super( engine );
>>>>>>>>>> +        m_engine = engine;
>>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>>   *
>>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>> "Wiki.jsp")
>>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>>> {@code
>>>>>>>>> Wiki.jsp})
>>>>>>>>>>   * @return The context path to the resource
>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>> (ServletContext)}
>>>>>>>>> instead
>>>>>>>>>>   */
>>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>>  {
>>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>>> -
>>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>>> -     */
>>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>>> -    {
>>>>>>>>>> -        int idx = 0;
>>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>>> -            idx = 1;
>>>>>>>>>> -
>>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>>> -        if( idx != -1 )
>>>>>>>>>> -        {
>>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>>> -
>>>>>>>>>> -            if( idx != -1 )
>>>>>>>>>> -            {
>>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>>> -        return name;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>>> template=foo.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>>> -     */
>>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>>> template, String
>>>>>>>>> name )
>>>>>>>>>> -    {
>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>>> that
>>>>>>>>> template
>>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>>> template,
>>>>>>>>> will
>>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>>> template.
>>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>> (ServletContext)}
>>>>>>>>> instead
>>>>>>>>>>   */
>>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>>> String name )
>>>>>>>>>>  {
>>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>>      }
>>>>>>>>>> -
>>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>>> template,
>>>>>>>>> name );
>>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>>> name );
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>>   * @return the path to the resource
>>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>>> (ServletContext)}
>>>>>>>>> instead
>>>>>>>>>>   */
>>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>>> String
>>>>>>>>> name )
>>>>>>>>>>  {
>>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>>      {
>>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>>> template,
>>>>>>>>> name );
>>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>>> name );
>>>>>>>>>>      }
>>>>>>>>>>
>>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /**
>>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>>> evaluation is
>>>>>>>>> lazy,
>>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>>> actually
>>>>>>>>> used
>>>>>>>>>> -     * for the first time.
>>>>>>>>>> -     */
>>>>>>>>>> -    /*
>>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>>> String
>>>>>>>>> key ) {
>>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>>> props =
>>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>>> if(
>>>>>>>>> props ==
>>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>>> IOException e ) {
>>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>>> properties",e);
>>>>>>>>> return
>>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>>> NeedsRefreshException
>>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>>> -     */
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>>> -     */
>>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>>> -    {
>>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>>> empty
>>>>>>>>> Set, if
>>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>>> does
>>>>>>>>> not check
>>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>>> just
>>>>>>>>> lists
>>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>>> available.
>>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>>> anything
>>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>>   *
>>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>>   * @param template The template to search
>>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>>   * @since 2.3.26
>>>>>>>>>>   */
>>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>>> String
>>>>>>>>> template )
>>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>>  {
>>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>>> place );
>>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>>> +        Set<String> skinSet =
>>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>>>
>>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>>>
>>>>>>>>>>      if( skinSet != null )
>>>>>>>>>>      {
>>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>>>
>>>>>>>>>>      return resultSet;
>>>>>>>>>>  }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>>> -     */
>>>>>>>>>> -    /*
>>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>>> templateName )
>>>>>>>>> throws
>>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>>> ServletContext
>>>>>>>>> context =
>>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>>> +PROPERTYFILE);
>>>>>>>>> if(
>>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>>> '"+templateName+"'
>>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>>> return p; }
>>>>>>>>>> -     */
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>>> This is in
>>>>>>>>> a HTML
>>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param context the wiki context
>>>>>>>>>> -     * @param type the marker
>>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>>> type )
>>>>>>>>>> -    {
>>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>>> -        }
>>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>>> (javascript.*)
>>>>>>>>> Returns
>>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>>> array.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param wiki context
>>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>>> LocaliedStrings
>>>>>>>>> array
>>>>>>>>>> -     * @since 2.5.108
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>>> context )
>>>>>>>>>> -    {
>>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>>> -
>>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>>> -
>>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>>> "templates.default" );
>>>>>>>>>> -
>>>>>>>>>> -        boolean first = true;
>>>>>>>>>> -
>>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>>> en.hasMoreElements(); )
>>>>>>>>>> -        {
>>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>>> -
>>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>>> -            {
>>>>>>>>>> -                if( first )
>>>>>>>>>> -                {
>>>>>>>>>> -                    first = false;
>>>>>>>>>> -                }
>>>>>>>>>> -                else
>>>>>>>>>> -                {
>>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>>> -                }
>>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>>> key ) +
>>>>>>>>> "\"" );
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>>> -
>>>>>>>>>> -        return(sb.toString());
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>>> content will
>>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>>> -     * <p>
>>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>>> (a script
>>>>>>>>> file or
>>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>>> (commonheader.jsp). For
>>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>>> function
>>>>>>>>> that should
>>>>>>>>>> -     * be run at page load.
>>>>>>>>>> -     * <p>
>>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>>> files, which
>>>>>>>>> is then
>>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>>> rendered but
>>>>>>>>> not yet
>>>>>>>>>> -     * sent to the recipient.
>>>>>>>>>> -     * <p>
>>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>>> method does
>>>>>>>>> not
>>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>>> Therefore,
>>>>>>>>> if you
>>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>>> time,
>>>>>>>>> you'll end
>>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>>> good
>>>>>>>>> idea to
>>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>>> String type,
>>>>>>>>> String resource )
>>>>>>>>>> -    {
>>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>>> (HashMap<String,
>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>> -
>>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>>> -
>>>>>>>>>> -        if( resources == null )
>>>>>>>>>> -        {
>>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        String resourceString = null;
>>>>>>>>>> -
>>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>>> src='" +
>>>>>>>>> resource + "'></script>";
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>>> css'
>>>>>>>>> href='" + resource + "' />";
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>>> resource +
>>>>>>>>> "\n</style>\n";
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>> -        }
>>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>>> -        {
>>>>>>>>>> -            resourceString = resource;
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        if( resourceString != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>>> resourceString );
>>>>>>>>>> -
>>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>>> are no
>>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>>> -     * @param type The resource request type
>>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>>> String
>>>>>>>>> type )
>>>>>>>>>> -    {
>>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>> -
>>>>>>>>>> -        if( hm == null )
>>>>>>>>>> -            return new String[0];
>>>>>>>>>> -
>>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>>> -
>>>>>>>>>> -        if( resources == null )
>>>>>>>>>> -            return new String[0];
>>>>>>>>>> -
>>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>>> -
>>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>>> -     *
>>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>>> -     * @return the array of types requested
>>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>>> tags
>>>>>>>>> instead
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>>> -    {
>>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>>> -
>>>>>>>>>> -        if( ctx != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>>> -
>>>>>>>>>> -            if( hm != null )
>>>>>>>>>> -            {
>>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>>> -
>>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> -
>>>>>>>>>> -        return res;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> +
>>>>>>>>>>  /**
>>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>>> TemplateManager does
>>>>>>>>>>   * not manage any modules.
>>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>>   */
>>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>>  {
>>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    /**
>>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>>> to the
>>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>>> as the
>>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>>> portion
>>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>>> short name
>>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>>> be added
>>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>>> directory path)
>>>>>>>>>> -     * will be processed recursively.
>>>>>>>>>> -     * @param context the servlet context
>>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>>> from
>>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>>> prefix.
>>>>>>>>> If not
>>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>>> -     */
>>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>> -    {
>>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>>> searchPath );
>>>>>>>>>> -        if ( resources != null )
>>>>>>>>>> -        {
>>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>>> -            {
>>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>>> prefix.length()
>>>>>>>>> );
>>>>>>>>>> -
>>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>>> -                {
>>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>>> shortName
>>>>>>>>> );
>>>>>>>>>> -                }
>>>>>>>>>> -
>>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>>> already
>>>>>>>>>> -                else
>>>>>>>>>> -                {
>>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>>> resolver.containsKey(
>>>>>>>>> shortName );
>>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>>> -                    {
>>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>>> -                    }
>>>>>>>>>> -                }
>>>>>>>>>> -            }
>>>>>>>>>> -        }
>>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>>  }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>>> URL:
>>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>>>
>>>>>>>>> ============
>>>>>>>>> ==================================================================
>>>>>>>>>> ---
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>> (original)
>>>>>>>>>> +++
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>>> TemplateResolution.java
>>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>>> {
>>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>>> TemplateResolution.class );
>>>>>>>>>>
>>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>>> +
>>>>>>>>>>  /**
>>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>>   *
>>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>>> servletContext
>>>>>>>>> ).get( getPath() );
>>>>>>>>>>      if( path == null )
>>>>>>>>>>      {
>>>>>>>>>> -            path = "/templates/" +
>>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>>> "/" + getPath();
>>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>>      }
>>>>>>>>>>      setPath( path );
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>
>>>>
>
>

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
Sorry, kid interrupted the message....

So yeah, I still think the original method of dynamically including content is the best.  We can add a new filter (that's the real reason why we had WikiJSPFilter originally, so we could bring that back) or do some Stripes magic.  The big problem-o is that we need to insert stuff into the stream *before* the actual plugin code is called.  So that means that we need to buffer stuff up until the page has finished rendering, then go back and insert the necessary HTML.  That's why the JSP Filter makes most sense.

/Janne

On 4 Mar 2010, at 19:36, Janne Jalkanen wrote:

> 
> 2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.
> 
> Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).
> 
> /Janne
> 
> On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:
> 
>> Janne and Dirk --
>> 
>> Here's my proposal to resolve the resource-inclusion issue.
>> 
>> 1. Editor JSPs. I've tested a nested-layout implementation, and it
>> works fine. I'll check this in at my next opportunity (not for a few
>> days, probably).
>> 
>> 2. Plugin resources. It turns out we have a ready-made class,
>> WikiModuleInfo, that enumerates the resources that modules (like
>> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
>> before forwarding to the JSP, we simply inspect the page text before
>> to see what plugins are asked for in the wiki markup. For any that are
>> encountered, we add any script or css resources requirements to a
>> request "queue," which is processed when the JSP actually renders (by
>> IncludeResourcesTag or JSTL code).
>> 
>> I am satisfied that (2) will be safe because we would just be fetching
>> resources the developer specifically required, as the modules XML
>> file, or (better) class annotations specify.
>> 
>> Andrew
>> 
>> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
>> <an...@gmail.com> wrote:
>>> Janne --
>>> 
>>> Agreed. Each editor has special needs that ought to be specified in
>>> the "editor JSP" (e.g., plain.jsp) itself.
>>> 
>>> In the current implementation, the scripts needed for the plain editor
>>> are included via a s:layout-component tag in Edit.jsp -- which
>>> encapsulates ALL editors. That means, indeed, that it is included for
>>> all editors, regardless of the user choice. But it is easy to imagine
>>> how this would be specified instead in the editor JSPs directly.
>>> Essentially, this would be done by turning Edit.jsp into a layout
>>> itself. It's a layout inside of a layout. It is straightforward to do;
>>> but I have not put the necessary (minor) JSP changes in the trunk just
>>> yet.
>>> 
>>> But, this is pre-Alpha. The goal all along has been to get *all* of
>>> the editors working and to allow them to specify their own resources.
>>> It will be done soon enough.
>>> 
>>> In the meantime, I received your message -- that you need a way to
>>> allow plugins to include their own resources -- loud and clear. I
>>> don't have an answer for that today, but will propose some options
>>> shortly.
>>> 
>>> Andrew
>>> 
>>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>>> Why would we include the plain text editor in the case that the user
>>>> preferences state FCK editor?  Or vice versa?
>>>> 
>>>> From the point of view of the layouts editors and plugins should be
>>>> equal.  The other one just happens to be implemented in JSP...
>>>> 
>>>> The choice of the editor is user-specific and has nothing to do with
>>>> the template choice.
>>>> 
>>>> /Janne
>>>> 
>>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>>> standard resources, which can be overridden in the template JSPs when
>>>>> they need something special. Essentially, the template JSP uses the
>>>>> s:layout-render tag to instruct which layout to use, and one more
>>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>>> 
>>>>> For example, the template JSP templates/default/Preferences.jsp
>>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>>> for example.
>>>>> 
>>>>> The plugin resources example is a valid example, though. I've got some
>>>>> ideas on how to do this safely but haven't had time to document them.
>>>>> (This is a very crazy week for me, professionally.)
>>>>> 
>>>>> Andrew
>>>>> 
>>>>> 
>>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>>> wrote:
>>>>> 
>>>>>> 
>>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>>> jsp's is a good admin experience when you're deploying a new
>>>>>> component.
>>>>>> 
>>>>>> /Janne
>>>>>> 
>>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>>> 
>>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>>> 
>>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>>> layout jsp)
>>>>>>> 
>>>>>>> 
>>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>>> probably
>>>>>>> also css) is needed.
>>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>>> correct
>>>>>>> resources.
>>>>>>> 
>>>>>>> 
>>>>>>> dirk
>>>>>>> 
>>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>>> <ja...@ecyrd.com>wrote:
>>>>>>> 
>>>>>>>> 
>>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>>> how do
>>>>>>>> plugins request resources, and how do individual templates then
>>>>>>>> fall back to
>>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>>> assumes that
>>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>>> template,
>>>>>>>> and plugins which request CSS and other components.
>>>>>>>> 
>>>>>>>> /Janne
>>>>>>>> 
>>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>>> 
>>>>>>>>> Author: ajaquith
>>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>>> New Revision: 917390
>>>>>>>>> 
>>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>>> Log:
>>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>>> should) be
>>>>>>>> included directly in template JSPs.
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>>> incubator/jspwiki/trunk/ChangeLog
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>> 
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>> Preferences.java
>>>>>>>>> 
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>> JSONRPCManager.java
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> ContentTag.java
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> EditorTag.java
>>>>>>>>> 
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeResourcesTag.java
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeTag.java
>>>>>>>>> 
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> RequestResourceTag.java
>>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>>> EditorManager.java
>>>>>>>>> 
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> TemplateManager.java
>>>>>>>>> 
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>> TemplateResolution.java
>>>>>>>>> 
>>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>> +
>>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>>> +
>>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>>> are now
>>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>>> doCatch()
>>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>>> debugging.
>>>>>>>>> +
>>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>>> feature was
>>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>>> View tab
>>>>>>>>> +        now simply displays the most recent save.
>>>>>>>>> +
>>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>>> JSPs.
>>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>>> used
>>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>>> customizable
>>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>>> +
>>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>>> Resources
>>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>>> +
>>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>>> as part
>>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>>> Stripesed.
>>>>>>>>> +
>>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>>> 
>>>>>>>>>      * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>>> changes
>>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>>      * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>>> spaces is
>>>>>>>>>        not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>>> 
>>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>>> 
>>>>>>>>>      * 3.0.0-svn-209
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>>> Release.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>> (original)
>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>> Mon Mar
>>>>>>>> 1 05:23:10 2010
>>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>>   *  <p>
>>>>>>>>>   *  If the build identifier is empty, it is not added.
>>>>>>>>>   */
>>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>>   *  This is the generic version string you should use
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>> Note.java
>>>>>>>> (original)
>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>>> Note.java Mon
>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>>> 
>>>>>>>>>      commentImage = "images/"+commentImage;
>>>>>>>>> 
>>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>>> ().findResource( ctx,
>>>>>>>>> -
>>>>>>>> engine.getTemplateDir(),
>>>>>>>>> -
>>>>>>>> commentImage );
>>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>>> 
>>>>>>>>>      return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>> Preferences.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>> Preferences.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>>> Preferences.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>>      }
>>>>>>>>>      else if( "availableSkins".equals( key ) )
>>>>>>>>>      {
>>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>>      }
>>>>>>>>>      else if( "availableTimeFormats".equals( key ) )
>>>>>>>>>      {
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>> JSONRPCManager.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>> JSONRPCManager.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>>> JSONRPCManager.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>>> 
>>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>>   */
>>>>>>>>>  public static void requestJSON( WikiContext context )
>>>>>>>>>  {
>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>> -
>>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>>> -
>>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>>> -
>>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>>> "JSON-RPC" );
>>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>>> -
>>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>>> -                                           "jsonrpc = new
>>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>>> -
>>>>>>>>>      getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>>> HttpServletRequest.class);
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> ContentTag.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> ContentTag.java
>>>>>>>> (original)
>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> ContentTag.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>> 
>>>>>>>>> import org.apache.wiki.*;
>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> /**
>>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>>              contentTemplate = beanName + "Content.jsp";
>>>>>>>>>          }
>>>>>>>>> 
>>>>>>>>> -            String page =
>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>> -
>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>> -
>>>>>>>>       contentTemplate );
>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>>          pageContext.include( page );
>>>>>>>>>      }
>>>>>>>>>      catch( ServletException e )
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> EditorTag.java
>>>>>>>> (original)
>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> EditorTag.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>>> 
>>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> /**
>>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>>> 
>>>>>>>>>      try
>>>>>>>>>      {
>>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>>> pageContext,
>>>>>>>>> -
>>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>>> -
>>>>>>>> editorPath );
>>>>>>>>> -
>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>>          if( page == null )
>>>>>>>>>          {
>>>>>>>>>              //FIXME: should be I18N ...
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeResourcesTag.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeResourcesTag.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeResourcesTag.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>>> */
>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>> 
>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> 
>>>>>>>>> /**
>>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>>> emits a
>>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>>> take
>>>>>>>>> - *  care of the actual inclusion.
>>>>>>>>> - *
>>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>> instead
>>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>>> into the
>>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>>> ServletFilter.
>>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>>> The
>>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>> on how
>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>> instead
>>>>>>>>> */
>>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>>> {
>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>> 
>>>>>>>>> -    private String m_type;
>>>>>>>>> -
>>>>>>>>>  public void initTag()
>>>>>>>>>  {
>>>>>>>>>      super.initTag();
>>>>>>>>> -        m_type = null;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  public void setType( String type )
>>>>>>>>>  {
>>>>>>>>> -        m_type = type;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>  {
>>>>>>>>> -        //String marker =
>>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>>> (m_wikiContext,
>>>>>>>> m_type);
>>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>>> m_type);
>>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>>> m_type);
>>>>>>>>> -
>>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>>> -
>>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>>> layout tags instead " +
>>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeTag.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeTag.java
>>>>>>>> (original)
>>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>>> IncludeTag.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>>> import javax.servlet.ServletException;
>>>>>>>>> 
>>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>>  {
>>>>>>>>>      try
>>>>>>>>>      {
>>>>>>>>> -            String page =
>>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>>> -
>>>>>>>>       m_wikiContext.getTemplate(),
>>>>>>>>> -
>>>>>>>>       m_page );
>>>>>>>>> -
>>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>>          if( page == null )
>>>>>>>>>          {
>>>>>>>>>              pageContext.getOut().println("No template file called
>>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> RequestResourceTag.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> RequestResourceTag.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> RequestResourceTag.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>>> */
>>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>> 
>>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>>> -
>>>>>>>>> /**
>>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>>> ().  You
>>>>>>>> may use
>>>>>>>>> - *  any of the request types defined there.
>>>>>>>>> - *
>>>>>>>>> - *  @see TemplateManager
>>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>>> JSPWiki to
>>>>>>>> insert
>>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>>> because it
>>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>>> instead. See
>>>>>>>> the default
>>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>>> on how
>>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>>> instead
>>>>>>>>> */
>>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>>> {
>>>>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>>>> -
>>>>>>>>> -    private String m_type;
>>>>>>>>> -    private String m_resource;
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>>   *  {@inheritDoc}
>>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>>  public void initTag()
>>>>>>>>>  {
>>>>>>>>>      super.initTag();
>>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>>  @Override
>>>>>>>>>  public int doWikiStartTag() throws Exception
>>>>>>>>>  {
>>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>>> -        {
>>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>>> m_type,
>>>>>>>> m_resource );
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>>      return SKIP_BODY;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>   *
>>>>>>>>>   *  @return The resource name.
>>>>>>>>>   */
>>>>>>>>>  public String getResource()
>>>>>>>>>  {
>>>>>>>>> -        return m_resource;
>>>>>>>>> +        return "";
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>   *
>>>>>>>>>   *  @param r Resource identifier.
>>>>>>>>>   */
>>>>>>>>>  public void setResource(String r)
>>>>>>>>>  {
>>>>>>>>> -        m_resource = r;
>>>>>>>>> +        // No-op.
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     *  Get the resource type.
>>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>>   *
>>>>>>>>>   *  @return The type of the resource.
>>>>>>>>>   */
>>>>>>>>>  public String getType()
>>>>>>>>>  {
>>>>>>>>> -        return m_type;
>>>>>>>>> +        return "";
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>>> "script".  Please
>>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>>> the
>>>>>>>> different kinds
>>>>>>>>> -     *  of types you can use.
>>>>>>>>> -     *
>>>>>>>>> -     *  @see TemplateManager
>>>>>>>>> +     *  This method does nothing.
>>>>>>>>>   *
>>>>>>>>>   *  @param type The type to be set.
>>>>>>>>>   */
>>>>>>>>> 
>>>>>>>>>  public void setType(String type)
>>>>>>>>>  {
>>>>>>>>> -        m_type = type;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>> }
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> EditorManager.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> EditorManager.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> EditorManager.java Mon
>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>>  /** Known name for the plain wikimarkup editor. */
>>>>>>>>>  public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>>> 
>>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>>> -
>>>>>>>>>  /** Known attribute name for storing the user edited text
>>>>>>>>> inside a
>>>>>>>> HTTP parameter. */
>>>>>>>>>  public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>>> 
>>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>>   */
>>>>>>>>>  public String getEditorName( WikiContext context )
>>>>>>>>>  {
>>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>>> -
>>>>>>>>>      String editor = null;
>>>>>>>>> 
>>>>>>>>>      // User has set an editor in preferences
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> TemplateManager.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> TemplateManager.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> TemplateManager.java Mon
>>>>>>>> Mar  1 05:23:10 2010
>>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>>> */
>>>>>>>>> package org.apache.wiki.ui;
>>>>>>>>> 
>>>>>>>>> -import java.io.IOException;
>>>>>>>>> -import java.io.InputStream;
>>>>>>>>> import java.util.*;
>>>>>>>>> 
>>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>>> */
>>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>>> {
>>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>>   * Attribute name for the resource resolver map returned by
>>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>>   */
>>>>>>>>>  private static final String RESOURCE_RESOLVER =
>>>>>>>>> "resourceResolver";
>>>>>>>>> 
>>>>>>>>> -    /**
>>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>>> window.onload.
>>>>>>>> Value
>>>>>>>>> -     * is {@value}.
>>>>>>>>> -     */
>>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>>> strings.
>>>>>>>>> -     */
>>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>>> "jslocalizedstrings";
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>>> -     */
>>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>>> -     */
>>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>>> -     */
>>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>>> -
>>>>>>>>>  /** The default directory for template resources. Value is
>>>>>>>>> {@value}.
>>>>>>>> */
>>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>>> 
>>>>>>>>>  /** The name of the default template. Value is {@value}. */
>>>>>>>>>  public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>>> 
>>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>>> "template.properties";
>>>>>>>>> -
>>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>>> "prefs.user.language.default";
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>>> in the
>>>>>>>>> -     * WikiContext.
>>>>>>>>> -     */
>>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>>> "jspwiki.resourceincludes";
>>>>>>>>> -
>>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>>> -
>>>>>>>>>  protected static final Logger log = LoggerFactory.getLogger(
>>>>>>>> TemplateManager.class );
>>>>>>>>> 
>>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>>> -
>>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>>> -
>>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>>> Collections.emptyList();
>>>>>>>>> -
>>>>>>>>>  /**
>>>>>>>>>   * <p>Resolves requests for resources relative to the
>>>>>>>>>   * <code>templates/<var>template</var></code> path to the actual
>>>>>>>> resources,
>>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>>   * for certain keys to return <code>null</code>. The map itself
>>>>>>>>> is
>>>>>>>>>   * immutable.
>>>>>>>>>   * </p>
>>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>>> ServletContext
>>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>>> some
>>>>>>>> reason.
>>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>>   * If the WikiEngine does not initialize, the default template
>>>>>>>>>   * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>>> requests.</p>
>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>>> 
>>>>>>>>>          // Add all of the resources the template contains
>>>>>>>>>          resolver = new HashMap<String,String>();
>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>> "/" +
>>>>>>>> template + "/", null );
>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>> + "/" +
>>>>>>>> template + "/", null );
>>>>>>>>> 
>>>>>>>>>          // Add resources the template does not contain, but
>>>>>>>>> default
>>>>>>>> does
>>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>>> "/" +
>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>>> + "/" +
>>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>>          resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>>          context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>>      }
>>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>>> manager per
>>>>>>>> engine.
>>>>>>>>> -     *
>>>>>>>>> -     * @param engine The owning engine.
>>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>>> this.
>>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>>> to the
>>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>>> as the
>>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>>> portion
>>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>>> short name
>>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>>> be added
>>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>> directory path)
>>>>>>>>> +     * will be processed recursively.
>>>>>>>>> +     * @param context the servlet context
>>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>>> from
>>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>>> prefix.
>>>>>>>> If not
>>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>>   */
>>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>> properties )
>>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>>  {
>>>>>>>>> -        super( engine );
>>>>>>>>> -        m_engine = engine;
>>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>>> -    }
>>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>>> searchPath );
>>>>>>>>> +        if ( resources != null )
>>>>>>>>> +        {
>>>>>>>>> +            for ( String resource : resources )
>>>>>>>>> +            {
>>>>>>>>> +                String shortName = resource.substring(
>>>>>>>>> prefix.length()
>>>>>>>> );
>>>>>>>>> +
>>>>>>>>> +                // Directory: process these entries too
>>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>>> +                {
>>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>>> shortName
>>>>>>>> );
>>>>>>>>> +                }
>>>>>>>>> 
>>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>>> already
>>>>>>>>> +                else
>>>>>>>>> +                {
>>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>>> resolver.containsKey(
>>>>>>>> shortName );
>>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>>> +                    {
>>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>>> +                    }
>>>>>>>>> +                }
>>>>>>>>> +            }
>>>>>>>>> +        }
>>>>>>>>> +    }
>>>>>>>>> +
>>>>>>>>>  /**
>>>>>>>>>   * Tries to locate a given resource from the template directory,
>>>>>>>> relative to
>>>>>>>>>   * the root of the JSPWiki webapp context (for example,
>>>>>>>>> relative to
>>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>>   * default template path either, <code>null</code> is returned.
>>>>>>>>>   *
>>>>>>>>>   *
>>>>>>>>> -     * @param sContext the servlet context
>>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>>   * @param path the path to the resource; for example,
>>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>>> jspwiki.css}.
>>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>>> looked up
>>>>>>>>> +     * relative to the webapp root
>>>>>>>>>   * @return The name of the resource which was found; for example,
>>>>>>>>>   * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>>> in
>>>>>>>> the
>>>>>>>>>   * <code>custom</code> template directory), or
>>>>>>>>>   * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>>   */
>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>> String
>>>>>>>> path )
>>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>>> servletContext,
>>>>>>>> String path )
>>>>>>>>>  {
>>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>>> -
>>>>>>>>> -        if( is == null )
>>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>>      {
>>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>>> removeTemplatePart( path ) );
>>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>>> -
>>>>>>>>> -            if( is != null )
>>>>>>>>> -                path = defaultPath;
>>>>>>>>> -            else
>>>>>>>>> -                path = null;
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        if( is != null )
>>>>>>>>> -        {
>>>>>>>>> -            try
>>>>>>>>> -            {
>>>>>>>>> -                is.close();
>>>>>>>>> -            }
>>>>>>>>> -            catch( IOException e )
>>>>>>>>> -            {
>>>>>>>>> -            }
>>>>>>>>> +            // This is already a full path
>>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>>      }
>>>>>>>>> -
>>>>>>>>> -        return path;
>>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>>> if it's
>>>>>>>> not
>>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>>> -     *
>>>>>>>>> -     * @param sContext
>>>>>>>>> -     * @param template
>>>>>>>>> -     * @param name
>>>>>>>>> -     * @return
>>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>>> evaluation is
>>>>>>>> lazy,
>>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>>> actually
>>>>>>>> used
>>>>>>>>> +     * for the first time.
>>>>>>>>> +     */
>>>>>>>>> +    /*
>>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>>> String
>>>>>>>> key ) {
>>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>>> props =
>>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>> if(
>>>>>>>> props ==
>>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>> IOException e ) {
>>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>>> properties",e);
>>>>>>>> return
>>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>>> NeedsRefreshException
>>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>>   */
>>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>>> String
>>>>>>>> template, String name )
>>>>>>>>> +    /**
>>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>>> +     */
>>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>>  {
>>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>>> -        {
>>>>>>>>> -            // This is already a full path
>>>>>>>>> -            return findResource( sContext, name );
>>>>>>>>> -        }
>>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>>> +    }
>>>>>>>>> 
>>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>>> 
>>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>>> +    /**
>>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>>> manager per
>>>>>>>> engine.
>>>>>>>>> +     *
>>>>>>>>> +     * @param engine The owning engine.
>>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>>> this.
>>>>>>>>> +     */
>>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>>> properties )
>>>>>>>>> +    {
>>>>>>>>> +        super( engine );
>>>>>>>>> +        m_engine = engine;
>>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>>   * current context or by the absolute name.
>>>>>>>>>   *
>>>>>>>>>   * @param pageContext the JSP PageContext
>>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>>> "Wiki.jsp")
>>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>>> {@code
>>>>>>>> Wiki.jsp})
>>>>>>>>>   * @return The context path to the resource
>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>> (ServletContext)}
>>>>>>>> instead
>>>>>>>>>   */
>>>>>>>>>  public String findJSP( PageContext pageContext, String name )
>>>>>>>>>  {
>>>>>>>>>      ServletContext sContext = pageContext.getServletContext();
>>>>>>>>> -
>>>>>>>>>      return findResource( sContext, name );
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     * Removes the template part of a name.
>>>>>>>>> -     */
>>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>>> -    {
>>>>>>>>> -        int idx = 0;
>>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>>> -            idx = 1;
>>>>>>>>> -
>>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>>> -        if( idx != -1 )
>>>>>>>>> -        {
>>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>>> -
>>>>>>>>> -            if( idx != -1 )
>>>>>>>>> -            {
>>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>>> -            }
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>>> -        return name;
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>>> template=foo.
>>>>>>>>> -     *
>>>>>>>>> -     * @param template The name of the template.
>>>>>>>>> -     * @param name The name of the resource.
>>>>>>>>> -     * @return The full name for a template.
>>>>>>>>> -     */
>>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>>> template, String
>>>>>>>> name )
>>>>>>>>> -    {
>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>>   * Attempts to locate a resource under the given template. If
>>>>>>>>> that
>>>>>>>> template
>>>>>>>>>   * does not exist, or the page does not exist under that
>>>>>>>>> template,
>>>>>>>> will
>>>>>>>>>   * attempt to locate a similarly named file under the default
>>>>>>>> template.
>>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>>   * @param template From which template we should seek initially?
>>>>>>>>>   * @param name Which resource are we looking for (e.g.
>>>>>>>> "DefaultLayout.jsp")
>>>>>>>>>   * @return path to the JSP page; null, if it was not found.
>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>> (ServletContext)}
>>>>>>>> instead
>>>>>>>>>   */
>>>>>>>>>  public String findJSP( PageContext pageContext, String template,
>>>>>>>> String name )
>>>>>>>>>  {
>>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>>                     + ((HttpServletRequest)
>>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>>          throw new InternalWikiException( "Illegal arguments to
>>>>>>>> findJSP(); please check logs." );
>>>>>>>>>      }
>>>>>>>>> -
>>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>>> template,
>>>>>>>> name );
>>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>>> name );
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>>   * @param template the name of the template to use
>>>>>>>>>   * @param name the name of the resource to fine
>>>>>>>>>   * @return the path to the resource
>>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>>> (ServletContext)}
>>>>>>>> instead
>>>>>>>>>   */
>>>>>>>>>  public String findResource( WikiContext ctx, String template,
>>>>>>>>> String
>>>>>>>> name )
>>>>>>>>>  {
>>>>>>>>>      if( m_engine.getServletContext() != null )
>>>>>>>>>      {
>>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>>> template,
>>>>>>>> name );
>>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>>> name );
>>>>>>>>>      }
>>>>>>>>> 
>>>>>>>>>      return getPath( template ) + "/" + name;
>>>>>>>>>  }
>>>>>>>>> 
>>>>>>>>>  /**
>>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>>> evaluation is
>>>>>>>> lazy,
>>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>>> actually
>>>>>>>> used
>>>>>>>>> -     * for the first time.
>>>>>>>>> -     */
>>>>>>>>> -    /*
>>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>>> String
>>>>>>>> key ) {
>>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>>> props =
>>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>>> if(
>>>>>>>> props ==
>>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>>> IOException e ) {
>>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>>> properties",e);
>>>>>>>> return
>>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>>> NeedsRefreshException
>>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>>> -     */
>>>>>>>>> -    /**
>>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>>> -     */
>>>>>>>>> -    private static final String getPath( String template )
>>>>>>>>> -    {
>>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>>> empty
>>>>>>>> Set, if
>>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>>> does
>>>>>>>> not check
>>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>>> just
>>>>>>>> lists
>>>>>>>>> -     * them. This may change in the future.
>>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>>> available.
>>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>>> anything
>>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>>   *
>>>>>>>>>   * @param servletContext the servlet context
>>>>>>>>>   * @param template The template to search
>>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>>   * @since 2.3.26
>>>>>>>>>   */
>>>>>>>>>  @SuppressWarnings( "unchecked" )
>>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>>> String
>>>>>>>> template )
>>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>>  {
>>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>>> SKIN_DIRECTORY );
>>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>>> place );
>>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>>> +        Set<String> skinSet =
>>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>>      TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>>> 
>>>>>>>>>      if( log.isDebugEnabled() )
>>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>>> 
>>>>>>>>>      if( skinSet != null )
>>>>>>>>>      {
>>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>>> 
>>>>>>>>>      return resultSet;
>>>>>>>>>  }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Always returns a valid property map.
>>>>>>>>> -     */
>>>>>>>>> -    /*
>>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>>> templateName )
>>>>>>>> throws
>>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>>> ServletContext
>>>>>>>> context =
>>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>>> +PROPERTYFILE);
>>>>>>>> if(
>>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>>> '"+templateName+"'
>>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>>> return p; }
>>>>>>>>> -     */
>>>>>>>>> -    /**
>>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>>> This is in
>>>>>>>> a HTML
>>>>>>>>> -     * or Javascript comment format.
>>>>>>>>> -     *
>>>>>>>>> -     * @param context the wiki context
>>>>>>>>> -     * @param type the marker
>>>>>>>>> -     * @return the generated marker comment
>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>> tags
>>>>>>>> instead
>>>>>>>>> -     */
>>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>>> type )
>>>>>>>>> -    {
>>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>>> -        {
>>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>>> -        }
>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>> -        {
>>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>>> -        }
>>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>>> (javascript.*)
>>>>>>>> Returns
>>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>>> array.
>>>>>>>>> -     *
>>>>>>>>> -     * @param wiki context
>>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>>> LocaliedStrings
>>>>>>>> array
>>>>>>>>> -     * @since 2.5.108
>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>> tags
>>>>>>>> instead
>>>>>>>>> -     */
>>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>>> context )
>>>>>>>>> -    {
>>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>>> -
>>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>>> -
>>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>>> "templates.default" );
>>>>>>>>> -
>>>>>>>>> -        boolean first = true;
>>>>>>>>> -
>>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>>> en.hasMoreElements(); )
>>>>>>>>> -        {
>>>>>>>>> -            String key = en.nextElement();
>>>>>>>>> -
>>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>>> -            {
>>>>>>>>> -                if( first )
>>>>>>>>> -                {
>>>>>>>>> -                    first = false;
>>>>>>>>> -                }
>>>>>>>>> -                else
>>>>>>>>> -                {
>>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>>> -                }
>>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>>> key ) +
>>>>>>>> "\"" );
>>>>>>>>> -            }
>>>>>>>>> -        }
>>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>>> -
>>>>>>>>> -        return(sb.toString());
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>>> content will
>>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>>> IncludeResourcesTag) in
>>>>>>>>> -     * WikiJSPFilter.
>>>>>>>>> -     * <p>
>>>>>>>>> -     * The resources can be of different types. For
>>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>>> (a script
>>>>>>>> file or
>>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>>> RESOURCE_INLINECSS
>>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>>> (commonheader.jsp). For
>>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>>> function
>>>>>>>> that should
>>>>>>>>> -     * be run at page load.
>>>>>>>>> -     * <p>
>>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>>> files, which
>>>>>>>> is then
>>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>>> rendered but
>>>>>>>> not yet
>>>>>>>>> -     * sent to the recipient.
>>>>>>>>> -     * <p>
>>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>>> method does
>>>>>>>> not
>>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>>> Therefore,
>>>>>>>> if you
>>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>>> time,
>>>>>>>> you'll end
>>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>>> good
>>>>>>>> idea to
>>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>>> -     *
>>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>>> -     * @param resource The resource to add.
>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>> tags
>>>>>>>> instead
>>>>>>>>> -     */
>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>>> String type,
>>>>>>>> String resource )
>>>>>>>>> -    {
>>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>>> (HashMap<String,
>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>> -
>>>>>>>>> -        if( resourcemap == null )
>>>>>>>>> -        {
>>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>>> -
>>>>>>>>> -        if( resources == null )
>>>>>>>>> -        {
>>>>>>>>> -            resources = new Vector<String>();
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        String resourceString = null;
>>>>>>>>> -
>>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>>> -        {
>>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>>> src='" +
>>>>>>>> resource + "'></script>";
>>>>>>>>> -        }
>>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>>> -        {
>>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>>> css'
>>>>>>>> href='" + resource + "' />";
>>>>>>>>> -        }
>>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>>> -        {
>>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>>> resource +
>>>>>>>> "\n</style>\n";
>>>>>>>>> -        }
>>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>>> -        {
>>>>>>>>> -            resourceString = resource;
>>>>>>>>> -        }
>>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>>> -        {
>>>>>>>>> -            resourceString = resource;
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        if( resourceString != null )
>>>>>>>>> -        {
>>>>>>>>> -            resources.add( resourceString );
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>>> resourceString );
>>>>>>>>> -
>>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>>> are no
>>>>>>>>> -     * resources, returns an empty array.
>>>>>>>>> -     *
>>>>>>>>> -     * @param ctx WikiContext
>>>>>>>>> -     * @param type The resource request type
>>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>> tags
>>>>>>>> instead
>>>>>>>>> -     */
>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>>> String
>>>>>>>> type )
>>>>>>>>> -    {
>>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>> -
>>>>>>>>> -        if( hm == null )
>>>>>>>>> -            return new String[0];
>>>>>>>>> -
>>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>>> -
>>>>>>>>> -        if( resources == null )
>>>>>>>>> -            return new String[0];
>>>>>>>>> -
>>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>>> -
>>>>>>>>> -        return resources.toArray( res );
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>>> -     *
>>>>>>>>> -     * @param ctx the wiki context
>>>>>>>>> -     * @return the array of types requested
>>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>>> tags
>>>>>>>> instead
>>>>>>>>> -     */
>>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>>> -    {
>>>>>>>>> -        String[] res = new String[0];
>>>>>>>>> -
>>>>>>>>> -        if( ctx != null )
>>>>>>>>> -        {
>>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>>> -
>>>>>>>>> -            if( hm != null )
>>>>>>>>> -            {
>>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>>> -
>>>>>>>>> -                res = keys.toArray( res );
>>>>>>>>> -            }
>>>>>>>>> -        }
>>>>>>>>> -
>>>>>>>>> -        return res;
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> +
>>>>>>>>>  /**
>>>>>>>>>   * Returns an empty collection, since at the moment the
>>>>>>>> TemplateManager does
>>>>>>>>>   * not manage any modules.
>>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>>   */
>>>>>>>>>  public Collection<WikiModuleInfo> modules()
>>>>>>>>>  {
>>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>>> -    }
>>>>>>>>> -
>>>>>>>>> -    /**
>>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>>> to the
>>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>>> as the
>>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>>> portion
>>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>>> short name
>>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>>> be added
>>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>>> directory path)
>>>>>>>>> -     * will be processed recursively.
>>>>>>>>> -     * @param context the servlet context
>>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>>> from
>>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>>> prefix.
>>>>>>>> If not
>>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>>> -     */
>>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>> -    {
>>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>>> searchPath );
>>>>>>>>> -        if ( resources != null )
>>>>>>>>> -        {
>>>>>>>>> -            for ( String resource : resources )
>>>>>>>>> -            {
>>>>>>>>> -                String shortName = resource.substring(
>>>>>>>>> prefix.length()
>>>>>>>> );
>>>>>>>>> -
>>>>>>>>> -                // Directory: process these entries too
>>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>>> -                {
>>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>>> shortName
>>>>>>>> );
>>>>>>>>> -                }
>>>>>>>>> -
>>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>>> already
>>>>>>>>> -                else
>>>>>>>>> -                {
>>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>>> resolver.containsKey(
>>>>>>>> shortName );
>>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>>> -                    {
>>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>>> -                    }
>>>>>>>>> -                }
>>>>>>>>> -            }
>>>>>>>>> -        }
>>>>>>>>> +        return Collections.emptyList();
>>>>>>>>>  }
>>>>>>>>> }
>>>>>>>>> 
>>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>> TemplateResolution.java
>>>>>>>>> URL:
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>>> 
>>>>>>>> ============
>>>>>>>> ==================================================================
>>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>> TemplateResolution.java
>>>>>>>> (original)
>>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>>> TemplateResolution.java
>>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>>> {
>>>>>>>>>  private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>>> TemplateResolution.class );
>>>>>>>>> 
>>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>>> +
>>>>>>>>>  /**
>>>>>>>>>   * Constructs a new TemplateResolution
>>>>>>>>>   *
>>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>>      String path = TemplateManager.getResourceResolver(
>>>>>>>>> servletContext
>>>>>>>> ).get( getPath() );
>>>>>>>>>      if( path == null )
>>>>>>>>>      {
>>>>>>>>> -            path = "/templates/" +
>>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>>> "/" + getPath();
>>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>>      }
>>>>>>>>>      setPath( path );
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>> 
>>> 


Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
2) doesn't work, since it fails to account for nested IncludePage commands.  It gets awfully complicated if you wish to include those, and you essentially end up rendering each page *twice* per every request.  It also makes a bunch of assumptions about the rendering pipeline I'm not comfortable with.

Second, the WikiModuleInfo resources turned out to be a bad idea; XML descriptors are a real pain, and we should move to annotations.  But the problem with both is that they're not dynamic - so a plugin cannot determine runtime which resources to include and what not (e.g. based on parameters or page content).

/Janne

On 4 Mar 2010, at 17:30, Andrew Jaquith wrote:

> Janne and Dirk --
> 
> Here's my proposal to resolve the resource-inclusion issue.
> 
> 1. Editor JSPs. I've tested a nested-layout implementation, and it
> works fine. I'll check this in at my next opportunity (not for a few
> days, probably).
> 
> 2. Plugin resources. It turns out we have a ready-made class,
> WikiModuleInfo, that enumerates the resources that modules (like
> PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
> before forwarding to the JSP, we simply inspect the page text before
> to see what plugins are asked for in the wiki markup. For any that are
> encountered, we add any script or css resources requirements to a
> request "queue," which is processed when the JSP actually renders (by
> IncludeResourcesTag or JSTL code).
> 
> I am satisfied that (2) will be safe because we would just be fetching
> resources the developer specifically required, as the modules XML
> file, or (better) class annotations specify.
> 
> Andrew
> 
> On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
> <an...@gmail.com> wrote:
>> Janne --
>> 
>> Agreed. Each editor has special needs that ought to be specified in
>> the "editor JSP" (e.g., plain.jsp) itself.
>> 
>> In the current implementation, the scripts needed for the plain editor
>> are included via a s:layout-component tag in Edit.jsp -- which
>> encapsulates ALL editors. That means, indeed, that it is included for
>> all editors, regardless of the user choice. But it is easy to imagine
>> how this would be specified instead in the editor JSPs directly.
>> Essentially, this would be done by turning Edit.jsp into a layout
>> itself. It's a layout inside of a layout. It is straightforward to do;
>> but I have not put the necessary (minor) JSP changes in the trunk just
>> yet.
>> 
>> But, this is pre-Alpha. The goal all along has been to get *all* of
>> the editors working and to allow them to specify their own resources.
>> It will be done soon enough.
>> 
>> In the meantime, I received your message -- that you need a way to
>> allow plugins to include their own resources -- loud and clear. I
>> don't have an answer for that today, but will propose some options
>> shortly.
>> 
>> Andrew
>> 
>> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>>> Why would we include the plain text editor in the case that the user
>>> preferences state FCK editor?  Or vice versa?
>>> 
>>> From the point of view of the layouts editors and plugins should be
>>> equal.  The other one just happens to be implemented in JSP...
>>> 
>>> The choice of the editor is user-specific and has nothing to do with
>>> the template choice.
>>> 
>>> /Janne
>>> 
>>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>>> That isn't a good example. The layout JSPs define a standard look, and
>>>> standard resources, which can be overridden in the template JSPs when
>>>> they need something special. Essentially, the template JSP uses the
>>>> s:layout-render tag to instruct which layout to use, and one more
>>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>> 
>>>> For example, the template JSP templates/default/Preferences.jsp
>>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>>> for example.
>>>> 
>>>> The plugin resources example is a valid example, though. I've got some
>>>> ideas on how to do this safely but haven't had time to document them.
>>>> (This is a very crazy week for me, professionally.)
>>>> 
>>>> Andrew
>>>> 
>>>> 
>>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>>> wrote:
>>>> 
>>>>> 
>>>>> Yup, this is also good example.  I don't think having to edit layout
>>>>> jsp's is a good admin experience when you're deploying a new
>>>>> component.
>>>>> 
>>>>> /Janne
>>>>> 
>>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>> 
>>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>> 
>>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>>> layout jsp)
>>>>>> 
>>>>>> 
>>>>>> When you would use the FCK editor, however, another javascript (and
>>>>>> probably
>>>>>> also css) is needed.
>>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>>> correct
>>>>>> resources.
>>>>>> 
>>>>>> 
>>>>>> dirk
>>>>>> 
>>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>>> <ja...@ecyrd.com>wrote:
>>>>>> 
>>>>>>> 
>>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>>> how do
>>>>>>> plugins request resources, and how do individual templates then
>>>>>>> fall back to
>>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>>> assumes that
>>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>>> template,
>>>>>>> and plugins which request CSS and other components.
>>>>>>> 
>>>>>>> /Janne
>>>>>>> 
>>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>> 
>>>>>>>> Author: ajaquith
>>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>>> New Revision: 917390
>>>>>>>> 
>>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>>> Log:
>>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>>> should) be
>>>>>>> included directly in template JSPs.
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>>>  incubator/jspwiki/trunk/ChangeLog
>>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>> 
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>> Preferences.java
>>>>>>>> 
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>> JSONRPCManager.java
>>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> ContentTag.java
>>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> EditorTag.java
>>>>>>>> 
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeResourcesTag.java
>>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeTag.java
>>>>>>>> 
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> RequestResourceTag.java
>>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>>> EditorManager.java
>>>>>>>> 
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> TemplateManager.java
>>>>>>>> 
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>> TemplateResolution.java
>>>>>>>> 
>>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -1,3 +1,30 @@
>>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>> +
>>>>>>>> +        * 3.0.0-svn-212
>>>>>>>> +
>>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>>> are now
>>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>>> doCatch()
>>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>>> debugging.
>>>>>>>> +
>>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>>> feature was
>>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>>> View tab
>>>>>>>> +        now simply displays the most recent save.
>>>>>>>> +
>>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>>> JSPs.
>>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>>> used
>>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>>> customizable
>>>>>>>> +        per-template, but still very easy to use.
>>>>>>>> +
>>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>>> Resources
>>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>>> +
>>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>>> as part
>>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>>> Stripesed.
>>>>>>>> +
>>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>> 
>>>>>>>>       * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>>> changes
>>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>>       * fixed a couple of Plugin unit tests (support for wiki
>>>>>>>> spaces is
>>>>>>>>         not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>> 
>>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>> 
>>>>>>>>       * 3.0.0-svn-209
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>>> Release.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>> Mon Mar
>>>>>>> 1 05:23:10 2010
>>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>>    *  <p>
>>>>>>>>    *  If the build identifier is empty, it is not added.
>>>>>>>>    */
>>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>>    *  This is the generic version string you should use
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>> Note.java
>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>>> Note.java Mon
>>>>>>> Mar  1 05:23:10 2010
>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>> 
>>>>>>>> 
>>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>> 
>>>>>>>>       commentImage = "images/"+commentImage;
>>>>>>>> 
>>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>>> ().findResource( ctx,
>>>>>>>> -
>>>>>>> engine.getTemplateDir(),
>>>>>>>> -
>>>>>>> commentImage );
>>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>> 
>>>>>>>>       return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>>   }
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>> Preferences.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>> Preferences.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>>> Preferences.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>>       }
>>>>>>>>       else if( "availableSkins".equals( key ) )
>>>>>>>>       {
>>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>>       }
>>>>>>>>       else if( "availableTimeFormats".equals( key ) )
>>>>>>>>       {
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>> JSONRPCManager.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>> JSONRPCManager.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>>> JSONRPCManager.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -38,7 +38,6 @@
>>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>> 
>>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>>    */
>>>>>>>>   public static void requestJSON( WikiContext context )
>>>>>>>>   {
>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>> -
>>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>>> -
>>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>>> -
>>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>>> "JSON-RPC" );
>>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>>> -
>>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>>> -                                           "jsonrpc = new
>>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>>> -
>>>>>>>>       getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>>> HttpServletRequest.class);
>>>>>>>>   }
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> ContentTag.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> ContentTag.java
>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> ContentTag.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>> 
>>>>>>>> import org.apache.wiki.*;
>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>> 
>>>>>>>> 
>>>>>>>> /**
>>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>>               contentTemplate = beanName + "Content.jsp";
>>>>>>>>           }
>>>>>>>> 
>>>>>>>> -            String page =
>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>> -
>>>>>>>        m_wikiContext.getTemplate(),
>>>>>>>> -
>>>>>>>        contentTemplate );
>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>>           pageContext.include( page );
>>>>>>>>       }
>>>>>>>>       catch( ServletException e )
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> EditorTag.java
>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> EditorTag.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>> 
>>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>> 
>>>>>>>> 
>>>>>>>> /**
>>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>> 
>>>>>>>>       try
>>>>>>>>       {
>>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>>> pageContext,
>>>>>>>> -
>>>>>>> m_wikiContext.getTemplate(),
>>>>>>>> -
>>>>>>> editorPath );
>>>>>>>> -
>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>>           if( page == null )
>>>>>>>>           {
>>>>>>>>               //FIXME: should be I18N ...
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeResourcesTag.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeResourcesTag.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeResourcesTag.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -20,41 +20,34 @@
>>>>>>>> */
>>>>>>>> package org.apache.wiki.tags;
>>>>>>>> 
>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>> 
>>>>>>>> /**
>>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>>> emits a
>>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>>> take
>>>>>>>> - *  care of the actual inclusion.
>>>>>>>> - *
>>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>> instead
>>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>>> into the
>>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>>> ServletFilter.
>>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>>> The
>>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>> on how
>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>> instead
>>>>>>>> */
>>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>>> {
>>>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>>> 
>>>>>>>> -    private String m_type;
>>>>>>>> -
>>>>>>>>   public void initTag()
>>>>>>>>   {
>>>>>>>>       super.initTag();
>>>>>>>> -        m_type = null;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   public void setType( String type )
>>>>>>>>   {
>>>>>>>> -        m_type = type;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   public int doWikiStartTag() throws Exception
>>>>>>>>   {
>>>>>>>> -        //String marker =
>>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>>> (m_wikiContext,
>>>>>>> m_type);
>>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>>> m_type);
>>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>>> m_type);
>>>>>>>> -
>>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>>> -
>>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>>> layout tags instead " +
>>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>>       return SKIP_BODY;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeTag.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeTag.java
>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>>> IncludeTag.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -25,6 +25,7 @@
>>>>>>>> import javax.servlet.ServletException;
>>>>>>>> 
>>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>> 
>>>>>>>> 
>>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>>   {
>>>>>>>>       try
>>>>>>>>       {
>>>>>>>> -            String page =
>>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>>> -
>>>>>>>        m_wikiContext.getTemplate(),
>>>>>>>> -
>>>>>>>        m_page );
>>>>>>>> -
>>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>>           if( page == null )
>>>>>>>>           {
>>>>>>>>               pageContext.getOut().println("No template file called
>>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> RequestResourceTag.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> RequestResourceTag.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> RequestResourceTag.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -20,21 +20,17 @@
>>>>>>>> */
>>>>>>>> package org.apache.wiki.tags;
>>>>>>>> 
>>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>> -
>>>>>>>> /**
>>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>>> ().  You
>>>>>>> may use
>>>>>>>> - *  any of the request types defined there.
>>>>>>>> - *
>>>>>>>> - *  @see TemplateManager
>>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>>> JSPWiki to
>>>>>>> insert
>>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>>> because it
>>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>>> instead. See
>>>>>>> the default
>>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>>> on how
>>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>>> instead
>>>>>>>> */
>>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>>> {
>>>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>>> -
>>>>>>>> -    private String m_type;
>>>>>>>> -    private String m_resource;
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>>    *  {@inheritDoc}
>>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>>   public void initTag()
>>>>>>>>   {
>>>>>>>>       super.initTag();
>>>>>>>> -        m_type = m_resource = null;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>>   @Override
>>>>>>>>   public int doWikiStartTag() throws Exception
>>>>>>>>   {
>>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>>> -        {
>>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>>> m_type,
>>>>>>> m_resource );
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>>       return SKIP_BODY;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>    *
>>>>>>>>    *  @return The resource name.
>>>>>>>>    */
>>>>>>>>   public String getResource()
>>>>>>>>   {
>>>>>>>> -        return m_resource;
>>>>>>>> +        return "";
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     *  Sets the resource name to be added.
>>>>>>>> +     *  This method does nothing.
>>>>>>>>    *
>>>>>>>>    *  @param r Resource identifier.
>>>>>>>>    */
>>>>>>>>   public void setResource(String r)
>>>>>>>>   {
>>>>>>>> -        m_resource = r;
>>>>>>>> +        // No-op.
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     *  Get the resource type.
>>>>>>>> +     *  Always returns the empty string.
>>>>>>>>    *
>>>>>>>>    *  @return The type of the resource.
>>>>>>>>    */
>>>>>>>>   public String getType()
>>>>>>>>   {
>>>>>>>> -        return m_type;
>>>>>>>> +        return "";
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>>> "script".  Please
>>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>>> the
>>>>>>> different kinds
>>>>>>>> -     *  of types you can use.
>>>>>>>> -     *
>>>>>>>> -     *  @see TemplateManager
>>>>>>>> +     *  This method does nothing.
>>>>>>>>    *
>>>>>>>>    *  @param type The type to be set.
>>>>>>>>    */
>>>>>>>> 
>>>>>>>>   public void setType(String type)
>>>>>>>>   {
>>>>>>>> -        m_type = type;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>> }
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> EditorManager.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> EditorManager.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> EditorManager.java Mon
>>>>>>> Mar  1 05:23:10 2010
>>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>>   /** Known name for the plain wikimarkup editor. */
>>>>>>>>   public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>> 
>>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>>> -
>>>>>>>>   /** Known attribute name for storing the user edited text
>>>>>>>> inside a
>>>>>>> HTTP parameter. */
>>>>>>>>   public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>> 
>>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>>    */
>>>>>>>>   public String getEditorName( WikiContext context )
>>>>>>>>   {
>>>>>>>> -        if( context.getRequestContext().equals
>>>>>>>> (WikiContext.PREVIEW) )
>>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>>> -
>>>>>>>>       String editor = null;
>>>>>>>> 
>>>>>>>>       // User has set an editor in preferences
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> TemplateManager.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> TemplateManager.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> TemplateManager.java Mon
>>>>>>> Mar  1 05:23:10 2010
>>>>>>>> @@ -20,8 +20,6 @@
>>>>>>>> */
>>>>>>>> package org.apache.wiki.ui;
>>>>>>>> 
>>>>>>>> -import java.io.IOException;
>>>>>>>> -import java.io.InputStream;
>>>>>>>> import java.util.*;
>>>>>>>> 
>>>>>>>> import javax.servlet.ServletContext;
>>>>>>>> @@ -46,7 +44,7 @@
>>>>>>>> */
>>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>>> {
>>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>>    * Attribute name for the resource resolver map returned by
>>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>>    */
>>>>>>>>   private static final String RESOURCE_RESOLVER =
>>>>>>>> "resourceResolver";
>>>>>>>> 
>>>>>>>> -    /**
>>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>>> window.onload.
>>>>>>> Value
>>>>>>>> -     * is {@value}.
>>>>>>>> -     */
>>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>>> strings.
>>>>>>>> -     */
>>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>>> "jslocalizedstrings";
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>>> -     */
>>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>>> -     */
>>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>>> -     */
>>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>>> -
>>>>>>>>   /** The default directory for template resources. Value is
>>>>>>>> {@value}.
>>>>>>> */
>>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>> 
>>>>>>>>   /** The name of the default template. Value is {@value}. */
>>>>>>>>   public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>> 
>>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>>> "template.properties";
>>>>>>>> -
>>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>>> "prefs.user.language.default";
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>>> in the
>>>>>>>> -     * WikiContext.
>>>>>>>> -     */
>>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>>> "jspwiki.resourceincludes";
>>>>>>>> -
>>>>>>>> -    // private Cache m_propertyCache;
>>>>>>>> -
>>>>>>>>   protected static final Logger log = LoggerFactory.getLogger(
>>>>>>> TemplateManager.class );
>>>>>>>> 
>>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>>> -
>>>>>>>> -    private WikiEngine m_engine;
>>>>>>>> -
>>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>>> Collections.emptyList();
>>>>>>>> -
>>>>>>>>   /**
>>>>>>>>    * <p>Resolves requests for resources relative to the
>>>>>>>>    * <code>templates/<var>template</var></code> path to the actual
>>>>>>> resources,
>>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>>    * for certain keys to return <code>null</code>. The map itself
>>>>>>>> is
>>>>>>>>    * immutable.
>>>>>>>>    * </p>
>>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>>> ServletContext
>>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>>> some
>>>>>>> reason.
>>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>>    * If the WikiEngine does not initialize, the default template
>>>>>>>>    * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>>> requests.</p>
>>>>>>>>    * @param servletContext the servlet context
>>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>> 
>>>>>>>>           // Add all of the resources the template contains
>>>>>>>>           resolver = new HashMap<String,String>();
>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>> "/" +
>>>>>>> template + "/", null );
>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>> + "/" +
>>>>>>> template + "/", null );
>>>>>>>> 
>>>>>>>>           // Add resources the template does not contain, but
>>>>>>>> default
>>>>>>> does
>>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>>> "/" +
>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>>> + "/" +
>>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>>           resolver = Collections.unmodifiableMap( resolver );
>>>>>>>>           context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>>       }
>>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>>> manager per
>>>>>>> engine.
>>>>>>>> -     *
>>>>>>>> -     * @param engine The owning engine.
>>>>>>>> -     * @param properties The property list used to initialize
>>>>>>>> this.
>>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>>> to the
>>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>>> as the
>>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>>> portion
>>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>>> short name
>>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>>> be added
>>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>> directory path)
>>>>>>>> +     * will be processed recursively.
>>>>>>>> +     * @param context the servlet context
>>>>>>>> +     * @param resolver the resource resolver map
>>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>>> from
>>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>>> prefix.
>>>>>>> If not
>>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>>    */
>>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>>> properties )
>>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>>> +    private static void addResources( ServletContext context,
>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>>   {
>>>>>>>> -        super( engine );
>>>>>>>> -        m_engine = engine;
>>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>>> -    }
>>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>>> searchPath );
>>>>>>>> +        if ( resources != null )
>>>>>>>> +        {
>>>>>>>> +            for ( String resource : resources )
>>>>>>>> +            {
>>>>>>>> +                String shortName = resource.substring(
>>>>>>>> prefix.length()
>>>>>>> );
>>>>>>>> +
>>>>>>>> +                // Directory: process these entries too
>>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>>> +                {
>>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>>> shortName
>>>>>>> );
>>>>>>>> +                }
>>>>>>>> 
>>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>>> already
>>>>>>>> +                else
>>>>>>>> +                {
>>>>>>>> +                    boolean alreadyProcessed =
>>>>>>>> resolver.containsKey(
>>>>>>> shortName );
>>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>>> +                    {
>>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>>> +                    }
>>>>>>>> +                }
>>>>>>>> +            }
>>>>>>>> +        }
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>>   /**
>>>>>>>>    * Tries to locate a given resource from the template directory,
>>>>>>> relative to
>>>>>>>>    * the root of the JSPWiki webapp context (for example,
>>>>>>>> relative to
>>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>>    * default template path either, <code>null</code> is returned.
>>>>>>>>    *
>>>>>>>>    *
>>>>>>>> -     * @param sContext the servlet context
>>>>>>>> +     * @param servletContext the servlet context
>>>>>>>>    * @param path the path to the resource; for example,
>>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>>> jspwiki.css}.
>>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>>> looked up
>>>>>>>> +     * relative to the webapp root
>>>>>>>>    * @return The name of the resource which was found; for example,
>>>>>>>>    * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>>> in
>>>>>>> the
>>>>>>>>    * <code>custom</code> template directory), or
>>>>>>>>    * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>>    */
>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>> String
>>>>>>> path )
>>>>>>>> +    private static String findResource( ServletContext
>>>>>>>> servletContext,
>>>>>>> String path )
>>>>>>>>   {
>>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>>> -
>>>>>>>> -        if( is == null )
>>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>>       {
>>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>>> DEFAULT_TEMPLATE,
>>>>>>> removeTemplatePart( path ) );
>>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>>> -
>>>>>>>> -            if( is != null )
>>>>>>>> -                path = defaultPath;
>>>>>>>> -            else
>>>>>>>> -                path = null;
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        if( is != null )
>>>>>>>> -        {
>>>>>>>> -            try
>>>>>>>> -            {
>>>>>>>> -                is.close();
>>>>>>>> -            }
>>>>>>>> -            catch( IOException e )
>>>>>>>> -            {
>>>>>>>> -            }
>>>>>>>> +            // This is already a full path
>>>>>>>> +            return findResource( servletContext, path );
>>>>>>>>       }
>>>>>>>> -
>>>>>>>> -        return path;
>>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>>> if it's
>>>>>>> not
>>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>>> -     *
>>>>>>>> -     * @param sContext
>>>>>>>> -     * @param template
>>>>>>>> -     * @param name
>>>>>>>> -     * @return
>>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>>> evaluation is
>>>>>>> lazy,
>>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>>> actually
>>>>>>> used
>>>>>>>> +     * for the first time.
>>>>>>>> +     */
>>>>>>>> +    /*
>>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>>> String
>>>>>>> key ) {
>>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>>> props =
>>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>> if(
>>>>>>> props ==
>>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>> IOException e ) {
>>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>>> properties",e);
>>>>>>> return
>>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>>> NeedsRefreshException
>>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>>    */
>>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>>> String
>>>>>>> template, String name )
>>>>>>>> +    /**
>>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>>> +     */
>>>>>>>> +    private static final String getPath( String template )
>>>>>>>>   {
>>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>>> -        {
>>>>>>>> -            // This is already a full path
>>>>>>>> -            return findResource( sContext, name );
>>>>>>>> -        }
>>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>>> +    }
>>>>>>>> 
>>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>>> +    private WikiEngine m_engine;
>>>>>>>> 
>>>>>>>> -        return findResource( sContext, fullname );
>>>>>>>> +    /**
>>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>>> manager per
>>>>>>> engine.
>>>>>>>> +     *
>>>>>>>> +     * @param engine The owning engine.
>>>>>>>> +     * @param properties The property list used to initialize
>>>>>>>> this.
>>>>>>>> +     */
>>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>>> properties )
>>>>>>>> +    {
>>>>>>>> +        super( engine );
>>>>>>>> +        m_engine = engine;
>>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>>    * current context or by the absolute name.
>>>>>>>>    *
>>>>>>>>    * @param pageContext the JSP PageContext
>>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>>> "Wiki.jsp")
>>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>>> {@code
>>>>>>> Wiki.jsp})
>>>>>>>>    * @return The context path to the resource
>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>> (ServletContext)}
>>>>>>> instead
>>>>>>>>    */
>>>>>>>>   public String findJSP( PageContext pageContext, String name )
>>>>>>>>   {
>>>>>>>>       ServletContext sContext = pageContext.getServletContext();
>>>>>>>> -
>>>>>>>>       return findResource( sContext, name );
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     * Removes the template part of a name.
>>>>>>>> -     */
>>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>>> -    {
>>>>>>>> -        int idx = 0;
>>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>>> -            idx = 1;
>>>>>>>> -
>>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>>> -        if( idx != -1 )
>>>>>>>> -        {
>>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>>> -
>>>>>>>> -            if( idx != -1 )
>>>>>>>> -            {
>>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>>> -            }
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        log.info( "Final name = " + name );
>>>>>>>> -        return name;
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>>> template=foo.
>>>>>>>> -     *
>>>>>>>> -     * @param template The name of the template.
>>>>>>>> -     * @param name The name of the resource.
>>>>>>>> -     * @return The full name for a template.
>>>>>>>> -     */
>>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>>> template, String
>>>>>>> name )
>>>>>>>> -    {
>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>>    * Attempts to locate a resource under the given template. If
>>>>>>>> that
>>>>>>> template
>>>>>>>>    * does not exist, or the page does not exist under that
>>>>>>>> template,
>>>>>>> will
>>>>>>>>    * attempt to locate a similarly named file under the default
>>>>>>> template.
>>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>>    * @param template From which template we should seek initially?
>>>>>>>>    * @param name Which resource are we looking for (e.g.
>>>>>>> "DefaultLayout.jsp")
>>>>>>>>    * @return path to the JSP page; null, if it was not found.
>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>> (ServletContext)}
>>>>>>> instead
>>>>>>>>    */
>>>>>>>>   public String findJSP( PageContext pageContext, String template,
>>>>>>> String name )
>>>>>>>>   {
>>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>>                      + ((HttpServletRequest)
>>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>>           throw new InternalWikiException( "Illegal arguments to
>>>>>>> findJSP(); please check logs." );
>>>>>>>>       }
>>>>>>>> -
>>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>>> template,
>>>>>>> name );
>>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>>> name );
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>>    * @param template the name of the template to use
>>>>>>>>    * @param name the name of the resource to fine
>>>>>>>>    * @return the path to the resource
>>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>>> (ServletContext)}
>>>>>>> instead
>>>>>>>>    */
>>>>>>>>   public String findResource( WikiContext ctx, String template,
>>>>>>>> String
>>>>>>> name )
>>>>>>>>   {
>>>>>>>>       if( m_engine.getServletContext() != null )
>>>>>>>>       {
>>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>>> template,
>>>>>>> name );
>>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>>> name );
>>>>>>>>       }
>>>>>>>> 
>>>>>>>>       return getPath( template ) + "/" + name;
>>>>>>>>   }
>>>>>>>> 
>>>>>>>>   /**
>>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>>> evaluation is
>>>>>>> lazy,
>>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>>> actually
>>>>>>> used
>>>>>>>> -     * for the first time.
>>>>>>>> -     */
>>>>>>>> -    /*
>>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>>> String
>>>>>>> key ) {
>>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>>> props =
>>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>>> if(
>>>>>>> props ==
>>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>>> IOException e ) {
>>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>>> properties",e);
>>>>>>> return
>>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>>> NeedsRefreshException
>>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>>> -     */
>>>>>>>> -    /**
>>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>>> -     */
>>>>>>>> -    private static final String getPath( String template )
>>>>>>>> -    {
>>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>>> empty
>>>>>>> Set, if
>>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>>> does
>>>>>>> not check
>>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>>> just
>>>>>>> lists
>>>>>>>> -     * them. This may change in the future.
>>>>>>>> +     * Lists the skins available under the current template.
>>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>>> available.
>>>>>>>> +     * Note that this method does not check whether there is
>>>>>>>> anything
>>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>>    *
>>>>>>>>    * @param servletContext the servlet context
>>>>>>>>    * @param template The template to search
>>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>>    * @since 2.3.26
>>>>>>>>    */
>>>>>>>>   @SuppressWarnings( "unchecked" )
>>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>>> String
>>>>>>> template )
>>>>>>>> +    public Set<String> listSkins()
>>>>>>>>   {
>>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>>> SKIN_DIRECTORY );
>>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>>> place );
>>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>>> +        Set<String> skinSet =
>>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>>       TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>> 
>>>>>>>>       if( log.isDebugEnabled() )
>>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>> 
>>>>>>>>       if( skinSet != null )
>>>>>>>>       {
>>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>> 
>>>>>>>>       return resultSet;
>>>>>>>>   }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Always returns a valid property map.
>>>>>>>> -     */
>>>>>>>> -    /*
>>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>>> templateName )
>>>>>>> throws
>>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>>> ServletContext
>>>>>>> context =
>>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>>> +PROPERTYFILE);
>>>>>>> if(
>>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>>> '"+templateName+"'
>>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>>> return p; }
>>>>>>>> -     */
>>>>>>>> -    /**
>>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>>> This is in
>>>>>>> a HTML
>>>>>>>> -     * or Javascript comment format.
>>>>>>>> -     *
>>>>>>>> -     * @param context the wiki context
>>>>>>>> -     * @param type the marker
>>>>>>>> -     * @return the generated marker comment
>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>> tags
>>>>>>> instead
>>>>>>>> -     */
>>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>>> type )
>>>>>>>> -    {
>>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>>> -        {
>>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>>> -        }
>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>> -        {
>>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>>> -        }
>>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>>> (javascript.*)
>>>>>>> Returns
>>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>>> array.
>>>>>>>> -     *
>>>>>>>> -     * @param wiki context
>>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>>> LocaliedStrings
>>>>>>> array
>>>>>>>> -     * @since 2.5.108
>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>> tags
>>>>>>> instead
>>>>>>>> -     */
>>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>>> context )
>>>>>>>> -    {
>>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>>> -
>>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>>> -
>>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>>> "templates.default" );
>>>>>>>> -
>>>>>>>> -        boolean first = true;
>>>>>>>> -
>>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>>> en.hasMoreElements(); )
>>>>>>>> -        {
>>>>>>>> -            String key = en.nextElement();
>>>>>>>> -
>>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>>> -            {
>>>>>>>> -                if( first )
>>>>>>>> -                {
>>>>>>>> -                    first = false;
>>>>>>>> -                }
>>>>>>>> -                else
>>>>>>>> -                {
>>>>>>>> -                    sb.append( ",\n" );
>>>>>>>> -                }
>>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>>> key ) +
>>>>>>> "\"" );
>>>>>>>> -            }
>>>>>>>> -        }
>>>>>>>> -        sb.append( "\n};\n" );
>>>>>>>> -
>>>>>>>> -        return(sb.toString());
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>>> content will
>>>>>>>> -     * be added at the resource-type marker (see
>>>>>>>> IncludeResourcesTag) in
>>>>>>>> -     * WikiJSPFilter.
>>>>>>>> -     * <p>
>>>>>>>> -     * The resources can be of different types. For
>>>>>>>> RESOURCE_SCRIPT and
>>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>>> (a script
>>>>>>> file or
>>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>>> RESOURCE_INLINECSS
>>>>>>>> -     * the resource should be something that can be added between
>>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>>> (commonheader.jsp). For
>>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>>> function
>>>>>>> that should
>>>>>>>> -     * be run at page load.
>>>>>>>> -     * <p>
>>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>>> files, which
>>>>>>> is then
>>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>>> rendered but
>>>>>>> not yet
>>>>>>>> -     * sent to the recipient.
>>>>>>>> -     * <p>
>>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>>> method does
>>>>>>> not
>>>>>>>> -     * check if the request already exists in the resources.
>>>>>>>> Therefore,
>>>>>>> if you
>>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>>> time,
>>>>>>> you'll end
>>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>>> good
>>>>>>> idea to
>>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>>> -     *
>>>>>>>> -     * @param ctx The current wiki context
>>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>>> -     * @param resource The resource to add.
>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>> tags
>>>>>>> instead
>>>>>>>> -     */
>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>>> String type,
>>>>>>> String resource )
>>>>>>>> -    {
>>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>>> (HashMap<String,
>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>> -
>>>>>>>> -        if( resourcemap == null )
>>>>>>>> -        {
>>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>>> -
>>>>>>>> -        if( resources == null )
>>>>>>>> -        {
>>>>>>>> -            resources = new Vector<String>();
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        String resourceString = null;
>>>>>>>> -
>>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>>> -        {
>>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>>> src='" +
>>>>>>> resource + "'></script>";
>>>>>>>> -        }
>>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>>> -        {
>>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>>> css'
>>>>>>> href='" + resource + "' />";
>>>>>>>> -        }
>>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>>> -        {
>>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>>> resource +
>>>>>>> "\n</style>\n";
>>>>>>>> -        }
>>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>>> -        {
>>>>>>>> -            resourceString = resource;
>>>>>>>> -        }
>>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>>> -        {
>>>>>>>> -            resourceString = resource;
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        if( resourceString != null )
>>>>>>>> -        {
>>>>>>>> -            resources.add( resourceString );
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>>> resourceString );
>>>>>>>> -
>>>>>>>> -        resourcemap.put( type, resources );
>>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>>> are no
>>>>>>>> -     * resources, returns an empty array.
>>>>>>>> -     *
>>>>>>>> -     * @param ctx WikiContext
>>>>>>>> -     * @param type The resource request type
>>>>>>>> -     * @return a String array for the resource requests
>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>> tags
>>>>>>> instead
>>>>>>>> -     */
>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>>> String
>>>>>>> type )
>>>>>>>> -    {
>>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>> -
>>>>>>>> -        if( hm == null )
>>>>>>>> -            return new String[0];
>>>>>>>> -
>>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>>> -
>>>>>>>> -        if( resources == null )
>>>>>>>> -            return new String[0];
>>>>>>>> -
>>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>>> -
>>>>>>>> -        return resources.toArray( res );
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>>> -     *
>>>>>>>> -     * @param ctx the wiki context
>>>>>>>> -     * @return the array of types requested
>>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>>> tags
>>>>>>> instead
>>>>>>>> -     */
>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>>> -    {
>>>>>>>> -        String[] res = new String[0];
>>>>>>>> -
>>>>>>>> -        if( ctx != null )
>>>>>>>> -        {
>>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>>> -
>>>>>>>> -            if( hm != null )
>>>>>>>> -            {
>>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>>> -
>>>>>>>> -                res = keys.toArray( res );
>>>>>>>> -            }
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        return res;
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> +
>>>>>>>>   /**
>>>>>>>>    * Returns an empty collection, since at the moment the
>>>>>>> TemplateManager does
>>>>>>>>    * not manage any modules.
>>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>>    */
>>>>>>>>   public Collection<WikiModuleInfo> modules()
>>>>>>>>   {
>>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    /**
>>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>>> to the
>>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>>> as the
>>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>>> portion
>>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>>> short name
>>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>>> be added
>>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>>> directory path)
>>>>>>>> -     * will be processed recursively.
>>>>>>>> -     * @param context the servlet context
>>>>>>>> -     * @param resolver the resource resolver map
>>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>>> from
>>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>>> prefix.
>>>>>>> If not
>>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>>> -     */
>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>> -    private static void addResources( ServletContext context,
>>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>> -    {
>>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>>> searchPath );
>>>>>>>> -        if ( resources != null )
>>>>>>>> -        {
>>>>>>>> -            for ( String resource : resources )
>>>>>>>> -            {
>>>>>>>> -                String shortName = resource.substring(
>>>>>>>> prefix.length()
>>>>>>> );
>>>>>>>> -
>>>>>>>> -                // Directory: process these entries too
>>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>>> -                {
>>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>>> shortName
>>>>>>> );
>>>>>>>> -                }
>>>>>>>> -
>>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>>> already
>>>>>>>> -                else
>>>>>>>> -                {
>>>>>>>> -                    boolean alreadyProcessed =
>>>>>>>> resolver.containsKey(
>>>>>>> shortName );
>>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>>> -                    {
>>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>>> -                    }
>>>>>>>> -                }
>>>>>>>> -            }
>>>>>>>> -        }
>>>>>>>> +        return Collections.emptyList();
>>>>>>>>   }
>>>>>>>> }
>>>>>>>> 
>>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>> TemplateResolution.java
>>>>>>>> URL:
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>> 
>>>>>>> ============
>>>>>>> ==================================================================
>>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>> TemplateResolution.java
>>>>>>> (original)
>>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>>> TemplateResolution.java
>>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>>> @@ -22,6 +22,8 @@
>>>>>>>> {
>>>>>>>>   private static final Logger LOG = LoggerFactory.getLogger(
>>>>>>> TemplateResolution.class );
>>>>>>>> 
>>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>>> +
>>>>>>>>   /**
>>>>>>>>    * Constructs a new TemplateResolution
>>>>>>>>    *
>>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>>       String path = TemplateManager.getResourceResolver(
>>>>>>>> servletContext
>>>>>>> ).get( getPath() );
>>>>>>>>       if( path == null )
>>>>>>>>       {
>>>>>>>> -            path = "/templates/" +
>>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>>> "/" + getPath();
>>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>>       }
>>>>>>>>       setPath( path );
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>> 
>>> 
>> 


Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Andrew Jaquith <an...@gmail.com>.
Janne and Dirk --

Here's my proposal to resolve the resource-inclusion issue.

1. Editor JSPs. I've tested a nested-layout implementation, and it
works fine. I'll check this in at my next opportunity (not for a few
days, probably).

2. Plugin resources. It turns out we have a ready-made class,
WikiModuleInfo, that enumerates the resources that modules (like
PLUGINS!) need. So I propose this: for the ViewActionBean "view" event
before forwarding to the JSP, we simply inspect the page text before
to see what plugins are asked for in the wiki markup. For any that are
encountered, we add any script or css resources requirements to a
request "queue," which is processed when the JSP actually renders (by
IncludeResourcesTag or JSTL code).

I am satisfied that (2) will be safe because we would just be fetching
resources the developer specifically required, as the modules XML
file, or (better) class annotations specify.

Andrew

On Wed, Mar 3, 2010 at 5:54 PM, Andrew Jaquith
<an...@gmail.com> wrote:
> Janne --
>
> Agreed. Each editor has special needs that ought to be specified in
> the "editor JSP" (e.g., plain.jsp) itself.
>
> In the current implementation, the scripts needed for the plain editor
> are included via a s:layout-component tag in Edit.jsp -- which
> encapsulates ALL editors. That means, indeed, that it is included for
> all editors, regardless of the user choice. But it is easy to imagine
> how this would be specified instead in the editor JSPs directly.
> Essentially, this would be done by turning Edit.jsp into a layout
> itself. It's a layout inside of a layout. It is straightforward to do;
> but I have not put the necessary (minor) JSP changes in the trunk just
> yet.
>
> But, this is pre-Alpha. The goal all along has been to get *all* of
> the editors working and to allow them to specify their own resources.
> It will be done soon enough.
>
> In the meantime, I received your message -- that you need a way to
> allow plugins to include their own resources -- loud and clear. I
> don't have an answer for that today, but will propose some options
> shortly.
>
> Andrew
>
> On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
>> Why would we include the plain text editor in the case that the user
>> preferences state FCK editor?  Or vice versa?
>>
>> From the point of view of the layouts editors and plugins should be
>> equal.  The other one just happens to be implemented in JSP...
>>
>> The choice of the editor is user-specific and has nothing to do with
>> the template choice.
>>
>> /Janne
>>
>> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>>> That isn't a good example. The layout JSPs define a standard look, and
>>> standard resources, which can be overridden in the template JSPs when
>>> they need something special. Essentially, the template JSP uses the
>>> s:layout-render tag to instruct which layout to use, and one more
>>> s:layout-component tags to override the JS, CSS, page title, etc.
>>>
>>> For example, the template JSP templates/default/Preferences.jsp
>>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>>> for example.
>>>
>>> The plugin resources example is a valid example, though. I've got some
>>> ideas on how to do this safely but haven't had time to document them.
>>> (This is a very crazy week for me, professionally.)
>>>
>>> Andrew
>>>
>>>
>>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>>> wrote:
>>>
>>>>
>>>> Yup, this is also good example.  I don't think having to edit layout
>>>> jsp's is a good admin experience when you're deploying a new
>>>> component.
>>>>
>>>> /Janne
>>>>
>>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>>
>>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>>
>>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>>> layout jsp)
>>>>>
>>>>>
>>>>> When you would use the FCK editor, however, another javascript (and
>>>>> probably
>>>>> also css) is needed.
>>>>> However, the layout jsp is not aware of every editor to add-in the
>>>>> correct
>>>>> resources.
>>>>>
>>>>>
>>>>> dirk
>>>>>
>>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>>> <ja...@ecyrd.com>wrote:
>>>>>
>>>>>>
>>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>>> how do
>>>>>> plugins request resources, and how do individual templates then
>>>>>> fall back to
>>>>>> resources they don't include?  I've got a bunch of code that
>>>>>> assumes that
>>>>>> templates can fall back to resources (e.g. images) from default
>>>>>> template,
>>>>>> and plugins which request CSS and other components.
>>>>>>
>>>>>> /Janne
>>>>>>
>>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>>
>>>>>>> Author: ajaquith
>>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>>> New Revision: 917390
>>>>>>>
>>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>>> Log:
>>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>>> should) be
>>>>>> included directly in template JSPs.
>>>>>>>
>>>>>>> Modified:
>>>>>>>  incubator/jspwiki/trunk/ChangeLog
>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>> Preferences.java
>>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>> JSONRPCManager.java
>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> ContentTag.java
>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> EditorTag.java
>>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeResourcesTag.java
>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeTag.java
>>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> RequestResourceTag.java
>>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>>> EditorManager.java
>>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> TemplateManager.java
>>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>> TemplateResolution.java
>>>>>>>
>>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>>> @@ -1,3 +1,30 @@
>>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>> +
>>>>>>> +        * 3.0.0-svn-212
>>>>>>> +
>>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>>> are now
>>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>>> doCatch()
>>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>>> debugging.
>>>>>>> +
>>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>>> feature was
>>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>>> View tab
>>>>>>> +        now simply displays the most recent save.
>>>>>>> +
>>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>>> JSPs.
>>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>>> used
>>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>>> customizable
>>>>>>> +        per-template, but still very easy to use.
>>>>>>> +
>>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>>> Resources
>>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>>> +
>>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>>> as part
>>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>>> Stripesed.
>>>>>>> +
>>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>>
>>>>>>>       * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>>> changes
>>>>>>> @@ -35,7 +62,7 @@
>>>>>>>       * fixed a couple of Plugin unit tests (support for wiki
>>>>>>> spaces is
>>>>>>>         not yet there), only the ReferringPagesPlugin still fails.
>>>>>>>
>>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>>
>>>>>>>       * 3.0.0-svn-209
>>>>>>>
>>>>>>>
>>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>>> Release.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>> Mon Mar
>>>>>> 1 05:23:10 2010
>>>>>>> @@ -77,7 +77,7 @@
>>>>>>>    *  <p>
>>>>>>>    *  If the build identifier is empty, it is not added.
>>>>>>>    */
>>>>>>> -    public static final String     BUILD         = "211";
>>>>>>> +    public static final String     BUILD         = "212";
>>>>>>>
>>>>>>>   /**
>>>>>>>    *  This is the generic version string you should use
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>> Note.java
>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>>> Note.java Mon
>>>>>> Mar  1 05:23:10 2010
>>>>>>> @@ -27,6 +27,7 @@
>>>>>>> import org.apache.wiki.WikiContext;
>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>> import org.apache.wiki.api.PluginException;
>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>
>>>>>>>
>>>>>>> @@ -86,9 +87,7 @@
>>>>>>>
>>>>>>>       commentImage = "images/"+commentImage;
>>>>>>>
>>>>>>> -        String resource = engine.getTemplateManager
>>>>>>> ().findResource( ctx,
>>>>>>> -
>>>>>> engine.getTemplateDir(),
>>>>>>> -
>>>>>> commentImage );
>>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>>
>>>>>>>       return ctx.getURL( WikiContext.NONE, resource );
>>>>>>>   }
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>> Preferences.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>> Preferences.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>>> Preferences.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -310,7 +310,7 @@
>>>>>>>       }
>>>>>>>       else if( "availableSkins".equals( key ) )
>>>>>>>       {
>>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>>       }
>>>>>>>       else if( "availableTimeFormats".equals( key ) )
>>>>>>>       {
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>> JSONRPCManager.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>> JSONRPCManager.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>>> JSONRPCManager.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -38,7 +38,6 @@
>>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>>
>>>>>>> @@ -149,15 +148,6 @@
>>>>>>>    */
>>>>>>>   public static void requestJSON( WikiContext context )
>>>>>>>   {
>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>> -
>>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>>> -
>>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>>> -
>>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>>> "JSON-RPC" );
>>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>>> -
>>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>>> -                                           "jsonrpc = new
>>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>>> -
>>>>>>>       getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>>> HttpServletRequest.class);
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> ContentTag.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> ContentTag.java
>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> ContentTag.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>
>>>>>>> import org.apache.wiki.*;
>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>
>>>>>>>
>>>>>>> /**
>>>>>>> @@ -181,9 +182,7 @@
>>>>>>>               contentTemplate = beanName + "Content.jsp";
>>>>>>>           }
>>>>>>>
>>>>>>> -            String page =
>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>> -
>>>>>>        m_wikiContext.getTemplate(),
>>>>>>> -
>>>>>>        contentTemplate );
>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>>           pageContext.include( page );
>>>>>>>       }
>>>>>>>       catch( ServletException e )
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> EditorTag.java
>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> EditorTag.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -27,6 +27,7 @@
>>>>>>>
>>>>>>> import org.apache.wiki.WikiEngine;
>>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>>
>>>>>>>
>>>>>>> /**
>>>>>>> @@ -58,10 +59,7 @@
>>>>>>>
>>>>>>>       try
>>>>>>>       {
>>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>>> pageContext,
>>>>>>> -
>>>>>> m_wikiContext.getTemplate(),
>>>>>>> -
>>>>>> editorPath );
>>>>>>> -
>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>>           if( page == null )
>>>>>>>           {
>>>>>>>               //FIXME: should be I18N ...
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeResourcesTag.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeResourcesTag.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeResourcesTag.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -20,41 +20,34 @@
>>>>>>> */
>>>>>>> package org.apache.wiki.tags;
>>>>>>>
>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>>
>>>>>>> /**
>>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>>> emits a
>>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>>> take
>>>>>>> - *  care of the actual inclusion.
>>>>>>> - *
>>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>> instead
>>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>>> into the
>>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>>> ServletFilter.
>>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>>> The
>>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>> on how
>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>> instead
>>>>>>> */
>>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>>> {
>>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>>
>>>>>>> -    private String m_type;
>>>>>>> -
>>>>>>>   public void initTag()
>>>>>>>   {
>>>>>>>       super.initTag();
>>>>>>> -        m_type = null;
>>>>>>>   }
>>>>>>>
>>>>>>>   public void setType( String type )
>>>>>>>   {
>>>>>>> -        m_type = type;
>>>>>>>   }
>>>>>>>
>>>>>>>   public int doWikiStartTag() throws Exception
>>>>>>>   {
>>>>>>> -        //String marker =
>>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>>> (m_wikiContext,
>>>>>> m_type);
>>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>>> m_type);
>>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>>> m_type);
>>>>>>> -
>>>>>>> -        pageContext.getOut().println( marker );
>>>>>>> -
>>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>>> layout tags instead " +
>>>>>>> +                     "of IncludeResourcesTag. See
>>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>>       return SKIP_BODY;
>>>>>>>   }
>>>>>>>
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeTag.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeTag.java
>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>>> IncludeTag.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -25,6 +25,7 @@
>>>>>>> import javax.servlet.ServletException;
>>>>>>>
>>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>>
>>>>>>>
>>>>>>> @@ -72,10 +73,7 @@
>>>>>>>   {
>>>>>>>       try
>>>>>>>       {
>>>>>>> -            String page =
>>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>>> -
>>>>>>        m_wikiContext.getTemplate(),
>>>>>>> -
>>>>>>        m_page );
>>>>>>> -
>>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>>           if( page == null )
>>>>>>>           {
>>>>>>>               pageContext.getOut().println("No template file called
>>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> RequestResourceTag.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> RequestResourceTag.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> RequestResourceTag.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -20,21 +20,17 @@
>>>>>>> */
>>>>>>> package org.apache.wiki.tags;
>>>>>>>
>>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>> -
>>>>>>> /**
>>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>>> ().  You
>>>>>> may use
>>>>>>> - *  any of the request types defined there.
>>>>>>> - *
>>>>>>> - *  @see TemplateManager
>>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>>> JSPWiki to
>>>>>> insert
>>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>>> because it
>>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>>> instead. See
>>>>>> the default
>>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>>> on how
>>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>>> instead
>>>>>>> */
>>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>>> {
>>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>> -
>>>>>>> -    private String m_type;
>>>>>>> -    private String m_resource;
>>>>>>>
>>>>>>>   /**
>>>>>>>    *  {@inheritDoc}
>>>>>>> @@ -43,7 +39,6 @@
>>>>>>>   public void initTag()
>>>>>>>   {
>>>>>>>       super.initTag();
>>>>>>> -        m_type = m_resource = null;
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> @@ -52,57 +47,47 @@
>>>>>>>   @Override
>>>>>>>   public int doWikiStartTag() throws Exception
>>>>>>>   {
>>>>>>> -        if( m_type != null && m_resource != null )
>>>>>>> -        {
>>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>>> m_type,
>>>>>> m_resource );
>>>>>>> -        }
>>>>>>> -
>>>>>>>       return SKIP_BODY;
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     *  Returns the resource that is to be added.
>>>>>>> +     *  Always returns the empty string.
>>>>>>>    *
>>>>>>>    *  @return The resource name.
>>>>>>>    */
>>>>>>>   public String getResource()
>>>>>>>   {
>>>>>>> -        return m_resource;
>>>>>>> +        return "";
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     *  Sets the resource name to be added.
>>>>>>> +     *  This method does nothing.
>>>>>>>    *
>>>>>>>    *  @param r Resource identifier.
>>>>>>>    */
>>>>>>>   public void setResource(String r)
>>>>>>>   {
>>>>>>> -        m_resource = r;
>>>>>>> +        // No-op.
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     *  Get the resource type.
>>>>>>> +     *  Always returns the empty string.
>>>>>>>    *
>>>>>>>    *  @return The type of the resource.
>>>>>>>    */
>>>>>>>   public String getType()
>>>>>>>   {
>>>>>>> -        return m_type;
>>>>>>> +        return "";
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>>> "script".  Please
>>>>>>> -     *  see the TemplateManager class for more information about
>>>>>>> the
>>>>>> different kinds
>>>>>>> -     *  of types you can use.
>>>>>>> -     *
>>>>>>> -     *  @see TemplateManager
>>>>>>> +     *  This method does nothing.
>>>>>>>    *
>>>>>>>    *  @param type The type to be set.
>>>>>>>    */
>>>>>>>
>>>>>>>   public void setType(String type)
>>>>>>>   {
>>>>>>> -        m_type = type;
>>>>>>>   }
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> EditorManager.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> EditorManager.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> EditorManager.java Mon
>>>>>> Mar  1 05:23:10 2010
>>>>>>> @@ -73,9 +73,6 @@
>>>>>>>   /** Known name for the plain wikimarkup editor. */
>>>>>>>   public static final String       EDITOR_PLAIN    = "plain";
>>>>>>>
>>>>>>> -    /** Known name for the preview editor component. */
>>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>>> -
>>>>>>>   /** Known attribute name for storing the user edited text
>>>>>>> inside a
>>>>>> HTTP parameter. */
>>>>>>>   public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>>
>>>>>>> @@ -189,9 +186,6 @@
>>>>>>>    */
>>>>>>>   public String getEditorName( WikiContext context )
>>>>>>>   {
>>>>>>> -        if( context.getRequestContext().equals
>>>>>>> (WikiContext.PREVIEW) )
>>>>>>> -            return EDITOR_PREVIEW;
>>>>>>> -
>>>>>>>       String editor = null;
>>>>>>>
>>>>>>>       // User has set an editor in preferences
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> TemplateManager.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> TemplateManager.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> TemplateManager.java Mon
>>>>>> Mar  1 05:23:10 2010
>>>>>>> @@ -20,8 +20,6 @@
>>>>>>> */
>>>>>>> package org.apache.wiki.ui;
>>>>>>>
>>>>>>> -import java.io.IOException;
>>>>>>> -import java.io.InputStream;
>>>>>>> import java.util.*;
>>>>>>>
>>>>>>> import javax.servlet.ServletContext;
>>>>>>> @@ -46,7 +44,7 @@
>>>>>>> */
>>>>>>> public class TemplateManager extends ModuleManager
>>>>>>> {
>>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>>
>>>>>>>   /**
>>>>>>>    * Attribute name for the resource resolver map returned by
>>>>>>> @@ -55,61 +53,14 @@
>>>>>>>    */
>>>>>>>   private static final String RESOURCE_RESOLVER =
>>>>>>> "resourceResolver";
>>>>>>>
>>>>>>> -    /**
>>>>>>> -     * Requests a JavaScript function to be called during
>>>>>>> window.onload.
>>>>>> Value
>>>>>>> -     * is {@value}.
>>>>>>> -     */
>>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>>> strings.
>>>>>>> -     */
>>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>>> "jslocalizedstrings";
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>>> -     */
>>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>>> -     */
>>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>>> -     */
>>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>>> -
>>>>>>>   /** The default directory for template resources. Value is
>>>>>>> {@value}.
>>>>>> */
>>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>>
>>>>>>>   /** The name of the default template. Value is {@value}. */
>>>>>>>   public static final String DEFAULT_TEMPLATE = "default";
>>>>>>>
>>>>>>> -    /** Name of the file that contains the properties. */
>>>>>>> -    public static final String PROPERTYFILE =
>>>>>>> "template.properties";
>>>>>>> -
>>>>>>> -    /** I18N string to mark the default locale */
>>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>>> "prefs.user.language.default";
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * The name under which the resource includes map is stored
>>>>>>> in the
>>>>>>> -     * WikiContext.
>>>>>>> -     */
>>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>>> "jspwiki.resourceincludes";
>>>>>>> -
>>>>>>> -    // private Cache m_propertyCache;
>>>>>>> -
>>>>>>>   protected static final Logger log = LoggerFactory.getLogger(
>>>>>> TemplateManager.class );
>>>>>>>
>>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>>> -
>>>>>>> -    private WikiEngine m_engine;
>>>>>>> -
>>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>>> Collections.emptyList();
>>>>>>> -
>>>>>>>   /**
>>>>>>>    * <p>Resolves requests for resources relative to the
>>>>>>>    * <code>templates/<var>template</var></code> path to the actual
>>>>>> resources,
>>>>>>> @@ -125,8 +76,8 @@
>>>>>>>    * for certain keys to return <code>null</code>. The map itself
>>>>>>> is
>>>>>>>    * immutable.
>>>>>>>    * </p>
>>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>>> ServletContext
>>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>>> some
>>>>>> reason.
>>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>>    * If the WikiEngine does not initialize, the default template
>>>>>>>    * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>>> requests.</p>
>>>>>>>    * @param servletContext the servlet context
>>>>>>> @@ -156,10 +107,10 @@
>>>>>>>
>>>>>>>           // Add all of the resources the template contains
>>>>>>>           resolver = new HashMap<String,String>();
>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>> "/" +
>>>>>> template + "/", null );
>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>> + "/" +
>>>>>> template + "/", null );
>>>>>>>
>>>>>>>           // Add resources the template does not contain, but
>>>>>>> default
>>>>>> does
>>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>>> "/" +
>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>>> + "/" +
>>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>>           resolver = Collections.unmodifiableMap( resolver );
>>>>>>>           context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>>       }
>>>>>>> @@ -167,18 +118,49 @@
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>>> manager per
>>>>>> engine.
>>>>>>> -     *
>>>>>>> -     * @param engine The owning engine.
>>>>>>> -     * @param properties The property list used to initialize
>>>>>>> this.
>>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>>> to the
>>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>>> as the
>>>>>>> +     * key, and the full path as the value. The short name is the
>>>>>> portion
>>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>>> short name
>>>>>>> +     * has already been added to the resource map, it will not
>>>>>>> be added
>>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>>> directory path)
>>>>>>> +     * will be processed recursively.
>>>>>>> +     * @param context the servlet context
>>>>>>> +     * @param resolver the resource resolver map
>>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>>> from
>>>>>>> +     * @param dir the directory to search relative to the path
>>>>>>> prefix.
>>>>>> If not
>>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>>    */
>>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>>> properties )
>>>>>>> +    @SuppressWarnings("unchecked")
>>>>>>> +    private static void addResources( ServletContext context,
>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>>   {
>>>>>>> -        super( engine );
>>>>>>> -        m_engine = engine;
>>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>>> -    }
>>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>>> searchPath );
>>>>>>> +        if ( resources != null )
>>>>>>> +        {
>>>>>>> +            for ( String resource : resources )
>>>>>>> +            {
>>>>>>> +                String shortName = resource.substring(
>>>>>>> prefix.length()
>>>>>> );
>>>>>>> +
>>>>>>> +                // Directory: process these entries too
>>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>>> +                {
>>>>>>> +                    addResources( context, resolver, prefix,
>>>>>>> shortName
>>>>>> );
>>>>>>> +                }
>>>>>>>
>>>>>>> +                // Regular resource: add it if we don't have it
>>>>>>> already
>>>>>>> +                else
>>>>>>> +                {
>>>>>>> +                    boolean alreadyProcessed =
>>>>>>> resolver.containsKey(
>>>>>> shortName );
>>>>>>> +                    if ( !alreadyProcessed )
>>>>>>> +                    {
>>>>>>> +                        resolver.put( shortName, resource );
>>>>>>> +                    }
>>>>>>> +                }
>>>>>>> +            }
>>>>>>> +        }
>>>>>>> +    }
>>>>>>> +
>>>>>>>   /**
>>>>>>>    * Tries to locate a given resource from the template directory,
>>>>>> relative to
>>>>>>>    * the root of the JSPWiki webapp context (for example,
>>>>>>> relative to
>>>>>>> @@ -188,63 +170,62 @@
>>>>>>>    * default template path either, <code>null</code> is returned.
>>>>>>>    *
>>>>>>>    *
>>>>>>> -     * @param sContext the servlet context
>>>>>>> +     * @param servletContext the servlet context
>>>>>>>    * @param path the path to the resource; for example,
>>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>>> jspwiki.css}.
>>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>>> looked up
>>>>>>> +     * relative to the webapp root
>>>>>>>    * @return The name of the resource which was found; for example,
>>>>>>>    * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>>> in
>>>>>> the
>>>>>>>    * <code>custom</code> template directory), or
>>>>>>>    * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>>    */
>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>> String
>>>>>> path )
>>>>>>> +    private static String findResource( ServletContext
>>>>>>> servletContext,
>>>>>> String path )
>>>>>>>   {
>>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>>> -
>>>>>>> -        if( is == null )
>>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>>       {
>>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>>> DEFAULT_TEMPLATE,
>>>>>> removeTemplatePart( path ) );
>>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>>> -
>>>>>>> -            if( is != null )
>>>>>>> -                path = defaultPath;
>>>>>>> -            else
>>>>>>> -                path = null;
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        if( is != null )
>>>>>>> -        {
>>>>>>> -            try
>>>>>>> -            {
>>>>>>> -                is.close();
>>>>>>> -            }
>>>>>>> -            catch( IOException e )
>>>>>>> -            {
>>>>>>> -            }
>>>>>>> +            // This is already a full path
>>>>>>> +            return findResource( servletContext, path );
>>>>>>>       }
>>>>>>> -
>>>>>>> -        return path;
>>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>>> if it's
>>>>>> not
>>>>>>> -     * found attempts to locate it from the default template.
>>>>>>> -     *
>>>>>>> -     * @param sContext
>>>>>>> -     * @param template
>>>>>>> -     * @param name
>>>>>>> -     * @return
>>>>>>> +     * Returns a property, as defined in the template. The
>>>>>>> evaluation is
>>>>>> lazy,
>>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>>> actually
>>>>>> used
>>>>>>> +     * for the first time.
>>>>>>> +     */
>>>>>>> +    /*
>>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>>> String
>>>>>> key ) {
>>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>>> props =
>>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>> if(
>>>>>> props ==
>>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>> IOException e ) {
>>>>>>> +     * log.warn("IO Exception while reading template
>>>>>>> properties",e);
>>>>>> return
>>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>>> NeedsRefreshException
>>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>>    */
>>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>>> String
>>>>>> template, String name )
>>>>>>> +    /**
>>>>>>> +     * Returns an absolute path to a given template.
>>>>>>> +     */
>>>>>>> +    private static final String getPath( String template )
>>>>>>>   {
>>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>>> -        {
>>>>>>> -            // This is already a full path
>>>>>>> -            return findResource( sContext, name );
>>>>>>> -        }
>>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>>> +    }
>>>>>>>
>>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>>> +    private WikiEngine m_engine;
>>>>>>>
>>>>>>> -        return findResource( sContext, fullname );
>>>>>>> +    /**
>>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>>> manager per
>>>>>> engine.
>>>>>>> +     *
>>>>>>> +     * @param engine The owning engine.
>>>>>>> +     * @param properties The property list used to initialize
>>>>>>> this.
>>>>>>> +     */
>>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>>> properties )
>>>>>>> +    {
>>>>>>> +        super( engine );
>>>>>>> +        m_engine = engine;
>>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> @@ -252,53 +233,17 @@
>>>>>>>    * current context or by the absolute name.
>>>>>>>    *
>>>>>>>    * @param pageContext the JSP PageContext
>>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>>> "Wiki.jsp")
>>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>>> {@code
>>>>>> Wiki.jsp})
>>>>>>>    * @return The context path to the resource
>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>> (ServletContext)}
>>>>>> instead
>>>>>>>    */
>>>>>>>   public String findJSP( PageContext pageContext, String name )
>>>>>>>   {
>>>>>>>       ServletContext sContext = pageContext.getServletContext();
>>>>>>> -
>>>>>>>       return findResource( sContext, name );
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     * Removes the template part of a name.
>>>>>>> -     */
>>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>>> -    {
>>>>>>> -        int idx = 0;
>>>>>>> -        if( name.startsWith( "/" ) )
>>>>>>> -            idx = 1;
>>>>>>> -
>>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>>> -        if( idx != -1 )
>>>>>>> -        {
>>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>>> -
>>>>>>> -            if( idx != -1 )
>>>>>>> -            {
>>>>>>> -                name = name.substring( idx + 1 );
>>>>>>> -            }
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        log.info( "Final name = " + name );
>>>>>>> -        return name;
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>>> template=foo.
>>>>>>> -     *
>>>>>>> -     * @param template The name of the template.
>>>>>>> -     * @param name The name of the resource.
>>>>>>> -     * @return The full name for a template.
>>>>>>> -     */
>>>>>>> -    private static final String makeFullJSPName( String
>>>>>>> template, String
>>>>>> name )
>>>>>>> -    {
>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>>    * Attempts to locate a resource under the given template. If
>>>>>>> that
>>>>>> template
>>>>>>>    * does not exist, or the page does not exist under that
>>>>>>> template,
>>>>>> will
>>>>>>>    * attempt to locate a similarly named file under the default
>>>>>> template.
>>>>>>> @@ -310,6 +255,7 @@
>>>>>>>    * @param template From which template we should seek initially?
>>>>>>>    * @param name Which resource are we looking for (e.g.
>>>>>> "DefaultLayout.jsp")
>>>>>>>    * @return path to the JSP page; null, if it was not found.
>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>> (ServletContext)}
>>>>>> instead
>>>>>>>    */
>>>>>>>   public String findJSP( PageContext pageContext, String template,
>>>>>> String name )
>>>>>>>   {
>>>>>>> @@ -319,8 +265,7 @@
>>>>>>>                      + ((HttpServletRequest)
>>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>>           throw new InternalWikiException( "Illegal arguments to
>>>>>> findJSP(); please check logs." );
>>>>>>>       }
>>>>>>> -
>>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>>> template,
>>>>>> name );
>>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>>> name );
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> @@ -337,45 +282,23 @@
>>>>>>>    * @param template the name of the template to use
>>>>>>>    * @param name the name of the resource to fine
>>>>>>>    * @return the path to the resource
>>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>>> (ServletContext)}
>>>>>> instead
>>>>>>>    */
>>>>>>>   public String findResource( WikiContext ctx, String template,
>>>>>>> String
>>>>>> name )
>>>>>>>   {
>>>>>>>       if( m_engine.getServletContext() != null )
>>>>>>>       {
>>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>>> template,
>>>>>> name );
>>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>>> name );
>>>>>>>       }
>>>>>>>
>>>>>>>       return getPath( template ) + "/" + name;
>>>>>>>   }
>>>>>>>
>>>>>>>   /**
>>>>>>> -     * Returns a property, as defined in the template. The
>>>>>>> evaluation is
>>>>>> lazy,
>>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>>> actually
>>>>>> used
>>>>>>> -     * for the first time.
>>>>>>> -     */
>>>>>>> -    /*
>>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>>> String
>>>>>> key ) {
>>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>>> props =
>>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>>> if(
>>>>>> props ==
>>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>>> IOException e ) {
>>>>>>> -     * log.warn("IO Exception while reading template
>>>>>>> properties",e);
>>>>>> return
>>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>>> NeedsRefreshException
>>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>>> -     */
>>>>>>> -    /**
>>>>>>> -     * Returns an absolute path to a given template.
>>>>>>> -     */
>>>>>>> -    private static final String getPath( String template )
>>>>>>> -    {
>>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>>> empty
>>>>>> Set, if
>>>>>>> -     * there are no extra skins available. Note that this method
>>>>>>> does
>>>>>> not check
>>>>>>> -     * whether there is anything actually in the directories, it
>>>>>>> just
>>>>>> lists
>>>>>>> -     * them. This may change in the future.
>>>>>>> +     * Lists the skins available under the current template.
>>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>>> available.
>>>>>>> +     * Note that this method does not check whether there is
>>>>>>> anything
>>>>>>> +     * actually in the directories, it just lists them.
>>>>>>>    *
>>>>>>>    * @param servletContext the servlet context
>>>>>>>    * @param template The template to search
>>>>>>> @@ -383,14 +306,14 @@
>>>>>>>    * @since 2.3.26
>>>>>>>    */
>>>>>>>   @SuppressWarnings( "unchecked" )
>>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>>> String
>>>>>> template )
>>>>>>> +    public Set<String> listSkins()
>>>>>>>   {
>>>>>>> -        String place = makeFullJSPName( template,
>>>>>>> SKIN_DIRECTORY );
>>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>>> place );
>>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>>> +        Set<String> skinSet =
>>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>>       TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>>
>>>>>>>       if( log.isDebugEnabled() )
>>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>>
>>>>>>>       if( skinSet != null )
>>>>>>>       {
>>>>>>> @@ -414,215 +337,7 @@
>>>>>>>
>>>>>>>       return resultSet;
>>>>>>>   }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Always returns a valid property map.
>>>>>>> -     */
>>>>>>> -    /*
>>>>>>> -     * private Properties getTemplateProperties( String
>>>>>>> templateName )
>>>>>> throws
>>>>>>> -     * IOException { Properties p = new Properties();
>>>>>>> ServletContext
>>>>>> context =
>>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>>> +PROPERTYFILE);
>>>>>> if(
>>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>>> '"+templateName+"'
>>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>>> return p; }
>>>>>>> -     */
>>>>>>> -    /**
>>>>>>> -     * Returns the include resources marker for a given type.
>>>>>>> This is in
>>>>>> a HTML
>>>>>>> -     * or Javascript comment format.
>>>>>>> -     *
>>>>>>> -     * @param context the wiki context
>>>>>>> -     * @param type the marker
>>>>>>> -     * @return the generated marker comment
>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>> tags
>>>>>> instead
>>>>>>> -     */
>>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>>> type )
>>>>>>> -    {
>>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>>> -        {
>>>>>>> -            return getJSLocalizedStrings( context );
>>>>>>> -        }
>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>> -        {
>>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>>> -        }
>>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>>> (javascript.*)
>>>>>> Returns
>>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>>> array.
>>>>>>> -     *
>>>>>>> -     * @param wiki context
>>>>>>> -     * @return Javascript snippet which defines the
>>>>>>> LocaliedStrings
>>>>>> array
>>>>>>> -     * @since 2.5.108
>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>> tags
>>>>>> instead
>>>>>>> -     */
>>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>>> context )
>>>>>>> -    {
>>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>>> -
>>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>>> -
>>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>>> "templates.default" );
>>>>>>> -
>>>>>>> -        boolean first = true;
>>>>>>> -
>>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>>> en.hasMoreElements(); )
>>>>>>> -        {
>>>>>>> -            String key = en.nextElement();
>>>>>>> -
>>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>>> -            {
>>>>>>> -                if( first )
>>>>>>> -                {
>>>>>>> -                    first = false;
>>>>>>> -                }
>>>>>>> -                else
>>>>>>> -                {
>>>>>>> -                    sb.append( ",\n" );
>>>>>>> -                }
>>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>>> key ) +
>>>>>> "\"" );
>>>>>>> -            }
>>>>>>> -        }
>>>>>>> -        sb.append( "\n};\n" );
>>>>>>> -
>>>>>>> -        return(sb.toString());
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Adds a resource request to the current request context. The
>>>>>> content will
>>>>>>> -     * be added at the resource-type marker (see
>>>>>>> IncludeResourcesTag) in
>>>>>>> -     * WikiJSPFilter.
>>>>>>> -     * <p>
>>>>>>> -     * The resources can be of different types. For
>>>>>>> RESOURCE_SCRIPT and
>>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>>> (a script
>>>>>> file or
>>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>>> RESOURCE_INLINECSS
>>>>>>> -     * the resource should be something that can be added between
>>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>>> (commonheader.jsp). For
>>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>>> function
>>>>>> that should
>>>>>>> -     * be run at page load.
>>>>>>> -     * <p>
>>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>>> files, which
>>>>>> is then
>>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>>> rendered but
>>>>>> not yet
>>>>>>> -     * sent to the recipient.
>>>>>>> -     * <p>
>>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>>> method does
>>>>>> not
>>>>>>> -     * check if the request already exists in the resources.
>>>>>>> Therefore,
>>>>>> if you
>>>>>>> -     * have a plugin which makes a new resource request every
>>>>>>> time,
>>>>>> you'll end
>>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>>> good
>>>>>> idea to
>>>>>>> -     * make this request only once during the page life cycle.
>>>>>>> -     *
>>>>>>> -     * @param ctx The current wiki context
>>>>>>> -     * @param type What kind of a request should be added?
>>>>>>> -     * @param resource The resource to add.
>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>> tags
>>>>>> instead
>>>>>>> -     */
>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>>> String type,
>>>>>> String resource )
>>>>>>> -    {
>>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>>> (HashMap<String,
>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>> -
>>>>>>> -        if( resourcemap == null )
>>>>>>> -        {
>>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>>> -
>>>>>>> -        if( resources == null )
>>>>>>> -        {
>>>>>>> -            resources = new Vector<String>();
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        String resourceString = null;
>>>>>>> -
>>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>>> -        {
>>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>>> src='" +
>>>>>> resource + "'></script>";
>>>>>>> -        }
>>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>>> -        {
>>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>>> css'
>>>>>> href='" + resource + "' />";
>>>>>>> -        }
>>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>>> -        {
>>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>>> resource +
>>>>>> "\n</style>\n";
>>>>>>> -        }
>>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>>> -        {
>>>>>>> -            resourceString = resource;
>>>>>>> -        }
>>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>>> -        {
>>>>>>> -            resourceString = resource;
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        if( resourceString != null )
>>>>>>> -        {
>>>>>>> -            resources.add( resourceString );
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>>> resourceString );
>>>>>>> -
>>>>>>> -        resourcemap.put( type, resources );
>>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>>> are no
>>>>>>> -     * resources, returns an empty array.
>>>>>>> -     *
>>>>>>> -     * @param ctx WikiContext
>>>>>>> -     * @param type The resource request type
>>>>>>> -     * @return a String array for the resource requests
>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>> tags
>>>>>> instead
>>>>>>> -     */
>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>>> String
>>>>>> type )
>>>>>>> -    {
>>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>> -
>>>>>>> -        if( hm == null )
>>>>>>> -            return new String[0];
>>>>>>> -
>>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>>> -
>>>>>>> -        if( resources == null )
>>>>>>> -            return new String[0];
>>>>>>> -
>>>>>>> -        String[] res = new String[resources.size()];
>>>>>>> -
>>>>>>> -        return resources.toArray( res );
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Returns all those types that have been requested so far.
>>>>>>> -     *
>>>>>>> -     * @param ctx the wiki context
>>>>>>> -     * @return the array of types requested
>>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>>> tags
>>>>>> instead
>>>>>>> -     */
>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>>> -    {
>>>>>>> -        String[] res = new String[0];
>>>>>>> -
>>>>>>> -        if( ctx != null )
>>>>>>> -        {
>>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>>> -
>>>>>>> -            if( hm != null )
>>>>>>> -            {
>>>>>>> -                Set<String> keys = hm.keySet();
>>>>>>> -
>>>>>>> -                res = keys.toArray( res );
>>>>>>> -            }
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        return res;
>>>>>>> -    }
>>>>>>> -
>>>>>>> +
>>>>>>>   /**
>>>>>>>    * Returns an empty collection, since at the moment the
>>>>>> TemplateManager does
>>>>>>>    * not manage any modules.
>>>>>>> @@ -631,50 +346,6 @@
>>>>>>>    */
>>>>>>>   public Collection<WikiModuleInfo> modules()
>>>>>>>   {
>>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    /**
>>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>>> to the
>>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>>> as the
>>>>>>> -     * key, and the full path as the value. The short name is the
>>>>>> portion
>>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>>> short name
>>>>>>> -     * has already been added to the resource map, it will not
>>>>>>> be added
>>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>>> directory path)
>>>>>>> -     * will be processed recursively.
>>>>>>> -     * @param context the servlet context
>>>>>>> -     * @param resolver the resource resolver map
>>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>>> from
>>>>>>> -     * @param dir the directory to search relative to the path
>>>>>>> prefix.
>>>>>> If not
>>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>>> -     */
>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>> -    private static void addResources( ServletContext context,
>>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>> -    {
>>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>>> searchPath );
>>>>>>> -        if ( resources != null )
>>>>>>> -        {
>>>>>>> -            for ( String resource : resources )
>>>>>>> -            {
>>>>>>> -                String shortName = resource.substring(
>>>>>>> prefix.length()
>>>>>> );
>>>>>>> -
>>>>>>> -                // Directory: process these entries too
>>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>>> -                {
>>>>>>> -                    addResources( context, resolver, prefix,
>>>>>>> shortName
>>>>>> );
>>>>>>> -                }
>>>>>>> -
>>>>>>> -                // Regular resource: add it if we don't have it
>>>>>>> already
>>>>>>> -                else
>>>>>>> -                {
>>>>>>> -                    boolean alreadyProcessed =
>>>>>>> resolver.containsKey(
>>>>>> shortName );
>>>>>>> -                    if ( !alreadyProcessed )
>>>>>>> -                    {
>>>>>>> -                        resolver.put( shortName, resource );
>>>>>>> -                    }
>>>>>>> -                }
>>>>>>> -            }
>>>>>>> -        }
>>>>>>> +        return Collections.emptyList();
>>>>>>>   }
>>>>>>> }
>>>>>>>
>>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>> TemplateResolution.java
>>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>>
>>>>>> ============
>>>>>> ==================================================================
>>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>> TemplateResolution.java
>>>>>> (original)
>>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>>> TemplateResolution.java
>>>>>> Mon Mar  1 05:23:10 2010
>>>>>>> @@ -22,6 +22,8 @@
>>>>>>> {
>>>>>>>   private static final Logger LOG = LoggerFactory.getLogger(
>>>>>> TemplateResolution.class );
>>>>>>>
>>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>>> +
>>>>>>>   /**
>>>>>>>    * Constructs a new TemplateResolution
>>>>>>>    *
>>>>>>> @@ -41,7 +43,7 @@
>>>>>>>       String path = TemplateManager.getResourceResolver(
>>>>>>> servletContext
>>>>>> ).get( getPath() );
>>>>>>>       if( path == null )
>>>>>>>       {
>>>>>>> -            path = "/templates/" +
>>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>>> "/" + getPath();
>>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>>       }
>>>>>>>       setPath( path );
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>
>

Re: svn commit: r917390 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/preferences/ src/java/org/apache/wiki/rpc/json/ src/java/org/apache/wiki/tags/ src/java/org/apache/wiki/ui/

Posted by Andrew Jaquith <an...@gmail.com>.
Janne --

Agreed. Each editor has special needs that ought to be specified in
the "editor JSP" (e.g., plain.jsp) itself.

In the current implementation, the scripts needed for the plain editor
are included via a s:layout-component tag in Edit.jsp -- which
encapsulates ALL editors. That means, indeed, that it is included for
all editors, regardless of the user choice. But it is easy to imagine
how this would be specified instead in the editor JSPs directly.
Essentially, this would be done by turning Edit.jsp into a layout
itself. It's a layout inside of a layout. It is straightforward to do;
but I have not put the necessary (minor) JSP changes in the trunk just
yet.

But, this is pre-Alpha. The goal all along has been to get *all* of
the editors working and to allow them to specify their own resources.
It will be done soon enough.

In the meantime, I received your message -- that you need a way to
allow plugins to include their own resources -- loud and clear. I
don't have an answer for that today, but will propose some options
shortly.

Andrew

On Wed, Mar 3, 2010 at 8:21 AM, Janne Jalkanen <ja...@iki.fi> wrote:
> Why would we include the plain text editor in the case that the user
> preferences state FCK editor?  Or vice versa?
>
> From the point of view of the layouts editors and plugins should be
> equal.  The other one just happens to be implemented in JSP...
>
> The choice of the editor is user-specific and has nothing to do with
> the template choice.
>
> /Janne
>
> On Wed, Mar 03, 2010 at 06:57:13AM -0800, Andrew Jaquith wrote:
>> That isn't a good example. The layout JSPs define a standard look, and
>> standard resources, which can be overridden in the template JSPs when
>> they need something special. Essentially, the template JSP uses the
>> s:layout-render tag to instruct which layout to use, and one more
>> s:layout-component tags to override the JS, CSS, page title, etc.
>>
>> For example, the template JSP templates/default/Preferences.jsp
>> overrides the JavaScript component so that jspwiki-prefs.js is included.
>> The editors are handled the same way. We add jspwiki-edit.js in Edit.jsp,
>> for example.
>>
>> The plugin resources example is a valid example, though. I've got some
>> ideas on how to do this safely but haven't had time to document them.
>> (This is a very crazy week for me, professionally.)
>>
>> Andrew
>>
>>
>> On Mar 3, 2010, at 0:14, Janne Jalkanen <ja...@ecyrd.com>
>> wrote:
>>
>>>
>>> Yup, this is also good example.  I don't think having to edit layout
>>> jsp's is a good admin experience when you're deploying a new
>>> component.
>>>
>>> /Janne
>>>
>>> On 2 Mar 2010, at 23:38, Dirk Frederickx wrote:
>>>
>>>> Another example is the editor jsp, such as plain.jsp.  It uses
>>>> jspwiki-edit.js,  (which probably would better be named as plain.js )
>>>>
>>>> However, currenly, jspwiki-edit.js is injected in another jsp (a
>>>> layout jsp)
>>>>
>>>>
>>>> When you would use the FCK editor, however, another javascript (and
>>>> probably
>>>> also css) is needed.
>>>> However, the layout jsp is not aware of every editor to add-in the
>>>> correct
>>>> resources.
>>>>
>>>>
>>>> dirk
>>>>
>>>> On Mon, Mar 1, 2010 at 7:46 PM, Janne Jalkanen
>>>> <ja...@ecyrd.com>wrote:
>>>>
>>>>>
>>>>> Hm?  If RequestResourceTag and IncludeResourcesTag are gone, then
>>>>> how do
>>>>> plugins request resources, and how do individual templates then
>>>>> fall back to
>>>>> resources they don't include?  I've got a bunch of code that
>>>>> assumes that
>>>>> templates can fall back to resources (e.g. images) from default
>>>>> template,
>>>>> and plugins which request CSS and other components.
>>>>>
>>>>> /Janne
>>>>>
>>>>> On 1 Mar 2010, at 07:23, ajaquith@apache.org wrote:
>>>>>
>>>>>> Author: ajaquith
>>>>>> Date: Mon Mar  1 05:23:10 2010
>>>>>> New Revision: 917390
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=917390&view=rev
>>>>>> Log:
>>>>>> Cleaned out all of the deadwood in TemplateManager. Deprecated
>>>>> IncludeResourcesTag and RequestResourceTag. Resources can (and
>>>>> should) be
>>>>> included directly in template JSPs.
>>>>>>
>>>>>> Modified:
>>>>>>  incubator/jspwiki/trunk/ChangeLog
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>> Preferences.java
>>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>> JSONRPCManager.java
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> ContentTag.java
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> EditorTag.java
>>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> IncludeResourcesTag.java
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeTag.java
>>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> RequestResourceTag.java
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>>> EditorManager.java
>>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> TemplateManager.java
>>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>> TemplateResolution.java
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/ChangeLog
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> --- incubator/jspwiki/trunk/ChangeLog (original)
>>>>>> +++ incubator/jspwiki/trunk/ChangeLog Mon Mar  1 05:23:10 2010
>>>>>> @@ -1,3 +1,30 @@
>>>>>> +2010-02-28 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>> +
>>>>>> +        * 3.0.0-svn-212
>>>>>> +
>>>>>> +        * Exceptions caught by WikiTagBase (and subclass tags)
>>>>>> are now
>>>>>> +        re-thrown so that they propagate upstream. Previously,
>>>>>> doCatch()
>>>>>> +        was swallowing them, which made for "interesting" JSP
>>>>>> debugging.
>>>>>> +
>>>>>> +        * Edit.jsp, Wiki.jsp, and PageInfo.jsp changed to put the
>>>>>> +        edit tab on the right. For editing, the live-preview
>>>>>> feature was
>>>>>> +        moved to a new "Preview" tab, also on the right. The
>>>>>> View tab
>>>>>> +        now simply displays the most recent save.
>>>>>> +
>>>>>> +        * The Error.jsp references were made consistent in all
>>>>>> JSPs.
>>>>>> +        Rather than use JSTL syntax (which won't evaluate when
>>>>>> used
>>>>>> +        with <% page errorPage %> tag), the references now all use
>>>>>> +        /Error.jsp, which itself jsp:includes the template JSP
>>>>>> +        Error.jsp using JSTL. This makes the error page
>>>>>> customizable
>>>>>> +        per-template, but still very easy to use.
>>>>>> +
>>>>>> +        * Cleaned out all of the deadwood in TemplateManager.
>>>>>> +        Deprecated IncludeResourcesTag and RequestResourceTag.
>>>>>> Resources
>>>>>> +        can (and should) be included directly in template JSPs.
>>>>>> +
>>>>>> +        * Small changes to Admin/AdministerProfiles action beans
>>>>>> as part
>>>>>> +        of a gradual overhaul to the Admin JSPs, which are being
>>>>> Stripesed.
>>>>>> +
>>>>>> 2010-02-28 Dirk Frederickx <br...@apache.org>
>>>>>>
>>>>>>       * v3.0.0-svn-211 : line up with latest template/stripes
>>>>>> changes
>>>>>> @@ -35,7 +62,7 @@
>>>>>>       * fixed a couple of Plugin unit tests (support for wiki
>>>>>> spaces is
>>>>>>         not yet there), only the ReferringPagesPlugin still fails.
>>>>>>
>>>>>> -2010-02-23 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>> +2010-02-27 Andrew Jaquith <ajaquith AT apache DOT org>
>>>>>>
>>>>>>       * 3.0.0-svn-209
>>>>>>
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/
>>>>>> Release.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
>>>>>> Mon Mar
>>>>> 1 05:23:10 2010
>>>>>> @@ -77,7 +77,7 @@
>>>>>>    *  <p>
>>>>>>    *  If the build identifier is empty, it is not added.
>>>>>>    */
>>>>>> -    public static final String     BUILD         = "211";
>>>>>> +    public static final String     BUILD         = "212";
>>>>>>
>>>>>>   /**
>>>>>>    *  This is the generic version string you should use
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Note.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>> Note.java
>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/
>>>>>> Note.java Mon
>>>>> Mar  1 05:23:10 2010
>>>>>> @@ -27,6 +27,7 @@
>>>>>> import org.apache.wiki.WikiContext;
>>>>>> import org.apache.wiki.WikiEngine;
>>>>>> import org.apache.wiki.api.PluginException;
>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>
>>>>>>
>>>>>> @@ -86,9 +87,7 @@
>>>>>>
>>>>>>       commentImage = "images/"+commentImage;
>>>>>>
>>>>>> -        String resource = engine.getTemplateManager
>>>>>> ().findResource( ctx,
>>>>>> -
>>>>> engine.getTemplateDir(),
>>>>>> -
>>>>> commentImage );
>>>>>> +        String resource = TemplateManager.getResourceResolver(
>>>>> engine.getServletContext() ).get( commentImage );
>>>>>>
>>>>>>       return ctx.getURL( WikiContext.NONE, resource );
>>>>>>   }
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>> Preferences.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/Preferences.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>> Preferences.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/preferences/
>>>>> Preferences.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -310,7 +310,7 @@
>>>>>>       }
>>>>>>       else if( "availableSkins".equals( key ) )
>>>>>>       {
>>>>>> -            return m_engine.getTemplateManager().listSkins(
>>>>> m_engine.getServletContext(), m_engine.getTemplateDir() );
>>>>>> +            return m_engine.getTemplateManager().listSkins();
>>>>>>       }
>>>>>>       else if( "availableTimeFormats".equals( key ) )
>>>>>>       {
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>> JSONRPCManager.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/JSONRPCManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>> JSONRPCManager.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/json/
>>>>> JSONRPCManager.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -38,7 +38,6 @@
>>>>>> import org.apache.wiki.log.LoggerFactory;
>>>>>> import org.apache.wiki.rpc.RPCCallable;
>>>>>> import org.apache.wiki.rpc.RPCManager;
>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>> import org.jabsorb.callback.InvocationCallback;
>>>>>> import org.jabsorb.JSONRPCBridge;
>>>>>>
>>>>>> @@ -149,15 +148,6 @@
>>>>>>    */
>>>>>>   public static void requestJSON( WikiContext context )
>>>>>>   {
>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>> -
>>>>> TemplateManager.RESOURCE_SCRIPT,
>>>>>> -
>>>>> context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
>>>>>> -
>>>>>> -        String jsonurl = context.getURL( WikiContext.NONE,
>>>>>> "JSON-RPC" );
>>>>>> -        TemplateManager.addResourceRequest(context,
>>>>>> -
>>>>> TemplateManager.RESOURCE_JSFUNCTION,
>>>>>> -                                           "jsonrpc = new
>>>>> JSONRpcClient(\""+jsonurl+"\");");
>>>>>> -
>>>>>>       getBridge(context).registerCallback(new WikiJSONAccessor(),
>>>>> HttpServletRequest.class);
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> ContentTag.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ContentTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> ContentTag.java
>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> ContentTag.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -28,6 +28,7 @@
>>>>>>
>>>>>> import org.apache.wiki.*;
>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> @@ -181,9 +182,7 @@
>>>>>>               contentTemplate = beanName + "Content.jsp";
>>>>>>           }
>>>>>>
>>>>>> -            String page =
>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>> -
>>>>>        m_wikiContext.getTemplate(),
>>>>>> -
>>>>>        contentTemplate );
>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>> pageContext.getServletContext() ).get( contentTemplate );
>>>>>>           pageContext.include( page );
>>>>>>       }
>>>>>>       catch( ServletException e )
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditorTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> EditorTag.java
>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> EditorTag.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -27,6 +27,7 @@
>>>>>>
>>>>>> import org.apache.wiki.WikiEngine;
>>>>>> import org.apache.wiki.ui.EditorManager;
>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> @@ -58,10 +59,7 @@
>>>>>>
>>>>>>       try
>>>>>>       {
>>>>>> -            String page = engine.getTemplateManager().findJSP(
>>>>> pageContext,
>>>>>> -
>>>>> m_wikiContext.getTemplate(),
>>>>>> -
>>>>> editorPath );
>>>>>> -
>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>> pageContext.getServletContext() ).get( editorPath );
>>>>>>           if( page == null )
>>>>>>           {
>>>>>>               //FIXME: should be I18N ...
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> IncludeResourcesTag.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeResourcesTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> IncludeResourcesTag.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> IncludeResourcesTag.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -20,41 +20,34 @@
>>>>>> */
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>>
>>>>>> /**
>>>>>> - *  This tag is used to include any programmatic includes into the
>>>>>> - *  output stream.  Actually, what it does is that it simply
>>>>>> emits a
>>>>>> - *  tiny marker into the stream, and then a ServletFilter will
>>>>>> take
>>>>>> - *  care of the actual inclusion.
>>>>>> - *
>>>>>> -*  @deprecated use the Stripes <code>layout-component</code> tags
>>>>> instead
>>>>>> + *  <p>This tag is used to include any programmatic includes
>>>>>> into the
>>>>>> + *  output stream. In JSPWiki 2.8 and earlier, this tag emitted a
>>>>>> + *  tiny marker into the stream which was replaced by
>>>>>> ServletFilter.
>>>>>> + *  <em>This tag has been deprecated because it is unsafe.</em>
>>>>>> The
>>>>>> + *  Stripes layout tags should be used instead. See the default
>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>> on how
>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>> + *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>> instead
>>>>>> */
>>>>>> public class IncludeResourcesTag extends WikiTagBase
>>>>>> {
>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    private String m_type;
>>>>>> -
>>>>>>   public void initTag()
>>>>>>   {
>>>>>>       super.initTag();
>>>>>> -        m_type = null;
>>>>>>   }
>>>>>>
>>>>>>   public void setType( String type )
>>>>>>   {
>>>>>> -        m_type = type;
>>>>>>   }
>>>>>>
>>>>>>   public int doWikiStartTag() throws Exception
>>>>>>   {
>>>>>> -        //String marker =
>>>>> m_wikiContext.getEngine().getTemplateManager().getMarker
>>>>> (m_wikiContext,
>>>>> m_type);
>>>>>> -        //String marker = TemplateManager.getMarker(pageContext,
>>>>> m_type);
>>>>>> -        String marker = TemplateManager.getMarker(m_wikiContext,
>>>>> m_type);
>>>>>> -
>>>>>> -        pageContext.getOut().println( marker );
>>>>>> -
>>>>>> +        pageContext.getOut().println( "<!-- Please use the Stripes
>>>>> layout tags instead " +
>>>>>> +                     "of IncludeResourcesTag. See
>>>>> layout/DefaultLayout.jsp for instructions. -->" );
>>>>>>       return SKIP_BODY;
>>>>>>   }
>>>>>>
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> IncludeTag.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IncludeTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeTag.java
>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>>> IncludeTag.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -25,6 +25,7 @@
>>>>>> import javax.servlet.ServletException;
>>>>>>
>>>>>> import org.apache.wiki.providers.ProviderException;
>>>>>> +import org.apache.wiki.ui.TemplateManager;
>>>>>> import org.apache.wiki.util.TextUtil;
>>>>>>
>>>>>>
>>>>>> @@ -72,10 +73,7 @@
>>>>>>   {
>>>>>>       try
>>>>>>       {
>>>>>> -            String page =
>>>>> m_wikiContext.getEngine().getTemplateManager().findJSP( pageContext,
>>>>>> -
>>>>>        m_wikiContext.getTemplate(),
>>>>>> -
>>>>>        m_page );
>>>>>> -
>>>>>> +            String page = TemplateManager.getResourceResolver(
>>>>> pageContext.getServletContext() ).get( m_page );
>>>>>>           if( page == null )
>>>>>>           {
>>>>>>               pageContext.getOut().println("No template file called
>>>>> '"+TextUtil.replaceEntities(m_page)+"'");
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> RequestResourceTag.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/RequestResourceTag.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> RequestResourceTag.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/
>>>>> RequestResourceTag.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -20,21 +20,17 @@
>>>>>> */
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> -import org.apache.wiki.ui.TemplateManager;
>>>>>> -
>>>>>> /**
>>>>>> - *  Provides easy access to TemplateManager.addResourceRequest
>>>>>> ().  You
>>>>> may use
>>>>>> - *  any of the request types defined there.
>>>>>> - *
>>>>>> - *  @see TemplateManager
>>>>>> + *  <p>In JSPWiki 2.8, this tag provided a way to instruct
>>>>>> JSPWiki to
>>>>> insert
>>>>>> + *  resource requests into JSPs. <em>This tag has been deprecated
>>>>> because it
>>>>>> + *  is unsafe.</em> The Stripes layout tags should be used
>>>>>> instead. See
>>>>> the default
>>>>>> + *  template {@code layout/DefaultLayout.jsp} for instructions
>>>>>> on how
>>>>>> + *  to include scripts and other resources in JSPs.</p>
>>>>>> *  @deprecated use the Stripes <code>layout-component</code> tags
>>>>> instead
>>>>>> */
>>>>>> public class RequestResourceTag extends WikiTagBase
>>>>>> {
>>>>>>   private static final long serialVersionUID = 0L;
>>>>>> -
>>>>>> -    private String m_type;
>>>>>> -    private String m_resource;
>>>>>>
>>>>>>   /**
>>>>>>    *  {@inheritDoc}
>>>>>> @@ -43,7 +39,6 @@
>>>>>>   public void initTag()
>>>>>>   {
>>>>>>       super.initTag();
>>>>>> -        m_type = m_resource = null;
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> @@ -52,57 +47,47 @@
>>>>>>   @Override
>>>>>>   public int doWikiStartTag() throws Exception
>>>>>>   {
>>>>>> -        if( m_type != null && m_resource != null )
>>>>>> -        {
>>>>>> -            TemplateManager.addResourceRequest( m_wikiContext,
>>>>>> m_type,
>>>>> m_resource );
>>>>>> -        }
>>>>>> -
>>>>>>       return SKIP_BODY;
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     *  Returns the resource that is to be added.
>>>>>> +     *  Always returns the empty string.
>>>>>>    *
>>>>>>    *  @return The resource name.
>>>>>>    */
>>>>>>   public String getResource()
>>>>>>   {
>>>>>> -        return m_resource;
>>>>>> +        return "";
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     *  Sets the resource name to be added.
>>>>>> +     *  This method does nothing.
>>>>>>    *
>>>>>>    *  @param r Resource identifier.
>>>>>>    */
>>>>>>   public void setResource(String r)
>>>>>>   {
>>>>>> -        m_resource = r;
>>>>>> +        // No-op.
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     *  Get the resource type.
>>>>>> +     *  Always returns the empty string.
>>>>>>    *
>>>>>>    *  @return The type of the resource.
>>>>>>    */
>>>>>>   public String getType()
>>>>>>   {
>>>>>> -        return m_type;
>>>>>> +        return "";
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     *  Set the type of the resource to be included.  For example,
>>>>> "script".  Please
>>>>>> -     *  see the TemplateManager class for more information about
>>>>>> the
>>>>> different kinds
>>>>>> -     *  of types you can use.
>>>>>> -     *
>>>>>> -     *  @see TemplateManager
>>>>>> +     *  This method does nothing.
>>>>>>    *
>>>>>>    *  @param type The type to be set.
>>>>>>    */
>>>>>>
>>>>>>   public void setType(String type)
>>>>>>   {
>>>>>> -        m_type = type;
>>>>>>   }
>>>>>>
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> EditorManager.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/EditorManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> EditorManager.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> EditorManager.java Mon
>>>>> Mar  1 05:23:10 2010
>>>>>> @@ -73,9 +73,6 @@
>>>>>>   /** Known name for the plain wikimarkup editor. */
>>>>>>   public static final String       EDITOR_PLAIN    = "plain";
>>>>>>
>>>>>> -    /** Known name for the preview editor component. */
>>>>>> -    public static final String       EDITOR_PREVIEW  = "preview";
>>>>>> -
>>>>>>   /** Known attribute name for storing the user edited text
>>>>>> inside a
>>>>> HTTP parameter. */
>>>>>>   public static final String       REQ_EDITEDTEXT  = "_editedtext";
>>>>>>
>>>>>> @@ -189,9 +186,6 @@
>>>>>>    */
>>>>>>   public String getEditorName( WikiContext context )
>>>>>>   {
>>>>>> -        if( context.getRequestContext().equals
>>>>>> (WikiContext.PREVIEW) )
>>>>>> -            return EDITOR_PREVIEW;
>>>>>> -
>>>>>>       String editor = null;
>>>>>>
>>>>>>       // User has set an editor in preferences
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> TemplateManager.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/TemplateManager.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> TemplateManager.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/
>>>>> TemplateManager.java Mon
>>>>> Mar  1 05:23:10 2010
>>>>>> @@ -20,8 +20,6 @@
>>>>>> */
>>>>>> package org.apache.wiki.ui;
>>>>>>
>>>>>> -import java.io.IOException;
>>>>>> -import java.io.InputStream;
>>>>>> import java.util.*;
>>>>>>
>>>>>> import javax.servlet.ServletContext;
>>>>>> @@ -46,7 +44,7 @@
>>>>>> */
>>>>>> public class TemplateManager extends ModuleManager
>>>>>> {
>>>>>> -    private static final String SKIN_DIRECTORY = "skins";
>>>>>> +    private static final String SKIN_DIR = "skins";
>>>>>>
>>>>>>   /**
>>>>>>    * Attribute name for the resource resolver map returned by
>>>>>> @@ -55,61 +53,14 @@
>>>>>>    */
>>>>>>   private static final String RESOURCE_RESOLVER =
>>>>>> "resourceResolver";
>>>>>>
>>>>>> -    /**
>>>>>> -     * Requests a JavaScript function to be called during
>>>>>> window.onload.
>>>>> Value
>>>>>> -     * is {@value}.
>>>>>> -     */
>>>>>> -    public static final String RESOURCE_JSFUNCTION = "jsfunction";
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Requests a JavaScript associative array with all localized
>>>>> strings.
>>>>>> -     */
>>>>>> -    public static final String RESOURCE_JSLOCALIZEDSTRINGS =
>>>>> "jslocalizedstrings";
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Requests a stylesheet to be inserted. Value is {@value}.
>>>>>> -     */
>>>>>> -    public static final String RESOURCE_STYLESHEET = "stylesheet";
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Requests a script to be loaded. Value is {@value}.
>>>>>> -     */
>>>>>> -    public static final String RESOURCE_SCRIPT = "script";
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Requests inlined CSS. Value is {@value}.
>>>>>> -     */
>>>>>> -    public static final String RESOURCE_INLINECSS = "inlinecss";
>>>>>> -
>>>>>>   /** The default directory for template resources. Value is
>>>>>> {@value}.
>>>>> */
>>>>>> -    public static final String DIRECTORY = "templates";
>>>>>> +    public static final String TEMPLATE_DIR = "templates";
>>>>>>
>>>>>>   /** The name of the default template. Value is {@value}. */
>>>>>>   public static final String DEFAULT_TEMPLATE = "default";
>>>>>>
>>>>>> -    /** Name of the file that contains the properties. */
>>>>>> -    public static final String PROPERTYFILE =
>>>>>> "template.properties";
>>>>>> -
>>>>>> -    /** I18N string to mark the default locale */
>>>>>> -    public static final String I18NDEFAULT_LOCALE =
>>>>> "prefs.user.language.default";
>>>>>> -
>>>>>> -    /**
>>>>>> -     * The name under which the resource includes map is stored
>>>>>> in the
>>>>>> -     * WikiContext.
>>>>>> -     */
>>>>>> -    public static final String RESOURCE_INCLUDES =
>>>>> "jspwiki.resourceincludes";
>>>>>> -
>>>>>> -    // private Cache m_propertyCache;
>>>>>> -
>>>>>>   protected static final Logger log = LoggerFactory.getLogger(
>>>>> TemplateManager.class );
>>>>>>
>>>>>> -    /** Requests a HTTP header. Value is {@value}. */
>>>>>> -    public static final String RESOURCE_HTTPHEADER = "httpheader";
>>>>>> -
>>>>>> -    private WikiEngine m_engine;
>>>>>> -
>>>>>> -    private static final List<WikiModuleInfo> EMPTY_MODULE_LIST =
>>>>> Collections.emptyList();
>>>>>> -
>>>>>>   /**
>>>>>>    * <p>Resolves requests for resources relative to the
>>>>>>    * <code>templates/<var>template</var></code> path to the actual
>>>>> resources,
>>>>>> @@ -125,8 +76,8 @@
>>>>>>    * for certain keys to return <code>null</code>. The map itself
>>>>>> is
>>>>>>    * immutable.
>>>>>>    * </p>
>>>>>> -     * <p>The resource resolver is guaranteed to initialize if the
>>>>> ServletContext
>>>>>> -     * is active, even if the WikiEngine cannot initialize for
>>>>>> some
>>>>> reason.
>>>>>> +     * <p>The resource resolver is guaranteed to initialize,
>>>>>> +     * even if the WikiEngine cannot initialize for some reason.
>>>>>>    * If the WikiEngine does not initialize, the default template
>>>>>>    * {@link #DEFAULT_TEMPLATE} will be used for all resource
>>>>> requests.</p>
>>>>>>    * @param servletContext the servlet context
>>>>>> @@ -156,10 +107,10 @@
>>>>>>
>>>>>>           // Add all of the resources the template contains
>>>>>>           resolver = new HashMap<String,String>();
>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>> "/" +
>>>>> template + "/", null );
>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>> + "/" +
>>>>> template + "/", null );
>>>>>>
>>>>>>           // Add resources the template does not contain, but
>>>>>> default
>>>>> does
>>>>>> -            addResources( context, resolver, "/" + DIRECTORY +
>>>>>> "/" +
>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>> +            addResources( context, resolver, "/" + TEMPLATE_DIR
>>>>>> + "/" +
>>>>> DEFAULT_TEMPLATE + "/", null );
>>>>>>           resolver = Collections.unmodifiableMap( resolver );
>>>>>>           context.setAttribute( RESOURCE_RESOLVER, resolver );
>>>>>>       }
>>>>>> @@ -167,18 +118,49 @@
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     * Creates a new TemplateManager. There is typically one
>>>>>> manager per
>>>>> engine.
>>>>>> -     *
>>>>>> -     * @param engine The owning engine.
>>>>>> -     * @param properties The property list used to initialize
>>>>>> this.
>>>>>> +     * Adds all of the resources under a specified path prefix
>>>>>> to the
>>>>>> +     * resource resolver map, with the "short name" of the path
>>>>>> as the
>>>>>> +     * key, and the full path as the value. The short name is the
>>>>> portion
>>>>>> +     * of the path after the prefix. If a resource with that
>>>>>> short name
>>>>>> +     * has already been added to the resource map, it will not
>>>>>> be added
>>>>>> +     * again. Any resources ending in {@code /} (i.e., a
>>>>>> directory path)
>>>>>> +     * will be processed recursively.
>>>>>> +     * @param context the servlet context
>>>>>> +     * @param resolver the resource resolver map
>>>>>> +     * @param prefix the path prefix that the search initiates
>>>>>> from
>>>>>> +     * @param dir the directory to search relative to the path
>>>>>> prefix.
>>>>> If not
>>>>>> +     * supplied, the path prefix directory itself will be searched
>>>>>>    */
>>>>>> -    public TemplateManager( WikiEngine engine, Properties
>>>>>> properties )
>>>>>> +    @SuppressWarnings("unchecked")
>>>>>> +    private static void addResources( ServletContext context,
>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>>   {
>>>>>> -        super( engine );
>>>>>> -        m_engine = engine;
>>>>>> -        getResourceResolver( engine.getServletContext() );
>>>>>> -    }
>>>>>> +        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>> +        Set<String> resources = context.getResourcePaths(
>>>>>> searchPath );
>>>>>> +        if ( resources != null )
>>>>>> +        {
>>>>>> +            for ( String resource : resources )
>>>>>> +            {
>>>>>> +                String shortName = resource.substring(
>>>>>> prefix.length()
>>>>> );
>>>>>> +
>>>>>> +                // Directory: process these entries too
>>>>>> +                if ( shortName.endsWith( "/" ) )
>>>>>> +                {
>>>>>> +                    addResources( context, resolver, prefix,
>>>>>> shortName
>>>>> );
>>>>>> +                }
>>>>>>
>>>>>> +                // Regular resource: add it if we don't have it
>>>>>> already
>>>>>> +                else
>>>>>> +                {
>>>>>> +                    boolean alreadyProcessed =
>>>>>> resolver.containsKey(
>>>>> shortName );
>>>>>> +                    if ( !alreadyProcessed )
>>>>>> +                    {
>>>>>> +                        resolver.put( shortName, resource );
>>>>>> +                    }
>>>>>> +                }
>>>>>> +            }
>>>>>> +        }
>>>>>> +    }
>>>>>> +
>>>>>>   /**
>>>>>>    * Tries to locate a given resource from the template directory,
>>>>> relative to
>>>>>>    * the root of the JSPWiki webapp context (for example,
>>>>>> relative to
>>>>>> @@ -188,63 +170,62 @@
>>>>>>    * default template path either, <code>null</code> is returned.
>>>>>>    *
>>>>>>    *
>>>>>> -     * @param sContext the servlet context
>>>>>> +     * @param servletContext the servlet context
>>>>>>    * @param path the path to the resource; for example,
>>>>>> -     * <code>/templates/custom/FindContent.jsp</code>
>>>>>> +     * {@code /templates/custom/FindContent.jsp} or {@code
>>>>>> jspwiki.css}.
>>>>>> +     * If the path starts with a slash (/), the resource is
>>>>>> looked up
>>>>>> +     * relative to the webapp root
>>>>>>    * @return The name of the resource which was found; for example,
>>>>>>    * <code>/templates/custom/FindContent.jsp</code> (if it exists
>>>>>> in
>>>>> the
>>>>>>    * <code>custom</code> template directory), or
>>>>>>    * <code>/templates/default/FindContent.jsp</code> (if not)
>>>>>>    */
>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>> String
>>>>> path )
>>>>>> +    private static String findResource( ServletContext
>>>>>> servletContext,
>>>>> String path )
>>>>>>   {
>>>>>> -        InputStream is = sContext.getResourceAsStream( path );
>>>>>> -
>>>>>> -        if( is == null )
>>>>>> +        if( path.charAt( 0 ) == '/' )
>>>>>>       {
>>>>>> -            String defaultPath = makeFullJSPName(
>>>>>> DEFAULT_TEMPLATE,
>>>>> removeTemplatePart( path ) );
>>>>>> -            is = sContext.getResourceAsStream( defaultPath );
>>>>>> -
>>>>>> -            if( is != null )
>>>>>> -                path = defaultPath;
>>>>>> -            else
>>>>>> -                path = null;
>>>>>> -        }
>>>>>> -
>>>>>> -        if( is != null )
>>>>>> -        {
>>>>>> -            try
>>>>>> -            {
>>>>>> -                is.close();
>>>>>> -            }
>>>>>> -            catch( IOException e )
>>>>>> -            {
>>>>>> -            }
>>>>>> +            // This is already a full path
>>>>>> +            return findResource( servletContext, path );
>>>>>>       }
>>>>>> -
>>>>>> -        return path;
>>>>>> +        return getResourceResolver( servletContext ).get( path );
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     * Attempts to find a resource from the given template, and
>>>>>> if it's
>>>>> not
>>>>>> -     * found attempts to locate it from the default template.
>>>>>> -     *
>>>>>> -     * @param sContext
>>>>>> -     * @param template
>>>>>> -     * @param name
>>>>>> -     * @return
>>>>>> +     * Returns a property, as defined in the template. The
>>>>>> evaluation is
>>>>> lazy,
>>>>>> +     * i.e. the properties are not loaded until the template is
>>>>>> actually
>>>>> used
>>>>>> +     * for the first time.
>>>>>> +     */
>>>>>> +    /*
>>>>>> +     * public String getTemplateProperty( WikiContext context,
>>>>>> String
>>>>> key ) {
>>>>>> +     * String template = context.getTemplate(); try { Properties
>>>>>> props =
>>>>>> +     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>> if(
>>>>> props ==
>>>>>> +     * null ) { try { props = getTemplateProperties( template );
>>>>>> +     * m_propertyCache.putInCache( template, props ); } catch(
>>>>> IOException e ) {
>>>>>> +     * log.warn("IO Exception while reading template
>>>>>> properties",e);
>>>>> return
>>>>>> +     * null; } } return props.getProperty( key ); } catch(
>>>>> NeedsRefreshException
>>>>>> +     * ex ) { // FIXME return null; } }
>>>>>>    */
>>>>>> -    private static String findResource( ServletContext sContext,
>>>>>> String
>>>>> template, String name )
>>>>>> +    /**
>>>>>> +     * Returns an absolute path to a given template.
>>>>>> +     */
>>>>>> +    private static final String getPath( String template )
>>>>>>   {
>>>>>> -        if( name.charAt( 0 ) == '/' )
>>>>>> -        {
>>>>>> -            // This is already a full path
>>>>>> -            return findResource( sContext, name );
>>>>>> -        }
>>>>>> +        return "/" + TEMPLATE_DIR + "/" + template + "/";
>>>>>> +    }
>>>>>>
>>>>>> -        String fullname = makeFullJSPName( template, name );
>>>>>> +    private WikiEngine m_engine;
>>>>>>
>>>>>> -        return findResource( sContext, fullname );
>>>>>> +    /**
>>>>>> +     * Creates a new TemplateManager. There is typically one
>>>>>> manager per
>>>>> engine.
>>>>>> +     *
>>>>>> +     * @param engine The owning engine.
>>>>>> +     * @param properties The property list used to initialize
>>>>>> this.
>>>>>> +     */
>>>>>> +    public TemplateManager( WikiEngine engine, Properties
>>>>>> properties )
>>>>>> +    {
>>>>>> +        super( engine );
>>>>>> +        m_engine = engine;
>>>>>> +        getResourceResolver( engine.getServletContext() );
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> @@ -252,53 +233,17 @@
>>>>>>    * current context or by the absolute name.
>>>>>>    *
>>>>>>    * @param pageContext the JSP PageContext
>>>>>> -     * @param name The name of the JSP page to look for (e.g
>>>>>> "Wiki.jsp")
>>>>>> +     * @param name The name of the JSP page to look for (e.g
>>>>>> {@code
>>>>> Wiki.jsp})
>>>>>>    * @return The context path to the resource
>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>> (ServletContext)}
>>>>> instead
>>>>>>    */
>>>>>>   public String findJSP( PageContext pageContext, String name )
>>>>>>   {
>>>>>>       ServletContext sContext = pageContext.getServletContext();
>>>>>> -
>>>>>>       return findResource( sContext, name );
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     * Removes the template part of a name.
>>>>>> -     */
>>>>>> -    private static final String removeTemplatePart( String name )
>>>>>> -    {
>>>>>> -        int idx = 0;
>>>>>> -        if( name.startsWith( "/" ) )
>>>>>> -            idx = 1;
>>>>>> -
>>>>>> -        idx = name.indexOf( '/', idx );
>>>>>> -        if( idx != -1 )
>>>>>> -        {
>>>>>> -            idx = name.indexOf( '/', idx + 1 ); // Find second "/"
>>>>>> -
>>>>>> -            if( idx != -1 )
>>>>>> -            {
>>>>>> -                name = name.substring( idx + 1 );
>>>>>> -            }
>>>>>> -        }
>>>>>> -
>>>>>> -        log.info( "Final name = " + name );
>>>>>> -        return name;
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Returns the full name (/templates/foo/bar) for name=bar,
>>>>> template=foo.
>>>>>> -     *
>>>>>> -     * @param template The name of the template.
>>>>>> -     * @param name The name of the resource.
>>>>>> -     * @return The full name for a template.
>>>>>> -     */
>>>>>> -    private static final String makeFullJSPName( String
>>>>>> template, String
>>>>> name )
>>>>>> -    {
>>>>>> -        return "/" + DIRECTORY + "/" + template + "/" + name;
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>>    * Attempts to locate a resource under the given template. If
>>>>>> that
>>>>> template
>>>>>>    * does not exist, or the page does not exist under that
>>>>>> template,
>>>>> will
>>>>>>    * attempt to locate a similarly named file under the default
>>>>> template.
>>>>>> @@ -310,6 +255,7 @@
>>>>>>    * @param template From which template we should seek initially?
>>>>>>    * @param name Which resource are we looking for (e.g.
>>>>> "DefaultLayout.jsp")
>>>>>>    * @return path to the JSP page; null, if it was not found.
>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>> (ServletContext)}
>>>>> instead
>>>>>>    */
>>>>>>   public String findJSP( PageContext pageContext, String template,
>>>>> String name )
>>>>>>   {
>>>>>> @@ -319,8 +265,7 @@
>>>>>>                      + ((HttpServletRequest)
>>>>> pageContext.getRequest()).getRequestURI() + "'" );
>>>>>>           throw new InternalWikiException( "Illegal arguments to
>>>>> findJSP(); please check logs." );
>>>>>>       }
>>>>>> -
>>>>>> -        return findResource( pageContext.getServletContext(),
>>>>>> template,
>>>>> name );
>>>>>> +        return findResource( pageContext.getServletContext(),
>>>>>> name );
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> @@ -337,45 +282,23 @@
>>>>>>    * @param template the name of the template to use
>>>>>>    * @param name the name of the resource to fine
>>>>>>    * @return the path to the resource
>>>>>> +     * @deprecated use {@link #getResourceResolver
>>>>>> (ServletContext)}
>>>>> instead
>>>>>>    */
>>>>>>   public String findResource( WikiContext ctx, String template,
>>>>>> String
>>>>> name )
>>>>>>   {
>>>>>>       if( m_engine.getServletContext() != null )
>>>>>>       {
>>>>>> -            return findResource( m_engine.getServletContext(),
>>>>>> template,
>>>>> name );
>>>>>> +            return findResource( m_engine.getServletContext(),
>>>>>> name );
>>>>>>       }
>>>>>>
>>>>>>       return getPath( template ) + "/" + name;
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>> -     * Returns a property, as defined in the template. The
>>>>>> evaluation is
>>>>> lazy,
>>>>>> -     * i.e. the properties are not loaded until the template is
>>>>>> actually
>>>>> used
>>>>>> -     * for the first time.
>>>>>> -     */
>>>>>> -    /*
>>>>>> -     * public String getTemplateProperty( WikiContext context,
>>>>>> String
>>>>> key ) {
>>>>>> -     * String template = context.getTemplate(); try { Properties
>>>>>> props =
>>>>>> -     * (Properties)m_propertyCache.getFromCache( template, -1 );
>>>>>> if(
>>>>> props ==
>>>>>> -     * null ) { try { props = getTemplateProperties( template );
>>>>>> -     * m_propertyCache.putInCache( template, props ); } catch(
>>>>> IOException e ) {
>>>>>> -     * log.warn("IO Exception while reading template
>>>>>> properties",e);
>>>>> return
>>>>>> -     * null; } } return props.getProperty( key ); } catch(
>>>>> NeedsRefreshException
>>>>>> -     * ex ) { // FIXME return null; } }
>>>>>> -     */
>>>>>> -    /**
>>>>>> -     * Returns an absolute path to a given template.
>>>>>> -     */
>>>>>> -    private static final String getPath( String template )
>>>>>> -    {
>>>>>> -        return "/" + DIRECTORY + "/" + template + "/";
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Lists the skins available under this template. Returns an
>>>>>> empty
>>>>> Set, if
>>>>>> -     * there are no extra skins available. Note that this method
>>>>>> does
>>>>> not check
>>>>>> -     * whether there is anything actually in the directories, it
>>>>>> just
>>>>> lists
>>>>>> -     * them. This may change in the future.
>>>>>> +     * Lists the skins available under the current template.
>>>>>> +     * Returns an empty Set, if there are no extra skins
>>>>>> available.
>>>>>> +     * Note that this method does not check whether there is
>>>>>> anything
>>>>>> +     * actually in the directories, it just lists them.
>>>>>>    *
>>>>>>    * @param servletContext the servlet context
>>>>>>    * @param template The template to search
>>>>>> @@ -383,14 +306,14 @@
>>>>>>    * @since 2.3.26
>>>>>>    */
>>>>>>   @SuppressWarnings( "unchecked" )
>>>>>> -    public Set<String> listSkins( ServletContext servletContext,
>>>>>> String
>>>>> template )
>>>>>> +    public Set<String> listSkins()
>>>>>>   {
>>>>>> -        String place = makeFullJSPName( template,
>>>>>> SKIN_DIRECTORY );
>>>>>> -        Set<String> skinSet = servletContext.getResourcePaths(
>>>>>> place );
>>>>>> +        String skinPath = TEMPLATE_DIR + "/" + SKIN_DIR;
>>>>>> +        Set<String> skinSet =
>>>>> m_engine.getServletContext().getResourcePaths( skinPath );
>>>>>>       TreeSet<String> resultSet = new TreeSet<String>();
>>>>>>
>>>>>>       if( log.isDebugEnabled() )
>>>>>> -            log.debug( "Listings skins from " + place );
>>>>>> +            log.debug( "Listings skins from " + skinPath );
>>>>>>
>>>>>>       if( skinSet != null )
>>>>>>       {
>>>>>> @@ -414,215 +337,7 @@
>>>>>>
>>>>>>       return resultSet;
>>>>>>   }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Always returns a valid property map.
>>>>>> -     */
>>>>>> -    /*
>>>>>> -     * private Properties getTemplateProperties( String
>>>>>> templateName )
>>>>> throws
>>>>>> -     * IOException { Properties p = new Properties();
>>>>>> ServletContext
>>>>> context =
>>>>>> -     * m_engine.getServletContext(); InputStream propertyStream =
>>>>>> -     * context.getResourceAsStream(getPath(templateName)
>>>>>> +PROPERTYFILE);
>>>>> if(
>>>>>> -     * propertyStream != null ) { p.load( propertyStream );
>>>>>> -     * propertyStream.close(); } else { log.debug("Template
>>>>> '"+templateName+"'
>>>>>> -     * does not have a propertyfile '"+PROPERTYFILE+"'."); }
>>>>>> return p; }
>>>>>> -     */
>>>>>> -    /**
>>>>>> -     * Returns the include resources marker for a given type.
>>>>>> This is in
>>>>> a HTML
>>>>>> -     * or Javascript comment format.
>>>>>> -     *
>>>>>> -     * @param context the wiki context
>>>>>> -     * @param type the marker
>>>>>> -     * @return the generated marker comment
>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>> tags
>>>>> instead
>>>>>> -     */
>>>>>> -    public static String getMarker( WikiContext context, String
>>>>>> type )
>>>>>> -    {
>>>>>> -        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) )
>>>>>> -        {
>>>>>> -            return getJSLocalizedStrings( context );
>>>>>> -        }
>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>> -        {
>>>>>> -            return "/* INCLUDERESOURCES (" + type + ") */";
>>>>>> -        }
>>>>>> -        return "<!-- INCLUDERESOURCES (" + type + ") -->";
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Extract all i18n strings in the javascript domain.
>>>>>> (javascript.*)
>>>>> Returns
>>>>>> -     * a javascript snippet which defines the LoacalizedStings
>>>>>> array.
>>>>>> -     *
>>>>>> -     * @param wiki context
>>>>>> -     * @return Javascript snippet which defines the
>>>>>> LocaliedStrings
>>>>> array
>>>>>> -     * @since 2.5.108
>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>> tags
>>>>> instead
>>>>>> -     */
>>>>>> -    private static String getJSLocalizedStrings( WikiContext
>>>>>> context )
>>>>>> -    {
>>>>>> -        StringBuilder sb = new StringBuilder();
>>>>>> -
>>>>>> -        sb.append( "var LocalizedStrings = {\n" );
>>>>>> -
>>>>>> -        ResourceBundle rb = context.getBundle(
>>>>>> "templates.default" );
>>>>>> -
>>>>>> -        boolean first = true;
>>>>>> -
>>>>>> -        for( Enumeration<String> en = rb.getKeys();
>>>>> en.hasMoreElements(); )
>>>>>> -        {
>>>>>> -            String key = en.nextElement();
>>>>>> -
>>>>>> -            if( key.startsWith( "javascript" ) )
>>>>>> -            {
>>>>>> -                if( first )
>>>>>> -                {
>>>>>> -                    first = false;
>>>>>> -                }
>>>>>> -                else
>>>>>> -                {
>>>>>> -                    sb.append( ",\n" );
>>>>>> -                }
>>>>>> -                sb.append( "\"" + key + "\":\"" + rb.getString(
>>>>>> key ) +
>>>>> "\"" );
>>>>>> -            }
>>>>>> -        }
>>>>>> -        sb.append( "\n};\n" );
>>>>>> -
>>>>>> -        return(sb.toString());
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Adds a resource request to the current request context. The
>>>>> content will
>>>>>> -     * be added at the resource-type marker (see
>>>>>> IncludeResourcesTag) in
>>>>>> -     * WikiJSPFilter.
>>>>>> -     * <p>
>>>>>> -     * The resources can be of different types. For
>>>>>> RESOURCE_SCRIPT and
>>>>>> -     * RESOURCE_STYLESHEET this is an URI path to the resource
>>>>>> (a script
>>>>> file or
>>>>>> -     * an external stylesheet) that needs to be included. For
>>>>> RESOURCE_INLINECSS
>>>>>> -     * the resource should be something that can be added between
>>>>>> -     * &lt;style>&lt;/style> in the header file
>>>>>> (commonheader.jsp). For
>>>>>> -     * RESOURCE_JSFUNCTION it is the name of the Javascript
>>>>>> function
>>>>> that should
>>>>>> -     * be run at page load.
>>>>>> -     * <p>
>>>>>> -     * The IncludeResourceTag inserts code in the template
>>>>>> files, which
>>>>> is then
>>>>>> -     * filled by the WikiFilter after the request has been
>>>>>> rendered but
>>>>> not yet
>>>>>> -     * sent to the recipient.
>>>>>> -     * <p>
>>>>>> -     * Note that ALL resource requests get rendered, so this
>>>>>> method does
>>>>> not
>>>>>> -     * check if the request already exists in the resources.
>>>>>> Therefore,
>>>>> if you
>>>>>> -     * have a plugin which makes a new resource request every
>>>>>> time,
>>>>> you'll end
>>>>>> -     * up with multiple resource requests rendered. It's thus a
>>>>>> good
>>>>> idea to
>>>>>> -     * make this request only once during the page life cycle.
>>>>>> -     *
>>>>>> -     * @param ctx The current wiki context
>>>>>> -     * @param type What kind of a request should be added?
>>>>>> -     * @param resource The resource to add.
>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>> tags
>>>>> instead
>>>>>> -     */
>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>> -    public static void addResourceRequest( WikiContext ctx,
>>>>>> String type,
>>>>> String resource )
>>>>>> -    {
>>>>>> -        HashMap<String, Vector<String>> resourcemap =
>>>>>> (HashMap<String,
>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>> -
>>>>>> -        if( resourcemap == null )
>>>>>> -        {
>>>>>> -            resourcemap = new HashMap<String, Vector<String>>();
>>>>>> -        }
>>>>>> -
>>>>>> -        Vector<String> resources = resourcemap.get( type );
>>>>>> -
>>>>>> -        if( resources == null )
>>>>>> -        {
>>>>>> -            resources = new Vector<String>();
>>>>>> -        }
>>>>>> -
>>>>>> -        String resourceString = null;
>>>>>> -
>>>>>> -        if( type.equals( RESOURCE_SCRIPT ) )
>>>>>> -        {
>>>>>> -            resourceString = "<script type='text/javascript'
>>>>>> src='" +
>>>>> resource + "'></script>";
>>>>>> -        }
>>>>>> -        else if( type.equals( RESOURCE_STYLESHEET ) )
>>>>>> -        {
>>>>>> -            resourceString = "<link rel='stylesheet' type='text/
>>>>>> css'
>>>>> href='" + resource + "' />";
>>>>>> -        }
>>>>>> -        else if( type.equals( RESOURCE_INLINECSS ) )
>>>>>> -        {
>>>>>> -            resourceString = "<style type='text/css'>\n" +
>>>>>> resource +
>>>>> "\n</style>\n";
>>>>>> -        }
>>>>>> -        else if( type.equals( RESOURCE_JSFUNCTION ) )
>>>>>> -        {
>>>>>> -            resourceString = resource;
>>>>>> -        }
>>>>>> -        else if( type.equals( RESOURCE_HTTPHEADER ) )
>>>>>> -        {
>>>>>> -            resourceString = resource;
>>>>>> -        }
>>>>>> -
>>>>>> -        if( resourceString != null )
>>>>>> -        {
>>>>>> -            resources.add( resourceString );
>>>>>> -        }
>>>>>> -
>>>>>> -        log.debug( "Request to add a resource: " +
>>>>>> resourceString );
>>>>>> -
>>>>>> -        resourcemap.put( type, resources );
>>>>>> -        ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Returns resource requests for a particular type. If there
>>>>>> are no
>>>>>> -     * resources, returns an empty array.
>>>>>> -     *
>>>>>> -     * @param ctx WikiContext
>>>>>> -     * @param type The resource request type
>>>>>> -     * @return a String array for the resource requests
>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>> tags
>>>>> instead
>>>>>> -     */
>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>> -    public static String[] getResourceRequests( WikiContext ctx,
>>>>>> String
>>>>> type )
>>>>>> -    {
>>>>>> -        HashMap<String, Vector<String>> hm = (HashMap<String,
>>>>> Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
>>>>>> -
>>>>>> -        if( hm == null )
>>>>>> -            return new String[0];
>>>>>> -
>>>>>> -        Vector<String> resources = hm.get( type );
>>>>>> -
>>>>>> -        if( resources == null )
>>>>>> -            return new String[0];
>>>>>> -
>>>>>> -        String[] res = new String[resources.size()];
>>>>>> -
>>>>>> -        return resources.toArray( res );
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Returns all those types that have been requested so far.
>>>>>> -     *
>>>>>> -     * @param ctx the wiki context
>>>>>> -     * @return the array of types requested
>>>>>> -     * @deprecated use the Stripes <code>layout-component</code>
>>>>>> tags
>>>>> instead
>>>>>> -     */
>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>> -    public static String[] getResourceTypes( WikiContext ctx )
>>>>>> -    {
>>>>>> -        String[] res = new String[0];
>>>>>> -
>>>>>> -        if( ctx != null )
>>>>>> -        {
>>>>>> -            HashMap<String, String> hm = (HashMap<String, String>)
>>>>> ctx.getVariable( RESOURCE_INCLUDES );
>>>>>> -
>>>>>> -            if( hm != null )
>>>>>> -            {
>>>>>> -                Set<String> keys = hm.keySet();
>>>>>> -
>>>>>> -                res = keys.toArray( res );
>>>>>> -            }
>>>>>> -        }
>>>>>> -
>>>>>> -        return res;
>>>>>> -    }
>>>>>> -
>>>>>> +
>>>>>>   /**
>>>>>>    * Returns an empty collection, since at the moment the
>>>>> TemplateManager does
>>>>>>    * not manage any modules.
>>>>>> @@ -631,50 +346,6 @@
>>>>>>    */
>>>>>>   public Collection<WikiModuleInfo> modules()
>>>>>>   {
>>>>>> -        return EMPTY_MODULE_LIST;
>>>>>> -    }
>>>>>> -
>>>>>> -    /**
>>>>>> -     * Adds all of the resources under a specified path prefix
>>>>>> to the
>>>>>> -     * resource resolver map, with the "short name" of the path
>>>>>> as the
>>>>>> -     * key, and the full path as the value. The short name is the
>>>>> portion
>>>>>> -     * of the path after the prefix. If a resource with that
>>>>>> short name
>>>>>> -     * has already been added to the resource map, it will not
>>>>>> be added
>>>>>> -     * again. Any resources ending in {@code /} (i.e., a
>>>>>> directory path)
>>>>>> -     * will be processed recursively.
>>>>>> -     * @param context the servlet context
>>>>>> -     * @param resolver the resource resolver map
>>>>>> -     * @param prefix the path prefix that the search initiates
>>>>>> from
>>>>>> -     * @param dir the directory to search relative to the path
>>>>>> prefix.
>>>>> If not
>>>>>> -     * supplied, the path prefix directory itself will be searched
>>>>>> -     */
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>> -    private static void addResources( ServletContext context,
>>>>> Map<String,String> resolver, String prefix, String dir )
>>>>>> -    {
>>>>>> -        String searchPath = dir == null ? prefix : prefix + dir;
>>>>>> -        Set<String> resources = context.getResourcePaths(
>>>>>> searchPath );
>>>>>> -        if ( resources != null )
>>>>>> -        {
>>>>>> -            for ( String resource : resources )
>>>>>> -            {
>>>>>> -                String shortName = resource.substring(
>>>>>> prefix.length()
>>>>> );
>>>>>> -
>>>>>> -                // Directory: process these entries too
>>>>>> -                if ( shortName.endsWith( "/" ) )
>>>>>> -                {
>>>>>> -                    addResources( context, resolver, prefix,
>>>>>> shortName
>>>>> );
>>>>>> -                }
>>>>>> -
>>>>>> -                // Regular resource: add it if we don't have it
>>>>>> already
>>>>>> -                else
>>>>>> -                {
>>>>>> -                    boolean alreadyProcessed =
>>>>>> resolver.containsKey(
>>>>> shortName );
>>>>>> -                    if ( !alreadyProcessed )
>>>>>> -                    {
>>>>>> -                        resolver.put( shortName, resource );
>>>>>> -                    }
>>>>>> -                }
>>>>>> -            }
>>>>>> -        }
>>>>>> +        return Collections.emptyList();
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>> TemplateResolution.java
>>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/TemplateResolution.java?rev=917390&r1=917389&r2=917390&view=diff
>>>>>>
>>>>> ============
>>>>> ==================================================================
>>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>> TemplateResolution.java
>>>>> (original)
>>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/
>>>>> TemplateResolution.java
>>>>> Mon Mar  1 05:23:10 2010
>>>>>> @@ -22,6 +22,8 @@
>>>>>> {
>>>>>>   private static final Logger LOG = LoggerFactory.getLogger(
>>>>> TemplateResolution.class );
>>>>>>
>>>>>> +    private static final String DEFAULT_PATH_PREFIX = "/" +
>>>>> TemplateManager.TEMPLATE_DIR + "/" +
>>>>> TemplateManager.DEFAULT_TEMPLATE + "/";
>>>>>> +
>>>>>>   /**
>>>>>>    * Constructs a new TemplateResolution
>>>>>>    *
>>>>>> @@ -41,7 +43,7 @@
>>>>>>       String path = TemplateManager.getResourceResolver(
>>>>>> servletContext
>>>>> ).get( getPath() );
>>>>>>       if( path == null )
>>>>>>       {
>>>>>> -            path = "/templates/" +
>>>>>> TemplateManager.DEFAULT_TEMPLATE +
>>>>> "/" + getPath();
>>>>>> +            path = DEFAULT_PATH_PREFIX + getPath();
>>>>>>       }
>>>>>>       setPath( path );
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>