You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jspwiki.apache.org by Bob Paige <bo...@gmail.com> on 2008/07/09 02:02:53 UTC

create a new page from a template?

Jann,

Is there some way to create a new page from a template? I've discovered how
to set a small amount of text in the new page by appending it to the URL,
but a more versatile approach would be great.

I'm thinking something like
http://localhost:8080/trivinwiki/Edit.jsp?page=MyNewPage&template=NameOfTemplatePage

Could page filters do the trick? Are page filters called before the editor
is displayed for new pages? Then I could look for some parameter on the URL
to determine which page I should return as the template.

I tried stepping through the debugger and it doesn't look like filters can
be used in this way, but I thought I'd ask.

-- 
Bobman

Re: create a new page from a template?

Posted by Dirk Frederickx <di...@gmail.com>.
You could use cloning:

http://localhost:8080/trivinwiki/Edit.jsp?page=MyNewPage&clone=NameOfTemplatePage



dirk

On Wed, Jul 9, 2008 at 2:02 AM, Bob Paige <bo...@gmail.com> wrote:
> Jann,
>
> Is there some way to create a new page from a template? I've discovered how
> to set a small amount of text in the new page by appending it to the URL,
> but a more versatile approach would be great.
>
> I'm thinking something like
> http://localhost:8080/trivinwiki/Edit.jsp?page=MyNewPage&template=NameOfTemplatePage
>
> Could page filters do the trick? Are page filters called before the editor
> is displayed for new pages? Then I could look for some parameter on the URL
> to determine which page I should return as the template.
>
> I tried stepping through the debugger and it doesn't look like filters can
> be used in this way, but I thought I'd ask.
>
> --
> Bobman
>

Re: create a new page from a template?

Posted by Murray Altheim <mu...@altheim.com>.
Bob Paige wrote:
> Murray,
> 
> I'm looking at your site, but I'm not finding the sources :)
> 
> Can you give me a pointer?

That particular snippet can be found in the HelloWorld or GroovyPlugin.
Almost all of the CeryleWikiPlugins are currently in one big jar file,
see

    http://purl.org/ceryle/wiki/Wiki.jsp?page=CeryleWikiPlugins

Bottom of the page lists the available distributions, the latest is
ceryle-wikiutil-src-1.0a12-20070216.jar.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: create a new page from a template?

Posted by Bob Paige <bo...@gmail.com>.
Murray,

I'm looking at your site, but I'm not finding the sources :)

Can you give me a pointer?

-- 
Bobman

On Tue, Jul 8, 2008 at 8:38 PM, Murray Altheim <mu...@altheim.com> wrote:

> Bob Paige wrote:
>
>> Jann,
>>
>> Is there some way to create a new page from a template? I've discovered
>> how
>> to set a small amount of text in the new page by appending it to the URL,
>> but a more versatile approach would be great.
>>
>> I'm thinking something like
>>
>> http://localhost:8080/trivinwiki/Edit.jsp?page=MyNewPage&template=NameOfTemplatePage
>>
>> Could page filters do the trick? Are page filters called before the editor
>> is displayed for new pages? Then I could look for some parameter on the
>> URL
>> to determine which page I should return as the template.
>>
>> I tried stepping through the debugger and it doesn't look like filters can
>> be used in this way, but I thought I'd ask.
>>
>
> Bob,
>
> Check out the NewPageHandler, part of the FormPlugin:
>
>  http://www.altheim.com/ceryle/wiki/Wiki.jsp?page=FormPlugin
>
> javadoc:
>
>
> http://www.altheim.com/ceryle/api/org/ceryle/wiki/handler/NewPageHandler.html
>
> Even if you don't use the form you can likely use the handler (it is
> itself a WikiPlugin).
>
> I think you've already mentioned this, but permitting users to
> programmatically create pages could be a security nightmare.
>
> Murray
>
> ...........................................................................
> Murray Altheim <murray07 at altheim.com>                           ===  =
> =
> http://www.altheim.com/murray/                                     = =
>  ===
> SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =
>
>      Boundless wind and moon - the eye within eyes,
>      Inexhaustible heaven and earth - the light beyond light,
>      The willow dark, the flower bright - ten thousand houses,
>      Knock at any door - there's one who will respond.
>                                      -- The Blue Cliff Record
>

