incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janne Jalkanen <janne.jalka...@ecyrd.com>
Subject 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/
Date Fri, 05 Mar 2010 07:47:22 GMT

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
> <janne.jalkanen@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
>>>> <andrew.r.jaquith@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 <janne.jalkanen@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 <janne.jalkanen@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
>>>>>>>>> <janne.jalkanen@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 <brushed@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 );
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>> 
>> 
>> 


Mime
View raw message