WildcardLinkSyntax


Some ideas about supporting wildcards for link= and linkto= options:

Use cases

All pages with links to XYZ

    linkto=XYZ

All pages in category XYZ

    linkto=Category.XYZ

All pages with links to pages in Main/

    linkto=Main.*

All pages with links to pages in Main/ except for Main.HomePage

    linkto=Main.*,-Main.HomePage

Pages not in Category.XYZ

    nolinkto=Category.XYZ

Pages not in any Category

    nolinkto=Category.*

All pages linked from XYZ

    linkfrom=XYZ

All pages linked from pages in Main

    linkfrom=Main.*

All pages linked from Cookbook pages other than Cookbook.Markup

    linkfrom=Cookbook.*,-Cookbook.Markup

"Wanted pages" -- missing pages linked from pages other than RecentChanges

    linkfrom=-*.*RecentChanges    if="!exists {=$FullName}"

"Orphan pages" -- pages not linked from any other page (excluding RecentChanges)

    nolinkfrom=-*.*RecentChanges

The union of pages in Category.ABC and Category.XYZ

    linkto=Category.XYZ,Category.ABC

The intersection of pages in Category.ABC and Category.XYZ

    ...? 
    (see "Notes and Discussion" below)

Underlying model

All values (the things appearing on the right side of the equals sign) represent lists of pages to be tested. The values may be wildcarded, thus a value of 'Main.*,PmWiki.*,-*.RecentChanges' means "all of the pages in the Main and PmWiki groups except for Main.RecentChanges and PmWiki.RecentChanges".

The option key determines the type of test to be performed:

    linkto=...      All pages with links to any of the pages in the list
    linkfrom=...    All pages linked from any of the pages in the list

    nolinkto=...    All pages not linked to any of the pages in the list
    nolinkfrom=...  All pages not linked from any of the pages in the list

As conditionals

These options to pagelist might also be available as conditionals, thus something like (:if linkto Main.*:) would be true if the current page links to any of the pages in the Main group.

Notes and discussion

More important than the symbol used is setting a flexible system for future intersection needs. I propose:

  • A ^ as a modifier to individual members of the linkto= list with () indicating logical intersections...
    • linkto=^Main.This,Main.That,Main.TheOther
      • Pages linking to That and TheOther, but only if those pages also link to This.
    • linkto=^Main.This,^Main.That,Main.TheOther
      • Pages linking to The Other, but only if those pages also link to This AND That.
    • linkto=^(Main.This,Main.That),Main.TheOther
      • Pages linking to The Other, but only if those pages also link to This OR That.
    • linkto=^(Main.This,-Main.That),Main.TheOther
      • Pages linking to The Other, but only if those pages also link to This OR DO NOT link to That.
    • linkto=(^(Main.This,-Main.That),Main.TheOther),^Main.Another
      • Pages linking to the above example, but they must ALSO link with Another.

A problem with the above formulation is that "DO NOT link to that" is specified by nolinkto=, not by a negative value to linkto. The two are different:

    linkto=-Main.That         # pages with links to any page other than Main.That
    nolinkto=Main.That        # pages that do not have a link to Main.That

I've also been playing with the notion of using '+' to indicate "required", thus one could do the following to indicate multiple required terms.

    linkto=+Main.This,+Main.That

At the moment I don't have a strong compulsion to incorporate grouping operators or full-fledge set operations, unless we come up with some real use cases where they would be needed (PmWikiPhilosophy #3).

Pm

Makes sense in all cases, but I wonder if using '-' instead of the 'no'-prefix would work better because we already use that for negation for group=, name=, etc.

Do you mean we should have "-linkto=..." and "-linkfrom=..." as options? Or something else?

(by way of establishing prior art: we already have things like "nolinkwikiwords", "nolinebreaks", "nogroupheaders", "noleft", "noright", etc.) --Pm

This is a long time after the discussion, but just some thoughts... Basically my thought is to have a space be an "and" operator and a comma be an "or" operator. Obviously anybody including the space would need to be careful to put quotes around everything to hold it together... A single level of parentheses would help with a lot of flexibility. Negation indicated through prefixed "-".

  • link="a b c"
    • Must have all of a, b, and c
  • link="a,b,c"
    • Must have at least one of a, b, or c
  • link="a b,c"
  • link="a (b,c)"
    • Equivalent markup (comma has higher precedence than space), must have a and at least one of b or c
  • link="(a b),c"
    • Must have either "both a and b" or c
  • link=a,-b
    • Technically this should mean "has a or does not have b". Practically it's probably going to be a source of confusion for most people since typically people associate "not" with "and not".
  • link="a -b"
    • Must have a and must not have b
  • link=-(a,b,c) d
  • link=-a -b -c d
    • Equivalent markup. Must not have a nor b nor c and must have d
  • link="-(a b),c"
    • Must not have BOTH a and b or else must have c

This is similar to the syntax for the search engine on ebay. It seems pretty consistent with the nomenclature used elsewhere in pmwiki where comma is always "or" whereas multiple terms in a pagelist are separated by space and imply boolean "and".

Peter Bowers March 14, 2009, at 08:04 AM

See FPLTemplate-Talk for an alternate solution to this and see http://pmwiki.qdk.org/pmwiki.php/PageListPlus/PageList for a live test.

References

 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.21 00.20 MarkupToHTML begin
 3: 00.26 00.24 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
 4: 00.26 00.25 ReadApprovedUrls SiteAdmin.ApprovedUrls end
 5: 00.33 00.30 MarkupToHTML end
 6: 00.33 00.31 MarkupToHTML begin
 7: 00.34 00.32 MarkupToHTML end
 8: 00.34 00.32 MarkupToHTML begin
 9: 00.35 00.32 MarkupToHTML end
10: 00.35 00.33 now
Peak memory: 3,879,432 bytes