Re: create a new page from a template?

Posted by Murray Altheim <mu...@altheim.com>.
Bob Paige wrote:
> Thanks for the pointer; I will look at that.
> 
> As far as security, I can imagine someone might try to view a page they
> otherwise don't have access to by creating a 'clone' of it (as Dirk
> suggests; I like that terminology, BTW). But isn't it possible to check the
> permissions for the original page within the plugin? I think I've seen that
> in the code I've been looking at so far.

Yes,

Here's some code for checking authentication:

     protected boolean CHECK_AUTHENTICATION = true;
     ...

     boolean authenticated = CHECK_AUTHENTICATION
             ? engine.getAuthorizationManager().isUserInRole(
                 context.getWikiSession(),Role.AUTHENTICATED)
             : true;

You can adapt this as needed for different roles.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: create a new page from a template?

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
You could try using the "htmltext" parameter to initialize the editor  
in case you're using e.g. FCK.

/Janne

On Mar 12, 2009, at 19:47 , Bob Paige wrote:

> (Reviving an old thread)
>
> We are using the "clone" feature described in this thread, but just  
> realized
> that it only works for the "plain" text editor, not the other ones.  
> Is there
> some way to either force the page to be saved before it is opened in  
> the
> editor, or to force the user to use the text editor just for that  
> one page?
> Some option on the URL, perhaps?
>
> -- 
> Bobman
>
> On Thu, Jul 10, 2008 at 9:19 AM, Murray Altheim  
> <mu...@altheim.com>wrote:
>
>> Bob Paige wrote:
>>
>>> Found the answer myself: http://www.jspwiki.org/wiki/NewPageHandler
>>>
>>> Jann (strongly) suggests we use the  
>>> VariableManager.expandVariables()
>>> call,
>>> which is just what I was looking for.
>>>
>>
>> Bob,
>>
>> In my previous reply* I provided a link to the NewPageHandler that is
>> part of the CeryleWikiPlugins.
>>
>>  http://purl.org/ceryle/wiki/Wiki.jsp?page=CeryleWikiPlugins
>>
>> This includes the NewPageHandler. The page on jspwiki.org is about
>> the outdated version that was part of the McKessonPlugins donated
>> by John Volkar to the CeryleWikiPlugins (as it states on that page in
>> an Information balloon). It's the same thing.
>>
>> Murray
>>
>> * Date: Wed, 09 Jul 2008 12:38:47 +1200
>> Message-ID: <48...@altheim.com>
>>
>> ...........................................................................
>> Murray Altheim <murray07 at altheim.com>                            
>> ===  =
>> =
>> http://www.altheim.com/murray/                                      
>> = =
>> ===
>> SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk                
>> = =  = =
>>
>>     Boundless wind and moon - the eye within eyes,
>>     Inexhaustible heaven and earth - the light beyond light,
>>     The willow dark, the flower bright - ten thousand houses,
>>     Knock at any door - there's one who will respond.
>>                                     -- The Blue Cliff Record
>>


Re: create a new page from a template?

Posted by Bob Paige <bo...@gmail.com>.
(Reviving an old thread)

We are using the "clone" feature described in this thread, but just realized
that it only works for the "plain" text editor, not the other ones. Is there
some way to either force the page to be saved before it is opened in the
editor, or to force the user to use the text editor just for that one page?
Some option on the URL, perhaps?

-- 
Bobman

On Thu, Jul 10, 2008 at 9:19 AM, Murray Altheim <mu...@altheim.com>wrote:

