[dokuwiki] Re: Plugin writing questions / recursive parser

  • From: "Chris Smith" <chris@xxxxxxxxxxxxx>
  • To: <dokuwiki@xxxxxxxxxxxxx>
  • Date: Fri, 23 Sep 2005 09:44:59 +0100

Its a little more complex than you have outlined.

Dokuwiki caches rendered wiki content and then either delivers or doesn't
deliver the whole wiki page based on the user/acl configuration.  There is
no mechanism to determine that the page needs to be rendered differently for
different users.  This would mean any page with your conditional syntax
needs to turn caching off.

As you mention you also have an issue with show source.

I think you could go someway to overcoming both problems using a modified
template.

(a) the edit button (which changes to show page & show source depending on
user and location) is disabled completely when a user doesn't have edit
access to that particular page.  You will need some extra tweaks to ensure a
show page button does show up when the user is visiting backlinks, index,
search, history, etc.

(b) instead of a syntax plugin, (in the template) you capture the output of
tpl_content and post process it, simply removing any content that shouldn't
be delivered.

If you do go the plugin route, you can call the renderer recursively.  Its
expensive in terms of resource and time.   In the long term it may be better
to come up with a solution (modification) that allows the plugin to capture
a stream of instructions/inject a stream of instructions.

e.g.

on matching an entry pattern, your plugin handler() tells the parser to
start a separate instruction stream; on exit, the parser sends to your
plugin handler() the instruction stream its captured and returns to the
original instruction stream adding whatever your plugin handler returns as
its next instruction.

during rendering, your render() function will receive its data, which is in
fact a whole sequence of render instructions.  render() decides what to do
with those instructions and if appropriate sends the renderer the
instruction stream asking it to process those instructions before proceeding
with any more instructions in its current stream.

Something like this would neatly sidestep the overhead having to instantiate
a second renderer.

Then again, perhaps a wiki ( a collabrative document generator ) is not the
ideal for a job like this.  I'll leave that questions to others :)

I hope this helps some,

Chris




> -----Original Message-----
> From: dokuwiki-bounce@xxxxxxxxxxxxx
> [mailto:dokuwiki-bounce@xxxxxxxxxxxxx]On Behalf Of Christopher Arndt
> Sent: 23 September 2005 02:10
> To: dokuwiki@xxxxxxxxxxxxx
> Subject: [dokuwiki] Plugin writing questions / recursive parser
>
>
> Hi,
>
> I just tried DokuWiki 2 days ago for the first time and I
> must say I really
> like it! Unlike with MediaWiki, I was immediately able to
> figure out, how to
> adapt thins to my liking and the source code is structured
> very well too.
>
> Anyway, in trying to make DokuWiki more useful as a
> documentation writer's
> environment, I decided to write a plugin, that allows certain
> text on a page to
> be hidden depending on what user is logged in. This would be
> especially useful
> in conjunction with a tool, that saves a statical version of
> the Wiki, so you
> could deploy slightly different versions of your wiki to e.g.
> different customers.
>
> The syntax I imagined goes something like this:
>
> <if joe>
> Here comes some text...
> </if>
>
> => show text only if the logged in user is "joe"
>
> <if not joe>
> Here comes some text...
> </if>
>
> => show text only if the logged in user is *not* "joe"
>
> <if @clients>
> Legal blurb here...
> </if>
>
> => show the legal blurb only if the logged in user belongs to
> the group "clients"
>
> <if not @clients,boss>
> FIXME The following description is totally out of date!
> </if>
>
> => leave users of the group "clients" and user "boss" unaware
> of "inaccuracies"
> of your text ;-)
>
> I am aware, that the hidden text would still be visible
> through the source
> code. As I already said, this plugin would mostly be useful
> when exporting your
> content somehow.
>
> The problem with this plugin would be, that basically any
> syntax should be
> allowed between the start/end tags. But that is AFAICS not
> easily achievable
> with the current plugin system. Am I missing something here?
>
> IMHO the parser should allow recursive parsing, i.e. the
> plugin would just feed
> the wiki text it finds between the start/end tags to the
> parser again (if the
> condition matches). Is this already possible/feasible?
>
> Chris
>
>

-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: