[pmwiki-users] Rethinking $RecipeInfo (was: Keeping recipes up to date)

Dominique Faure dominique.faure at gmail.com
Thu Feb 15 13:40:39 CST 2007


On 2/15/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Thu, Feb 15, 2007 at 08:37:23AM -0600, Patrick R. Michaud wrote:
> > On Thu, Feb 15, 2007 at 09:18:25AM +0100, Jiri Hladůvka / OBUTEX wrote:
> > > Patrick R. Michaud napsal(a):
> > > >Over time many people have asked for a way to keep track of
> > > >when new versions of recipes become available on pmwiki.org .
> > >
> > > I have a lot of recipes installed but only 4 lines are displayed by
> > > RecipeUpdates recipe.  Maybe I have old recipes (not having
> > > version identification) while there is the newer version
> > > in PmWiki.org already equipped with version info.
> >
> > [...] if a script in cookbook/ hasn't been loaded by the
> > local configuration, we don't yet have a way to be able
> > to determine any version information for that script.
>
> In thinking about this further, since I suspect there may
> be a lot of sites that load recipe scripts only in certain
> situations (e.g., only in a particular group or in response
> to specific ?action= requests), perhaps we need to rethink
> the whole $RecipeInfo approach.
>
> I now see that a limitation of the $RecipeInfo array approach
> is that it's effective only when a script is actually
> loaded, which is a problem for sites (like pmwiki.org)
> that selectively load recipes.  What we really want is a way
> to statically detect version information in a script
> without actually loading it.
>
> It's relatively easy to scan the files in cookbook/ for
> strings matching a given pattern, so perhaps we just
> need a way of specifying recipe information in the comments
> of script files.  Perhaps something as simple as...?
>
>     # RecipeInfo: Name=RandomQuotes Version=2007-02-15
>
> Then, recipeupdates.php would scan the files in cookbook/
> for "RecipeInfo:" strings and process them to get the
> recipe name and version information for any recipes that
> weren't already loaded.
>
> Most recipes could then simply provide a RecipeInfo:
> line in the comments instead of explicitly setting
> values of $RecipeInfo.
>
> For scripts that don't normally appear in cookbook/ (e.g., skins),
> we could continue to support the $RecipeInfo array in order
> for them to have versions checked.  Or we could encode
> optional RecipeInfo information in skin templates, which scripts/skins.php
> can automatically extract when the template is loaded:
>
>     <!-- RecipeInfo: Name=LeanSkin Version=2007-02-15 -->
>
> Comments?  Anyone see any better answers, or think that this
> might be too much trouble to go to?
>

From the parsing point of view, I don't see any real difference between:

  # RecipeInfo: Name=RandomQuotes Version=2007-02-15

and:

  $RecipeInfo['RandomQuotes']['Version']='2007-02-15';

The former would reduce a bit the memory allocation and initialization
time at runtime.
The latter could provide a framework for storing recipe dedicated
parameters (even if global variables are prefered until now):
  ...
  $RecipeInfo['RandomQuotes']['Version']='2007-02-15';

  $defaults =& $RecipeInfo['RandomQuotes'];
  SDV($defaults['VarName'], '$RandomSection');

  $FmtPV[$defaults['VarName']] = 'RandomSection($pn)';
  ...

Dom


More information about the pmwiki-users mailing list