incubator-jspwiki-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jukka Karvanen <jukka.karva...@iki.fi>
Subject JSPWiki clone Template with Variables
Date Thu, 28 May 2009 06:19:20 GMT
Hi All,

I have used JSPWiki 2.8 version for a while and I am not familiar with 
3.0 features and development status. I decided to check first with email 
before doing any further investigations.

I am not sure is it possible to do same thing other way in 3.0 version. 
I checked that the modified files still exist in 3.0, but I am not sure 
are those working same way.

Need:
Make end user easier to create consistent wiki pages with template page 
with variables.

I found the clone feature, but I did not find similar variable expansion 
as for example in TWiki.

After modifcation with a couple of lines of extra code, I can call 
Edit.jsp with variables expanded in new clone page.
Edit.jsp?page=Notes%20Db%20View%20times&clone=DefaultNote&expand=true&backpage=Db%20View%20times

So I can create this kind of links in my pages:
[{InsertPage page='Notes Db View times'},default=
'Auto-generated page. Add description and comments to page <a 
href="Edit.jsp?page=Notes Db View 
times&clone=DefaultNote&expand=true&backpage=Db View times"\>Notes Db 
View times</a>'}]

Content of page file Defaultnote.txt:
![{$backpage}]
[Edit:{$pagename}]
----



Modified files FCK.jsp and plain.jsp:

--------------
...
<%
  String clone = request.getParameter( "clone" );
  if( clone != null )
  {
    WikiPage p = engine.getPage( clone );
    if( p != null )
    {
        AuthorizationManager mgr = engine.getAuthorizationManager();
        PagePermission pp = new PagePermission( p, 
PagePermission.VIEW_ACTION );

        try
        {           
          if( mgr.checkPermission( context.getWikiSession(), pp ) )
          {
            usertext = engine.getPureText( p );
          }
        }
        catch( Exception e ) {  /*log.error( "Accessing clone page 
"+clone, e );*/ }
//**********************************************************//
        //Adding parameter expand to url with clone variables like 
{$pagename},... are expanded
        //Note variables are plain {$name} without []-characters
        //by Jukka Karvanen
        String expand = request.getParameter( "expand" );
        if( expand != null )
        {
          usertext=engine.getVariableManager().expandVariables(context 
,usertext);
        }
//**********************************************************//
    }
  }
%>

-------

What you think is this feasible also for 3.0 version?

Jukka


Mime
View raw message