You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jspwiki.apache.org by Brian Burch <br...@PingToo.com> on 2009/04/08 18:25:29 UTC
Wiki Page Name and Wiki Page Heading
I am still working on my new PhotoCollection plugin. Thanks to Janne's
previous help, I have an ugly version working and am trying to improve
its appearance before making it generally available.
Because my design accesses an external directory tree (and might access
more than one in a future version), I need to generate wiki page names
that are very likely to be unique, which means they tend to be a bit
long-winded because they carry a lot of the file system path,
e.g. FilesPictures2008_04-franceDSCF1234.JPG
One of the most valuable features of my plugin is that users can add
text information to each directory and image, but even if they add
nothing the page titles will automatically provide valuable search
criteria, e.g. what photos did I take in my several visits to France?
My plugin already has the logic to generate these "probably unique" wiki
page names, but it also creates "human friendly" titles for the pages,
which are not intended to be unique at all,
e.g. Photos 2008 04-france DSCF1234.JPG
I've been trying hard to follow the jspWiki execution sequence starting
from Edit.jsp and referring to JSPWikiForDummies. I can see how it
achieves something similar to what I want to do....
<meta name="wikiEditUrl" content='/Edit.jsp?page=JSPWikiForDummies' />
and
<div class="pagename">JSP Wiki For Dummies</div>
This is controlled by the jspwiki.properties value for
jspwiki.breakTitleWithSpaces, but I want to use my own logic rather than
this "standard" mapping.
I have a (more-or-less) camelcase wiki page name and I want to assign a
different (human-friendly, non-unique) page title when creating the new
page.
My plugin running under the "parent page" generates the appropriate wiki
text of the "child" page plugin and inserts it into the url via the
_editedtext (undocumented) servlet parameter.
When the new "child" wiki page is saved, my plugin generates its own
friendly title.
1. I could store the friendly title as a page variable, e.g. called
friendlyPageName.
2. I could clone Header.jsp to create my own localheader.jsp, but
substitute the line:
<div class="pagename"><wiki:PageName /></div>
with something like this:
<div class="pagename"><wiki:Variable var="friendlyPageName"
default="pagename" /></div>
The intention is to allow the normal breakTitleWithSpaces behaviour to
occur with any page that does not embed this particular plugin. Would
this solution work, or have I overlooked something important?
Can anyone save me some time with an opinion? I'll get there in the end,
but jspWiki is so complex that it takes me ages to grasp how even quite
simple things happen (sorry!).
Brian
Re: Wiki Page Name and Wiki Page Heading
Posted by Andrew Jaquith <an...@gmail.com>.
Brian, the most "portable" way to do this would be to create your own
.tld file, then add it to the META-INF directory inside the JAR file
that contains your custom tags, for example using the Ant <metainf>
target.
Then, in your JSPs, just make sure you import your tag library by the
URI defined in your .tld file.
So in your .tld file you'd have a declaration like this...
<taglib>
...
<uri>http://www.pingtoo.com/brian.tld</uri>
...and the import would look like this:
<%@ taglib uri="http://www.pingtoo.com/brian.tld" prefix="b" %>
This is definitely the best way, because you won't have to hack up the
jspwiki.tld file, and it keeps your .tld with your custom classes.
Andrew
On Thu, Apr 9, 2009 at 2:38 AM, Janne Jalkanen <ja...@ecyrd.com> wrote:
>> I feel somewhat constrained because I am working with a submitted plugin
>> which is not intended to be packaged as part of jspWiki. It is part of my
>> own namespace at the moment, copied into WEB-INF/lib and loaded via
>> jspwiki.plugin.searchpath. I haven't worked with tags before, but I can see
>> that the standard set are all defined in WEB-INF/jspwiki.tld. If I were to
>> add my own tag definition to WEB-INF/jspwiki.tld, do you think the same
>> ClassLoader that loads my plugin from my own jar would also be find my
>> custom tag in the same jar?
>
> Yup, that should work perfectly!
>
> /Janne
>
Re: Wiki Page Name and Wiki Page Heading
Posted by Janne Jalkanen <ja...@ecyrd.com>.
> I feel somewhat constrained because I am working with a submitted
> plugin which is not intended to be packaged as part of jspWiki. It
> is part of my own namespace at the moment, copied into WEB-INF/lib
> and loaded via jspwiki.plugin.searchpath. I haven't worked with tags
> before, but I can see that the standard set are all defined in WEB-
> INF/jspwiki.tld. If I were to add my own tag definition to WEB-INF/
> jspwiki.tld, do you think the same ClassLoader that loads my plugin
> from my own jar would also be find my custom tag in the same jar?
Yup, that should work perfectly!
/Janne
Re: Wiki Page Name and Wiki Page Heading
Posted by Brian Burch <br...@PingToo.com>.
Janne Jalkanen wrote:
>
> The quick solution would probably be for you to extend PageNameTag to
> provide your own prettification routine, if the page name appears to be
> a part of your photo collection. Then you can use your own tag in the
> template, or you can replace the regular PageNameTag by editing
> jspwiki.tld.
>
> And hey, that's why this list is for - no large software project can be
> grasped easily, so it's good to have a place where you can ask stuff ;-)
Thanks, Janne, for both the quick tip and also the encouragement.
I had already thought about extending PageNameTag with my own
PrettyPageNameTag while I was researching my question. It certainly
seems the most natural solution to my problem, but I was nervous about
getting the execution environment right.
I feel somewhat constrained because I am working with a submitted plugin
which is not intended to be packaged as part of jspWiki. It is part of
my own namespace at the moment, copied into WEB-INF/lib and loaded via
jspwiki.plugin.searchpath. I haven't worked with tags before, but I can
see that the standard set are all defined in WEB-INF/jspwiki.tld. If I
were to add my own tag definition to WEB-INF/jspwiki.tld, do you think
the same ClassLoader that loads my plugin from my own jar would also be
find my custom tag in the same jar?
Brian
Re: Wiki Page Name and Wiki Page Heading
Posted by Janne Jalkanen <ja...@ecyrd.com>.
The quick solution would probably be for you to extend PageNameTag to
provide your own prettification routine, if the page name appears to
be a part of your photo collection. Then you can use your own tag in
the template, or you can replace the regular PageNameTag by editing
jspwiki.tld.
And hey, that's why this list is for - no large software project can
be grasped easily, so it's good to have a place where you can ask
stuff ;-)
/Janne
On 8 Apr 2009, at 19:25, Brian Burch wrote:
> I am still working on my new PhotoCollection plugin. Thanks to
> Janne's previous help, I have an ugly version working and am trying
> to improve its appearance before making it generally available.
>
> Because my design accesses an external directory tree (and might
> access more than one in a future version), I need to generate wiki
> page names that are very likely to be unique, which means they tend
> to be a bit long-winded because they carry a lot of the file system
> path,
>
> e.g. FilesPictures2008_04-franceDSCF1234.JPG
>
> One of the most valuable features of my plugin is that users can add
> text information to each directory and image, but even if they add
> nothing the page titles will automatically provide valuable search
> criteria, e.g. what photos did I take in my several visits to France?
>
> My plugin already has the logic to generate these "probably unique"
> wiki page names, but it also creates "human friendly" titles for the
> pages, which are not intended to be unique at all,
>
> e.g. Photos 2008 04-france DSCF1234.JPG
>
> I've been trying hard to follow the jspWiki execution sequence
> starting from Edit.jsp and referring to JSPWikiForDummies. I can see
> how it achieves something similar to what I want to do....
>
> <meta name="wikiEditUrl" content='/Edit.jsp?page=JSPWikiForDummies' />
>
> and
>
> <div class="pagename">JSP Wiki For Dummies</div>
>
> This is controlled by the jspwiki.properties value for
> jspwiki.breakTitleWithSpaces, but I want to use my own logic rather
> than this "standard" mapping.
>
> I have a (more-or-less) camelcase wiki page name and I want to
> assign a different (human-friendly, non-unique) page title when
> creating the new page.
>
> My plugin running under the "parent page" generates the appropriate
> wiki text of the "child" page plugin and inserts it into the url via
> the _editedtext (undocumented) servlet parameter.
>
> When the new "child" wiki page is saved, my plugin generates its own
> friendly title.
>
> 1. I could store the friendly title as a page variable, e.g. called
> friendlyPageName.
>
> 2. I could clone Header.jsp to create my own localheader.jsp, but
> substitute the line:
>
> <div class="pagename"><wiki:PageName /></div>
>
> with something like this:
>
> <div class="pagename"><wiki:Variable var="friendlyPageName"
> default="pagename" /></div>
>
> The intention is to allow the normal breakTitleWithSpaces behaviour
> to occur with any page that does not embed this particular plugin.
> Would this solution work, or have I overlooked something important?
>
> Can anyone save me some time with an opinion? I'll get there in the
> end, but jspWiki is so complex that it takes me ages to grasp how
> even quite simple things happen (sorry!).
>
> Brian