> Bob Paige wrote:
>
>> Found the answer myself: http://www.jspwiki.org/wiki/NewPageHandler
>>
>> Jann (strongly) suggests we use the VariableManager.expandVariables()
>> call,
>> which is just what I was looking for.
>>
>
> Bob,
>
> In my previous reply* I provided a link to the NewPageHandler that is
> part of the CeryleWikiPlugins.
>
>   http://purl.org/ceryle/wiki/Wiki.jsp?page=CeryleWikiPlugins
>
> This includes the NewPageHandler. The page on jspwiki.org is about
> the outdated version that was part of the McKessonPlugins donated
> by John Volkar to the CeryleWikiPlugins (as it states on that page in
> an Information balloon). It's the same thing.
>
> Murray
>
> * Date: Wed, 09 Jul 2008 12:38:47 +1200
>  Message-ID: <48...@altheim.com>
>
> ...........................................................................
> Murray Altheim <murray07 at altheim.com>                           ===  =
> =
> http://www.altheim.com/murray/                                     = =
>  ===
> SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =
>
>      Boundless wind and moon - the eye within eyes,
>      Inexhaustible heaven and earth - the light beyond light,
>      The willow dark, the flower bright - ten thousand houses,
>      Knock at any door - there's one who will respond.
>                                      -- The Blue Cliff Record
>

Re: create a new page from a template?

Posted by Murray Altheim <mu...@altheim.com>.
Bob Paige wrote:
> Found the answer myself: http://www.jspwiki.org/wiki/NewPageHandler
> 
> Jann (strongly) suggests we use the VariableManager.expandVariables() call,
> which is just what I was looking for.

Bob,

In my previous reply* I provided a link to the NewPageHandler that is
part of the CeryleWikiPlugins.

    http://purl.org/ceryle/wiki/Wiki.jsp?page=CeryleWikiPlugins

This includes the NewPageHandler. The page on jspwiki.org is about
the outdated version that was part of the McKessonPlugins donated
by John Volkar to the CeryleWikiPlugins (as it states on that page in
an Information balloon). It's the same thing.

Murray

* Date: Wed, 09 Jul 2008 12:38:47 +1200
   Message-ID: <48...@altheim.com>
...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record

Re: create a new page from a template?

Posted by Bob Paige <bo...@gmail.com>.
Found the answer myself: http://www.jspwiki.org/wiki/NewPageHandler

Jann (strongly) suggests we use the VariableManager.expandVariables() call,
which is just what I was looking for.

-- 
Bobman

On Thu, Jul 10, 2008 at 8:23 AM, Bob Paige <bo...@gmail.com> wrote:

> Dirk,
>
> This is just what I was looking for.
>
> Related question: I'm doing some other work with page variables, but it
> appears the page variables are not evaluated when you clone a page. I see
> how page cloning is implemented in the plain.jsp page; is there a simple
> call I can make into the wiki engine to have it evaluate page variables on
> the raw page?
>
> --
> Bobman
>
>
> On Thu, Jul 10, 2008 at 4:02 AM, Dirk Frederickx <
> dirk.frederickx@gmail.com> wrote:
>
>> Cloning is just build in the plain.jsp, it is not a plugin.
>> It was added with the inclusing of the BrushedTemplate.
>> (ref. http://www.jspwiki.org/wiki/BrushedTemplateClonePage)
>>
>>
>>
>> dirk
>>
>> On Thu, Jul 10, 2008 at 3:01 AM, Bob Paige <bo...@gmail.com> wrote:
>> > Is cloning a new feature in JSPWiki, or a plugin? I'm using 2.6.3.
>> >
>> > --
>> > Bobman
>> >
>> > On Wed, Jul 9, 2008 at 2:43 PM, Dirk Frederickx <
>> dirk.frederickx@gmail.com>
>> > wrote:
>> >
>> >> > As far as security, I can imagine someone might try to view a page
>> they
>> >> > otherwise don't have access to by creating a 'clone' of it (as Dirk
>> >> > suggests; I like that terminology, BTW). But isn't it possible to
>> check
>> >> the
>> >> > permissions for the original page within the plugin? I think I've
>> seen
>> >> that
>> >> > in the code I've been looking at so far.
>> >>
>> >> Good point! I need to add e permission check around the cloning
>> >> functionality (next commit)
>> >> Here is how you can do it yourself :
>> >>
>> >>
>> >>  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 );*/ }
>> >>    }
>> >>  }
>> >>
>> >> dirk
>> >>
>> >
>>
>
>

Re: create a new page from a template?

