Hey Murray, take a look at:
CeryleWikiPlugins\src\org\ceryle\wiki\plugin\Include.java
It's just like InsertPage, but evaluates the wikitext content of the
included page in the context of the plugin containing page.
So page variable references and plugins on the included page will show
values as though they were on the *calling* page.
I use this as a poor mans templating device...
/**
* Almost exactly like the InsertPage plugin <b>except</b> that the
'foreign' page's wiki text is
* evaluated in the context of the current page.
* <p>
* References to attachments, footnotes, etc will try to link to the
same name on the current page
* (though the 'real' target for the original refernece was on the
'foreign' page, and might not
* exist on the current one).
* <p>
* So why 'Include' instead of 'Insert', well, Including allows queries
that are defined on the
* foreign page which use the [.] (this-page notation) to work properly.
* <p>
* Trivial example, [{Include Backlinks}] Where page 'Backlinks' has a
pages='TO [.]' query on it.
* <p>
* Think of this plugin as 'including' the raw wiki-text from the other
page into the current one.
* <p>
* This plugin is most useful when you have a bit of boilerplate that
contains a complicated query
* that must be evaluated in the context of the current page. (The need
which spwaned this plugin
* was a Personalized/Project TO-DO List format that involved 9
complicated Queries. In the spirit
* of DRY this plugin was born.
*
* @author John Volkar (john.volkar at gmail.com)
* @author Janne Jalkanen & Scott Hurlbert - Original authors of
InsertPage (which was ripped off
* shamelessly).
*/
-----Original Message-----
From: Murray Altheim [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 07, 2008 5:27 AM
To: [email protected]
Subject: Re: Anything similar to wikipedia templates?
[EMAIL PROTECTED] wrote:
> Murray Altheim wrote:
>> As an author/maintainer of the TranscludePlugin, I perked up my ears
>> when reading about this, but on looking at the WikiMedia templating
>> feature I frankly think it's got to be one of the ugliest things I've
>> seen in awhile.
>>
>> What I would be willing to do is incorporate an API-like method into
>> the TranscludePlugin, such that someone could extend it with their
>> own Substitution (transform) feature. That wouldn't be a lot of work
>> for me, and if someone was so masochistic as to want to duplicate the
>> WikiMedia features, hell, all power to 'em.
>>
>> If this would suit, let me know and we can discuss adding the hook to
>> TranscludePlugin to permit this.
>
> Well, I actually had a look at the InsertPage plugin (source) and the
> TranscludePlugin (jspwiki.org description).
> In either case what's really needed is just a substitution mechanism
> to be build on top/hookable to either.
> After that, your right, all power to 'em.
What I'm thinking of is pretty simple. Because the common content that
exists between the two plugins (and potentially others) is passed as a
String, I'd pass the results of the existing transclude() method through
a pass-through method
public String transform( String content )
{
return content;
}
and create a single method API called transform(), e.g.,
public interface Transformable
{
public String transform( String content );
}
> Not yet exactly planned to do either, but If I had enough time (unsure
> I have ;-) I would probably do right now, looks not that difficult
> (at least for the InsertPage where I had a look). If only this could
> be useful to others, would probably be better to agree on syntax to
> specify parameters.
I'd leave all that up to the implementors/implementation, as people may
wish to handle this in different ways. We after all already have a
filter mechanism via com.ecyrd.jspwiki.filters.PageFilter, so I suppose
this could be a new thing or mixed in with that.
> Whether or not such a specific feature (I mean the Wikipedia
> templating stuff - or something alike) may prove useful (or ugly -
> this also may depend on how things grow up ..) is a different story.
> Personally I feel this could help a lot in avoiding duplication
> whenever (part of) a wiki content should be commonly structured
> (visually) over a number of standard things. But I'm eager to ear
> other opinions :-)
Back in 1993 and 1994 I wrote a complicated HTML editor using HyperCard
that did all sorts of header and footer type transclusions, permitted
users to declare and instantiate parameter entities, etc. and generally
created a very complicated system. It got good reviews but I don't know
how many people ever used the arcane features that I spent so much time
perfecting. But I'm all in favour of enabling those who want to do that
even if I happen to find it a bit off-putting, mostly because in my own
experience I know that there's probably people out there (who we never
hear from) using JSPWiki for all sorts of oddball applications (I know I
am).
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