[pmwiki-users] cookbook-recipeinfo was: Summary line in PITS and Cookbook

Crisses crisses at kinhost.org
Mon Aug 21 04:52:23 CDT 2006


On Aug 21, 2006, at 12:03 AM, Patrick R. Michaud wrote:

> On Sun, Aug 20, 2006 at 10:41:05PM -0400, Crisses wrote:
>>    Hi,
>>    I am very interested in figuring out exactly what "recipeinfo"  
>> is doing in
>>    the Cookbook.
>
> Actually, "recipeinfo" itself doesn't do anything -- it's just
> a normal div that puts a gray box around its contents.  :-)
>
> Yes, I'm serious.

I understood that there had to be special markup rules -- that was  
much more what I was interested in :)

> The code that does the "magic" in the cookbook is a special markup
> rule that records "properties", and a way of saving those properties
> as page attributes and reading them as page variables.  The markup is:
>
>     Markup('^Property:', 'directives',
>       '/^([A-Z][-\\w]+):(\\s.*)?$/e',
>       "'<:block,0><div class=\'property-$1\'>'.PSS('$0').'</div>' .
>        PZZ(SetProperty(\$pagename, 'recipe$1', PSS(trim('$2'))))");
>
> This says that every markup line beginning with a capitalized
> word and a colon is saved as a "recipe" property in the page.
> Thus a markup like
>
>     Summary: This is a summary
>
> stores the value "This is a summary" as a "recipeSummary" property.

If it allowed storing arbitrary user-created properties on-the-fly  
I'd be more concerned, but below here, you clarify that only certain  
properties are allowed:

> The rest of the code handles saving selected properties as
> attributes, and making them available as page variables:
>
>     foreach(array('Summary', 'Version', 'Votes') as $p) {
>        $SaveProperties[] = "recipe$p";
>        $FmtPV["\$Recipe$p"] = "@\$page['recipe$p']";
>     }
>
> Thus, lines in a cookbook page beginning with "Summary:", "Version:",
> or "Votes:" are automatically saved to page files, and they can be
> accessed via the {$RecipeSummary}, {$RecipeVersion}, and
> {$RecipeVotes} page variables.

This is *exactly* what I needed :)

Also, can you go into how these variables can be used?  Especially  
with regards to categories.  Can these be made to automatically add  
the page to certain categories?

In my case it will be:
Author:Clive Barker
Title:The Damnation Game
Year:1986
as an example.

Then I'd want it to add to categories (respectively):
Author_Clive_Barker
Title_The_Damnation_Game
Year_1986

This would make a new wiki I'm working on most user-friendly, as the  
users would only have to add the information to the page template I  
create: the wiki will bother with category markup.

I might alter the markup to be definition lists on the site in question:
:Author:Clive Barker

As a definition list seems pretty natural to me for this type of use.

> This approach is still somewhat in its formative stages -- I'm
> wanting to make a bit of a cleaner interface for dealing with
> page properties and attributes in general.  But the approach
> should also be relatively safe with respect to future versions
> of PmWiki.

Of course -- otherwise we'd all have to edit the Cookbook again ;)

Is it too early to document this as a Cookbook recipe?

Crisses




More information about the pmwiki-users mailing list