Posted by Bob Paige <bo...@gmail.com>.
Dirk,

This is just what I was looking for.

Related question: I'm doing some other work with page variables, but it
appears the page variables are not evaluated when you clone a page. I see
how page cloning is implemented in the plain.jsp page; is there a simple
call I can make into the wiki engine to have it evaluate page variables on
the raw page?

-- 
Bobman

On Thu, Jul 10, 2008 at 4:02 AM, Dirk Frederickx <di...@gmail.com>
wrote:

> Cloning is just build in the plain.jsp, it is not a plugin.
> It was added with the inclusing of the BrushedTemplate.
> (ref. http://www.jspwiki.org/wiki/BrushedTemplateClonePage)
>
>
>
> dirk
>
> On Thu, Jul 10, 2008 at 3:01 AM, Bob Paige <bo...@gmail.com> wrote:
> > Is cloning a new feature in JSPWiki, or a plugin? I'm using 2.6.3.
> >
> > --
> > Bobman
> >
> > On Wed, Jul 9, 2008 at 2:43 PM, Dirk Frederickx <
> dirk.frederickx@gmail.com>
> > wrote:
> >
> >> > As far as security, I can imagine someone might try to view a page
> they
> >> > otherwise don't have access to by creating a 'clone' of it (as Dirk
> >> > suggests; I like that terminology, BTW). But isn't it possible to
> check
> >> the
> >> > permissions for the original page within the plugin? I think I've seen
> >> that
> >> > in the code I've been looking at so far.
> >>
> >> Good point! I need to add e permission check around the cloning
> >> functionality (next commit)
> >> Here is how you can do it yourself :
> >>
> >>
> >>  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 );*/ }
> >>    }
> >>  }
> >>
> >> dirk
> >>
> >
>

Re: create a new page from a template?

Posted by Dirk Frederickx <di...@gmail.com>.
Cloning is just build in the plain.jsp, it is not a plugin.
It was added with the inclusing of the BrushedTemplate.
(ref. http://www.jspwiki.org/wiki/BrushedTemplateClonePage)



dirk

On Thu, Jul 10, 2008 at 3:01 AM, Bob Paige <bo...@gmail.com> wrote:
> Is cloning a new feature in JSPWiki, or a plugin? I'm using 2.6.3.
>
> --
> Bobman
>
> On Wed, Jul 9, 2008 at 2:43 PM, Dirk Frederickx <di...@gmail.com>
> wrote:
>
>> > As far as security, I can imagine someone might try to view a page they
>> > otherwise don't have access to by creating a 'clone' of it (as Dirk
>> > suggests; I like that terminology, BTW). But isn't it possible to check
>> the
>> > permissions for the original page within the plugin? I think I've seen
>> that
>> > in the code I've been looking at so far.
>>
>> Good point! I need to add e permission check around the cloning
>> functionality (next commit)
>> Here is how you can do it yourself :
>>
>>
>>  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 );*/ }
>>    }
>>  }
>>
>> dirk
>>
>

Re: create a new page from a template?

Posted by Bob Paige <bo...@gmail.com>.
Is cloning a new feature in JSPWiki, or a plugin? I'm using 2.6.3.

-- 
Bobman

On Wed, Jul 9, 2008 at 2:43 PM, Dirk Frederickx <di...@gmail.com>
wrote:

> > As far as security, I can imagine someone might try to view a page they
> > otherwise don't have access to by creating a 'clone' of it (as Dirk
> > suggests; I like that terminology, BTW). But isn't it possible to check
> the
> > permissions for the original page within the plugin? I think I've seen
> that
> > in the code I've been looking at so far.
>
> Good point! I need to add e permission check around the cloning
> functionality (next commit)
> Here is how you can do it yourself :
>
>
>  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 );*/ }
>    }
>  }
>
> dirk
>

Re: create a new page from a template?

Posted by Dirk Frederickx <di...@gmail.com>.
> As far as security, I can imagine someone might try to view a page they
> otherwise don't have access to by creating a 'clone' of it (as Dirk
> suggests; I like that terminology, BTW). But isn't it possible to check the
> permissions for the original page within the plugin? I think I've seen that
> in the code I've been looking at so far.

Good point! I need to add e permission check around the cloning
functionality (next commit)
Here is how you can do it yourself :


  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 );*/ }
    }
  }

dirk

Re: create a new page from a template?

Posted by Bob Paige <bo...@gmail.com>.
Thanks for the pointer; I will look at that.

As far as security, I can imagine someone might try to view a page they
otherwise don't have access to by creating a 'clone' of it (as Dirk
suggests; I like that terminology, BTW). But isn't it possible to check the
permissions for the original page within the plugin? I think I've seen that
in the code I've been looking at so far.

-- 
Bobman

On Tue, Jul 8, 2008 at 8:38 PM, Murray Altheim <mu...@altheim.com> wrote:

> Bob Paige wrote:
>
>> Jann,
>>
>> Is there some way to create a new page from a template? I've discovered
>> how
>> to set a small amount of text in the new page by appending it to the URL,
>> but a more versatile approach would be great.
>>
>> I'm thinking something like
>>
>> http://localhost:8080/trivinwiki/Edit.jsp?page=MyNewPage&template=NameOfTemplatePage
>>
>> Could page filters do the trick? Are page filters called before the editor
>> is displayed for new pages? Then I could look for some parameter on the
>> URL
>> to determine which page I should return as the template.
>>
>> I tried stepping through the debugger and it doesn't look like filters can
>> be used in this way, but I thought I'd ask.
>>
>
> Bob,
>
> Check out the NewPageHandler, part of the FormPlugin:
>
>  http://www.altheim.com/ceryle/wiki/Wiki.jsp?page=FormPlugin
>
> javadoc:
>
>
> http://www.altheim.com/ceryle/api/org/ceryle/wiki/handler/NewPageHandler.html
>
> Even if you don't use the form you can likely use the handler (it is
> itself a WikiPlugin).
>
> I think you've already mentioned this, but permitting users to
> programmatically create pages could be a security nightmare.
>
> Murray
>
> ...........................................................................
> Murray Altheim <murray07 at altheim.com>                           ===  =
> =
> http://www.altheim.com/murray/                                     = =
>  ===
> SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =
>
>      Boundless wind and moon - the eye within eyes,
>      Inexhaustible heaven and earth - the light beyond light,
>      The willow dark, the flower bright - ten thousand houses,
>      Knock at any door - there's one who will respond.
>                                      -- The Blue Cliff Record
>

Re: create a new page from a template?

Posted by Murray Altheim <mu...@altheim.com>.
Bob Paige wrote:
> Jann,
> 
> Is there some way to create a new page from a template? I've discovered how
> to set a small amount of text in the new page by appending it to the URL,
> but a more versatile approach would be great.
> 
> I'm thinking something like
> http://localhost:8080/trivinwiki/Edit.jsp?page=MyNewPage&template=NameOfTemplatePage
> 
> Could page filters do the trick? Are page filters called before the editor
> is displayed for new pages? Then I could look for some parameter on the URL
> to determine which page I should return as the template.
> 
> I tried stepping through the debugger and it doesn't look like filters can
> be used in this way, but I thought I'd ask.

Bob,

Check out the NewPageHandler, part of the FormPlugin:

   http://www.altheim.com/ceryle/wiki/Wiki.jsp?page=FormPlugin

javadoc:

   http://www.altheim.com/ceryle/api/org/ceryle/wiki/handler/NewPageHandler.html

Even if you don't use the form you can likely use the handler (it is
itself a WikiPlugin).

I think you've already mentioned this, but permitting users to
programmatically create pages could be a security nightmare.

Murray

...........................................................................
Murray Altheim <murray07 at altheim.com>                           ===  = =
http://www.altheim.com/murray/                                     = =  ===
SGML Grease Monkey, Banjo Player, Wantanabe Zen Monk               = =  = =

       Boundless wind and moon - the eye within eyes,
       Inexhaustible heaven and earth - the light beyond light,
       The willow dark, the flower bright - ten thousand houses,
       Knock at any door - there's one who will respond.
                                       -- The Blue Cliff Record